Search in sources :

Example 21 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_subject_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_subject_test(String segment) {
    String documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||X";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, documentReferenceMessage);
    List<Resource> documentReferenceList = ResourceUtils.getResourceList(e, ResourceType.DocumentReference);
    String s = context.getParser().encodeResourceToString(documentReferenceList.get(0));
    Class<? extends IBaseResource> klass = DocumentReference.class;
    DocumentReference documentReference = (DocumentReference) context.getParser().parseResource(klass, s);
    assertThat(documentReference.hasSubject()).isTrue();
    assertThat(documentReference.getSubject().getReference()).startsWith("Patient");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent 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");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.r4.model.Organization) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Encounter(org.hl7.fhir.r4.model.Encounter) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent 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");
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 24 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class HL7ConditionFHIRConversionTest method validateProblemHappyTestTwo.

// Tests the PRB segment (problem) with all supported message types. This tests
// all the fields in the happy path (Part 2).
@ParameterizedTest
@ValueSource(strings = { "MSH|^~\\&|||||20040629164652|1|PPR^PC1|331|P|2.3.1||\r" // "MSH|^~\\&|||||20040629164652|1|PPR^PC2|331|P|2.3.1||\r",
// "MSH|^~\\&|||||20040629164652|1|PPR^PC3|331|P|2.3.1||\r",
})
void validateProblemHappyTestTwo(String msh) {
    String hl7message = msh + "PID||||||||||||||||||||||||||||||\r" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\r" + // // PRB.14 for clinical Status
    "PRB|AD|20170110074000|K80.00^Cholelithiasis^I10|53956||||||||||remission^Remission^http://terminology.hl7.org/CodeSystem/condition-clinical|||||||||||||\r";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    // Find the conditions from the FHIR bundle.
    List<Resource> conditionResource = ResourceUtils.getResourceList(e, ResourceType.Condition);
    assertThat(conditionResource).hasSize(1);
    Condition condition = (Condition) conditionResource.get(0);
    // Verify code is set correctly.
    DatatypeUtils.checkCommonCodeableConceptAssertions(condition.getCode(), "K80.00", "Cholelithiasis", "http://hl7.org/fhir/sid/icd-10-cm", // PRB.3
    "Cholelithiasis");
    // Verify clinicalStatus is set correctly
    DatatypeUtils.checkCommonCodeableConceptAssertions(condition.getClinicalStatus(), "remission", "Remission", "http://terminology.hl7.org/CodeSystem/condition-clinical", // PRB.14
    "Remission");
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with BundleEntryComponent

use of org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class HL7ConditionFHIRConversionTest method validateProblemWithInvalidClinicalStatusAndResolutionDate.

// Tests that if PRB.9 is set and PRB.14 is INVALID, default Condition.clinicalStatus to "resolved"
@Test
void validateProblemWithInvalidClinicalStatusAndResolutionDate() {
    String hl7message = "MSH|^~\\&|||||20040629164652|1|PPR^PC1|331|P|2.3.1||\r" + "PID||||||||||||||||||||||||||||||\r" + // PRB.9 Actual Problem Resolution Date used in connection with INVALID PRB.14 to trigger Resolved clinicalStatus
    "PRB|AD|20170110074000|K80.00^Cholelithiasis^I10|53956|||||20150907175347|||||INVALID|||||||||||||\r";
    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);
    Condition condition = (Condition) conditionResource.get(0);
    // Verify clinicalStatus has a Resolved coding with correct system and text (based on PRB.9 and INVALID PRB.14)
    DatatypeUtils.checkCommonCodeableConceptAssertions(condition.getClinicalStatus(), "resolved", "Resolved", "http://terminology.hl7.org/CodeSystem/condition-clinical", null);
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)265 Resource (org.hl7.fhir.r4.model.Resource)167 Test (org.junit.jupiter.api.Test)126 Bundle (org.hl7.fhir.r4.model.Bundle)116 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)96 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)88 ArrayList (java.util.ArrayList)67 Date (java.util.Date)52 Reference (org.hl7.fhir.r4.model.Reference)52 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)51 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)42 Patient (org.hl7.fhir.r4.model.Patient)37 IOException (java.io.IOException)36 Observation (org.hl7.fhir.r4.model.Observation)36 Test (org.junit.Test)35 BundleEntryComponent (org.hl7.fhir.r5.model.Bundle.BundleEntryComponent)34 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)33 Condition (org.hl7.fhir.r4.model.Condition)32 HashMap (java.util.HashMap)31 Encounter (org.hl7.fhir.r4.model.Encounter)31