Search in sources :

Example 96 with Patient

use of org.hl7.fhir.r5.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7PatientFHIRConversionTest method patient_deceased_conversion_test1.

/**
 * In order to generate messageHeader resource, MSH should have MSH.24.2 as this is required
 * attribute for source attribute, and source is required for MessageHeader resource.
 */
@Test
void patient_deceased_conversion_test1() {
    String patientMsgDeceasedEmpty = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Mouse^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|12345 testing ave^^Minneapolis^MN^55407^^^^MN053|USAA|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|Y|2|USA||||\n";
    String patientMsgNotDeadBooleanN = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Mouse^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|12345 testing ave^^Minneapolis^MN^55407^^^^MN053|USAA|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|Y|2|USA||||N\n";
    String patientMsgDeceasedDateOnlyYYYY = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Mouse^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|12345 testing ave^^Minneapolis^MN^55407^^^^MN053|USAA|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|Y|2|USA|||2006|\n";
    String patientMsgDeceasedDateOnlyYYYYMM = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Mouse^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|12345 testing ave^^Minneapolis^MN^55407^^^^MN053|USAA|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|Y|2|USA|||200611|\n";
    Patient patientObjDeceasedEmpty = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgDeceasedEmpty);
    assertThat(patientObjDeceasedEmpty.hasDeceased()).isFalse();
    assertThat(patientObjDeceasedEmpty.hasDeceasedBooleanType()).isFalse();
    assertThat(patientObjDeceasedEmpty.hasDeceasedDateTimeType()).isFalse();
    Patient patientObjNotDeadBooleanN = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgNotDeadBooleanN);
    assertThat(patientObjNotDeadBooleanN.hasDeceased()).isTrue();
    assertThat(patientObjNotDeadBooleanN.hasDeceasedBooleanType()).isTrue();
    assertThat(patientObjNotDeadBooleanN.getDeceasedBooleanType().booleanValue()).isFalse();
    Patient patientObjDeceasedDateOnlyYYYY = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgDeceasedDateOnlyYYYY);
    assertThat(patientObjDeceasedDateOnlyYYYY.hasDeceased()).isTrue();
    assertThat(patientObjDeceasedDateOnlyYYYY.hasDeceasedDateTimeType()).isTrue();
    assertThat(patientObjDeceasedDateOnlyYYYY.hasDeceasedBooleanType()).isFalse();
    assertThat(patientObjDeceasedDateOnlyYYYY.getDeceasedDateTimeType().asStringValue()).isEqualTo("2006");
    Patient patientObjDeceasedDateOnlyYYYYMM = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgDeceasedDateOnlyYYYYMM);
    assertThat(patientObjDeceasedDateOnlyYYYYMM.hasDeceased()).isTrue();
    assertThat(patientObjDeceasedDateOnlyYYYYMM.hasDeceasedDateTimeType()).isTrue();
    assertThat(patientObjDeceasedDateOnlyYYYYMM.hasDeceasedBooleanType()).isFalse();
    assertThat(patientObjDeceasedDateOnlyYYYYMM.getDeceasedDateTimeType().asStringValue()).isEqualTo("2006-11");
// More related tests in patient_deceased_conversion_test2
}
Also used : Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 97 with Patient

use of org.hl7.fhir.r5.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7PatientFHIRConversionTest method patient_deceased_conversion_test2.

@Test
void patient_deceased_conversion_test2() {
    String patientMsgDeceasedDateOnlyYYYYMMDDHHMMSSZZZZ = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Mouse^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|12345 testing ave^^Minneapolis^MN^55407^^^^MN053|USAA|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|Y|2|USA|||20061120115930+0100|\n";
    String patientMsgDeceasedBooleanYOnly = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Mouse^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|12345 testing ave^^Minneapolis^MN^55407^^^^MN053|USAA|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|Y|2|USA||||Y\n";
    String patientMsgDeceasedDateAndBooleanY = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Mouse^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|12345 testing ave^^Minneapolis^MN^55407^^^^MN053|USAA|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|Y|2|USA|||20061120|Y\n";
    Patient patientObjDeceasedBooleanYOnly = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgDeceasedBooleanYOnly);
    assertThat(patientObjDeceasedBooleanYOnly.hasDeceased()).isTrue();
    assertThat(patientObjDeceasedBooleanYOnly.hasDeceasedDateTimeType()).isFalse();
    assertThat(patientObjDeceasedBooleanYOnly.hasDeceasedBooleanType()).isTrue();
    assertThat(patientObjDeceasedBooleanYOnly.getDeceasedBooleanType().booleanValue()).isTrue();
    Patient patientObjDeceasedDateOnlyYYYYMMDDHHMMSSZZZZ = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgDeceasedDateOnlyYYYYMMDDHHMMSSZZZZ);
    assertThat(patientObjDeceasedDateOnlyYYYYMMDDHHMMSSZZZZ.hasDeceased()).isTrue();
    assertThat(patientObjDeceasedDateOnlyYYYYMMDDHHMMSSZZZZ.hasDeceasedDateTimeType()).isTrue();
    assertThat(patientObjDeceasedDateOnlyYYYYMMDDHHMMSSZZZZ.hasDeceasedBooleanType()).isFalse();
    assertThat(patientObjDeceasedDateOnlyYYYYMMDDHHMMSSZZZZ.getDeceasedDateTimeType().asStringValue()).isEqualTo("2006-11-20T11:59:30+01:00");
    Patient patientObjDeceasedDateAndBooleanY = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgDeceasedDateAndBooleanY);
    assertThat(patientObjDeceasedDateAndBooleanY.hasDeceased()).isTrue();
    assertThat(patientObjDeceasedDateAndBooleanY.hasDeceasedDateTimeType()).isTrue();
    assertThat(patientObjDeceasedDateAndBooleanY.hasDeceasedBooleanType()).isFalse();
    // DateUtil.formatToDate
    assertThat(patientObjDeceasedDateAndBooleanY.getDeceasedDateTimeType().asStringValue()).isEqualTo("2006-11-20");
}
Also used : Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 98 with Patient

