use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7EncounterFHIRConversionTest method test_encounter_PV2segment_missing.
// Test messages with PV1 segment and no PV2 segment, and no serviceProvider provided
// Extension list should be empty and serviceProvider should be null
@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_PV2segment_missing(String message) {
String hl7message = "MSH|^~\\&|WHI_LOAD_GENERATOR|IBM_TORONTO_LAB||IBM|20210330144208|8078780|" + message + "|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|^^^^^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";
Encounter encounter = ResourceUtils.getEncounter(ftv, hl7message);
Narrative encText = encounter.getText();
assertNull(encText.getStatus());
assertThat(encText.getDiv().getChildNodes()).isEmpty();
List<Extension> extensionList = encounter.getExtension();
assertNotNull(extensionList);
assertThat(extensionList).isEmpty();
Reference serviceProvider = encounter.getServiceProvider();
assertThat(serviceProvider).isNotNull();
assertThat(serviceProvider.getReference()).isNull();
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7EncounterFHIRConversionTest method test_encounter_PV1_serviceProvider.
// Test for serviceProvider reference in messages with both PV1 and PV2 segments
// Part 2: Field PV2.23 is provided but no PV2.23.8; serviceProvider id should use backup field 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_PV1_serviceProvider(String message) {
String hl7message = "MSH|^~\\&|TestSystem||TestTransformationAgent||20150502090000||" + message + "|controlID|P|2.6\r" + "EVN||20210330144208||ADT_EVENT|007|20210309140700\r" + "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\r" + "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\r" + "PV2||TEL||||X-5546||20210330144208|20210309||||||||||||n|N|South Shore Hosptial Weymouth|||||||||N||||||\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();
assertThat(providerString).isEqualTo("Organization/toronto");
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);
// PV1.3.4.1
assertThat(orgResource.getIdentifierFirstRep().getValue()).hasToString("Toronto");
// Because ID is name based
assertThat(orgResource.getIdentifierFirstRep().getSystem()).hasToString("urn:id:extID");
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT 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.r4.model.codesystems.ResourceTypes.PATIENT 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.r4.model.codesystems.ResourceTypes.PATIENT in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7EncounterFHIRConversionTest method test_encounter_modeOfarrival_invalid_with_system.
@Test
void test_encounter_modeOfarrival_invalid_with_system() {
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|||||||||N||||||AMB^AMBULATORY^FUNKY\n";
Encounter encounter = ResourceUtils.getEncounter(ftv, hl7message);
List<Extension> extensionList = encounter.getExtension();
assertNotNull(extensionList);
assertThat(extensionList).isNotEmpty();
boolean extFound = false;
for (Extension ext : extensionList) {
if (ext.getUrl().equals("http://hl7.org/fhir/StructureDefinition/encounter-modeOfArrival")) {
extFound = true;
assertTrue(ext.getValue() instanceof Coding);
Coding valueCoding = (Coding) ext.getValue();
assertThat(valueCoding.getCode()).isEqualTo("AMB");
assertThat(valueCoding.getDisplay()).isEqualTo("AMBULATORY");
assertThat(valueCoding.getSystem()).isEqualTo("urn:id:FUNKY");
break;
}
}
assertTrue(extFound, "modeOfArrival extension not found");
}
Aggregations