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

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