org.hl7.fhir.dstu3.model.Address Java Examples

The following examples show how to use org.hl7.fhir.dstu3.model.Address. 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: LocationEntityBuilder.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
public LocationEntityBuilder addAddress(String addressLine1, String addressLine2,
                                        String addressLine3, String city,
                                        String county, String postcode) {
    LocationAddress locationAddress = new LocationAddress();
    locationAddress.setAddressType(Address.AddressType.BOTH);
    locationAddress.setAddressUse(Address.AddressUse.HOME);
    AddressEntity addressEntity = new AddressEntity();
    addressEntity.setAddress1(addressLine1);
    addressEntity.setAddress2(addressLine2);
    addressEntity.setAddress3(addressLine3);
    addressEntity.setCity(city);
    addressEntity.setCounty(county);
    addressEntity.setPostcode(postcode);
    locationAddress.setAddress(addressEntity);
    addresses.add(locationAddress);
    return this;
}
 
Example #2
Source File: BaseAddressToFHIRAddressTransformerTest.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Test
public void testPatientAddressTransformation(){

    BaseAddress baseAddress = new PatientAddressBuilder().build();
    Address address = transformer.transform(baseAddress);

    assertThat(address, not(nullValue()));
    assertThat(address.getUse(), not(nullValue()));
    assertThat(address.getUse(), equalTo(Address.AddressUse.HOME));
    assertThat(address.getType(), not(nullValue()));
    assertThat(address.getType(), equalTo(Address.AddressType.BOTH));
    assertThat(address.getLine().get(0).getValue(), equalTo("121b Baker Street"));
    assertThat(address.getLine().get(1).getValue(), equalTo("Marylebone"));
    assertThat(address.getLine().size(), equalTo(2));
    //assertThat(address.getLine().get(3).getValue(), nullValue());
    assertThat(address.getDistrict(), equalTo("Middlesex"));
    assertThat(address.getCity(), equalTo("London"));
    assertThat(address.getPostalCode(), equalTo("W1 2TW"));

}
 
Example #3
Source File: FhirXmlIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
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 #4
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private String displayAddress(Address address) {
  StringBuilder s = new StringBuilder();
  if (address.hasText())
    s.append(address.getText());
  else {
    for (StringType p : address.getLine()) {
      s.append(p.getValue());
      s.append(" ");
    }
    if (address.hasCity()) {
      s.append(address.getCity());
      s.append(" ");
    }
    if (address.hasState()) {
      s.append(address.getState());
      s.append(" ");
    }

    if (address.hasPostalCode()) {
      s.append(address.getPostalCode());
      s.append(" ");
    }

    if (address.hasCountry()) {
      s.append(address.getCountry());
      s.append(" ");
    }
  }
  if (address.hasUse())
    s.append("("+address.getUse().toString()+")");
  return s.toString();
}
 
Example #5
Source File: FhirJsonIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
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 #6
Source File: FhirStu3.java    From synthea with Apache License 2.0 5 votes vote down vote up
/**
 * Map the clinician into a FHIR Practitioner resource, and add it to the given Bundle.
 * @param bundle The Bundle to add to
 * @param clinician The clinician
 * @return The added Entry
 */
protected static BundleEntryComponent practitioner(Bundle bundle, Clinician clinician) {
  Practitioner practitionerResource = new Practitioner();

  practitionerResource.addIdentifier().setSystem("http://hl7.org/fhir/sid/us-npi")
  .setValue("" + clinician.identifier);
  practitionerResource.setActive(true);
  practitionerResource.addName().setFamily(
      (String) clinician.attributes.get(Clinician.LAST_NAME))
    .addGiven((String) clinician.attributes.get(Clinician.FIRST_NAME))
    .addPrefix((String) clinician.attributes.get(Clinician.NAME_PREFIX));

  Address address = new Address()
      .addLine((String) clinician.attributes.get(Clinician.ADDRESS))
      .setCity((String) clinician.attributes.get(Clinician.CITY))
      .setPostalCode((String) clinician.attributes.get(Clinician.ZIP))
      .setState((String) clinician.attributes.get(Clinician.STATE));
  if (COUNTRY_CODE != null) {
    address.setCountry(COUNTRY_CODE);
  }
  practitionerResource.addAddress(address);

  if (clinician.attributes.get(Person.GENDER).equals("M")) {
    practitionerResource.setGender(AdministrativeGender.MALE);
  } else if (clinician.attributes.get(Person.GENDER).equals("F")) {
    practitionerResource.setGender(AdministrativeGender.FEMALE);
  }

  return newEntry(bundle, practitionerResource, clinician.getResourceID());
}
 
