use of org.hl7.fhir.dstu3.model.Device in project synthea by synthetichealth.
the class FhirStu3 method supplyDelivery.
/**
* Map the JsonObject for a Supply into a FHIR SupplyDelivery and add it to the Bundle.
*
* @param rand Source of randomness to use when generating ids etc
* @param personEntry The Person entry.
* @param bundle Bundle to add to.
* @param supply The supplied object to add.
* @param encounter The encounter during which the supplies were delivered
* @return The added Entry.
*/
private static BundleEntryComponent supplyDelivery(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, HealthRecord.Supply supply, Encounter encounter) {
SupplyDelivery supplyResource = new SupplyDelivery();
supplyResource.setStatus(SupplyDeliveryStatus.COMPLETED);
supplyResource.setPatient(new Reference(personEntry.getFullUrl()));
CodeableConcept type = new CodeableConcept();
type.addCoding().setCode("device").setDisplay("Device").setSystem("http://hl7.org/fhir/supply-item-type");
supplyResource.setType(type);
SupplyDeliverySuppliedItemComponent suppliedItem = new SupplyDeliverySuppliedItemComponent();
suppliedItem.setItem(mapCodeToCodeableConcept(supply.codes.get(0), SNOMED_URI));
SimpleQuantity quantity = new SimpleQuantity();
quantity.setValue(supply.quantity);
suppliedItem.setQuantity(quantity);
supplyResource.setSuppliedItem(suppliedItem);
supplyResource.setOccurrence(convertFhirDateTime(supply.start, true));
return newEntry(rand, bundle, supplyResource);
}
use of org.hl7.fhir.dstu3.model.Device in project synthea by synthetichealth.
the class FhirStu3 method convertToFHIR.
/**
* Convert the given Person into a FHIR Bundle, containing the Patient and the
* associated entries from their health record.
*
* @param person Person to generate the FHIR from
* @param stopTime Time the simulation ended
* @return FHIR Bundle containing the Person's health record.
*/
public static Bundle convertToFHIR(Person person, long stopTime) {
Bundle bundle = new Bundle();
if (TRANSACTION_BUNDLE) {
bundle.setType(BundleType.TRANSACTION);
} else {
bundle.setType(BundleType.COLLECTION);
}
BundleEntryComponent personEntry = basicInfo(person, bundle, stopTime);
for (Encounter encounter : person.record.encounters) {
BundleEntryComponent encounterEntry = encounter(person, personEntry, bundle, encounter);
for (HealthRecord.Entry condition : encounter.conditions) {
condition(person, personEntry, bundle, encounterEntry, condition);
}
for (HealthRecord.Entry allergy : encounter.allergies) {
allergy(person, personEntry, bundle, encounterEntry, allergy);
}
for (Observation observation : encounter.observations) {
// Observation resources in stu3 don't support Attachments
if (observation.value instanceof Attachment) {
media(person, personEntry, bundle, encounterEntry, observation);
} else {
observation(person, personEntry, bundle, encounterEntry, observation);
}
}
for (Procedure procedure : encounter.procedures) {
procedure(person, personEntry, bundle, encounterEntry, procedure);
}
for (Medication medication : encounter.medications) {
medication(person, personEntry, bundle, encounterEntry, medication);
}
for (HealthRecord.Entry immunization : encounter.immunizations) {
immunization(person, personEntry, bundle, encounterEntry, immunization);
}
for (Report report : encounter.reports) {
report(person, personEntry, bundle, encounterEntry, report);
}
for (CarePlan careplan : encounter.careplans) {
careplan(person, personEntry, bundle, encounterEntry, careplan);
}
for (ImagingStudy imagingStudy : encounter.imagingStudies) {
imagingStudy(person, personEntry, bundle, encounterEntry, imagingStudy);
}
for (HealthRecord.Device device : encounter.devices) {
device(person, personEntry, bundle, device);
}
for (HealthRecord.Supply supply : encounter.supplies) {
supplyDelivery(person, personEntry, bundle, supply, encounter);
}
// one claim per encounter
BundleEntryComponent encounterClaim = encounterClaim(person, personEntry, bundle, encounterEntry, encounter.claim);
explanationOfBenefit(personEntry, bundle, encounterEntry, person, encounterClaim, encounter);
}
return bundle;
}
use of org.hl7.fhir.dstu3.model.Device in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ObservationFHIRConversionTest method extendedObservationTestMostMessages.
// Tests most fields of OBX
@ParameterizedTest
@ValueSource(strings = { "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|ADT^A01|||2.6||||||||2.6\r", "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|ADT^A03|||2.6||||||||2.6\r", "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|ADT^A04|||2.6||||||||2.6\r", "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|ADT^A08|||2.6||||||||2.6\r", "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|ADT^A28|||2.6||||||||2.6\r", "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|ADT^A31|||2.6||||||||2.6\r", "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|OMP^O09|||2.6||||||||2.6\r", "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|ORM^O01|||2.6||||||||2.6\r", "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|ORU^R01|||2.6||||||||2.6\r", "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|PPR^PC1|||2.6||||||||2.6\r", // "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|PPR^PC3|||2.6||||||||2.6\r",
"MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|VXU^V04|||2.6||||||||2.6\r" })
// Suppress warnings about too many assertions in a test. Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
void extendedObservationTestMostMessages(String msh) throws IOException {
String hl7message = msh + "OBX|1|CWE|DQW^Some text 1^SNM3|100|DQW^Other text 2^SNM3|mm^Text 3^SNM3|56-98|IND|25|ST|F|20210322153839|LKJ|20210320153850|N56|1111^ClinicianLastName^ClinicianFirstName^^^^Title|Manual^Text the 4th^SNM3|Device_1234567^mySystem|20210322153925|Observation Site^Text 5^SNM3|INST^Instance Identifier System||Radiology^Radiological Services|467 Albany Hospital^^Albany^NY|Cardiology^ContactLastName^Jane^Q^^Dr.^MD\r";
// use special created engine
String json = message.convert(hl7message, customEngine);
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
assertThat(obsResource).hasSize(1);
Observation obs = (Observation) obsResource.get(0);
assertThat(obs.hasValueCodeableConcept()).isTrue();
// Check the coding (OBX.3)
assertThat(obs.hasCode()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getCode(), "DQW", "Some text 1", "http://terminology.hl7.org/CodeSystem/SNM3", "Some text 1");
// Check the value (OBX.5)
assertThat(obs.hasValueCodeableConcept()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getValueCodeableConcept(), "DQW", "Other text 2", "http://terminology.hl7.org/CodeSystem/SNM3", "Other text 2");
// OBX.6 is ignored because the record can only have one valueX and this one is valueCodeableConcept. See test test_observation_NM_result.
assertThat(obs.hasReferenceRange()).isTrue();
assertThat(obs.getReferenceRange()).hasSize(1);
ObservationReferenceRangeComponent range = obs.getReferenceRangeFirstRep();
assertThat(range).isNotNull();
assertThat(range.hasHigh()).isTrue();
assertThat(range.hasLow()).isTrue();
Quantity high = range.getHigh();
assertThat(high.getUnit()).isEqualTo("mm");
assertThat(high.getValue().floatValue()).isEqualTo(98.0f);
Quantity low = range.getLow();
assertThat(low.getValue().floatValue()).isEqualTo(56.0f);
assertThat(low.getUnit()).isEqualTo("mm");
// Check interpretation (OBX.8)
assertThat(obs.hasInterpretation()).isTrue();
assertThat(obs.getInterpretation()).hasSize(1);
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getInterpretationFirstRep(), "IND", "Indeterminate", "http://terminology.hl7.org/CodeSystem/v2-0078", null);
// Check the effective Date Time (OBX.14)
assertThat(obs.hasEffective()).isTrue();
assertThat(obs.hasEffectiveDateTimeType()).isTrue();
assertThat(obs.getEffectiveDateTimeType().asStringValue()).isEqualTo("2021-03-20T15:38:50+08:00");
// Check performer (OBX.16 Practictioner + OBX.23/OBX.24/OBX.25 Organization)
assertThat(obs.hasPerformer()).isTrue();
// Practioner and Organization
assertThat(obs.getPerformer()).hasSize(2);
// Get Practitioner and see that it is populated with OBX.16 information
assertThat(obs.getPerformer().get(0).hasReference()).isTrue();
List<Resource> practitionerResource = e.stream().filter(v -> ResourceType.Practitioner == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(practitionerResource).hasSize(1);
Practitioner doctor = ResourceUtils.getResourcePractitioner(practitionerResource.get(0), ResourceUtils.context);
assertThat(doctor.getName().get(0).getFamily()).isEqualTo("ClinicianLastName");
// Get Organization and see that it is populated with OBX.23/OBX.24/OBX.25 information
assertThat(obs.getPerformer().get(1).hasReference()).isTrue();
List<Resource> organizationResource = e.stream().filter(v -> ResourceType.Organization == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(organizationResource).hasSize(1);
Organization org = ResourceUtils.getResourceOrganization(organizationResource.get(0), ResourceUtils.context);
// from OBX.23
assertThat(org.getName()).isEqualTo("Radiology");
assertThat(org.getAddress().get(0).getLine().get(0).getValueAsString()).isEqualTo(// from OBX.24
"467 Albany Hospital");
// from OBX.24
assertThat(org.getAddress().get(0).getCity()).isEqualTo("Albany");
// from OBX.24
assertThat(org.getAddress().get(0).getState()).isEqualTo("NY");
// from OBX.25
assertThat(org.getContact().get(0).getName().getFamily()).isEqualTo("ContactLastName");
// from OBX.25
assertThat(org.getContact().get(0).getName().getGiven().get(0).getValueAsString()).isEqualTo("Jane");
// from OBX.25
assertThat(org.getContact().get(0).getName().getText()).isEqualTo("Dr. Jane Q ContactLastName");
// purpose added because of OBX.25
assertThat(org.getContact().get(0).hasPurpose()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(org.getContact().get(0).getPurpose(), "ADMIN", "Administrative", "http://terminology.hl7.org/CodeSystem/contactentity-type", "Organization Medical Director");
// Check method (OBX.17)
assertThat(obs.hasMethod()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getMethod(), "Manual", "Text the 4th", "http://terminology.hl7.org/CodeSystem/SNM3", "Text the 4th");
// Check device (OBX.18)
assertThat(obs.hasDevice()).isTrue();
assertThat(obs.getDevice().hasReference()).isTrue();
List<Resource> deviceResource = e.stream().filter(v -> ResourceType.Device == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(deviceResource).hasSize(1);
Device device = ResourceUtils.getResourceDevice(deviceResource.get(0), ResourceUtils.context);
assertThat(device.getIdentifier().get(0).getValue()).isEqualTo("Device_1234567");
assertThat(device.getIdentifier().get(0).getSystem()).isEqualTo("urn:id:mySystem");
// Check bodySite (OBX.20)
assertThat(obs.hasBodySite()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getBodySite(), "Observation Site", "Text 5", "http://terminology.hl7.org/CodeSystem/SNM3", "Text 5");
// Check identifier (OBX.21)
assertThat(obs.hasIdentifier()).isTrue();
assertThat(obs.getIdentifier()).hasSize(2);
assertThat(obs.getIdentifier().get(1).getValue()).isEqualTo("INST");
assertThat(obs.getIdentifier().get(1).getSystem()).isEqualTo("urn:id:Instance_Identifier_System");
// OBX.23/OBX.24/OBX.25 went into Performer: Organization. Checked above.
// Check for ABSENCE of category (because no SPM) Presence of category tested in extendedObservationUnusualRangesAndOtherTest
assertThat(obs.hasCategory()).isFalse();
}
use of org.hl7.fhir.dstu3.model.Device in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ObservationFHIRConversionTest method extendedObservationTestForRDEMessages.
// Tests resources created for Observations from RDE messages
@ParameterizedTest
@ValueSource(strings = { "MSH|^~\\&|WHI_LOAD_GENERATOR|IBM_TORONTO_LAB||IBM|20210407191342|25739|RDE^O11|MSGID_f209e83f-20db-474d-a7ae-82e5c3894273|T|2.6\r", "MSH|^~\\&|WHI_LOAD_GENERATOR|IBM_TORONTO_LAB||IBM|20210407191342|25739|RDE^O25|MSGID_f209e83f-20db-474d-a7ae-82e5c3894273|T|2.6\r" })
// Suppress warnings about too many assertions in a test. Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
void extendedObservationTestForRDEMessages(String msh) throws IOException {
String hl7message = msh + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|RE|||3200|||||20210407191342||2799^BY^VERIFIED||||20210407191342||||||ORDERING FAC NAME||||||||I\r" + "RXE|^Q24H&0600^^20210407191342^^ROU|DEFAULTMED^cefTRIAXone (ROCEPHIN) 2 g in sodium chloride 0.9 % 50 mL IVPB|2||g||||||||\n" + "OBX|1|NM|Most Current Weight^Most current measured weight (actual)||90|kg||IND||||||20210320153850||1111^ClinicianLastName^ClinicianFirstName^^^^Title|Manual^Text the 4th^SNM3|Device_1234567^mySystem|20210322153925|Observation Site^Text 5^SNM3|INST^Instance Identifier System||Radiology^Radiological Services|467 Albany Hospital^^Albany^NY|Cardiology^ContactLastName^Jane^Q^^Dr.^MD\r";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
assertThat(obsResource).hasSize(1);
Observation obs = (Observation) obsResource.get(0);
// Check the coding (OBX.3)
assertThat(obs.hasCode()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getCode(), "Most Current Weight", "Most current measured weight (actual)", null, "Most current measured weight (actual)");
// Check the value (OBX.5)
assertNotNull(obs.getValueQuantity());
Quantity q = obs.getValueQuantity();
// code for unit
assertNull(q.getCode());
// unit units to OBX.6.1
assertEquals("kg", q.getUnit());
// system for unit
assertNull(q.getSystem());
assertEquals(90f, q.getValue().floatValue());
// = is not put in comparator
assertNull(q.getComparator());
// Check that there is no reference range, OBX.6 and OBX.7
assertThat(obs.hasReferenceRange()).isFalse();
// Check interpretation (OBX.8)
assertThat(obs.hasInterpretation()).isTrue();
assertThat(obs.getInterpretation()).hasSize(1);
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getInterpretationFirstRep(), "IND", "Indeterminate", "http://terminology.hl7.org/CodeSystem/v2-0078", null);
// Check the effective Date Time (OBX.14)
assertThat(obs.hasEffective()).isTrue();
assertThat(obs.hasEffectiveDateTimeType()).isTrue();
assertThat(obs.getEffectiveDateTimeType().asStringValue()).isEqualTo("2021-03-20T15:38:50+08:00");
// Check performer (OBX.16 Practictioner + OBX.23/OBX.24/OBX.25 Organization)
assertThat(obs.hasPerformer()).isTrue();
// Practioner and Organization
assertThat(obs.getPerformer()).hasSize(2);
// Get Practitioner and see that it is populated with OBX.16 information
assertThat(obs.getPerformer().get(0).hasReference()).isTrue();
List<Resource> practitionerResource = e.stream().filter(v -> ResourceType.Practitioner == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(practitionerResource).hasSize(1);
Practitioner doctor = ResourceUtils.getResourcePractitioner(practitionerResource.get(0), ResourceUtils.context);
assertThat(doctor.getName().get(0).getFamily()).isEqualTo("ClinicianLastName");
// Get Organization and see that it is populated with OBX.23/OBX.24/OBX.25 information
assertThat(obs.getPerformer().get(1).hasReference()).isTrue();
List<Resource> organizationResource = e.stream().filter(v -> ResourceType.Organization == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(organizationResource).hasSize(1);
Organization org = ResourceUtils.getResourceOrganization(organizationResource.get(0), ResourceUtils.context);
// from OBX.23
assertThat(org.getName()).isEqualTo("Radiology");
assertThat(org.getAddress().get(0).getLine().get(0).getValueAsString()).isEqualTo(// from OBX.24
"467 Albany Hospital");
// from OBX.24
assertThat(org.getAddress().get(0).getCity()).isEqualTo("Albany");
// from OBX.24
assertThat(org.getAddress().get(0).getState()).isEqualTo("NY");
// from OBX.25
assertThat(org.getContact().get(0).getName().getFamily()).isEqualTo("ContactLastName");
// from OBX.25
assertThat(org.getContact().get(0).getName().getGiven().get(0).getValueAsString()).isEqualTo("Jane");
// There should be no suffix, currently not putting degree 'Title' in suffix
assertThat(org.getContact().get(0).getName().getSuffix()).isEmpty();
// from OBX.25
assertThat(org.getContact().get(0).getName().getText()).isEqualTo("Dr. Jane Q ContactLastName");
// purpose added because of OBX.25
assertThat(org.getContact().get(0).hasPurpose()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(org.getContact().get(0).getPurpose(), "ADMIN", "Administrative", "http://terminology.hl7.org/CodeSystem/contactentity-type", "Organization Medical Director");
// Check method (OBX.17)
assertThat(obs.hasMethod()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getMethod(), "Manual", "Text the 4th", "http://terminology.hl7.org/CodeSystem/SNM3", "Text the 4th");
// Check device (OBX.18)
assertThat(obs.hasDevice()).isTrue();
assertThat(obs.getDevice().hasReference()).isTrue();
List<Resource> deviceResource = e.stream().filter(v -> ResourceType.Device == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(deviceResource).hasSize(1);
Device device = ResourceUtils.getResourceDevice(deviceResource.get(0), ResourceUtils.context);
assertThat(device.getIdentifier().get(0).getValue()).isEqualTo("Device_1234567");
assertThat(device.getIdentifier().get(0).getSystem()).isEqualTo("urn:id:mySystem");
// Check bodySite (OBX.20)
assertThat(obs.hasBodySite()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getBodySite(), "Observation Site", "Text 5", "http://terminology.hl7.org/CodeSystem/SNM3", "Text 5");
// Check identifier (OBX.21)
assertThat(obs.hasIdentifier()).isTrue();
assertThat(obs.getIdentifier()).hasSize(2);
assertThat(obs.getIdentifier().get(1).getValue()).isEqualTo("INST");
assertThat(obs.getIdentifier().get(1).getSystem()).isEqualTo("urn:id:Instance_Identifier_System");
// OBX.23/OBX.24/OBX.25 went into Performer: Organization. Checked above.
// Check for ABSENCE of category (because no SPM) Presence of category tested in extendedObservationUnusualRangesAndOtherTest
assertThat(obs.hasCategory()).isFalse();
}
use of org.hl7.fhir.dstu3.model.Device in project summary-care-record-api by NHSDigital.
the class ParticipantAgentMapper method setDeviceCoding.
private static void setDeviceCoding(org.hl7.fhir.r4.model.Device fhirDevice, Device agentDevice1) {
CodeableConcept type = fhirDevice.getType();
Coding coding = type.getCodingFirstRep();
if (!type.isEmpty() && isNotEmpty(coding.getCode()) && isNotEmpty(coding.getDisplay())) {
agentDevice1.setCodeCode(coding.getCode());
agentDevice1.setCodeDisplayName(coding.getDisplay());
} else {
throw new FhirValidationException("Missing mandatory elements: Device.type");
}
}
Aggregations