Search in sources :

Example 71 with Annotation

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

the class Hl7ImmunizationFHIRConversionTest method testDoubleMultipleNestedEducation.

// The following creates education records which combine information from related OBX's, indicated by matching OBX.4 value
// There are three ORC/RXA/RXR/OBX* sections, two differ only by dates and other small differences; enough to ensure we
// are finding the correct matching publication and presentation dates for the correct siblings and there is no data bleed.
// Others have handle various cases of completeness of data, according to rules outlined in Immunization.yml.
// For each of RXA sections below, Immunization.education should be (dates & xx vary):
// 
// "education": [
// {
// "documentType": "DTaP, xx UF",
// "publicationDate": "2007-05-17",
// "presentationDate": "2014-12-03"
// },
// {
// "documentType": "Hep B, xx UF",
// "publicationDate": "2012-02-02",
// "presentationDate": "2014-12-03"
// }
// ],
@Test
void testDoubleMultipleNestedEducation() throws IOException {
    String hl7VUXmessageRep = "MSH|^~\\&|||||20160106165800070+0000||VXU^V04^VXU_V04|20210205NH0000 01|P|2.5.1|||||||||Z22^CDCPHPHINVS|||\n" + "PID|1||12345^^^^MR||TestPatient^Jane^^^^^L||||||\n" + "NK1|1|LASTNAME^FIRST^^^^^L|SPO^SPOUSE^HL70063||^PRN^PH^^^603^7772222\n" + // ----- FIRST IMMUNIZATION SET. ----- Descriptions have AA, and dates 2007.
    "ORC|RE||2623980^EHR|||||||||^ORDERINGLASTNAME^FIRST^^^^^^^L^^^MD|\n" + "RXA|0|1|20160105||33^PNEUMOCOCCAL POLYSACCHARIDE PPV23^CVX|0.5|ML^^UCUM|||||||||||||||\n" + "RXR|C28161^Intramuscular^NCIT|LD^Left Deltoid^HL70163|\n" + // Reference will be used as DocumentType
    "OBX|1|CE|30956-7^Vaccine Type^LN|2|107^DTaP, AA1 UF^CVX||||||F\n" + "OBX|2|DT|29768-9^Date Vaccine Information Statement Published^LN|2|20070517||||||F\n" + "OBX|3|DT|29769-7^Date Vaccine Information Statement Presented^LN|2|20071203||||||F\n" + // Random OBX to prove it doesn't confuse searching or group association.
    "OBX|4|CWE|64994-7^funding pgm eligibility^LN||V01^Insured^HL70064||||||F||||||VXC40^per immunization^CDCPHINVS\n" + // Reference will be used as DocumentType
    "OBX|5|CE|30956-7^Vaccine Type^LN|3|45^Hep B, AA2 UF^CVX||||||F\n" + "OBX|6|DT|29768-9^Date Vaccine Information Statement Published^LN|3|20070202||||||F\n" + "OBX|7|DT|29769-7^Date Vaccine Information Statement Presented^LN|3|20071203||||||F\n" + // 48767-8 record in group will be ignore.
    "OBX|2|DT|69764-9^HIB Info Sheet^LN|8|20070505||||||F|||20130531\n" + "OBX|3|DT|29768-9^VIS Publication Date^LN|8|20070606||||||F|||20130531\n" + "OBX|4|DT|29769-7^VIS Presentation Date^LN|8|20070707||||||F|||20130531\n" + "OBX|5|ST|48767-8^Annotation^LN|8|Some text from doctor||||||F|||20130531\n" + // -----  SECOND IMMUNIZATION SET. ----- Descriptions have BB, and dates 2014.
    "ORC|RE||2623980^EHR|||||||||^ORDERINGLASTNAME^FIRST^^^^^^^L^^^MD|\n" + "RXA|0|1|20160105||33^PNEUMOCOCCAL POLYSACCHARIDE PPV23^CVX|0.5|ML^^UCUM||||||||||||||||\n" + "RXR|C28161^Intramuscular^NCIT|LD^Left Deltoid^HL70163|\n" + // Random OBX to prove it doesn't confuse searching or group association.
    "OBX|1|CWE|64994-7^funding pgm eligibility^LN||V01^Insured^HL70064||||||F||||||VXC40^per immunization^CDCPHINVS\n" + // Reference will be used as DocumentType
    "OBX|2|CE|30956-7^Vaccine Type^LN|2|107^DTaP, BB1 UF^CVX||||||F\n" + "OBX|3|DT|29768-9^Date Vaccine Information Statement Published^LN|2|20140517||||||F\n" + "OBX|4|DT|29769-7^Date Vaccine Information Statement Presented^LN|2|20141203||||||F\n" + // Reference will be used as DocumentType
    "OBX|5|CE|30956-7^Vaccine Type^LN|3|45^Hep B, BB2 UF^CVX||||||F\n" + "OBX|6|DT|29768-9^Date Vaccine Information Statement Published^LN|3|20140202||||||F\n" + "OBX|7|DT|29769-7^Date Vaccine Information Statement Presented^LN|3|20141203||||||F\n" + // 'unspecified' is used as DocumentType.
    "OBX|32|DT|29768-9^Date Vaccine Information Statement Published^LN|6|20140503||||||F\n" + "OBX|33|DT|29769-7^Date Vaccine Information Statement Presented^LN|6|20140505||||||F\n" + // -----  THIRD IMMUNIZATION SET. ----- Descriptions have CC, and dates 2017.
    "ORC|RE||2623980^EHR|||||||||^ORDERINGLASTNAME^FIRST^^^^^^^L^^^MD|\n" + "RXA|0|1|20160105||33^PNEUMOCOCCAL POLYSACCHARIDE PPV23^CVX|0.5|ML^^UCUM||||||||||||||||\n" + "RXR|C28161^Intramuscular^NCIT|LD^Left Deltoid^HL70163|\n" + // OBX times have type TS to prove that works
    "OBX|8|CE|69764-9^Vaccine Type^LN|4|45^Hep B, CC3a UF^CVX||||||F\n" + "OBX|9|CE|30956-7^Vaccine Type^LN|4|45^Hep B, CC3b UF^CVX||||||F\n" + "OBX|10|TS|29768-9^Date Vaccine Information Statement Published^LN|4|20170303||||||F\n" + "OBX|11|TS|29769-7^Date Vaccine Information Statement Presented^LN|4|20170305||||||F\n" + // OBX times have type DTM to prove that works
    "OBX|21|CE|69764-9^Vaccine Type^LN|5|45^Hep B, CC4 UF^CVX||||||F\n" + "OBX|22|DTM|29768-9^Date Vaccine Information Statement Published^LN|5|20170403011212000+0000||||||F\n" + "OBX|23|DTM|29769-7^Date Vaccine Information Statement Presented^LN|5|20170405011212000+0000||||||F\n" + // 'unspecified' is used as DocumentType.
    "OBX|43|DT|29769-7^Date Vaccine Information Statement Presented^LN|7|20170605||||||F\n" + "ORC|RE||9999^EHR|||||||\n";
    List<Bundle.BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7VUXmessageRep);
    List<Resource> immunizations = ResourceUtils.getResourceList(e, ResourceType.Immunization);
    assertThat(immunizations).hasSize(3);
    // First immunization set. Descriptions have AA, and dates 2007.
    Immunization immunization = (Immunization) immunizations.get(0);
    assertThat(immunization.getEducation()).hasSize(3);
    checkImmunizationEducation(immunization.getEducation().get(1), "DTaP, AA1 UF", "2007-05-17", "2007-12-03");
    checkImmunizationEducation(immunization.getEducation().get(2), "Hep B, AA2 UF", "2007-02-02", "2007-12-03");
    // Degenerate 69764-9 without CE/CWE data. DocumentType will default to "unspecified"
    checkImmunizationEducation(immunization.getEducation().get(0), "unspecified", "2007-06-06", "2007-07-07");
    // Second immunization set. Descriptions have BB, and dates 2014.
    immunization = (Immunization) immunizations.get(1);
    assertThat(immunization.getEducation()).hasSize(3);
    // Reference used as DocumentType
    checkImmunizationEducation(immunization.getEducation().get(0), "DTaP, BB1 UF", "2014-05-17", "2014-12-03");
    // Reference used as DocumentType
    checkImmunizationEducation(immunization.getEducation().get(1), "Hep B, BB2 UF", "2014-02-02", "2014-12-03");
    // Has no DocumentType nor Reference record. 'unspecified' is used as DocumentType.
    checkImmunizationEducation(immunization.getEducation().get(2), "unspecified", "2014-05-03", "2014-05-05");
    // Second immunization set. Descriptions have CC, and dates 2017.
    immunization = (Immunization) immunizations.get(2);
    assertThat(immunization.getEducation()).hasSize(3);
    // Has both DocumentType and Reference records.  DocumentType will be used.
    checkImmunizationEducation(immunization.getEducation().get(0), "Hep B, CC3a UF", "2017-03-03", "2017-03-05");
    // Has only DocumentType record.  DocumentType will be used.
    checkImmunizationEducation(immunization.getEducation().get(1), "Hep B, CC4 UF", "2017-04-03", "2017-04-05");
    // Has no DocumentType nor Reference record nor PublicationDate. 'unspecified' is used as DocumentType.
    checkImmunizationEducation(immunization.getEducation().get(2), "unspecified", null, "2017-06-05");
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Test(org.junit.jupiter.api.Test)

