use of org.hl7.fhir.r4b.model.Bundle in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7EncounterFHIRConversionTest method test_encounter_visitdescription_missing.
@Test
void test_encounter_visitdescription_missing() {
String hl7message = "MSH|^~\\&|WHI_LOAD_GENERATOR|IBM_TORONTO_LAB||IBM|20210330144208|8078780|ADT^A01|MSGID_4e1c575f-6c6d-47b2-ab9f-829f20c96db2|T|2.3\n" + "EVN||20210330144208||ADT_EVENT|007|20210309140700\n" + "PID|1||0a8a1752-e336-43e1-bf7f-0c8f6f437ca3^^^MRN||Patient^Load^Generator||19690720|M|Patient^Alias^Generator|AA|9999^^CITY^STATE^ZIP^CAN|COUNTY|(866)845-0900||ENGLISH^ENGLISH|SIN|NONE|Account_0a8a1752-e336-43e1-bf7f-0c8f6f437ca3|123-456-7890|||N|BIRTH PLACE|N||||||N\n" + "PV1||I|^^^Toronto^^5642 Hilly Av||||2905^Doctor^Attending^M^IV^^M.D|5755^Doctor^Referring^^Sr|770542^Doctor^Consulting^Jr||||||||59367^Doctor^Admitting|S|Visit_0a3be81e-144b-4885-9b4e-c5cd33c8f038|||||||||||||||||||||||||20210407191342\n" + "PV2||TEL||||X-5546||20210330144208|20210309||||||||||||n|N|South Shore Hosptial Weymouth^SSHW^^^^^^SSH-WEYMOUTH|||||||||N||||||\n";
String json = ftv.convert(hl7message, OPTIONS);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
assertThat(patientResource).hasSize(1);
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
assertThat(encounterResource).hasSize(1);
Encounter encounter = ResourceUtils.getResourceEncounter(encounterResource.get(0), context);
// This assertion is to confirm that we do not get a type from PV1.18
assertThat(encounter.hasType()).isFalse();
Narrative encText = encounter.getText();
assertNull(encText.getStatus());
assertThat(encText.getDiv().getChildNodes()).isEmpty();
}
use of org.hl7.fhir.r4b.model.Bundle in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7EncounterFHIRConversionTest method testEncounterReferencesObservationAndDiagnosis.
/**
* Testing Encounter correctly references Observation AND Diagnosis when both are present.
*/
@Test
void testEncounterReferencesObservationAndDiagnosis() throws IOException {
String hl7message = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.6|\n" + "PID|||1234^^^^MR||DOE^JANE^|||F|||||||||||||||||||||\n" + "PV1|1|O|Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||\n" + "OBX|1|SN|24467-3^CD3+CD4+ (T4 helper) cells [#/volume] in Blood^LN||=^440|{Cells}/uL^cells per microliter^UCUM|649-1346 cells/mcL|L|||F\r" + "DG1|1|ICD10|^Ovarian Cancer|||||||||||||||||||||\r";
String json = ftv.convert(hl7message, OPTIONS);
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);
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
assertThat(encounterResource).hasSize(1);
Encounter enc = (Encounter) encounterResource.get(0);
List<Reference> reasonRefs = enc.getReasonReference();
assertEquals(2, reasonRefs.size());
// Guess at the order of the references
Reference refObservation = reasonRefs.get(0);
Reference refCondition = reasonRefs.get(1);
// If guessed wrong, reverse them
if (!refObservation.getReference().contains("Observation")) {
refObservation = reasonRefs.get(1);
refCondition = reasonRefs.get(0);
}
assertTrue(refObservation.getReference().contains("Observation"));
assertTrue(refCondition.getReference().contains("Condition"));
}
use of org.hl7.fhir.r4b.model.Bundle in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7EncounterFHIRConversionTest method test_encounter_PV2_serviceProvider_idfix.
@Test
void test_encounter_PV2_serviceProvider_idfix() {
String hl7message = "MSH|^~\\&|WHI_LOAD_GENERATOR|IBM_TORONTO_LAB||IBM|20210330144208|8078780|ADT^A01|MSGID_4e1c575f-6c6d-47b2-ab9f-829f20c96db2|T|2.3\n" + "EVN||20210330144208||ADT_EVENT|007|20210309140700\n" + "PID|1||0a8a1752-e336-43e1-bf7f-0c8f6f437ca3^^^MRN||Patient^Load^Generator||19690720|M|Patient^Alias^Generator|AA|9999^^CITY^STATE^ZIP^CAN|COUNTY|(866)845-0900||ENGLISH^ENGLISH|SIN|NONE|Account_0a8a1752-e336-43e1-bf7f-0c8f6f437ca3|123-456-7890|||N|BIRTH PLACE|N||||||N\n" + "PV1||I|^^^Toronto^^5642 Hilly Av||||2905^Doctor^Attending^M^IV^^M.D|5755^Doctor^Referring^^Sr|770542^Doctor^Consulting^Jr||||||||59367^Doctor^Admitting||Visit_0a3be81e-144b-4885-9b4e-c5cd33c8f038|||||||||||||||||||||||||20210407191342\n" + "PV2||TEL||||X-5546||20210330144208|20210309||||||||||||n|N|South Shore Hosptial Weymouth^SSHW^^^^^^SSH*WEYMOUTH WEST_BUILD-7.F|||||||||N||||||\n";
String json = ftv.convert(hl7message, OPTIONS);
assertThat(json).isNotBlank();
LOGGER.debug("FHIR json result:\n" + json);
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
assertThat(encounterResource).hasSize(1);
Encounter encounter = ResourceUtils.getResourceEncounter(encounterResource.get(0), context);
Reference serviceProvider = encounter.getServiceProvider();
assertThat(serviceProvider).isNotNull();
String providerString = serviceProvider.getReference();
assertThat(providerString).isEqualTo("Organization/ssh-weymouth-west-build-7.f");
List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
assertThat(organizations).hasSize(1);
Organization orgResource = ResourceUtils.getResourceOrganization(organizations.get(0), context);
assertThat(orgResource.getId()).isEqualTo(providerString);
assertThat(orgResource.getName()).isEqualTo("South Shore Hosptial Weymouth");
assertThat(orgResource.getIdentifier()).hasSize(1);
// PV2.23.1
assertThat(orgResource.getIdentifierFirstRep().getValue()).hasToString("SSH*WEYMOUTH WEST_BUILD-7.F");
// Because ID is name based
assertThat(orgResource.getIdentifierFirstRep().getSystem()).hasToString("urn:id:extID");
}
use of org.hl7.fhir.r4b.model.Bundle in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7EncounterFHIRConversionTest method test_encounter_with_serviceProvider_from_PV1_3_4.
// Test for serviceProvider reference in messages with PV1 segment and no PV2 segment
// Use serviceProvider from PV1-3.4.1
@ParameterizedTest
@ValueSource(strings = { "ADT^A01", /* "ADT^A02", "ADT^A03", "ADT^A04", */
"ADT^A08", // MDM messages are not tested here because they do not have PV2 segments
"OMP^O09", "ORU^R01", "RDE^O11", "RDE^O25", "VXU^V04" })
void test_encounter_with_serviceProvider_from_PV1_3_4(String message) {
String hl7message = "MSH|^~\\&|TestSystem||TestTransformationAgent||20150502090000||" + message + "|controlID|P|2.6\r" + "EVN|A01|20150502090000|\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + // PV1-3.4 used for serviceProvider reference; used for both id and name
"PV1||I|INT^0001^02^Toronto East|||||||SUR||||||||S|VisitNumber^^^Toronto North|A|||||||||||||||||||Toronto West||||||\r";
String json = ftv.convert(hl7message, OPTIONS);
assertThat(json).isNotBlank();
LOGGER.debug("FHIR json result:\n" + json);
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
assertThat(encounterResource).hasSize(1);
Encounter encounter = ResourceUtils.getResourceEncounter(encounterResource.get(0), context);
Reference serviceProvider = encounter.getServiceProvider();
assertThat(serviceProvider).isNotNull();
String providerString = serviceProvider.getReference();
// Also verify underscore replacement for VALID_ID
assertThat(providerString).isEqualTo("Organization/toronto-east");
List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
assertThat(organizations).hasSize(1);
Organization orgResource = ResourceUtils.getResourceOrganization(organizations.get(0), context);
assertThat(orgResource.getId()).isEqualTo(providerString);
// PV1.3.4.1
assertThat(orgResource.getName()).isEqualTo("Toronto East");
assertThat(orgResource.getIdentifier()).hasSize(1);
// PV1.3.4.1
assertThat(orgResource.getIdentifierFirstRep().getValue()).hasToString("Toronto East");
// Because ID is name based
assertThat(orgResource.getIdentifierFirstRep().getSystem()).hasToString("urn:id:extID");
}
use of org.hl7.fhir.r4b.model.Bundle in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7ConditionFHIRConversionTest method validateProblemWithOnsetDateTimeWithNoOnsetString.
// Tests that onset[x] is set to PRB.16 if it is present AND
// Tests that onset[x] is set to PRB.16 if it is present and PRB.17 is present.
@ParameterizedTest
@ValueSource(strings = { // PRB.17 purposely empty
"PRB|AD|20170110074000|K80.00^Cholelithiasis^I10|53956||||||||||||20180310074000||\r", // PRB.17 present
"PRB|AD|20170110074000|K80.00^Cholelithiasis^I10|53956||||||||||||20180310074000|textual representation of the time when the problem began|\r" })
void validateProblemWithOnsetDateTimeWithNoOnsetString(String segmentPRB) {
String hl7message = "MSH|^~\\&|||||20040629164652|1|PPR^PC1|331|P|2.3.1||\r" + "PID||||||||||||||||||||||||||||||\r" + segmentPRB;
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
// Find the condition from the FHIR bundle.
List<Resource> conditionResource = ResourceUtils.getResourceList(e, ResourceType.Condition);
assertThat(conditionResource).hasSize(1);
// Get the condition Resource
Condition condition = (Condition) conditionResource.get(0);
// Verify onset is set correctly to PRB.16
// PRB.16
assertThat(condition.getOnset().toString()).containsPattern("2018-03-10T07:40:00");
}
Aggregations