Example #7
Source File: LocationEntityToFHIRLocationTransformerTest.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Test
public void testTransformLocationEntity(){

    LocationEntity locationEntity = new LocationEntityBuilder()
            .setName("Example Location")
            .addAddress("20 High Street", "Holmfirth", null,
                    "Halifax", "West Yorkshire", "HX1 2TT")
            .addHomePhone("0113240998")
            .build();

    Location location = transformer.transform(locationEntity);

    // Check that the Name has been populated
    assertThat(location, not(nullValue()));
    assertThat(location.getName(), equalTo("Example Location"));

    // Check that the Address has been populated
    Address address = location.getAddress();
    assertThat(address, not(nullValue()));
    assertThat(address.getLine().get(0).getValue(), equalTo("20 High Street"));
    assertThat(address.getLine().get(1).getValue(), equalTo("Holmfirth"));
    assertThat(address.getLine().size(),equalTo(2));
   // assertThat(address.getLine().get(3), nullValue());
    assertThat(address.getDistrict(), equalTo("West Yorkshire"));
    assertThat(address.getCity(), equalTo("Halifax"));
    assertThat(address.getPostalCode(), equalTo("HX1 2TT"));

    // Check that the Telephone Number has been populated
    assertThat(location.getTelecom(), not(nullValue()));
    assertThat(location.getTelecom().size(), equalTo(1));
    ContactPoint phoneNumber = location.getTelecom().get(0);
    assertThat(phoneNumber.getValue(), equalTo("0113240998"));
    assertThat(phoneNumber.getUse().getDisplay(), equalTo("Home"));
}
 
Example #8
Source File: PractitionerEntityBuilder.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
public PractitionerEntityBuilder addAddress(String line1, String line2, String line3, String city, String district, String postcode) {
    PractitionerAddress address = new PractitionerAddress();
    address.setAddressType(Address.AddressType.BOTH);
    address.setAddressUse(Address.AddressUse.WORK);
    AddressEntity addressEntity = new AddressEntity();
    addressEntity.setAddress1(line1);
    addressEntity.setAddress2(line2);
    addressEntity.setAddress3(line3);
    addressEntity.setCity(city);
    addressEntity.setCounty(district);
    addressEntity.setPostcode(postcode);
    address.setAddress(addressEntity);
    addresses.add(address);
    return this;
}
 
