Search in sources :

Example 56 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7IdentifierFHIRConversionTest method medicationRequestIdentifierTest3.

@Test
void medicationRequestIdentifierTest3() throws IOException {
    // Test: Visit number from MSH-7, extID from RXE-2
    String medicationRequest = "MSH|^~\\&|PROSLOV|MYHOSPITAL|WHIA|IBM|20170215080000||OMP^O09|MSGID005520|T|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "PID|1||000054321^^^MRN\r" + "PV1||I||||||||SUR||||||||S||A|||||||||||||||||||SF|K||||20170215080000\r" + "ORC|NW||CD2017071101^RX|||E|10^BID^D4^^^R||20170215080000\r" + "RXO|^DOCUSATE SODIUM 100 MG CAPSULE|100||mg|||||G||10||5|\r";
    MedicationRequest medReq = ResourceUtils.getMedicationRequest(ftv, medicationRequest);
    // Expect 3 identifiers
    assertThat(medReq.hasIdentifier()).isTrue();
    assertThat(medReq.getIdentifier()).hasSize(3);
    List<Identifier> identifiers = medReq.getIdentifier();
    // Match the id's to position; we can't depend on an order.
    int posVN = getIdentifierPositionByValue("20170215080000", identifiers);
    assertThat(posVN).isNotSameAs(-1);
    int posExtId = getIdentifierPositionByValue("DOCUSATE SODIUM 100 MG CAPSULE", identifiers);
    assertThat(posExtId).isNotSameAs(-1);
    int posRX = getIdentifierPositionByValue("CD2017071101", identifiers);
    assertThat(posRX).isNotSameAs(-1);
    // Identifier 1: Visit number
    Identifier identifier = medReq.getIdentifier().get(posVN);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // MSH-7
    assertThat(value).isEqualTo("20170215080000");
    assertThat(system).isNull();
    CodeableConcept type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // Identifier 2: extID based on RXO-1.2
    identifier = medReq.getIdentifier().get(posExtId);
    value = identifier.getValue();
    system = identifier.getSystem();
    // RXO-1.2
    assertThat(value).isEqualTo("DOCUSATE SODIUM 100 MG CAPSULE");
    assertThat(system).isEqualTo("urn:id:extID");
    // Identifier 3: RX
    identifier = medReq.getIdentifier().get(posRX);
    value = identifier.getValue();
    system = identifier.getSystem();
    // ORC.3.1
    assertThat(value).isEqualTo("CD2017071101");
    // ORC-3.2 any whitespace gets replaced with underscores
    assertThat(system).isEqualTo("urn:id:RX");
    type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "FILL", "Filler Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Identifier(org.hl7.fhir.r4.model.Identifier) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 57 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7IdentifierFHIRConversionTest method conditionDg1IdentifierTest3.

@Test
void conditionDg1IdentifierTest3() {
    String withDG132 = "MSH|^~\\&|||||201610015080000||ADT^A01^ADT_A01|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6||||||\r" + "PID|||10290^^^WEST^MR||||20040530|M||||||||||||||||||||||N\n" + "PV1||I||||||||SUR||||||||S||A|||||||||||||||||||SF|K||||20170215080000\n" + "DG1|1|ICD10|^Ovarian Cancer|Test|20210322154449|A|E123|R45|Y|J76|C|15|1458.98||1|123^DOE^JOHN^A^|C|Y|20210322154326||S1234|Parent Diagnosis|Value345|Group567|DiagnosisG45|Y\r";
    Condition condition = ResourceUtils.getCondition(ftv, withDG132);
    // Expect 2 identifiers
    assertThat(condition.hasIdentifier()).isTrue();
    assertThat(condition.getIdentifier()).hasSize(2);
    List<Identifier> identifiers = condition.getIdentifier();
    // Match the id's to position; we can't depend on an order.
    int posVN = getIdentifierPositionByValue("201610015080000", identifiers);
    assertThat(posVN).isNotSameAs(-1);
    int posExtId = getIdentifierPositionByValue("Ovarian Cancer", identifiers);
    assertThat(posExtId).isNotSameAs(-1);
    // Identifier 1: Visit number
    Identifier identifier = condition.getIdentifier().get(posVN);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // MSH.7
    assertThat(value).isEqualTo("201610015080000");
    assertThat(system).isNull();
    CodeableConcept type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // Identifier 3: DG1.3.2
    identifier = condition.getIdentifier().get(posExtId);
    value = identifier.getValue();
    system = identifier.getSystem();
    // DG1.3.2
    assertThat(value).isEqualTo("Ovarian Cancer");
    assertThat(system).isEqualTo("urn:id:extID");
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Identifier(org.hl7.fhir.r4.model.Identifier) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 58 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7OrderRequestFHIRConversionTest method testBroadORCPlusOBRFields2.

@Test
void testBroadORCPlusOBRFields2() {
    String hl7message = "MSH|^~\\&|||||20180924152907|34001|ORU^R01^ORU_R01|213|T|2.6|||||||||||\n" + // PID.18 is empty, MSH.7 will be used as identifier visit number
    "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // PV1.19  is empty, MSH.7 will be used as identifier visit number
    "PV1|1|E|||||||||||||||||||||||||||||||||||||||||||\n" + // ORC.5 with purposely bad code to see that 'unknown' is result
    "ORC|RE|248648498^|248648498^||ZZ||||20120628071200||||||||||||||||||||||\n" + "OBR|1|248648498^|248648498^|83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C|||||||L||||||||||||||F||^^^20120606120606|||||||||||||||||||||||\n";
    String json = ftv.convert(hl7message, PatientUtils.OPTIONS);
    assertThat(json).isNotBlank();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle bundle = (Bundle) bundleResource;
    List<BundleEntryComponent> e = bundle.getEntry();
    List<Resource> serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    // Important that we have exactly one service request (no duplication).  OBR creates it as a reference.
    assertThat(serviceRequestList).hasSize(1);
    ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequestList.get(0), context);
    assertThat(serviceRequest.hasStatus()).isTrue();
    assertThat(serviceRequest.hasIdentifier()).isTrue();
    assertThat(serviceRequest.getIdentifier()).hasSize(3);
    // Identifier 1: visit number should be set by in this test by tertiary MSH.7
    // See notes about identifier testing in previous tests
    Identifier identifier = serviceRequest.getIdentifier().get(0);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // MSH.7 as a string, not as a date
    assertThat(value).isEqualTo("20180924152907");
    assertThat(system).isNull();
    CodeableConcept type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // OBR.27[0].4 should create an ServiceRequest.occurrenceDateTime date
    assertThat(serviceRequest.hasOccurrenceDateTimeType()).isTrue();
    assertThat(serviceRequest.getOccurrenceDateTimeType().toString()).containsPattern("2012-06-06T12:06:06");
    // // ORC.5 creates the serviceRequest.status() purposely an unknown code
    assertThat(serviceRequest.hasStatus()).isTrue();
    assertThat(serviceRequest.getStatusElement().getCode()).isEqualTo("unknown");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Bundle(org.hl7.fhir.r4.model.Bundle) Resource(org.hl7.fhir.r4.model.Resource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 59 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.

the class FHIRConverterTest method testCodingSystems.

@Test
/*
     * This tests some of coding systems of interest or potential problems
     */
void testCodingSystems() throws FHIRException {
    String hl7VUXmessageRep = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|201305330||VXU^V04^VXU_V04|20130531RI881401010105|P|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "EVN|A01|20130617154644||01\r" + "PID|1||12345678^^^MYEMR^MR||TestPatient^John|||M|\r" + "ORC|RE||197027|||||||^Clerk^Myron||MD67895^Pediatric^MARY^^^^MD^^RIA|||||RI2050\r" + // Test MVX
    "RXA|0|1|20130528|20130529|48^HIB PRP-T^CVX|0.5|ML^^ISO+||00^new immunization record^NIP001|^Sticker^Nurse|^^^RI2050||||33k2a|20131210|PMC^sanofi^MVX|||CP|A\r" + // Test HL70162 & HL70163
    "RXR|C28161^IM^NCIT^IM^INTRAMUSCULAR^HL70162|RT^right thigh^HL70163\r";
    String json = ftv.convert(hl7VUXmessageRep, OPTIONS);
    FHIRContext context = new FHIRContext();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle b = (Bundle) bundleResource;
    assertThat(b.getType()).isEqualTo(BundleType.COLLECTION);
    assertThat(b.getId()).isNotNull();
    List<BundleEntryComponent> e = b.getEntry();
    List<Resource> obsResource = e.stream().filter(v -> ResourceType.Immunization == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    assertThat(obsResource).hasSize(1);
    Immunization immunization = (Immunization) obsResource.get(0);
    // Check that organization identifier (MVX) has a system
    Organization org = (Organization) immunization.getManufacturer().getResource();
    List<Identifier> li = org.getIdentifier();
    Identifier ident = li.get(0);
    assertThat(ident.hasSystem()).isTrue();
    assertThat(ident.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/MVX");
    assertThat(ident.hasValue()).isTrue();
    assertThat(ident.getValue()).isEqualTo("PMC");
    // Check that route (HL70162) has a system
    CodeableConcept route = immunization.getRoute();
    assertThat(route.hasCoding()).isTrue();
    List<Coding> codings = route.getCoding();
    assertThat(codings.size()).isEqualTo(2);
    Coding coding = codings.get(0);
    // If the first one is not the one we want look at the second one.
    if (coding.getCode().contains("C28161")) {
        coding = codings.get(1);
    }
    assertThat(coding.hasSystem()).isTrue();
    assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0162");
    // Check that site (HL70163) has a system
    CodeableConcept site = immunization.getSite();
    coding = site.getCodingFirstRep();
    assertThat(coding.hasSystem()).isTrue();
    assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0163");
}
Also used : FHIRContext(io.github.linuxforhealth.fhir.FHIRContext) Immunization(org.hl7.fhir.r4.model.Immunization) Organization(org.hl7.fhir.r4.model.Organization) Bundle(org.hl7.fhir.r4.model.Bundle) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 60 with Identifier

use of org.hl7.fhir.r4.model.Identifier in project BridgeServer2 by Sage-Bionetworks.

the class CRCController method createPatient.

Patient createPatient(Account account) {
    Patient patient = new Patient();
    patient.setActive(true);
    patient.setId(account.getId());
    Identifier identifier = new Identifier();
    identifier.setValue(account.getId());
    identifier.setSystem(USER_ID_VALUE_NS);
    patient.addIdentifier(identifier);
    Coding coding = new Coding();
    coding.setSystem("source");
    coding.setCode("sage");
    Meta meta = new Meta();
    meta.setTag(ImmutableList.of(coding));
    patient.setMeta(meta);
    HumanName name = new HumanName();
    if (isNotBlank(account.getFirstName())) {
        name.addGiven(account.getFirstName());
    }
    if (isNotBlank(account.getLastName())) {
        name.setFamily(account.getLastName());
    }
    patient.addName(name);
    Map<String, String> atts = account.getAttributes();
    if (isNotBlank(atts.get("gender"))) {
        if ("female".equalsIgnoreCase(atts.get("gender"))) {
            patient.setGender(AdministrativeGender.FEMALE);
        } else if ("male".equalsIgnoreCase(atts.get("gender"))) {
            patient.setGender(AdministrativeGender.MALE);
        } else {
            patient.setGender(AdministrativeGender.OTHER);
        }
    } else {
        patient.setGender(AdministrativeGender.UNKNOWN);
    }
    if (isNotBlank(atts.get("dob"))) {
        LocalDate localDate = LocalDate.parse(atts.get("dob"));
        patient.setBirthDate(localDate.toDate());
    }
    Address address = new Address();
    if (isNotBlank(atts.get("address1"))) {
        address.addLine(atts.get("address1"));
    }
    if (isNotBlank(atts.get("address2"))) {
        address.addLine(atts.get("address2"));
    }
    if (isNotBlank(atts.get("city"))) {
        address.setCity(atts.get("city"));
    }
    if (isNotBlank(atts.get("state"))) {
        address.setState(atts.get("state"));
    } else {
        address.setState("NY");
    }
    if (isNotBlank(atts.get("zip_code"))) {
        address.setPostalCode(atts.get("zip_code"));
    }
    patient.addAddress(address);
    if (isNotBlank(atts.get("home_phone"))) {
        ContactPoint contact = new ContactPoint();
        contact.setSystem(ContactPointSystem.PHONE);
        contact.setValue(atts.get("home_phone"));
        patient.addTelecom(contact);
    }
    if (account.getPhone() != null && TRUE.equals(account.getPhoneVerified())) {
        ContactPoint contact = new ContactPoint();
        contact.setSystem(ContactPointSystem.SMS);
        contact.setValue(account.getPhone().getNumber());
        patient.addTelecom(contact);
    }
    if (account.getEmail() != null && TRUE.equals(account.getEmailVerified())) {
        ContactPoint contact = new ContactPoint();
        contact.setSystem(ContactPointSystem.EMAIL);
        contact.setValue(account.getEmail());
        patient.addTelecom(contact);
    }
    Reference ref = new Reference("CUZUCK");
    ref.setDisplay("COVID Recovery Corps");
    ContactComponent contact = new ContactComponent();
    contact.setOrganization(ref);
    patient.addContact(contact);
    return patient;
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta) HumanName(org.hl7.fhir.dstu3.model.HumanName) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) Identifier(org.hl7.fhir.dstu3.model.Identifier) Address(org.hl7.fhir.dstu3.model.Address) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) ContactComponent(org.hl7.fhir.dstu3.model.Patient.ContactComponent) Patient(org.hl7.fhir.dstu3.model.Patient) LocalDate(org.joda.time.LocalDate)

Aggregations

Identifier (org.hl7.fhir.r4.model.Identifier)212 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)143 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)125 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)116 Test (org.junit.Test)109 Test (org.junit.jupiter.api.Test)84 ArrayList (java.util.ArrayList)67 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)66 Reference (org.hl7.fhir.r4.model.Reference)57 Identifier (org.hl7.fhir.dstu3.model.Identifier)55 Patient (org.hl7.fhir.r4.model.Patient)55 Coding (org.hl7.fhir.r4.model.Coding)49 List (java.util.List)47 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)41 Practitioner (org.hl7.fhir.r4.model.Practitioner)41 Date (java.util.Date)40 Collectors (java.util.stream.Collectors)38 Resource (org.hl7.fhir.r4.model.Resource)37 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)36 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)34