本文整理汇总了Java中org.hl7.fhir.instance.model.Patient.addName方法的典型用法代码示例。如果您正苦于以下问题:Java Patient.addName方法的具体用法?Java Patient.addName怎么用?Java Patient.addName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hl7.fhir.instance.model.Patient
的用法示例。
在下文中一共展示了Patient.addName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExtensionOnComposite
import org.hl7.fhir.instance.model.Patient; //导入方法依赖的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());
}
示例2: testExtensionOnPrimitive
import org.hl7.fhir.instance.model.Patient; //导入方法依赖的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());
}
示例3: testExtensionOnComposite
import org.hl7.fhir.instance.model.Patient; //导入方法依赖的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());
}
示例4: testExtensionOnPrimitive
import org.hl7.fhir.instance.model.Patient; //导入方法依赖的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());
}
示例5: addNames
import org.hl7.fhir.instance.model.Patient; //导入方法依赖的package包/类
public static void addNames(AdtMessage source, Patient target, Mapper mapper) throws TransformException, MapperException {
List<HumanName> names = NameConverter.convert(PatientCommon.getPatientNames(source.getPidSegment()), mapper);
for (HumanName name : names)
if (name != null)
target.addName(name);
}
示例6: newPatient
import org.hl7.fhir.instance.model.Patient; //导入方法依赖的package包/类
public Patient newPatient() {
final Patient p = new Patient();
if (rand.nextBoolean()) {
ObjectId id = new ObjectId();
p.setId(id.toHexString());
} else {
p.setId(UUID.randomUUID().toString());
}
p.setGender(rand.nextBoolean() ? AdministrativeGender.MALE
: AdministrativeGender.FEMALE);
final String ssn =
String.format("%03d-%02d-%04d", rand.nextInt(999)+1, rand.nextInt(99)+1, rand.nextInt(9999)+1 );
p.addIdentifier(newIdentifier(IdentifierUse.OFFICIAL, "SSN", ssn));
HumanName bsmith=
HumanNameUtil.newHumanName("Bill Smith", new String[] {"Smith"}, new String [] {"Bill"}, null, NameUse.USUAL);
HumanName wsmith =
HumanNameUtil.newHumanName("W Smith", new String[] {"Smith"}, new String [] {"Bill"}, new String [] {"Jr"});
p.addName(bsmith);
p.addName(wsmith);
long msec = (long) (rand.nextFloat() * System.currentTimeMillis());
p.setBirthDate(new Date(msec));
p.addTelecom((new ContactPointBuilder()).email("[email protected]").home().build());
p.addTelecom((new ContactPointBuilder()).email("[email protected]").work().build());
p.addTelecom((new ContactPointBuilder()).phone("248.555.0743").home().build());
p.addTelecom((new ContactPointBuilder()).phone("248.557.1243").work().build());
return p;
}
示例7: testMoreExtensions
import org.hl7.fhir.instance.model.Patient; //导入方法依赖的package包/类
@Test
public void testMoreExtensions() throws Exception {
Patient patient = new Patient();
patient.addIdentifier().setUse(IdentifierUse.OFFICIAL).setSystem("urn:example").setValue("7000135");
Extension ext = new Extension();
ext.setUrl("http://example.com/extensions#someext");
ext.setValue(new DateTimeType("2011-01-02T11:13:15"));
// Add the extension to the resource
patient.getExtension().add(ext);
// END SNIPPET: resourceExtension
// START SNIPPET: resourceStringExtension
HumanName name = patient.addName();
name.addFamily("Shmoe");
StringType given = name.addGivenElement();
given.setValue("Joe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue(new StringType("given"));
given.getExtension().add(ext2);
StringType given2 = name.addGivenElement();
given2.setValue("Shmoe");
Extension given2ext = new Extension().setUrl("http://examples.com#givenext_parent");
given2.getExtension().add(given2ext);
given2ext.addExtension().setUrl("http://examples.com#givenext_child").setValue(new StringType("CHILD"));
// END SNIPPET: resourceStringExtension
// START SNIPPET: subExtension
Extension parent = new Extension().setUrl("http://example.com#parent");
patient.getExtension().add(parent);
Extension child1 = new Extension().setUrl("http://example.com#child").setValue(new StringType("value1"));
parent.getExtension().add(child1);
Extension child2 = new Extension().setUrl("http://example.com#child").setValue(new StringType("value1"));
parent.getExtension().add(child2);
// END SNIPPET: subExtension
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString("<Patient xmlns=\"http://hl7.org/fhir\"><extension><url value=\"http://example.com/extensions#someext\"/><valueDateTime value=\"2011-01-02T11:13:15\"/></extension>"));
assertThat(
enc,
containsString("<extension><extension><url value=\"http://example.com#child\"/><valueString value=\"value1\"/></extension><extension><url value=\"http://example.com#child\"/><valueString value=\"value1\"/></extension><url value=\"http://example.com#parent\"/></extension>"));
assertThat(enc, containsString("<given value=\"Joe\"><extension><url value=\"http://examples.com#givenext\"/><valueString value=\"given\"/></extension></given>"));
assertThat(enc, containsString("<given value=\"Shmoe\"><extension><extension><url value=\"http://examples.com#givenext\"/><valueString value=\"given\"/></extension><url value=\"http://examples.com#givenext_child\"/></extension></given>"));
}
示例8: testExtensionOnPrimitive
import org.hl7.fhir.instance.model.Patient; //导入方法依赖的package包/类
@Test
public void testExtensionOnPrimitive() throws Exception {
Patient patient = new Patient();
HumanName name = patient.addName();
StringType family = name.addFamilyElement();
family.setValue("Shmoe");
family.addExtension().setUrl("http://examples.com#givenext").setValue( new StringType("Hello"));
String enc = new FhirContext().newJsonParser().encodeResourceToString(patient);
ourLog.info(enc);
//@formatter:off
assertThat(enc, containsString(("{\n" +
" \"resourceType\":\"Patient\",\n" +
" \"name\":[\n" +
" {\n" +
" \"family\":[\n" +
" \"Shmoe\"\n" +
" ],\n" +
" \"_family\":[\n" +
" {\n" +
" \"extension\":[\n" +
" {\n" +
" \"url\":\"http://examples.com#givenext\",\n" +
" \"valueString\":\"Hello\"\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]\n" +
"}").replace("\n", "").replaceAll(" +", "")));
//@formatter:on
Patient parsed = new FhirContext().newJsonParser().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());
}
示例9: testMoreExtensions
import org.hl7.fhir.instance.model.Patient; //导入方法依赖的package包/类
@Test
public void testMoreExtensions() throws Exception {
Patient patient = new Patient();
patient.addIdentifier().setUse(IdentifierUse.OFFICIAL).setSystem("urn:example").setValue("7000135");
Extension ext = new Extension();
ext.setUrl("http://example.com/extensions#someext");
ext.setValue(new DateTimeType("2011-01-02T11:13:15"));
// Add the extension to the resource
patient.getExtension().add(ext);
// END SNIPPET: resourceExtension
// START SNIPPET: resourceStringExtension
HumanName name = patient.addName();
name.addFamily("Shmoe");
StringType given = name.addGivenElement();
given.setValue("Joe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue(new StringType("given"));
given.getExtension().add(ext2);
StringType given2 = name.addGivenElement();
given2.setValue("Shmoe");
Extension given2ext = new Extension().setUrl("http://examples.com#givenext_parent");
given2.getExtension().add(given2ext);
given2ext.addExtension().setUrl("http://examples.com#givenext_child").setValue(new StringType("CHILD"));
// END SNIPPET: resourceStringExtension
// START SNIPPET: subExtension
Extension parent = new Extension().setUrl("http://example.com#parent");
patient.getExtension().add(parent);
Extension child1 = new Extension().setUrl("http://example.com#child").setValue(new StringType("value1"));
parent.getExtension().add(child1);
Extension child2 = new Extension().setUrl("http://example.com#child").setValue(new StringType("value1"));
parent.getExtension().add(child2);
// END SNIPPET: subExtension
String output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(output);
String enc = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(enc, containsString(
"<Patient xmlns=\"http://hl7.org/fhir\"><extension url=\"http://example.com/extensions#someext\"><valueDateTime value=\"2011-01-02T11:13:15\"/></extension>"));
assertThat(enc, containsString(
"<extension url=\"http://example.com#parent\"><extension url=\"http://example.com#child\"><valueString value=\"value1\"/></extension><extension url=\"http://example.com#child\"><valueString value=\"value1\"/></extension></extension>"));
assertThat(enc, containsString(
"<given value=\"Joe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"given\"/></extension></given>"));
assertThat(enc, containsString(
"<given value=\"Shmoe\"><extension url=\"http://examples.com#givenext_parent\"><extension url=\"http://examples.com#givenext_child\"><valueString value=\"CHILD\"/></extension></extension></given>"));
}