Example #9
Source File: PractitionerEntityToFHIRPractitionerTransformerTest.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@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 #10
Source File: PractitionerEntityToFHIRPractitionerTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Practitioner transform(final PractitionerEntity practitionerEntity) {
    final Practitioner practitioner = new Practitioner();

    Meta meta = new Meta().addProfile(CareConnectProfile.Practitioner_1);

    if (practitionerEntity.getUpdated() != null) {
        meta.setLastUpdated(practitionerEntity.getUpdated());
    }
    else {
        if (practitionerEntity.getCreated() != null) {
            meta.setLastUpdated(practitionerEntity.getCreated());
        }
    }
    practitioner.setMeta(meta);
    if (practitionerEntity.getActive() != null) {
        practitioner.setActive(practitionerEntity.getActive());
    }

    for(PractitionerIdentifier identifier :practitionerEntity.getIdentifiers())
    {
        Identifier ident = practitioner.addIdentifier();
        ident = daoutils.getIdentifier(identifier, ident);
    }

    practitioner.setId(practitionerEntity.getId().toString());

    if (practitionerEntity.getNames().size() > 0) {

        practitioner.addName()
                .setFamily(practitionerEntity.getNames().get(0).getFamilyName())
                .addGiven(practitionerEntity.getNames().get(0).getGivenName())
                .addPrefix(practitionerEntity.getNames().get(0).getPrefix());
    }
    for(int f=0;f<practitionerEntity.getTelecoms().size();f++)
    {
        practitioner.addTelecom()
                .setSystem(practitionerEntity.getTelecoms().get(f).getSystem())
                .setValue(practitionerEntity.getTelecoms().get(f).getValue())
                .setUse(practitionerEntity.getTelecoms().get(f).getTelecomUse());
    }


    for (PractitionerAddress practitionerAddress : practitionerEntity.getAddresses()){
        Address address = addressTransformer.transform(practitionerAddress);
        practitioner.addAddress(address);
    }

    if (practitionerEntity.getGender() !=null)
    {
        practitioner.setGender(daoutils.getGender(practitionerEntity.getGender()));
    }

    return practitioner;

}
 
Example #11
Source File: PatientAddressBuilder.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public PatientAddressBuilder setAddressType(Address.AddressType addressType) {
    this.addressType = addressType;
    return this;
}
 
Example #12
Source File: PatientAddressBuilder.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public PatientAddressBuilder setAddressUse(Address.AddressUse addressUse) {
    this.addressUse = addressUse;
    return this;
}
 
Example #13
Source File: PractitionerEntityToFHIRPractitionerTransformerTest.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Before
public void setup(){
    Transformer<BaseAddress, Address> addressTransformer = new BaseAddressToFHIRAddressTransformer();
    transformer = new PractitionerEntityToFHIRPractitionerTransformer(addressTransformer);
}
 
Example #14
Source File: Convert.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public Address makeAddressFromAD(Element e) {
		if (e == null)
			return null;
	  Address a = new Address();
  	String use = e.getAttribute("use");
	  if (use != null) {
	  	if (use.equals("H") || use.equals("HP") || use.equals("HV"))
	  		a.setUse(AddressUse.HOME);
	  	else if (use.equals("WP") || use.equals("DIR") || use.equals("PUB"))
	  		a.setUse(AddressUse.WORK);
	  	else if (use.equals("TMP"))
	  		a.setUse(AddressUse.TEMP);
	  	else if (use.equals("BAD"))
	  		a.setUse(AddressUse.OLD);
	  }
	  Node n = e.getFirstChild();
	  while (n != null) {
	  	if (n.getNodeType() == Node.ELEMENT_NODE) {
	  		String v = n.getTextContent();
	  		if (n.getLocalName().equals("additionalLocator"))
	  			a.getLine().add(makeString(v));
//	  		else if (e.getLocalName().equals("unitID"))
//	  			else if (e.getLocalName().equals("unitType"))
	  			else if (n.getLocalName().equals("deliveryAddressLine"))
		  			a.getLine().add(makeString(v));
//	  			else if (e.getLocalName().equals("deliveryInstallationType"))
//	  			else if (e.getLocalName().equals("deliveryInstallationArea"))
//	  			else if (e.getLocalName().equals("deliveryInstallationQualifier"))
//	  			else if (e.getLocalName().equals("deliveryMode"))
//	  			else if (e.getLocalName().equals("deliveryModeIdentifier"))
	  			else if (n.getLocalName().equals("streetAddressLine"))
		  			a.getLine().add(makeString(v));
//	  			else if (e.getLocalName().equals("houseNumber"))
//	  			else if (e.getLocalName().equals("buildingNumberSuffix"))
//	  			else if (e.getLocalName().equals("postBox"))
//	  			else if (e.getLocalName().equals("houseNumberNumeric"))
//	  			else if (e.getLocalName().equals("streetName"))
//	  			else if (e.getLocalName().equals("streetNameBase"))
//	  			else if (e.getLocalName().equals("streetNameType"))
	  			else if (n.getLocalName().equals("direction"))
		  			a.getLine().add(makeString(v));
	  			else if (n.getLocalName().equals("careOf"))
		  			a.getLine().add(makeString(v));
//	  			else if (e.getLocalName().equals("censusTract"))
	  			else if (n.getLocalName().equals("country"))
		  			a.setCountry(v);
	  			//else if (e.getLocalName().equals("county"))
	  			else if (n.getLocalName().equals("city"))
		  			a.setCity(v);
//	  			else if (e.getLocalName().equals("delimiter"))
//	  			else if (e.getLocalName().equals("precinct"))
	  			else if (n.getLocalName().equals("state"))
		  			a.setState(v);
	  			else if (n.getLocalName().equals("postalCode"))
		  			a.setPostalCode(v);
	  	}  		
	  	n = n.getNextSibling();
	  }
	  return a;
  }
 