use of org.hl7.fhir.r5.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7PatientFHIRConversionTest method patientCommunicationLanguage.

@Test
void patientCommunicationLanguage() {
    String patientSpeaksEnglishWithSystem = "MSH|^~\\&|MyEMR|DE-000001| |CAIRLO|20160701123030-0700||VXU^V04^VXU_V04|CA0001|P|2.6|||ER|AL|||||Z22^CDCPHINVS|DE-000001\r" + "PID|1||PA123456^^^MYEMR^MR||DOE^JOHN|||M|||||||ENG^English^HL70296|||||||||Y|2\r";
    // NO coding system given in the CWE
    String patientEnglishNoSystem = "MSH|^~\\&|MyEMR|DE-000001| |CAIRLO|20160701123030-0700||VXU^V04^VXU_V04|CA0001|P|2.6|||ER|AL|||||Z22^CDCPHINVS|DE-000001\r" + "PID|1||PA123456^^^MYEMR^MR||DOE^JANE|||M|||||||ENG^English|||||||||Y|2\r";
    // NO coding system given in the CWE
    String patientEnglishCodeOnly = "MSH|^~\\&|MyEMR|DE-000001| |CAIRLO|20160701123030-0700||VXU^V04^VXU_V04|CA0001|P|2.6|||ER|AL|||||Z22^CDCPHINVS|DE-000001\r" + "PID|1||PA123456^^^MYEMR^MR||DOE^JANE|||M|||||||ENG|||||||||Y|2\r";
    Patient patientObjEnglish = PatientUtils.createPatientFromHl7Segment(ftv, patientSpeaksEnglishWithSystem);
    assertThat(patientObjEnglish.hasCommunication()).isTrue();
    assertThat(patientObjEnglish.getCommunication().get(0).getPreferred()).isTrue();
    assertThat(patientObjEnglish.getCommunication()).hasSize(1);
    Patient.PatientCommunicationComponent cc = patientObjEnglish.getCommunication().get(0);
    assertThat(cc.getPreferred()).isTrue();
    assertThat(cc.getLanguage().getText()).isEqualTo("English");
    Coding code = cc.getLanguage().getCodingFirstRep();
    assertThat(code.getCode()).isEqualTo("ENG");
    assertThat(code.getSystem()).isEqualTo("urn:id:v2-0296");
    assertThat(code.getDisplay()).isEqualTo("English");
    Patient patientObjNoSystem = PatientUtils.createPatientFromHl7Segment(ftv, patientEnglishNoSystem);
    assertThat(patientObjNoSystem.hasCommunication()).isTrue();
    assertThat(patientObjNoSystem.getCommunication().get(0).getPreferred()).isTrue();
    assertThat(patientObjNoSystem.getCommunication()).hasSize(1);
    Patient.PatientCommunicationComponent ccNoCode = patientObjNoSystem.getCommunication().get(0);
    assertThat(ccNoCode.getPreferred()).isTrue();
    assertThat(ccNoCode.getLanguage().getText()).isEqualTo("English");
    Coding codeNo = ccNoCode.getLanguage().getCodingFirstRep();
    assertThat(codeNo.getCode()).isEqualTo("ENG");
    assertThat(code.getDisplay()).isEqualTo("English");
    assertThat(codeNo.hasDisplay()).isTrue();
    Patient patientObjCodeOnly = PatientUtils.createPatientFromHl7Segment(ftv, patientEnglishCodeOnly);
    assertThat(patientObjCodeOnly.hasCommunication()).isTrue();
    assertThat(patientObjCodeOnly.getCommunication().get(0).getPreferred()).isTrue();
    assertThat(patientObjCodeOnly.getCommunication()).hasSize(1);
    Patient.PatientCommunicationComponent ccCodeOnly = patientObjCodeOnly.getCommunication().get(0);
    assertThat(ccCodeOnly.getPreferred()).isTrue();
    assertThat(ccCodeOnly.getLanguage().hasText()).isFalse();
    Coding coding = ccCodeOnly.getLanguage().getCodingFirstRep();
    assertThat(coding.getCode()).isEqualTo("ENG");
    assertThat(coding.getSystem()).isNull();
    assertThat(coding.getDisplay()).isNull();
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 99 with Patient

use of org.hl7.fhir.r5.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7TelecomFHIRConversionTest method patient_telcom_test.

// 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")
@Test
void patient_telcom_test() {
    String patientPhone = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + // Home has 2 phones and an email, work has one phone and two emails
    "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^||20060504|M|||||^PRN^PH^^22^555^1111313^^^^^^^^^^^3~^PRN^CP^^22^555^2221313^^^^^^^^^^^1~^NET^X.400^email.test@gmail.com^^^^^^^^^^^^^^2|^PRN^PH^^^555^1111414^889~^^^professional@buisness.com~^^^moose.mickey@buisness.com^^^^^^^^^^^^^^4||||||||||||||||\n";
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientPhone);
    assertThat(patient.hasTelecom()).isTrue();
    List<ContactPoint> contacts = patient.getTelecom();
    assertThat(contacts.size()).isEqualTo(6);
    // First home contact
    ContactPoint contact = contacts.get(0);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.HOME);
    assertThat(contact.getValue()).hasToString("+22 555 111 1313");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("3");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.PHONE);
    // Second home contact is mobile
    contact = contacts.get(1);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.MOBILE);
    assertThat(contact.getValue()).hasToString("+22 555 222 1313");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("1");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.PHONE);
    // Third home contact is an email
    contact = contacts.get(2);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.HOME);
    assertThat(contact.getValue()).hasToString("email.test@gmail.com");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("2");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.EMAIL);
    // First work contact is work phone
    contact = contacts.get(3);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.WORK);
    assertThat(contact.getValue()).hasToString("(555) 111 1414 ext. 889");
    assertThat(contact.hasRank()).isFalse();
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.PHONE);
    // Second work contact is external work email
    contact = contacts.get(4);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.WORK);
    assertThat(contact.getValue()).hasToString("professional@buisness.com");
    assertThat(contact.hasRank()).isFalse();
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.EMAIL);
    // Third work contact is internal work email and is ranked for contact
    contact = contacts.get(5);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.WORK);
    assertThat(contact.getValue()).hasToString("moose.mickey@buisness.com");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("4");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.EMAIL);
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test)

