Search in sources :

Example 26 with Resource

use of org.alfresco.event.sdk.model.v1.model.Resource in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testInsuranceCoverageFromIN2.

@Test
// Tests empty IN2.63 missing telecom.
void testInsuranceCoverageFromIN2() throws IOException {
    String hl7message = "MSH|^~\\&|||||20151008111200||ADT^A01^ADT_A01|MSGID000001|T|2.6|||||||||\n" + "EVN||20210407191342||||||\n" + "PID|||MR1^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // FT1.7 is required transaction code (currently not used)
    "FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to second XV Coverage.identifier
    "IN1|1|Value1^^System3^Value4^^System6" + // IN1.5 to 15 NOT REFERENCED (See test testBasicInsuranceCoverageFields)
    "|IdValue1^^^IdSystem4^^^^|Large Blue Organization|||||||||||" + // IN1.18 through IN1.35 NOT REFERENCED
    "|DoeFake^Judy^^^Rev.|||||||||||||||||||" + // IN1.37 through IN1.53 NOT REFERENCED
    "|MEMBER36|||||||||||||||||\n" + // IN2.63 purposely empty to ensure an empty telecom is not created.
    "IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" + // IN2.72 to Coverage.relationship and RelatedPerson.relationship.  (Backup for IN1.17) Codes from table 0344
    "04|\n";
    // 04 = Natural child
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // From PV1
    assertThat(encounters).hasSize(1);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // From PID
    assertThat(patients).hasSize(1);
    Patient patient = (Patient) patients.get(0);
    String patientId = patient.getId();
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // From Payor created by IN1
    assertThat(organizations).hasSize(1);
    List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
    // From IN1 segment
    assertThat(coverages).hasSize(1);
    Coverage coverage = (Coverage) coverages.get(0);
    // Confirm Coverage Identifiers
    // XV, XV, MB, SN
    assertThat(coverage.getIdentifier()).hasSize(4);
    // Coverage Identifiers deep check in testBasicInsuranceCoverageFields
    // Confirm Coverage Beneficiary references to Patient, and Payor references to Organization
    assertThat(coverage.getBeneficiary().getReference()).isEqualTo(patientId);
    assertThat(coverage.getPayorFirstRep().getReference()).isEqualTo(organizations.get(0).getId());
    // Expect one RelatedPerson
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // From IN2.72
    assertThat(relatedPersons).hasSize(1);
    RelatedPerson related = (RelatedPerson) relatedPersons.get(0);
    // Because IN2.63 is empty
    assertThat(related.hasTelecom()).isFalse();
    assertThat(related.getName()).hasSize(1);
    HumanName relatedName = related.getName().get(0);
    // Simplified name test.  Deeper tests in other tests.
    // from IN1.16 aggregate
    assertThat(relatedName.getText()).isEqualTo("Rev. Judy DoeFake");
    // Check coverage relationship
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "child", "Child", "http://terminology.hl7.org/CodeSystem/subscriber-relationship", // IN2.72 (04 = Natural child)
    null);
    // Check relatedPerson relationship
    assertThat(related.getRelationship()).hasSize(1);
    DatatypeUtils.checkCommonCodeableConceptAssertions(related.getRelationship().get(0), "PRN", "parent", "http://terminology.hl7.org/CodeSystem/v3-RoleCode", // IN2.72 (04 = Natural child)
    null);
    // Confirm the Coverage (subscriber) references the RelatedPerson
    assertThat(coverage.getSubscriber().getReference()).isEqualTo(related.getId());
    // Confirm the RelatedPerson references the Patient
    assertThat(related.getPatient().getReference()).isEqualTo(patientId);
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization, Patient, Encounter, RelatedPerson
    assertThat(e).hasSize(5);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 27 with Resource

use of org.alfresco.event.sdk.model.v1.model.Resource 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 28 with Resource

use of org.alfresco.event.sdk.model.v1.model.Resource 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 29 with Resource

use of org.alfresco.event.sdk.model.v1.model.Resource 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 30 with Resource

use of org.alfresco.event.sdk.model.v1.model.Resource 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)

Aggregations

Resource (org.hl7.fhir.r4.model.Resource)312 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)172 Test (org.junit.jupiter.api.Test)166 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)143 Test (org.junit.Test)99 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)98 Bundle (org.hl7.fhir.r4.model.Bundle)90 Resource (org.hl7.fhir.dstu3.model.Resource)85 ArrayList (java.util.ArrayList)71 FHIRException (org.hl7.fhir.exceptions.FHIRException)71 Resource (org.hl7.fhir.r5.model.Resource)65 NodeResource (org.alfresco.event.sdk.model.v1.model.NodeResource)59 Reference (org.hl7.fhir.r4.model.Reference)58 EventData (org.alfresco.event.sdk.model.v1.model.EventData)54 DataAttributes (org.alfresco.event.sdk.model.v1.model.DataAttributes)52 Observation (org.hl7.fhir.r4.model.Observation)45 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)44 FileInputStream (java.io.FileInputStream)43 IOException (java.io.IOException)43 List (java.util.List)42