Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
package gov.va.med.pbm.ampl.fhir.unmarshall.dstu2.unbundle;
import java.util.Optional;
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
import gov.va.med.pbm.ampl.model.Location;
/**
* The UnbundleLocation class marshals a {@link ca.uhn.fhir.model.dstu2.resource.Location} resource to a client readable JSON
* format.
*
* @author Ian Meinert
*
*/
public class UnbundleLocation {
private ResourceReferenceDt resourceReference;
/**
* Overloaded constructor accepting a {@link ResourceReferenceDt}.
*
* @param resourceReference {@link ResourceReferenceDt}
*/
public UnbundleLocation(ResourceReferenceDt resourceReference) {
this.resourceReference = resourceReference;
}
/**
* This method returns the marshalled {@link ResourceReferenceDt} as a {@link Location}.
*
* @return {@link Location}
*/
public Location getResourceAsLocation() {
Optional<ca.uhn.fhir.model.dstu2.resource.Location> optLocation = Optional
.ofNullable((ca.uhn.fhir.model.dstu2.resource.Location) resourceReference.getResource());
return this.getLocation(optLocation);
}
/**
* This method returns the marshalled an Optional {@link ca.uhn.fhir.model.dstu2.resource.Location} as a {@link Location}.
*
* @param optLocation Optional {@link ca.uhn.fhir.model.dstu2.resource.Location}
* @return {@link Location}
*/
public Location getLocation(Optional<ca.uhn.fhir.model.dstu2.resource.Location> optLocation) {
Location location = new Location();
if (optLocation.isPresent()) {
ca.uhn.fhir.model.dstu2.resource.Location fhirLocation = optLocation.get();
UnbundleFacility unbundler = new UnbundleFacility(fhirLocation.getManagingOrganization());
location.setFacility(unbundler.getResourceAsOrganization());
location.setName(fhirLocation.getName());
location.setPhysicalType(fhirLocation.getPhysicalType().getText());
location.setSpecialty(fhirLocation.getType().getText());
}
return location;
}
}