Example 72 with Annotation

use of org.hl7.fhir.dstu2016may.model.Annotation in project openmrs-module-fhir2 by openmrs.

the class MedicationRequestTranslatorImplTest method toOpenMrsType_shouldTranslateNoteToCommentToFullFiller.

@Test
public void toOpenMrsType_shouldTranslateNoteToCommentToFullFiller() {
    medicationRequest.addNote(new Annotation().setText(COMMENT_TO_THE_FULL_FILLER));
    DrugOrder result = medicationRequestTranslator.toOpenmrsType(new DrugOrder(), medicationRequest);
    assertThat(result, notNullValue());
    assertThat(result.getCommentToFulfiller(), equalTo(COMMENT_TO_THE_FULL_FILLER));
}
Also used : DrugOrder(org.openmrs.DrugOrder) Annotation(org.hl7.fhir.r4.model.Annotation) Test(org.junit.Test)

Example 73 with Annotation

use of org.hl7.fhir.dstu2016may.model.Annotation in project pathling by aehrc.

the class AsyncAspect method maybeExecuteAsynchronously.

@Around("@annotation(asyncSupported)")
private IBaseResource maybeExecuteAsynchronously(@Nonnull final ProceedingJoinPoint joinPoint, @Nonnull final AsyncSupported asyncSupported) throws Throwable {
    final Object[] args = joinPoint.getArgs();
    final HttpServletRequest request = getRequest(args);
    final String prefer = request.getHeader(ASYNC_HEADER);
    if (prefer != null && prefer.equals(ASYNC_HEADER_VALUE)) {
        log.info("Asynchronous processing requested");
        processRequestAsynchronously(joinPoint, args, spark);
        throw new ProcessingNotCompletedException("Accepted", buildOperationOutcome());
    } else {
        return (IBaseResource) joinPoint.proceed(args);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Around(org.aspectj.lang.annotation.Around)

Example 74 with Annotation

use of org.hl7.fhir.dstu2016may.model.Annotation in project org.hl7.fhir.core by hapifhir.

the class DeviceUseStatement10_30 method convertDeviceUseStatement.

public static org.hl7.fhir.dstu2.model.DeviceUseStatement convertDeviceUseStatement(org.hl7.fhir.dstu3.model.DeviceUseStatement src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2.model.DeviceUseStatement tgt = new org.hl7.fhir.dstu2.model.DeviceUseStatement();
    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
    if (src.hasBodySite())
        tgt.setBodySite(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getBodySite()));
    if (src.hasWhenUsed())
        tgt.setWhenUsed(Period10_30.convertPeriod(src.getWhenUsed()));
    if (src.hasDevice())
        tgt.setDevice(Reference10_30.convertReference(src.getDevice()));
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getIndication()) tgt.addIndication(CodeableConcept10_30.convertCodeableConcept(t));
    for (Annotation t : src.getNote()) tgt.addNotes(t.getText());
    if (src.hasRecordedOnElement())
        tgt.setRecordedOnElement(DateTime10_30.convertDateTime(src.getRecordedOnElement()));
    if (src.hasSubject())
        tgt.setSubject(Reference10_30.convertReference(src.getSubject()));
    if (src.hasTiming())
        tgt.setTiming(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getTiming()));
    return tgt;
}
Also used : Annotation(org.hl7.fhir.dstu3.model.Annotation)

