use of ca.uhn.fhir.model.dstu2.composite.AddressDt in project eCRNow by drajer-health.
the class Dstu2CdaHeaderGenerator method getOrganizationXml.
public static String getOrganizationXml(Organization org, LaunchDetails details) {
StringBuilder sb = new StringBuilder(200);
if (org != null) {
IdentifierDt id = org.getIdentifierFirstRep();
if (id != null && !id.isEmpty()) {
sb.append(CdaGeneratorUtils.getXmlForII(details.getAssigningAuthorityId(), id.getValue()));
} else {
sb.append(CdaGeneratorUtils.getXmlForII(details.getAssigningAuthorityId(), org.getId().getValue()));
}
sb.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.NAME_EL_NAME, org.getName()));
sb.append(Dstu2CdaFhirUtilities.getTelecomXml(org.getTelecom()));
sb.append(Dstu2CdaFhirUtilities.getAddressXml(org.getAddress()));
} else {
// ***************
// NOTE : THIS IS TEMPORARY --------
// For Connectathon testing add defaults, this needs to be removed after connectathon and
// replaced with the commented out code.
// ***************
sb.append(CdaGeneratorUtils.getXmlForII(details.getAssigningAuthorityId(), "UtahOutpatientClinic"));
sb.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.NAME_EL_NAME, "Utah Outpatient Clinic"));
List<ContactPointDt> cps = new ArrayList<ContactPointDt>();
ContactPointDt cp = new ContactPointDt();
cp.setSystem(ContactPointSystemEnum.PHONE);
cp.setUse(ContactPointUseEnum.HOME);
cp.setValue("5557770123");
cps.add(cp);
sb.append(Dstu2CdaFhirUtilities.getTelecomXml(cps));
List<AddressDt> addrs = new ArrayList<AddressDt>();
AddressDt addr = new AddressDt();
List<StringDt> addrLine = new ArrayList<StringDt>();
addrLine.add(new StringDt("0987 Facility Drive"));
addr.setLine(addrLine);
addr.setCity("alt Lake City");
addr.setState("UT");
addr.setCountry("US");
addr.setPostalCode("84101");
addr.setUse(AddressUseEnum.WORK);
addrs.add(addr);
sb.append(Dstu2CdaFhirUtilities.getAddressXml(addrs));
/* sb.append(CdaGeneratorUtils.getNFXMLForII(CdaGeneratorConstants.NF_NI));
sb.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.NAME_EL_NAME, CdaGeneratorConstants.UNKNOWN_VALUE));
List<ContactPointDt> cps = null;
sb.append(CdaFhirUtilities.getTelecomXml(cps));
List<AddressDt> addrs = null;
sb.append(CdaFhirUtilities.getAddressXml(addrs)); */
}
return sb.toString();
}
use of ca.uhn.fhir.model.dstu2.composite.AddressDt in project synthea by synthetichealth.
the class FhirDstu2 method practitioner.
/**
* 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 Entry practitioner(Bundle bundle, Clinician clinician) {
Practitioner practitionerResource = new Practitioner();
practitionerResource.addIdentifier().setSystem("http://hl7.org/fhir/sid/us-npi").setValue(clinician.npi);
practitionerResource.setActive(true);
practitionerResource.getName().addFamily((String) clinician.attributes.get(Clinician.LAST_NAME)).addGiven((String) clinician.attributes.get(Clinician.FIRST_NAME)).addPrefix((String) clinician.attributes.get(Clinician.NAME_PREFIX));
AddressDt address = new AddressDt().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(AdministrativeGenderEnum.MALE);
} else if (clinician.attributes.get(Person.GENDER).equals("F")) {
practitionerResource.setGender(AdministrativeGenderEnum.FEMALE);
}
return newEntry(bundle, practitionerResource, clinician.getResourceID());
}
use of ca.uhn.fhir.model.dstu2.composite.AddressDt in project synthea by synthetichealth.
the class FhirDstu2 method provider.
/**
* Map the Provider into a FHIR Organization resource, and add it to the given Bundle.
*
* @param bundle
* The Bundle to add to
* @param provider
* The Provider
* @return The added Entry
*/
protected static Entry provider(Bundle bundle, Provider provider) {
ca.uhn.fhir.model.dstu2.resource.Organization organizationResource = new ca.uhn.fhir.model.dstu2.resource.Organization();
CodeableConceptDt organizationType = mapCodeToCodeableConcept(new Code("http://hl7.org/fhir/ValueSet/organization-type", "prov", "Healthcare Provider"), "Healthcare Provider");
organizationResource.addIdentifier().setSystem("https://github.com/synthetichealth/synthea").setValue((String) provider.getResourceID());
organizationResource.setName(provider.name);
organizationResource.setType(organizationType);
AddressDt address = new AddressDt().addLine(provider.address).setCity(provider.city).setPostalCode(provider.zip).setState(provider.state);
if (COUNTRY_CODE != null) {
address.setCountry(COUNTRY_CODE);
}
organizationResource.addAddress(address);
if (provider.phone != null && !provider.phone.isEmpty()) {
ContactPointDt contactPoint = new ContactPointDt().setSystem(ContactPointSystemEnum.PHONE).setValue(provider.phone);
organizationResource.addTelecom(contactPoint);
}
return newEntry(bundle, organizationResource, provider.getResourceID());
}
use of ca.uhn.fhir.model.dstu2.composite.AddressDt in project synthea by synthetichealth.
the class FhirDstu2 method basicInfo.
/**
* Map the given Person to a FHIR Patient resource, and add it to the given Bundle.
*
* @param person
* The Person
* @param bundle
* The Bundle to add to
* @param stopTime
* Time the simulation ended
* @return The created Entry
*/
@SuppressWarnings("rawtypes")
private static Entry basicInfo(Person person, Bundle bundle, long stopTime) {
Patient patientResource = new Patient();
patientResource.addIdentifier().setSystem("https://github.com/synthetichealth/synthea").setValue((String) person.attributes.get(Person.ID));
patientResource.addIdentifier().setType(IdentifierTypeCodesEnum.MR).setSystem("http://hospital.smarthealthit.org").setValue((String) person.attributes.get(Person.ID));
patientResource.addIdentifier().setType(IdentifierTypeCodesEnum.SOCIAL_BENEFICIARY_IDENTIFIER).setSystem("http://hl7.org/fhir/sid/us-ssn").setValue((String) person.attributes.get(Person.IDENTIFIER_SSN));
if (person.attributes.get(Person.IDENTIFIER_DRIVERS) != null) {
patientResource.addIdentifier().setType(IdentifierTypeCodesEnum.DL).setSystem("urn:oid:2.16.840.1.113883.4.3.25").setValue((String) person.attributes.get(Person.IDENTIFIER_DRIVERS));
}
ExtensionDt raceExtension = new ExtensionDt();
raceExtension.setUrl("http://hl7.org/fhir/StructureDefinition/us-core-race");
String race = (String) person.attributes.get(Person.RACE);
ExtensionDt ethnicityExtension = new ExtensionDt();
ethnicityExtension.setUrl("http://hl7.org/fhir/StructureDefinition/us-core-ethnicity");
String ethnicity = (String) person.attributes.get(Person.ETHNICITY);
String raceDisplay;
switch(race) {
case "white":
raceDisplay = "White";
break;
case "black":
raceDisplay = "Black or African American";
break;
case "asian":
raceDisplay = "Asian";
break;
case "native":
raceDisplay = "American Indian or Alaska Native";
break;
case "hawaiian":
raceDisplay = "Native Hawaiian or Other Pacific Islander";
break;
default:
raceDisplay = "Other";
break;
}
String ethnicityDisplay;
if (ethnicity.equals("hispanic")) {
ethnicityDisplay = "Hispanic or Latino";
} else {
ethnicityDisplay = "Not Hispanic or Latino";
}
Code raceCode = new Code("http://hl7.org/fhir/v3/Race", (String) raceEthnicityCodes.get(race), raceDisplay);
Code ethnicityCode = new Code("http://hl7.org/fhir/v3/Ethnicity", (String) raceEthnicityCodes.get(ethnicity), ethnicityDisplay);
raceExtension.setValue(mapCodeToCodeableConcept(raceCode, "http://hl7.org/fhir/v3/Race"));
ethnicityExtension.setValue(mapCodeToCodeableConcept(ethnicityCode, "http://hl7.org/fhir/v3/Ethnicity"));
patientResource.addUndeclaredExtension(raceExtension);
patientResource.addUndeclaredExtension(ethnicityExtension);
String firstLanguage = (String) person.attributes.get(Person.FIRST_LANGUAGE);
Map languageMap = (Map) languageLookup.get(firstLanguage);
Code languageCode = new Code((String) languageMap.get("system"), (String) languageMap.get("code"), (String) languageMap.get("display"));
List<Communication> communication = new ArrayList<Communication>();
Communication language = new Communication();
language.setLanguage(mapCodeToCodeableConcept(languageCode, (String) languageMap.get("system")));
communication.add(language);
patientResource.setCommunication(communication);
HumanNameDt name = patientResource.addName();
name.setUse(NameUseEnum.OFFICIAL);
name.addGiven((String) person.attributes.get(Person.FIRST_NAME));
List<StringDt> officialFamilyNames = new ArrayList<StringDt>();
officialFamilyNames.add(new StringDt((String) person.attributes.get(Person.LAST_NAME)));
name.setFamily(officialFamilyNames);
if (person.attributes.get(Person.NAME_PREFIX) != null) {
name.addPrefix((String) person.attributes.get(Person.NAME_PREFIX));
}
if (person.attributes.get(Person.NAME_SUFFIX) != null) {
name.addSuffix((String) person.attributes.get(Person.NAME_SUFFIX));
}
if (person.attributes.get(Person.MAIDEN_NAME) != null) {
HumanNameDt maidenName = patientResource.addName();
maidenName.setUse(NameUseEnum.MAIDEN);
maidenName.addGiven((String) person.attributes.get(Person.FIRST_NAME));
List<StringDt> maidenFamilyNames = new ArrayList<StringDt>();
maidenFamilyNames.add(new StringDt((String) person.attributes.get(Person.MAIDEN_NAME)));
maidenName.setFamily(maidenFamilyNames);
if (person.attributes.get(Person.NAME_PREFIX) != null) {
maidenName.addPrefix((String) person.attributes.get(Person.NAME_PREFIX));
}
if (person.attributes.get(Person.NAME_SUFFIX) != null) {
maidenName.addSuffix((String) person.attributes.get(Person.NAME_SUFFIX));
}
}
ExtensionDt mothersMaidenNameExtension = new ExtensionDt();
mothersMaidenNameExtension.setUrl("http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName");
String mothersMaidenName = (String) person.attributes.get(Person.NAME_MOTHER);
mothersMaidenNameExtension.setValue(new StringDt(mothersMaidenName));
patientResource.addUndeclaredExtension(mothersMaidenNameExtension);
long birthdate = (long) person.attributes.get(Person.BIRTHDATE);
patientResource.setBirthDate(new DateDt(new Date(birthdate)));
ExtensionDt birthSexExtension = new ExtensionDt();
birthSexExtension.setUrl("http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex");
if (person.attributes.get(Person.GENDER).equals("M")) {
patientResource.setGender(AdministrativeGenderEnum.MALE);
birthSexExtension.setValue(new CodeDt("M"));
} else if (person.attributes.get(Person.GENDER).equals("F")) {
patientResource.setGender(AdministrativeGenderEnum.FEMALE);
birthSexExtension.setValue(new CodeDt("F"));
}
patientResource.addUndeclaredExtension(birthSexExtension);
String state = (String) person.attributes.get(Person.STATE);
AddressDt addrResource = patientResource.addAddress();
addrResource.addLine((String) person.attributes.get(Person.ADDRESS)).setCity((String) person.attributes.get(Person.CITY)).setPostalCode((String) person.attributes.get(Person.ZIP)).setState(state);
if (COUNTRY_CODE != null) {
addrResource.setCountry(COUNTRY_CODE);
}
Point2D.Double coord = person.getLonLat();
if (coord != null) {
ExtensionDt geolocationExtension = new ExtensionDt();
geolocationExtension.setUrl("http://hl7.org/fhir/StructureDefinition/geolocation");
ExtensionDt latitudeExtension = new ExtensionDt();
ExtensionDt longitudeExtension = new ExtensionDt();
latitudeExtension.setUrl("latitude");
longitudeExtension.setUrl("longitude");
latitudeExtension.setValue(new DecimalDt(coord.getY()));
longitudeExtension.setValue(new DecimalDt(coord.getX()));
geolocationExtension.addUndeclaredExtension(latitudeExtension);
geolocationExtension.addUndeclaredExtension(longitudeExtension);
addrResource.addUndeclaredExtension(geolocationExtension);
}
AddressDt birthplace = new AddressDt();
birthplace.setCity((String) person.attributes.get(Person.BIRTH_CITY)).setState((String) person.attributes.get(Person.BIRTH_STATE)).setCountry((String) person.attributes.get(Person.BIRTH_COUNTRY));
ExtensionDt birthplaceExtension = new ExtensionDt();
birthplaceExtension.setUrl("http://hl7.org/fhir/StructureDefinition/birthPlace");
birthplaceExtension.setValue(birthplace);
patientResource.addUndeclaredExtension(birthplaceExtension);
if (person.attributes.get(Person.MULTIPLE_BIRTH_STATUS) != null) {
patientResource.setMultipleBirth(new IntegerDt((int) person.attributes.get(Person.MULTIPLE_BIRTH_STATUS)));
} else {
patientResource.setMultipleBirth(new BooleanDt(false));
}
patientResource.addTelecom().setSystem(ContactPointSystemEnum.PHONE).setUse(ContactPointUseEnum.HOME).setValue((String) person.attributes.get(Person.TELECOM));
String maritalStatus = ((String) person.attributes.get(Person.MARITAL_STATUS));
if (maritalStatus != null) {
patientResource.setMaritalStatus(MaritalStatusCodesEnum.forCode(maritalStatus.toUpperCase()));
} else {
patientResource.setMaritalStatus(MaritalStatusCodesEnum.S);
}
if (!person.alive(stopTime)) {
patientResource.setDeceased(convertFhirDateTime((Long) person.attributes.get(Person.DEATHDATE), true));
}
String generatedBySynthea = "Generated by <a href=\"https://github.com/synthetichealth/synthea\">Synthea</a>." + "Version identifier: " + Utilities.SYNTHEA_VERSION + " . " + " Person seed: " + person.seed + " Population seed: " + person.populationSeed;
patientResource.setText(new NarrativeDt(new XhtmlDt(generatedBySynthea), NarrativeStatusEnum.GENERATED));
// DALY and QALY values
// we only write the last(current) one to the patient record
Double dalyValue = (Double) person.attributes.get("most-recent-daly");
Double qalyValue = (Double) person.attributes.get("most-recent-qaly");
if (dalyValue != null) {
ExtensionDt dalyExtension = new ExtensionDt();
dalyExtension.setUrl(SYNTHEA_EXT + "disability-adjusted-life-years");
DecimalDt daly = new DecimalDt(dalyValue);
dalyExtension.setValue(daly);
patientResource.addUndeclaredExtension(dalyExtension);
ExtensionDt qalyExtension = new ExtensionDt();
qalyExtension.setUrl(SYNTHEA_EXT + "quality-adjusted-life-years");
DecimalDt qaly = new DecimalDt(qalyValue);
qalyExtension.setValue(qaly);
patientResource.addUndeclaredExtension(qalyExtension);
}
return newEntry(bundle, patientResource, (String) person.attributes.get(Person.ID));
}
use of ca.uhn.fhir.model.dstu2.composite.AddressDt in project eCRNow by drajer-health.
the class Dstu2CdaFhirUtilities method getAddressXml.
public static String getAddressXml(List<AddressDt> addrs) {
StringBuilder addrString = new StringBuilder(200);
if (addrs != null && addrs.size() > 0) {
for (AddressDt addr : addrs) {
if (addr.getUseElement().getValueAsEnum() == AddressUseEnum.HOME || addr.getUseElement().getValueAsEnum() == AddressUseEnum.WORK) {
logger.info(" Found Home or Work Address ");
addrString.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.ADDR_EL_NAME));
// Address Line
if (!StringUtils.isEmpty(addr.getLineFirstRep().getValueAsString())) {
addrString.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.ST_ADDR_LINE_EL_NAME, addr.getLineFirstRep().getValue()));
} else {
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.ST_ADDR_LINE_EL_NAME, CdaGeneratorConstants.NF_NI));
}
// City
if (!StringUtils.isEmpty(addr.getCity())) {
addrString.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.CITY_EL_NAME, addr.getCity()));
} else {
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.CITY_EL_NAME, CdaGeneratorConstants.NF_NI));
}
// State
if (!StringUtils.isEmpty(addr.getState())) {
addrString.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.STATE_EL_NAME, addr.getState()));
} else {
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.STATE_EL_NAME, CdaGeneratorConstants.NF_NI));
}
// Postal Code
if (!StringUtils.isEmpty(addr.getPostalCode())) {
addrString.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.POSTAL_CODE_EL_NAME, addr.getPostalCode()));
} else {
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.POSTAL_CODE_EL_NAME, CdaGeneratorConstants.NF_NI));
}
// Country
if (!StringUtils.isEmpty(addr.getCountry())) {
addrString.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.COUNTRY_EL_NAME, addr.getCountry()));
} else {
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.COUNTRY_EL_NAME, CdaGeneratorConstants.NF_NI));
}
addrString.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.ADDR_EL_NAME));
break;
}
}
} else {
logger.info(" Did not find the Address ");
addrString.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.ADDR_EL_NAME));
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.ST_ADDR_LINE_EL_NAME, CdaGeneratorConstants.NF_NI));
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.CITY_EL_NAME, CdaGeneratorConstants.NF_NI));
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.STATE_EL_NAME, CdaGeneratorConstants.NF_NI));
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.POSTAL_CODE_EL_NAME, CdaGeneratorConstants.NF_NI));
addrString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.COUNTRY_EL_NAME, CdaGeneratorConstants.NF_NI));
addrString.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.ADDR_EL_NAME));
}
// logger.info(" Address String = " + addrString.toString());
return addrString.toString();
}
Aggregations