Example 100 with Patient

use of org.hl7.fhir.r5.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestRateQuantityRXO.

@Test
void dosageInstructionTestRateQuantityRXO() {
    // Test dosageInstruction.rateQuantity where RXO.21 exists and RXO.17 does not exist -> use RXO segment, no range
    String hl7message = "MSH|^~\\\\&|||||20210101000000||OMP^O09|MSGID|T|2.6\n" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|OP||||||||||||||||||||||\n" + // RXO.22.3 purposely empty to check that default system is used
    "RXO|00054418425^Dexamethasone 4 MG Oral Tablet^NDC||||||||||||||||||||6|PC||||||||\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    // Confirm that one medicationRequest was created.
    assertThat(medicationRequestList).hasSize(1);
    MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    Quantity rateQuantity = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getRateQuantity();
    // dosageInstruction.doseAndRate.rateQuantity RXO.21
    // RXO.21
    assertThat(rateQuantity.getValue()).hasToString("6.0");
    // RXO.22.1
    assertThat(rateQuantity.getUnit()).isEqualTo("PC");
    // default
    assertThat(rateQuantity.getSystem()).isEqualTo("http://unitsofmeasure.org");
    // Verify no extraneous resources
    // Expect MedicationRequest, and Patient
    assertThat(e).hasSize(2);
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Quantity(org.hl7.fhir.r4.model.Quantity) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.Test)576 Test (org.junit.jupiter.api.Test)442 Patient (org.hl7.fhir.r4.model.Patient)437 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)255 HashMap (java.util.HashMap)251 Patient (org.hl7.fhir.dstu3.model.Patient)249 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)228 Bundle (org.hl7.fhir.r4.model.Bundle)203 Path (javax.ws.rs.Path)188 Date (java.util.Date)171 Produces (javax.ws.rs.Produces)163 ArrayList (java.util.ArrayList)156 JsonObject (javax.json.JsonObject)141 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)140 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)138 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)137 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)128 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)128 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)125 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)120