Example 75 with Annotation

use of org.hl7.fhir.dstu2016may.model.Annotation in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method displayLeaf.

private boolean displayLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, String name, boolean showCodeDetails) throws FHIRException, UnsupportedEncodingException, IOException {
    if (ew == null)
        return false;
    Base e = ew.getBase();
    Map<String, String> displayHints = readDisplayHints(defn);
    if (name.endsWith("[x]"))
        name = name.substring(0, name.length() - 3);
    if (!showCodeDetails && e instanceof PrimitiveType && isDefault(displayHints, ((PrimitiveType) e)))
        return false;
    if (e instanceof StringType) {
        x.addText(name + ": " + ((StringType) e).getValue());
        return true;
    } else if (e instanceof CodeType) {
        x.addText(name + ": " + ((CodeType) e).getValue());
        return true;
    } else if (e instanceof IdType) {
        x.addText(name + ": " + ((IdType) e).getValue());
        return true;
    } else if (e instanceof DateTimeType) {
        x.addText(name + ": " + ((DateTimeType) e).toHumanDisplay());
        return true;
    } else if (e instanceof InstantType) {
        x.addText(name + ": " + ((InstantType) e).toHumanDisplay());
        return true;
    } else if (e instanceof Extension) {
        x.addText("Extensions: todo");
        return true;
    } else if (e instanceof org.hl7.fhir.dstu2.model.DateType) {
        x.addText(name + ": " + ((org.hl7.fhir.dstu2.model.DateType) e).toHumanDisplay());
        return true;
    } else if (e instanceof Enumeration) {
        // todo: look up a display name if there is one
        x.addText(((Enumeration<?>) e).getValue().toString());
        return true;
    } else if (e instanceof BooleanType) {
        if (((BooleanType) e).getValue()) {
            x.addText(name);
            return true;
        }
    } else if (e instanceof CodeableConcept) {
        renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
        return true;
    } else if (e instanceof Coding) {
        renderCoding((Coding) e, x, showCodeDetails);
        return true;
    } else if (e instanceof Annotation) {
        renderAnnotation((Annotation) e, x, showCodeDetails);
        return true;
    } else if (e instanceof org.hl7.fhir.dstu2.model.IntegerType) {
        x.addText(Integer.toString(((org.hl7.fhir.dstu2.model.IntegerType) e).getValue()));
        return true;
    } else if (e instanceof org.hl7.fhir.dstu2.model.DecimalType) {
        x.addText(((org.hl7.fhir.dstu2.model.DecimalType) e).getValue().toString());
        return true;
    } else if (e instanceof Identifier) {
        renderIdentifier((Identifier) e, x);
        return true;
    } else if (e instanceof HumanName) {
        renderHumanName((HumanName) e, x);
        return true;
    } else if (e instanceof SampledData) {
        renderSampledData((SampledData) e, x);
        return true;
    } else if (e instanceof Address) {
        renderAddress((Address) e, x);
        return true;
    } else if (e instanceof ContactPoint) {
        renderContactPoint((ContactPoint) e, x);
        return true;
    } else if (e instanceof Timing) {
        renderTiming((Timing) e, x);
        return true;
    } else if (e instanceof Quantity) {
        renderQuantity((Quantity) e, x, showCodeDetails);
        return true;
    } else if (e instanceof Ratio) {
        renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
        x.addText("/");
        renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
        return true;
    } else if (e instanceof Period) {
        Period p = (Period) e;
        x.addText(name + ": ");
        x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
        x.addText(" --> ");
        x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
        return true;
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        if (r.hasDisplayElement())
            x.addText(r.getDisplay());
        else if (r.hasReferenceElement()) {
            ResourceWithReference tr = resolveReference(res, r.getReference());
            // getDisplayForReference(tr.getReference()));
            x.addText(tr == null ? r.getReference() : "????");
        } else
            x.addText("??");
        return true;
    } else if (e instanceof Narrative) {
        return false;
    } else if (e instanceof Resource) {
        return false;
    } else if (!(e instanceof Attachment))
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
    return false;
}
Also used : Address(org.hl7.fhir.dstu2.model.Address) StringType(org.hl7.fhir.dstu2.model.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Attachment(org.hl7.fhir.dstu2.model.Attachment) HumanName(org.hl7.fhir.dstu2.model.HumanName) ContactPoint(org.hl7.fhir.dstu2.model.ContactPoint) Identifier(org.hl7.fhir.dstu2.model.Identifier) Coding(org.hl7.fhir.dstu2.model.Coding) Narrative(org.hl7.fhir.dstu2.model.Narrative) SampledData(org.hl7.fhir.dstu2.model.SampledData) PrimitiveType(org.hl7.fhir.dstu2.model.PrimitiveType) Ratio(org.hl7.fhir.dstu2.model.Ratio) InstantType(org.hl7.fhir.dstu2.model.InstantType) Enumeration(org.hl7.fhir.dstu2.model.Enumeration) Reference(org.hl7.fhir.dstu2.model.Reference) BooleanType(org.hl7.fhir.dstu2.model.BooleanType) Resource(org.hl7.fhir.dstu2.model.Resource) DomainResource(org.hl7.fhir.dstu2.model.DomainResource) Quantity(org.hl7.fhir.dstu2.model.Quantity) Period(org.hl7.fhir.dstu2.model.Period) Base(org.hl7.fhir.dstu2.model.Base) Annotation(org.hl7.fhir.dstu2.model.Annotation) IdType(org.hl7.fhir.dstu2.model.IdType) Extension(org.hl7.fhir.dstu2.model.Extension) DateTimeType(org.hl7.fhir.dstu2.model.DateTimeType) CodeType(org.hl7.fhir.dstu2.model.CodeType) EventTiming(org.hl7.fhir.dstu2.model.Timing.EventTiming) Timing(org.hl7.fhir.dstu2.model.Timing) CodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept)

Aggregations

NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 Trace (com.newrelic.api.agent.Trace)13 Operation (gov.cms.bfd.server.war.Operation)13 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)12 Annotation (org.hl7.fhir.r4.model.Annotation)12 NoResultException (javax.persistence.NoResultException)11 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)9 Annotation (org.hl7.fhir.dstu3.model.Annotation)9 Search (ca.uhn.fhir.rest.annotation.Search)8 OffsetLinkBuilder (gov.cms.bfd.server.war.commons.OffsetLinkBuilder)8 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)8 Read (ca.uhn.fhir.rest.annotation.Read)7 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)7 Patient (org.hl7.fhir.dstu3.model.Patient)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)6 Resource (org.hl7.fhir.r4.model.Resource)6 Test (org.junit.jupiter.api.Test)6