本文整理汇总了Java中org.hl7.fhir.instance.model.StringType类的典型用法代码示例。如果您正苦于以下问题:Java StringType类的具体用法?Java StringType怎么用?Java StringType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringType类属于org.hl7.fhir.instance.model包,在下文中一共展示了StringType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateParametersParameterComponent
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testCreateParametersParameterComponent() {
String[] names = { "type", "resourceUrl", "name", "_lastUpdated" };
String[] values = { "master", "http://fhirserver.net", "Mike", "ge2016-02-16" };
for (int i = 0; i < names.length; i++) {
String name = names[i];
String value = values[i];
ParametersParameterComponent expected = new ParametersParameterComponent();
expected.setName(name);
StringType strTypeVal = new StringType();
strTypeVal.setValue(value);
expected.setValue(strTypeVal);
ParametersParameterComponent actual = ParametersUtil.createParameter(name,
value);
assertNotNull(actual);
assertEquals("name", actual.getName(), expected.getName());
assertEquals("value", actual.getValue().toString(),
expected.getValue().toString());
}
}
示例2: testExtensionOnComposite
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testExtensionOnComposite() throws Exception {
Patient patient = new Patient();
HumanName name = patient.addName();
name.addFamily("Shmoe");
HumanName given = name.addGiven("Joe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue( new StringType("Hello"));
given.getExtension().add(ext2);
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString("<name><extension url=\"http://examples.com#givenext\"><valueString value=\"Hello\"/></extension><family value=\"Shmoe\"/><given value=\"Joe\"/></name>"));
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, new StringReader(enc));
assertEquals(1, parsed.getName().get(0).getExtension().size());
Extension ext = parsed.getName().get(0).getExtension().get(0);
assertEquals("Hello", ((IPrimitiveType<?>)ext.getValue()).getValue());
}
示例3: testExtensionOnPrimitive
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testExtensionOnPrimitive() throws Exception {
Patient patient = new Patient();
HumanName name = patient.addName();
StringType family = name.addFamilyElement();
family.setValue("Shmoe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue( new StringType("Hello"));
family.getExtension().add(ext2);
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString("<name><family value=\"Shmoe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"Hello\"/></extension></family></name>"));
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, new StringReader(enc));
assertEquals(1, parsed.getName().get(0).getFamily().get(0).getExtension().size());
Extension ext = parsed.getName().get(0).getFamily().get(0).getExtension().get(0);
assertEquals("Hello", ((IPrimitiveType<?>)ext.getValue()).getValue());
}
示例4: testExtensions
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testExtensions() throws DataFormatException {
MyPatient patient = new MyPatient();
patient.setPetName(new StringType("Fido"));
patient.getImportantDates().add(new DateTimeType("2010-01-02"));
patient.getImportantDates().add(new DateTimeType("2014-01-26T11:11:11"));
patient.addName().addFamily("Smith");
IParser p = ourCtx.newXmlParser();
String str = p.encodeResourceToString(patient);
ourLog.info(str);
assertThat(str, StringContains.containsString("<Patient xmlns=\"http://hl7.org/fhir\">"));
assertThat(str, StringContains.containsString("<extension url=\"http://example.com/dontuse#petname\"><valueString value=\"Fido\"/></extension>"));
assertThat(str, StringContains.containsString("<modifierExtension url=\"http://example.com/dontuse#importantDates\"><valueDateTime value=\"2010-01-02\"/></modifierExtension>"));
assertThat(str, StringContains.containsString("<modifierExtension url=\"http://example.com/dontuse#importantDates\"><valueDateTime value=\"2014-01-26T11:11:11\"/></modifierExtension>"));
assertThat(str, StringContains.containsString("<name><family value=\"Smith\"/></name>"));
}
示例5: testEncodingNullExtension
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testEncodingNullExtension() {
Patient p = new Patient();
Extension extension = new Extension().setUrl("http://foo#bar");
p.getExtension().add(extension);
String str = ourCtx.newJsonParser().encodeResourceToString(p);
assertEquals("{\"resourceType\":\"Patient\"}", str);
extension.setValue(new StringType());
str = ourCtx.newJsonParser().encodeResourceToString(p);
assertEquals("{\"resourceType\":\"Patient\"}", str);
extension.setValue(new StringType(""));
str = ourCtx.newJsonParser().encodeResourceToString(p);
assertEquals("{\"resourceType\":\"Patient\"}", str);
}
示例6: testEncodeExt
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testEncodeExt() throws Exception {
ValueSet valueSet = new ValueSet();
valueSet.setId("123456");
ValueSetDefineComponent define = valueSet.getDefine();
ConceptDefinitionComponent code = define.addConcept();
code.setCode("someCode");
code.setDisplay("someDisplay");
code.addExtension().setUrl("urn:alt").setValue( new StringType("alt name"));
String encoded = ourCtx.newJsonParser().encodeResourceToString(valueSet);
ourLog.info(encoded);
assertThat(encoded, (containsString("123456")));
assertEquals(
"{\"resourceType\":\"ValueSet\",\"id\":\"123456\",\"define\":{\"concept\":[{\"extension\":[{\"url\":\"urn:alt\",\"valueString\":\"alt name\"}],\"code\":\"someCode\",\"display\":\"someDisplay\"}]}}",
encoded);
}
示例7: summariseSlicing
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
private String summariseSlicing(ElementDefinitionSlicingComponent slice) {
StringBuilder b = new StringBuilder();
boolean first = true;
for (StringType d : slice.getDiscriminator()) {
if (first)
first = false;
else
b.append(", ");
b.append(d);
}
b.append("(");
if (slice.hasOrdered())
b.append(slice.getOrderedElement().asStringValue());
b.append("/");
if (slice.hasRules())
b.append(slice.getRules().toCode());
b.append(")");
if (slice.hasDescription()) {
b.append(" \"");
b.append(slice.getDescription());
b.append("\"");
}
return b.toString();
}
示例8: processConstant
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
private Base processConstant(ExecutionContext context, String constant) throws PathEngineException {
if (constant.equals("true")) {
return new BooleanType(true);
} else if (constant.equals("false")) {
return new BooleanType(false);
} else if (constant.equals("{}")) {
return null;
} else if (Utilities.isInteger(constant)) {
return new IntegerType(constant);
} else if (Utilities.isDecimal(constant)) {
return new DecimalType(constant);
} else if (constant.startsWith("\'")) {
return new StringType(processConstantString(constant));
} else if (constant.startsWith("%")) {
return resolveConstant(context, constant);
} else if (constant.startsWith("@")) {
return processDateConstant(context.appInfo, constant.substring(1));
} else {
return new StringType(constant);
}
}
示例9: resolveConstant
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
private Base resolveConstant(ExecutionContext context, String s) throws PathEngineException {
if (s.equals("%sct"))
return new StringType("http://snomed.info/sct");
else if (s.equals("%loinc"))
return new StringType("http://loinc.org");
else if (s.equals("%ucum"))
return new StringType("http://unitsofmeasure.org");
else if (s.equals("%context"))
return context.context;
else if (s.equals("%resource")) {
if (context.resource == null)
throw new PathEngineException("Cannot use %resource in this context");
return context.resource;
} else if (s.equals("%us-zip"))
return new StringType("[0-9]{5}(-[0-9]{4}){0,1}");
else if (s.startsWith("%\"vs-"))
return new StringType("http://hl7.org/fhir/ValueSet/"+s.substring(5, s.length()-1)+"");
else if (s.startsWith("%\"cs-"))
return new StringType("http://hl7.org/fhir/"+s.substring(5, s.length()-1)+"");
else if (s.startsWith("%\"ext-"))
return new StringType("http://hl7.org/fhir/StructureDefinition/"+s.substring(6, s.length()-1));
else if (hostServices == null)
throw new PathEngineException("Unknown fixed constant '"+s+"'");
else
return hostServices.resolveConstant(context.appInfo, s);
}
示例10: funcSubstring
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
private List<Base> funcSubstring(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws PathEngineException {
List<Base> result = new ArrayList<Base>();
List<Base> n1 = execute(context, focus, exp.getParameters().get(0), true);
int i1 = Integer.parseInt(n1.get(0).primitiveValue());
int i2 = -1;
if (exp.parameterCount() == 2) {
List<Base> n2 = execute(context, focus, exp.getParameters().get(1), true);
i2 = Integer.parseInt(n2.get(0).primitiveValue());
}
if (focus.size() == 1) {
String sw = convertToString(focus.get(0));
String s;
if (i1 < 0 || i1 >= sw.length())
return new ArrayList<Base>();
if (exp.parameterCount() == 2)
s = sw.substring(i1, Math.min(sw.length(), i1+i2));
else
s = sw.substring(i1);
if (!Utilities.noString(s))
result.add(new StringType(s));
}
return result;
}
示例11: testEncodeExtensionUndeclaredNonModifier
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testEncodeExtensionUndeclaredNonModifier() {
Observation obs = new Observation();
obs.setId("1");
obs.getMeta().addProfile("http://profile");
Extension ext = obs.addExtension();
ext.setUrl("http://exturl").setValue(new StringType("ext_url_value"));
obs.getCode().setText("CODE");
IParser parser = ourCtx.newXmlParser();
String output = parser.setPrettyPrint(true).encodeResourceToString(obs);
ourLog.info(output);
// @formatter:off
assertThat(output, stringContainsInOrder("<id value=\"1\"/>", "<meta>", "<profile value=\"http://profile\"/>",
"<extension url=\"http://exturl\">", "<valueString value=\"ext_url_value\"/>", "<text value=\"CODE\"/>"));
assertThat(output, not(stringContainsInOrder("<url value=\"http://exturl\"/>")));
// @formatter:on
obs = parser.parseResource(Observation.class, output);
assertEquals(1, obs.getExtension().size());
assertEquals("http://exturl", obs.getExtension().get(0).getUrl());
assertEquals("ext_url_value", ((StringType) obs.getExtension().get(0).getValue()).getValue());
}
示例12: testEncodingNullExtension
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testEncodingNullExtension() {
Patient p = new Patient();
Extension extension = new Extension().setUrl("http://foo#bar");
p.getExtension().add(extension);
String str = ourCtx.newXmlParser().encodeResourceToString(p);
assertEquals("<Patient xmlns=\"http://hl7.org/fhir\"/>", str);
extension.setValue(new StringType());
str = ourCtx.newXmlParser().encodeResourceToString(p);
assertEquals("<Patient xmlns=\"http://hl7.org/fhir\"/>", str);
extension.setValue(new StringType(""));
str = ourCtx.newXmlParser().encodeResourceToString(p);
assertEquals("<Patient xmlns=\"http://hl7.org/fhir\"/>", str);
}
示例13: testExtensionOnComposite
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testExtensionOnComposite() throws Exception {
Patient patient = new Patient();
HumanName name = patient.addName();
name.addFamily("Shmoe");
HumanName given = name.addGiven("Joe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue(new StringType("Hello"));
given.getExtension().add(ext2);
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString(
"<name><extension url=\"http://examples.com#givenext\"><valueString value=\"Hello\"/></extension><family value=\"Shmoe\"/><given value=\"Joe\"/></name>"));
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, new StringReader(enc));
assertEquals(1, parsed.getName().get(0).getExtension().size());
Extension ext = parsed.getName().get(0).getExtension().get(0);
assertEquals("Hello", ((IPrimitiveType<?>) ext.getValue()).getValue());
}
示例14: testExtensionOnPrimitive
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testExtensionOnPrimitive() throws Exception {
Patient patient = new Patient();
HumanName name = patient.addName();
StringType family = name.addFamilyElement();
family.setValue("Shmoe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue(new StringType("Hello"));
family.getExtension().add(ext2);
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString(
"<name><family value=\"Shmoe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"Hello\"/></extension></family></name>"));
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, new StringReader(enc));
assertEquals(1, parsed.getName().get(0).getFamily().get(0).getExtension().size());
Extension ext = parsed.getName().get(0).getFamily().get(0).getExtension().get(0);
assertEquals("Hello", ((IPrimitiveType<?>) ext.getValue()).getValue());
}
示例15: testExtensions
import org.hl7.fhir.instance.model.StringType; //导入依赖的package包/类
@Test
public void testExtensions() throws DataFormatException {
MyPatientHl7Org patient = new MyPatientHl7Org();
patient.setPetName(new StringType("Fido"));
patient.getImportantDates().add(new DateTimeType("2010-01-02"));
patient.getImportantDates().add(new DateTimeType("2014-01-26T11:11:11"));
patient.addName().addFamily("Smith");
IParser p = ourCtx.newXmlParser();
String str = p.encodeResourceToString(patient);
ourLog.info(str);
assertThat(str, StringContains.containsString("<Patient xmlns=\"http://hl7.org/fhir\">"));
assertThat(str, StringContains.containsString(
"<extension url=\"http://example.com/dontuse#petname\"><valueString value=\"Fido\"/></extension>"));
assertThat(str, StringContains.containsString(
"<modifierExtension url=\"http://example.com/dontuse#importantDates\"><valueDateTime value=\"2010-01-02\"/></modifierExtension>"));
assertThat(str, StringContains.containsString(
"<modifierExtension url=\"http://example.com/dontuse#importantDates\"><valueDateTime value=\"2014-01-26T11:11:11\"/></modifierExtension>"));
assertThat(str, StringContains.containsString("<name><family value=\"Smith\"/></name>"));
}