Search in sources :

Example 1 with MedicationStatement

use of org.hl7.fhir.r4.model.MedicationStatement in project org.hl7.fhir.core by hapifhir.

the class ArgonautConverter method processMedicationsSection.

private void processMedicationsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
    scanSection("Medications", section);
    ListResource list = new ListResource();
    list.setId(context.getBaseId() + "-list-medications");
    list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafmedicationlist");
    list.setSubject(context.getSubjectRef());
    list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
    list.setTitle(cda.getChild(section, "title").getTextContent());
    list.setStatus(ListStatus.CURRENT);
    list.setMode(ListMode.SNAPSHOT);
    list.setDateElement(context.getNow());
    list.setSource(context.getAuthorRef());
    buildNarrative(list, cda.getChild(section, "text"));
    int i = 0;
    for (Element c : cda.getChildren(section, "entry")) {
        // allergy problem act
        Element sa = cda.getChild(c, "substanceAdministration");
        MedicationStatement ms = new MedicationStatement();
        ms.setId(context.getBaseId() + "-medication-" + i);
        ms.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/medicationstatement-daf-dafmedicationstatement");
        i++;
        ms.setSubject(context.getSubjectRef());
        boolean found = false;
        for (Element e : cda.getChildren(sa, "id")) {
            Identifier id = convert.makeIdentifierFromII(e);
            ms.getIdentifier().add(id);
        }
        if (!found) {
            ms.setStatus(MedicationStatementStatus.COMPLETED);
            list.addEntry().setItem(new Reference().setReference("MedicationStatement/" + ms.getId()));
            // allergy observation
            Element mm = cda.getChild(cda.getChild(cda.getChild(sa, "consumable"), "manufacturedProduct"), "manufacturedMaterial");
            ms.setMedication(new Reference().setReference("#med"));
            Medication med = new Medication();
            med.setId("med");
            med.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(mm, "code")), null));
            ms.getContained().add(med);
            Dosage dosage = ms.addDosage();
            // allergy observation
            Element qty = cda.getChild(sa, "doseQuantity");
            try {
                if (cda.getChild(qty, "low") != null) {
                    // todo: this is not correct?
                    dosage.getExtension().add(new Extension().setUrl("http://healthintersections.com.au/fhir/extensions/medication-statement-range").setValue(convert.makeRangeFromIVLPQ(qty)));
                } else {
                    dosage.setDose(convert.makeQuantityFromPQ(qty));
                }
            } catch (Exception e) {
                System.out.println("  invalid dose quantity '" + qty.getAttribute("value") + " " + qty.getAttribute("unit") + "' (" + e.getClass().getName() + ") in " + context.getBaseId());
            }
            dosage.setRoute(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sa, "routeCode")), null));
            Type t = convert.makeSomethingFromGTS(cda.getChildren(sa, "effectiveTime"));
            if (t instanceof Timing) {
                dosage.setTiming((Timing) t);
                if (dosage.getTiming().hasRepeat() && dosage.getTiming().getRepeat().hasBounds())
                    ms.setEffective(dosage.getTiming().getRepeat().getBounds());
            } else if (t instanceof Period)
                ms.setEffective(t);
            else
                throw new Exception("Undecided how to handle " + t.getClass().getName());
            for (Element e : cda.getChildren(sa, "author")) {
                if (ms.hasInformationSource())
                    throw new Error("additional author discovered");
                Practitioner p = processPerformer(cda, convert, context, e, "assignedAuthor", "assignedPerson");
                Reference ref = new Reference().setReference("Practitioner/" + p.getId()).setDisplay(p.getUserString("display"));
                ms.setInformationSource(ref);
                ms.setDateAssertedElement(convert.makeDateTimeFromTS(cda.getChild(e, "time")));
            }
            saveResource(ms);
        }
    }
    saveResource(list);
}
Also used : Element(org.w3c.dom.Element) IOException(java.io.IOException) NodeType(org.hl7.fhir.utilities.xhtml.NodeType) ObservationRelationshipType(org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType)

Example 2 with MedicationStatement

use of org.hl7.fhir.r4.model.MedicationStatement in project org.hl7.fhir.core by hapifhir.

the class ProfileUtilitiesTests method execute.

