use of org.hl7.fhir.r4.model.IntegerType in project synthea by synthetichealth.
the class FhirR4 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 BundleEntryComponent basicInfo(Person person, Bundle bundle, long stopTime) {
Patient patientResource = new Patient();
patientResource.addIdentifier().setSystem(SYNTHEA_IDENTIFIER).setValue((String) person.attributes.get(Person.ID));
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient");
patientResource.setMeta(meta);
}
Code mrnCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "MR", "Medical Record Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(mrnCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem("http://hospital.smarthealthit.org").setValue((String) person.attributes.get(Person.ID));
Code ssnCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "SS", "Social Security Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(ssnCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem("http://hl7.org/fhir/sid/us-ssn").setValue((String) person.attributes.get(Person.IDENTIFIER_SSN));
if (person.attributes.get(Person.IDENTIFIER_DRIVERS) != null) {
Code driversCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "DL", "Driver's License");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(driversCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem("urn:oid:2.16.840.1.113883.4.3.25").setValue((String) person.attributes.get(Person.IDENTIFIER_DRIVERS));
}
if (person.attributes.get(Person.IDENTIFIER_PASSPORT) != null) {
Code passportCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "PPN", "Passport Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(passportCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem(SHR_EXT + "passportNumber").setValue((String) person.attributes.get(Person.IDENTIFIER_PASSPORT));
}
if (person.attributes.get(Person.CONTACT_EMAIL) != null) {
ContactComponent contact = new ContactComponent();
HumanName contactName = new HumanName();
contactName.setUse(HumanName.NameUse.OFFICIAL);
contactName.addGiven((String) person.attributes.get(Person.CONTACT_GIVEN_NAME));
contactName.setFamily((String) person.attributes.get(Person.CONTACT_FAMILY_NAME));
contact.setName(contactName);
contact.addTelecom().setSystem(ContactPointSystem.EMAIL).setUse(ContactPointUse.HOME).setValue((String) person.attributes.get(Person.CONTACT_EMAIL));
patientResource.addContact(contact);
}
if (USE_US_CORE_IG) {
// We do not yet account for mixed race
Extension raceExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-race");
String race = (String) person.attributes.get(Person.RACE);
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 raceNum = (String) raceEthnicityCodes.get(race);
Extension raceCodingExtension = new Extension("ombCategory");
Coding raceCoding = new Coding();
if (raceDisplay.equals("Other")) {
raceCoding.setSystem("http://terminology.hl7.org/CodeSystem/v3-NullFlavor");
raceCoding.setCode("UNK");
raceCoding.setDisplay("Unknown");
} else {
raceCoding.setSystem("urn:oid:2.16.840.1.113883.6.238");
raceCoding.setCode(raceNum);
raceCoding.setDisplay(raceDisplay);
}
raceCodingExtension.setValue(raceCoding);
raceExtension.addExtension(raceCodingExtension);
Extension raceTextExtension = new Extension("text");
raceTextExtension.setValue(new StringType(raceDisplay));
raceExtension.addExtension(raceTextExtension);
patientResource.addExtension(raceExtension);
// We do not yet account for mixed ethnicity
Extension ethnicityExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity");
String ethnicity = (String) person.attributes.get(Person.ETHNICITY);
String ethnicityDisplay;
if (ethnicity.equals("hispanic")) {
ethnicity = "hispanic";
ethnicityDisplay = "Hispanic or Latino";
} else {
ethnicity = "nonhispanic";
ethnicityDisplay = "Not Hispanic or Latino";
}
String ethnicityNum = (String) raceEthnicityCodes.get(ethnicity);
Extension ethnicityCodingExtension = new Extension("ombCategory");
Coding ethnicityCoding = new Coding();
ethnicityCoding.setSystem("urn:oid:2.16.840.1.113883.6.238");
ethnicityCoding.setCode(ethnicityNum);
ethnicityCoding.setDisplay(ethnicityDisplay);
ethnicityCodingExtension.setValue(ethnicityCoding);
ethnicityExtension.addExtension(ethnicityCodingExtension);
Extension ethnicityTextExtension = new Extension("text");
ethnicityTextExtension.setValue(new StringType(ethnicityDisplay));
ethnicityExtension.addExtension(ethnicityTextExtension);
patientResource.addExtension(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<PatientCommunicationComponent> communication = new ArrayList<PatientCommunicationComponent>();
communication.add(new PatientCommunicationComponent(mapCodeToCodeableConcept(languageCode, (String) languageMap.get("system"))));
patientResource.setCommunication(communication);
HumanName name = patientResource.addName();
name.setUse(HumanName.NameUse.OFFICIAL);
name.addGiven((String) person.attributes.get(Person.FIRST_NAME));
name.setFamily((String) person.attributes.get(Person.LAST_NAME));
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) {
HumanName maidenName = patientResource.addName();
maidenName.setUse(HumanName.NameUse.MAIDEN);
maidenName.addGiven((String) person.attributes.get(Person.FIRST_NAME));
maidenName.setFamily((String) person.attributes.get(Person.MAIDEN_NAME));
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));
}
}
Extension mothersMaidenNameExtension = new Extension("http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName");
String mothersMaidenName = (String) person.attributes.get(Person.NAME_MOTHER);
mothersMaidenNameExtension.setValue(new StringType(mothersMaidenName));
patientResource.addExtension(mothersMaidenNameExtension);
long birthdate = (long) person.attributes.get(Person.BIRTHDATE);
patientResource.setBirthDate(new Date(birthdate));
Extension birthSexExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex");
if (person.attributes.get(Person.GENDER).equals("M")) {
patientResource.setGender(AdministrativeGender.MALE);
birthSexExtension.setValue(new CodeType("M"));
} else if (person.attributes.get(Person.GENDER).equals("F")) {
patientResource.setGender(AdministrativeGender.FEMALE);
birthSexExtension.setValue(new CodeType("F"));
} else if (person.attributes.get(Person.GENDER).equals("UNK")) {
patientResource.setGender(AdministrativeGender.UNKNOWN);
}
if (USE_US_CORE_IG) {
patientResource.addExtension(birthSexExtension);
}
String state = (String) person.attributes.get(Person.STATE);
if (USE_US_CORE_IG) {
state = Location.getAbbreviation(state);
}
Address 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);
}
Address birthplace = new Address();
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));
Extension birthplaceExtension = new Extension("http://hl7.org/fhir/StructureDefinition/patient-birthPlace");
birthplaceExtension.setValue(birthplace);
patientResource.addExtension(birthplaceExtension);
if (person.attributes.get(Person.MULTIPLE_BIRTH_STATUS) != null) {
patientResource.setMultipleBirth(new IntegerType((int) person.attributes.get(Person.MULTIPLE_BIRTH_STATUS)));
} else {
patientResource.setMultipleBirth(new BooleanType(false));
}
patientResource.addTelecom().setSystem(ContactPointSystem.PHONE).setUse(ContactPointUse.HOME).setValue((String) person.attributes.get(Person.TELECOM));
String maritalStatus = ((String) person.attributes.get(Person.MARITAL_STATUS));
if (maritalStatus != null) {
Code maritalStatusCode = new Code("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", maritalStatus, maritalStatus);
patientResource.setMaritalStatus(mapCodeToCodeableConcept(maritalStatusCode, "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"));
} else {
Code maritalStatusCode = new Code("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", "S", "Never Married");
patientResource.setMaritalStatus(mapCodeToCodeableConcept(maritalStatusCode, "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"));
}
Point2D.Double coord = person.getLonLat();
if (coord != null) {
Extension geolocation = addrResource.addExtension();
geolocation.setUrl("http://hl7.org/fhir/StructureDefinition/geolocation");
geolocation.addExtension("latitude", new DecimalType(coord.getY()));
geolocation.addExtension("longitude", new DecimalType(coord.getX()));
}
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.getSeed() + " Population seed: " + person.populationSeed;
patientResource.setText(new Narrative().setStatus(NarrativeStatus.GENERATED).setDiv(new XhtmlNode(NodeType.Element).setValue(generatedBySynthea)));
if (USE_SHR_EXTENSIONS) {
patientResource.setMeta(new Meta().addProfile(SHR_EXT + "shr-entity-Patient"));
// Patient profile requires race, ethnicity, birthsex,
// MothersMaidenName, FathersName, Person-extension
patientResource.addExtension().setUrl(SHR_EXT + "shr-actor-FictionalPerson-extension").setValue(new BooleanType(true));
String fathersName = (String) person.attributes.get(Person.NAME_FATHER);
Extension fathersNameExtension = new Extension(SHR_EXT + "shr-entity-FathersName-extension", new HumanName().setText(fathersName));
patientResource.addExtension(fathersNameExtension);
String ssn = (String) person.attributes.get(Person.IDENTIFIER_SSN);
Extension ssnExtension = new Extension(SHR_EXT + "shr-demographics-SocialSecurityNumber-extension", new StringType(ssn));
patientResource.addExtension(ssnExtension);
}
// 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) {
Extension dalyExtension = new Extension(SYNTHEA_EXT + "disability-adjusted-life-years");
DecimalType daly = new DecimalType(dalyValue);
dalyExtension.setValue(daly);
patientResource.addExtension(dalyExtension);
Extension qalyExtension = new Extension(SYNTHEA_EXT + "quality-adjusted-life-years");
DecimalType qaly = new DecimalType(qalyValue);
qalyExtension.setValue(qaly);
patientResource.addExtension(qalyExtension);
}
return newEntry(bundle, patientResource, (String) person.attributes.get(Person.ID));
}
use of org.hl7.fhir.r4.model.IntegerType in project synthea by synthetichealth.
the class HospitalExporterStu3 method addHospitalExtensions.
/**
* Add FHIR extensions to capture additional information.
*/
public static void addHospitalExtensions(Provider h, Organization organizationResource) {
Table<Integer, String, AtomicInteger> utilization = h.getUtilization();
// calculate totals for utilization
int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream().mapToInt(ai -> ai.get()).sum();
Extension encountersExtension = new Extension(SYNTHEA_URI + "utilization-encounters-extension");
IntegerType encountersValue = new IntegerType(totalEncounters);
encountersExtension.setValue(encountersValue);
organizationResource.addExtension(encountersExtension);
int totalProcedures = utilization.column(Provider.PROCEDURES).values().stream().mapToInt(ai -> ai.get()).sum();
Extension proceduresExtension = new Extension(SYNTHEA_URI + "utilization-procedures-extension");
IntegerType proceduresValue = new IntegerType(totalProcedures);
proceduresExtension.setValue(proceduresValue);
organizationResource.addExtension(proceduresExtension);
int totalLabs = utilization.column(Provider.LABS).values().stream().mapToInt(ai -> ai.get()).sum();
Extension labsExtension = new Extension(SYNTHEA_URI + "utilization-labs-extension");
IntegerType labsValue = new IntegerType(totalLabs);
labsExtension.setValue(labsValue);
organizationResource.addExtension(labsExtension);
int totalPrescriptions = utilization.column(Provider.PRESCRIPTIONS).values().stream().mapToInt(ai -> ai.get()).sum();
Extension prescriptionsExtension = new Extension(SYNTHEA_URI + "utilization-prescriptions-extension");
IntegerType prescriptionsValue = new IntegerType(totalPrescriptions);
prescriptionsExtension.setValue(prescriptionsValue);
organizationResource.addExtension(prescriptionsExtension);
Integer bedCount = h.getBedCount();
if (bedCount != null) {
Extension bedCountExtension = new Extension(SYNTHEA_URI + "bed-count-extension");
IntegerType bedCountValue = new IntegerType(bedCount);
bedCountExtension.setValue(bedCountValue);
organizationResource.addExtension(bedCountExtension);
}
}
use of org.hl7.fhir.r4.model.IntegerType in project bunsen by cerner.
the class TestData method newPatient.
/**
* Returns a FHIR Patient for testing purposes.
*/
public static Patient newPatient() {
Patient patient = new Patient();
patient.setId("test-patient");
patient.setMultipleBirth(new IntegerType(1));
return patient;
}
use of org.hl7.fhir.r4.model.IntegerType in project bunsen by cerner.
the class TestData method newBunsenTestProfilePatient.
/**
* Returns a new Patient from Bunsen Test profile for testing.
*
* @return a FHIR Patient for testing.
*/
public static Patient newBunsenTestProfilePatient() {
Patient patient = new Patient();
patient.setId("test-bunsen-test-profile-patient");
patient.setGender(AdministrativeGender.MALE);
patient.setActive(true);
patient.setMultipleBirth(new IntegerType(1));
patient.setBirthDateElement(new DateType("1945-01-01"));
// set extension field
Extension booleanField = patient.addExtension();
booleanField.setUrl(BUNSEN_TEST_BOOLEAN_FIELD);
booleanField.setValue(new BooleanType(true));
Extension integerField = patient.addExtension();
integerField.setUrl(BUNSEN_TEST_INTEGER_FIELD);
integerField.setValue(new IntegerType(45678));
Extension integerArrayField1 = patient.addExtension();
integerArrayField1.setUrl(BUNSEN_TEST_INTEGER_ARRAY_FIELD);
integerArrayField1.setValue(new IntegerType(6666));
Extension integerArrayField2 = patient.addExtension();
integerArrayField2.setUrl(BUNSEN_TEST_INTEGER_ARRAY_FIELD);
integerArrayField2.setValue(new IntegerType(9999));
// add multiple nested extensions
final Extension nestedExtension1 = patient.addExtension();
nestedExtension1.setUrl(BUNSEN_TEST_NESTED_EXT_FIELD);
nestedExtension1.setValue(null);
final Extension nestedExtension2 = patient.addExtension();
nestedExtension2.setUrl(BUNSEN_TEST_NESTED_EXT_FIELD);
nestedExtension2.setValue(null);
// add text as sub-extension to nestedExtension
final Extension textExt1 = nestedExtension1.addExtension();
textExt1.setUrl("text");
textExt1.setValue(new StringType("Text1 Sub-extension of nestedExtension1 field"));
final Extension textExt2 = nestedExtension1.addExtension();
textExt2.setUrl("text");
textExt2.setValue(new StringType("Text2 Sub-extension of nestedExtension1 field"));
final Extension textExt3 = nestedExtension2.addExtension();
textExt3.setUrl("text");
textExt3.setValue(new StringType("Text3 Sub-extension of nestedExtension2 field"));
// add multiple codeableConcept extensions to nestedExtension
final CodeableConcept codeableconcept1 = new CodeableConcept();
codeableconcept1.addCoding().setSystem("http://snomed.info/sct").setCode("CC1").setDisplay("CC1 - Codeable Concept Extension").setUserSelected(true);
final CodeableConcept codeableconcept2 = new CodeableConcept();
codeableconcept2.addCoding().setSystem("http://snomed.info/sct").setCode("CC2").setDisplay("CC2 - Codeable Concept Extension").setUserSelected(true);
final CodeableConcept codeableconcept3 = new CodeableConcept();
codeableconcept3.addCoding().setSystem("http://snomed.info/sct").setCode("CC3").setDisplay("CC3 - Codeable Concept Extension").setUserSelected(true);
final Extension codeableConceptExt1 = nestedExtension1.addExtension();
codeableConceptExt1.setUrl(BUNSEN_TEST_CODEABLE_CONCEPT_EXT_FIELD);
codeableConceptExt1.setValue(codeableconcept1);
final Extension codeableConceptExt2 = nestedExtension1.addExtension();
codeableConceptExt2.setUrl(BUNSEN_TEST_CODEABLE_CONCEPT_EXT_FIELD);
codeableConceptExt2.setValue(codeableconcept2);
final Extension codeableConceptExt3 = nestedExtension2.addExtension();
codeableConceptExt3.setUrl(BUNSEN_TEST_CODEABLE_CONCEPT_EXT_FIELD);
codeableConceptExt3.setValue(codeableconcept3);
// add multiple ModifierExtension fields
Extension stringModifierExtension = patient.addModifierExtension();
stringModifierExtension.setUrl(BUNSEN_TEST_STRING_MODIFIER_EXT_FIELD);
stringModifierExtension.setValue(new StringType("test string modifier value"));
CodeableConcept concept1 = new CodeableConcept();
concept1.addCoding().setSystem("http://snomed.info/sct").setCode("C-1").setDisplay("C-1 Codeable Concept Modifier Extension").setUserSelected(true);
Extension codeableConceptField = patient.addModifierExtension();
codeableConceptField.setUrl(BUNSEN_TEST_CODEABLE_CONCEPT_MODIFIER_EXT_FIELD);
codeableConceptField.setValue(concept1);
CodeableConcept concept2 = new CodeableConcept();
concept2.addCoding().setSystem("http://snomed.info/sct").setCode("C-2").setDisplay("C-2 Codeable Concept Modifier Extension").setUserSelected(true);
Extension codeableConceptField2 = patient.addModifierExtension();
codeableConceptField2.setUrl(BUNSEN_TEST_CODEABLE_CONCEPT_MODIFIER_EXT_FIELD);
codeableConceptField2.setValue(concept2);
return patient;
}
use of org.hl7.fhir.r4.model.IntegerType in project hapi-fhir-jpaserver-starter by hapifhir.
the class ElasticsearchLastNR4IT method testLastN.
@Test
void testLastN() throws IOException, InterruptedException {
Thread.sleep(2000);
Patient pt = new Patient();
pt.addName().setFamily("Lastn").addGiven("Arthur");
IIdType id = ourClient.create().resource(pt).execute().getId().toUnqualifiedVersionless();
Observation obs = new Observation();
obs.getSubject().setReferenceElement(id);
String observationCode = "testobservationcode";
String codeSystem = "http://testobservationcodesystem";
obs.getCode().addCoding().setCode(observationCode).setSystem(codeSystem);
obs.setValue(new StringType(observationCode));
Date effectiveDtm = new GregorianCalendar().getTime();
obs.setEffective(new DateTimeType(effectiveDtm));
obs.getCategoryFirstRep().addCoding().setCode("testcategorycode").setSystem("http://testcategorycodesystem");
IIdType obsId = ourClient.create().resource(obs).execute().getId().toUnqualifiedVersionless();
myElasticsearchSvc.refreshIndex(ElasticsearchSvcImpl.OBSERVATION_INDEX);
Parameters output = ourClient.operation().onType(Observation.class).named("lastn").withParameter(Parameters.class, "max", new IntegerType(1)).andParameter("subject", new StringType("Patient/" + id.getIdPart())).execute();
Bundle b = (Bundle) output.getParameter().get(0).getResource();
assertEquals(1, b.getTotal());
assertEquals(obsId, b.getEntry().get(0).getResource().getIdElement().toUnqualifiedVersionless());
}
Aggregations