Java Code Examples for org.hl7.fhir.dstu3.model.Address#setCountry()

The following examples show how to use org.hl7.fhir.dstu3.model.Address#setCountry() . 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: 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 2
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 3
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;
}