public void execute(String[] args) throws FileNotFoundException, IOException, FHIRException {
    System.out.println("loading context");
    context = SimpleWorkerContext.fromPack(Utilities.path(root, "validation.zip"));
    comp = new ProfileComparer(context);
    compare("patient-daf-dafpatient.profile.xml", "patient-qicore-qicore-patient.profile.xml");
    compare("encounter-daf-dafencounter.profile.xml", "encounter-qicore-qicore-encounter.profile.xml");
    compare("substance-daf-dafsubstance.profile.xml", "substance-qicore-qicore-substance.profile.xml");
    compare("medication-daf-dafmedication.profile.xml", "medication-qicore-qicore-medication.profile.xml");
    compare("procedure-daf-dafprocedure.profile.xml", "procedure-qicore-qicore-procedure.profile.xml");
    compare("familymemberhistory-daf-daffamilymemberhistory.profile.xml", "familymemberhistory-qicore-qicore-familymemberhistory.profile.xml");
    compare("immunization-daf-dafimmunization.profile.xml", "immunization-qicore-qicore-immunization.profile.xml");
    compare("condition-daf-dafcondition.profile.xml", "condition-qicore-qicore-condition.profile.xml");
    compare("allergyintolerance-daf-dafallergyintolerance.profile.xml", "allergyintolerance-qicore-qicore-allergyintolerance.profile.xml");
    compare("medicationadministration-daf-dafmedicationadministration.profile.xml", "medicationadministration-qicore-qicore-medicationadministration.profile.xml");
    compare("medicationdispense-daf-dafmedicationdispense.profile.xml", "medicationdispense-qicore-qicore-medicationdispense.profile.xml");
    compare("medicationprescription-daf-dafmedicationprescription.profile.xml", "medicationprescription-qicore-qicore-medicationprescription.profile.xml");
    compare("medicationstatement-daf-dafmedicationstatement.profile.xml", "medicationstatement-qicore-qicore-medicationstatement.profile.xml");
    compare("observation-daf-smokingstatus-dafsmokingstatus.profile.xml", "observation-qicore-qicore-observation.profile.xml");
    compare("observation-daf-vitalsigns-dafvitalsigns.profile.xml", "observation-qicore-qicore-observation.profile.xml");
    // compare("observation-daf-results-dafresultobs.profile.xml", "observation-qicore-qicore-observation.profile.xml");
    // compare("diagnosticorder-daf-dafdiagnosticorder.profile.xml", "diagnosticorder-qicore-qicore-diagnosticorder.profile.xml");
    // compare("diagnosticreport-daf-dafdiagnosticreport.profile.xml", "diagnosticreport-qicore-qicore-diagnosticreport.profile.xml");
    System.out.println("processing output");
    for (ProfileComparison outcome : comp.getComparisons()) {
        if (outcome.getSubset() != null)
            new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "intersection-" + outcome.getId() + ".xml")), outcome.getSubset());
        if (outcome.getSuperset() != null)
            new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "union-" + outcome.getId() + ".xml")), outcome.getSuperset());
        System.out.println("\r\n" + outcome.getId() + ": Comparison of " + outcome.getLeft().getUrl() + " and " + outcome.getRight().getUrl());
        for (ValidationMessage vm : outcome.getMessages()) if (vm.getLevel() == IssueSeverity.INFORMATION)
            System.out.println(vm.summary());
        for (ValidationMessage vm : outcome.getMessages()) if (vm.getLevel() == IssueSeverity.WARNING)
            System.out.println(vm.summary());
        for (ValidationMessage vm : outcome.getMessages()) if (vm.getLevel() == IssueSeverity.ERROR)
            System.out.println(vm.summary());
        for (ValidationMessage vm : outcome.getMessages()) if (vm.getLevel() == IssueSeverity.FATAL)
            System.out.println(vm.summary());
        System.out.println("done. " + Integer.toString(outcome.getMessages().size()) + " messages");
        System.out.println("=================================================================");
    }
}
Also used : ProfileComparison(org.hl7.fhir.dstu3.conformance.ProfileComparer.ProfileComparison) XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ProfileComparer(org.hl7.fhir.dstu3.conformance.ProfileComparer) FileOutputStream(java.io.FileOutputStream)

Example 3 with MedicationStatement

use of org.hl7.fhir.r4.model.MedicationStatement in project fhir-bridge by ehrbase.

the class AntikoagulanzienBeliebigesEreignisPointEventConverter method convertInternal.

