org.hl7.fhir.dstu3.model.HumanName Java Examples
The following examples show how to use
org.hl7.fhir.dstu3.model.HumanName.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public static String displayHumanName(HumanName name) { StringBuilder s = new StringBuilder(); if (name.hasText()) s.append(name.getText()); else { for (StringType p : name.getGiven()) { s.append(p.getValue()); s.append(" "); } if (name.hasFamily()) { s.append(name.getFamily()); s.append(" "); } } if (name.hasUse() && name.getUse() != NameUse.USUAL) s.append("("+name.getUse().toString()+")"); return s.toString(); }
Example #2
Source File: Example01_CreateAPatient.java From fhirstarters with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void main(String[] theArgs) { // Create a resource instance Patient pat = new Patient(); // Add a "name" element HumanName name = pat.addName(); name.setFamily("Simpson").addGiven("Homer").addGiven("J"); // Add an "identifier" element Identifier identifier = pat.addIdentifier(); identifier.setSystem("http://acme.org/MRNs").setValue("7000135"); // Model is designed to be chained pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("12345"); }
Example #3
Source File: Example01_CreateAPatient.java From fhirstarters with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void main(String[] theArgs) { // Create a resource instance Patient pat = new Patient(); // Add a "name" element HumanName name = pat.addName(); name.setFamily("Simpson").addGiven("Homer").addGiven("J"); // Add an "identifier" element Identifier identifier = pat.addIdentifier(); identifier.setSystem("http://acme.org/MRNs").setValue("7000135"); // Model is designed to be chained pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("12345"); }
Example #4
Source File: Convert.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
public HumanName makeNameFromEN(Element e) { if (e == null) return null; HumanName hn = new HumanName(); String use = e.getAttribute("use"); if (use != null) { if (use.equals("L")) hn.setUse(NameUse.USUAL); else if (use.equals("C")) hn.setUse(NameUse.OFFICIAL); else if (use.equals("P") || use.equals("A")) hn.setUse(NameUse.ANONYMOUS); else if (use.equals("TMP")) hn.setUse(NameUse.TEMP); else if (use.equals("BAD")) hn.setUse(NameUse.OLD); } Node n = e.getFirstChild(); while (n != null) { if (n.getNodeType() == Node.ELEMENT_NODE) { String v = n.getTextContent(); if (n.getLocalName().equals("family")) hn.setFamilyElement(makeString(v)); else if (n.getLocalName().equals("given")) hn.getGiven().add(makeString(v)); else if (n.getLocalName().equals("prefix")) hn.getPrefix().add(makeString(v)); else if (n.getLocalName().equals("suffix")) hn.getSuffix().add(makeString(v)); } n = n.getNextSibling(); } return hn; }
Example #5
Source File: FhirUpdateTest.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void updateTest() { stubFhirRequest(put(urlEqualTo("/Patient/1234?_format=xml")).willReturn(okXml(toXml(new OperationOutcome())))); template.requestBody("direct:start", toXml(new Patient().addName(new HumanName().setFamily("Smith")).setId("1234")), MethodOutcome.class); }
Example #6
Source File: FhirCreateTest.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void createTest() { stubFhirRequest(post(urlEqualTo("/Patient?_format=xml")).willReturn(okXml(toXml(new OperationOutcome())))); template.requestBody("direct:start", toXml(new Patient().addName(new HumanName().setFamily("Smith"))), MethodOutcome.class); }
Example #7
Source File: PractitionerEntityToFHIRPractitionerTransformerTest.java From careconnect-reference-implementation with Apache License 2.0 | 5 votes |
@Test public void testTransformer(){ PractitionerEntity practitionerEntity = new PractitionerEntityBuilder() .addName("Dr", "Jenny", "Jones") .addAddress("Church Lane Surgery", "Holmfirth", null, "Halifax", "West Yorkshire", "HX1 2TT") .build(); Practitioner practitioner = transformer.transform(practitionerEntity); assertThat(practitioner, not(nullValue())); assertThat(practitioner.getId(), not(nullValue())); assertThat(practitioner.getId(), equalTo((new Long(PractitionerEntityBuilder.DEFAULT_ID)).toString())); assertThat(practitioner.getActive(), equalTo(true)); List<HumanName> practitionerNames = practitioner.getName(); assertThat(practitionerNames, not(nullValue())); assertThat(practitionerNames.size(), equalTo(1)); //assertThat(practitionerNames.get(0).getUse(), equalTo(HumanName.NameUse.USUAL)); HumanName name = practitionerNames.get(0); assertThat(name.getPrefixAsSingleString(), equalTo("Dr")); assertThat(name.getGivenAsSingleString(), equalTo("Jenny")); assertThat(name.getFamily(), equalTo("Jones")); assertThat(practitioner.getAddress(), not(nullValue())); List<Address> addresses = practitioner.getAddress(); assertThat(addresses.size(), equalTo(1)); Address address = addresses.get(0); assertThat(address.getLine().get(0).getValue(), equalTo("Church Lane Surgery")); assertThat(address.getLine().get(1).getValue(), equalTo("Holmfirth")); assertThat(address.getLine().size(), equalTo(2)); assertThat(address.getDistrict(), equalTo("West Yorkshire")); assertThat(address.getCity(), equalTo("Halifax")); assertThat(address.getPostalCode(), equalTo("HX1 2TT")); assertThat(address.getUse(), equalTo(Address.AddressUse.WORK)); }
Example #8
Source File: PatientEntityToFHIRPatientTransformerTest.java From careconnect-reference-implementation with Apache License 2.0 | 5 votes |
@Test public void testTransformSimplePatientEntity() throws FHIRException { LocalDate dateOfBirth = LocalDate.of(1996, 6, 21); final PatientEntity patientEntity = new PatientEntityBuilder() .setDateOfBirth(dateOfBirth) .build(); final Patient patient = transformer.transform(patientEntity); assertThat(patient, not(nullValue())); assertThat(patient.getActive(), equalTo(true)); assertThat(patient.getName().size(), equalTo(1)); HumanName name = patient.getName().get(0); assertThat(name.getGivenAsSingleString(), equalTo("John")); assertThat(name.getFamily(), equalTo("Smith")); assertThat(name.getUse(), equalTo(HumanName.NameUse.OFFICIAL)); assertThat(name.getPrefixAsSingleString(), equalTo("Mr")); assertThat(patient.getGender(), equalTo(Enumerations.AdministrativeGender.MALE)); assertThat(patient.getBirthDate(), not(nullValue())); LocalDate patientDoB = DateUtils.asLocalDate(patient.getBirthDate()); assertThat(patientDoB, equalTo(dateOfBirth)); }
Example #9
Source File: PractitionerEntityBuilder.java From careconnect-reference-implementation with Apache License 2.0 | 5 votes |
public PractitionerEntityBuilder addName(String prefix, String givenName, String familyName){ PractitionerName name = new PractitionerName(); name.setFamilyName(familyName); name.setGivenName(givenName); name.setPrefix(prefix); name.setNameUse(HumanName.NameUse.USUAL); names.add(name); return this; }
Example #10
Source File: PatientEntityBuilder.java From careconnect-reference-implementation with Apache License 2.0 | 5 votes |
public PatientEntity build() { final PatientEntity patientEntity = new PatientEntity(); patientEntity.setId(patientId); patientEntity.setActive(active); patientEntity.setDateOfBirth(DateUtils.asDate(dateOfBirth)); patientEntity.setGender("MALE"); final PatientName name = patientEntity.addName(); name.setNameUse(HumanName.NameUse.OFFICIAL); name.setGivenName("John"); name.setFamilyName("Smith"); name.setPrefix("Mr"); // KGM 18/12/2017 Removed following line. Add name does this functionality // patientEntity.getNames().add(name); return patientEntity; }
Example #11
Source File: FhirJsonIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
private Patient createPatient() { Patient patient = new Patient(); patient.addName(new HumanName() .addGiven("Sherlock") .setFamily("Holmes")) .addAddress(new Address().addLine("221b Baker St, Marylebone, London NW1 6XE, UK")); return patient; }
Example #12
Source File: FhirXmlIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
private Patient createPatient() { Patient patient = new Patient(); patient.addName(new HumanName() .addGiven("Sherlock") .setFamily("Holmes")) .addAddress(new Address().addLine("221b Baker St, Marylebone, London NW1 6XE, UK")); return patient; }
Example #13
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
private void renderHumanName(HumanName name, XhtmlNode x) { x.addText(displayHumanName(name)); }
Example #14
Source File: TestData.java From bunsen with Apache License 2.0 | 4 votes |
/** * Returns a new Patient for testing. * * @return a FHIR Patient for testing. */ public static Patient newPatient() { Patient patient = new Patient(); patient.setId("test-patient"); patient.setGender(AdministrativeGender.MALE); patient.setActive(true); patient.setMultipleBirth(new IntegerType(1)); patient.setBirthDateElement(new DateType("1945-01-02")); patient.addGeneralPractitioner().setReference("Practitioner/12345"); Identifier practitionerIdentifier = new Identifier(); practitionerIdentifier.setId("P123456"); practitionerIdentifier.getAssigner().setReference("Organization/123456"); patient.getGeneralPractitionerFirstRep().setIdentifier(practitionerIdentifier); Address address = patient.addAddress(); address.addLine("123 Fake Street"); address.setCity("Chicago"); address.setState("IL"); address.setDistrict("12345"); Extension birthSex = patient.addExtension(); birthSex.setUrl(US_CORE_BIRTHSEX); birthSex.setValue(new CodeType("M")); Extension ethnicity = patient.addExtension(); ethnicity.setUrl(US_CORE_ETHNICITY); ethnicity.setValue(null); Coding ombCoding = new Coding(); ombCoding.setSystem("urn:oid:2.16.840.1.113883.6.238"); ombCoding.setCode("2135-2"); ombCoding.setDisplay("Hispanic or Latino"); // Add category to ethnicity extension Extension ombCategory = ethnicity.addExtension(); ombCategory.setUrl("ombCategory"); ombCategory.setValue(ombCoding); // Add multiple detailed sub-extension to ethnicity extension Coding detailedCoding1 = new Coding(); detailedCoding1.setSystem("urn:oid:2.16.840.1.113883.6.238"); detailedCoding1.setCode("2165-9"); detailedCoding1.setDisplay("South American"); Coding detailedCoding2 = new Coding(); detailedCoding2.setSystem("urn:oid:2.16.840.1.113883.6.238"); detailedCoding2.setCode("2166-7"); detailedCoding2.setDisplay("Argentinean"); final Extension detailed1 = ethnicity.addExtension(); detailed1.setUrl("detailed"); detailed1.setValue(detailedCoding1); final Extension detailed2 = ethnicity.addExtension(); detailed2.setUrl("detailed"); detailed2.setValue(detailedCoding2); // Add text display to ethnicity extension Extension ethnicityText = ethnicity.addExtension(); ethnicityText.setUrl("text"); ethnicityText.setValue(new StringType("Not Hispanic or Latino")); // Human Name HumanName humanName = new HumanName(); humanName.setFamily("family_name"); humanName.addGiven("given_name"); humanName.addGiven("middle_name"); patient.addName(humanName); return patient; }
Example #15
Source File: BaseHumanName.java From careconnect-reference-implementation with Apache License 2.0 | 4 votes |
public HumanName.NameUse getNameUse() { return this.nameUse; }
Example #16
Source File: BaseHumanName.java From careconnect-reference-implementation with Apache License 2.0 | 4 votes |
public void setNameUse(HumanName.NameUse nameUse) { this.nameUse = nameUse; }