Example #15
Source File: PractitionerEntityToFHIRPractitionerTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public PractitionerEntityToFHIRPractitionerTransformer(@Autowired Transformer<BaseAddress, Address> addressTransformer) {
    this.addressTransformer = addressTransformer;
}
 
Example #16
Source File: ConceptMapEntityToFHIRConceptMapTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public ConceptMapEntityToFHIRConceptMapTransformer(@Autowired Transformer<BaseAddress, Address> addressTransformer) {
    this.addressTransformer = addressTransformer;
}
 
Example #17
Source File: PractitionerRoleToFHIRPractitionerRoleTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public PractitionerRoleToFHIRPractitionerRoleTransformer(@Autowired Transformer<BaseAddress, Address> addressTransformer) {
    this.addressTransformer = addressTransformer;
}
 
Example #18
Source File: BaseAddressToFHIRAddressTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Address transform(BaseAddress baseAddress) {

    Address address= new Address();
    AddressEntity addressEntity = baseAddress.getAddress();
    if (addressEntity.getAddress1()!=null && !addressEntity.getAddress1().isEmpty())
    {
        address.addLine(addressEntity.getAddress1().trim());
    }
    if (addressEntity.getAddress2()!=null && !addressEntity.getAddress2().isEmpty())
    {
        address.addLine(addressEntity.getAddress2().trim());
    }
    if (addressEntity.getAddress3()!=null && !addressEntity.getAddress3().isEmpty())
    {
        address.addLine(addressEntity.getAddress3().trim());
    }
    if (addressEntity.getAddress4()!=null && !addressEntity.getAddress4().isEmpty())
    {
        address.addLine(addressEntity.getAddress4().trim());
    }
    if (addressEntity.getPostcode() !=null)
    {
        address.setPostalCode(addressEntity.getPostcode());
    }
    if (addressEntity.getCity() != null) {
        address.setCity(addressEntity.getCity());
    }
    if (addressEntity.getCounty() != null) {
        address.setDistrict(addressEntity.getCounty());
    }
    if (addressEntity.getCountry() != null) {
        address.setCountry(addressEntity.getCountry());
    }

    if (baseAddress.getAddressType() != null) {
        address.setType(baseAddress.getAddressType());
    }
    if (baseAddress.getAddressUse() != null) {
        address.setUse(baseAddress.getAddressUse());
    }

    return address;
}
 
Example #19
Source File: BaseAddress.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public void setAddressType(Address.AddressType addressType) {
    this.addressType = addressType;
}
 
Example #20
Source File: BaseAddress.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public Address.AddressType getAddressType() {
    return addressType;
}
 
Example #21
Source File: BaseAddress.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public void setAddressUse(Address.AddressUse addressUse) {
    this.addressUse = addressUse;
}
 
Example #22
Source File: BaseAddress.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public Address.AddressUse getAddressUse() {
    return addressUse;
}
 
Example #23
Source File: TestData.java    From bunsen with Apache License 2.0 4 votes vote down vote up
/**
 * 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 #24
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void renderAddress(Address address, XhtmlNode x) {
  x.addText(displayAddress(address));
}