@Override
protected AntikoagulanzienBeliebigesEreignisPointEvent convertInternal(MedicationStatement resource) {
    AntikoagulanzienBeliebigesEreignisPointEvent antikoagulanzienBeliebigesEreignisPointEvent = new AntikoagulanzienBeliebigesEreignisPointEvent();
    for (Coding coding : resource.getMedicationCodeableConcept().getCoding()) {
        if (coding.getSystem().equals("http://fhir.de/CodeSystem/bfarm/atc")) {
            DvCodedTextParser.getInstance().parseFHIRCoding(coding).ifPresent(antikoagulanzienBeliebigesEreignisPointEvent::setArzneimittelName);
        }
    }
    getGrundDefiningCode(resource).ifPresent(antikoagulanzienBeliebigesEreignisPointEvent::setGrund);
    return antikoagulanzienBeliebigesEreignisPointEvent;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) AntikoagulanzienBeliebigesEreignisPointEvent(org.ehrbase.fhirbridge.ehr.opt.geccomedikationcomposition.definition.AntikoagulanzienBeliebigesEreignisPointEvent)

Example 4 with MedicationStatement

use of org.hl7.fhir.r4.model.MedicationStatement in project fhir-bridge by ehrbase.

the class AntikoagulanzienObservationConverter method convertInternal.

@Override
protected AntikoagulanzienObservation convertInternal(MedicationStatement resource) {
    AntikoagulanzienObservation antikoagulanzienObservation = new AntikoagulanzienObservation();
    List<AntikoagulanzienBeliebigesEreignisChoice> ereignisList = new ArrayList<>();
    for (Coding coding : resource.getMedicationCodeableConcept().getCoding()) {
        if (coding.getSystem().equals("http://fhir.de/CodeSystem/bfarm/atc")) {
            ereignisList.add(new AntikoagulanzienBeliebigesEreignisPointEventConverter().convert(resource));
        }
    }
    antikoagulanzienObservation.setBeliebigesEreignis(ereignisList);
    return antikoagulanzienObservation;
}
Also used : AntikoagulanzienBeliebigesEreignisChoice(org.ehrbase.fhirbridge.ehr.opt.geccomedikationcomposition.definition.AntikoagulanzienBeliebigesEreignisChoice) Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) AntikoagulanzienObservation(org.ehrbase.fhirbridge.ehr.opt.geccomedikationcomposition.definition.AntikoagulanzienObservation)

Example 5 with MedicationStatement

use of org.hl7.fhir.r4.model.MedicationStatement in project fhir-bridge by ehrbase.

the class Covid19TherapieObservationConverter method convertInternal.

@Override
protected Covid19TherapieObservation convertInternal(MedicationStatement resource) {
    Covid19TherapieObservation covid19TherapieObservation = new Covid19TherapieObservation();
    List<Covid19TherapieBeliebigesEreignisChoice> ereignisList = new ArrayList<>();
    for (Coding coding : resource.getMedicationCodeableConcept().getCoding()) {
        if (coding.getSystem().equals("http://fhir.de/CodeSystem/bfarm/atc")) {
            ereignisList.add(new Covid19TherapieBeliebigesEreignisPointEventConverter().convert(resource));
        }
    }
    covid19TherapieObservation.setBeliebigesEreignis(ereignisList);
    return covid19TherapieObservation;
}
Also used : Covid19TherapieObservation(org.ehrbase.fhirbridge.ehr.opt.geccomedikationcomposition.definition.Covid19TherapieObservation) Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) Covid19TherapieBeliebigesEreignisChoice(org.ehrbase.fhirbridge.ehr.opt.geccomedikationcomposition.definition.Covid19TherapieBeliebigesEreignisChoice)

Aggregations

ArrayList (java.util.ArrayList)11 MedicationStatement (org.hl7.fhir.r4.model.MedicationStatement)9 Test (org.junit.jupiter.api.Test)9 Coding (org.hl7.fhir.r4.model.Coding)8 Reference (org.hl7.fhir.dstu3.model.Reference)6 IdType (org.hl7.fhir.dstu3.model.IdType)5 Date (java.util.Date)4 RCMRMT030101UK04Component2 (org.hl7.v3.RCMRMT030101UK04Component2)4 RCMRMT030101UK04EhrExtract (org.hl7.v3.RCMRMT030101UK04EhrExtract)4 DateTimeType (org.hl7.fhir.dstu3.model.DateTimeType)3 Extension (org.hl7.fhir.dstu3.model.Extension)3 Bundle (org.hl7.fhir.r4.model.Bundle)3 UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)2 FileOutputStream (java.io.FileOutputStream)2 List (java.util.List)2 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)2 MedicationRequest (org.hl7.fhir.dstu3.model.MedicationRequest)2 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)2 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 Condition (org.hl7.fhir.r4.model.Condition)2