Search in sources :

Example 1 with ItemData

use of de.difuture.uds.odm2fhir.odm.model.ItemData in project odm2fhir by num-codex.

the class ImagingProcedures method map.

protected Stream<DomainResource> map(FormData formData) {
    var techniqueGroup = formData.getItemGroupData("bildgebung.bildgebende_verfahren_ct");
    var befundGroup = formData.getItemGroupData("bildgebung.befund_bildgebender_verfahren_ct");
    var generalCoding = formData.getItemData("bildgebende_verfahren");
    if (!"1".equals(generalCoding.getValue())) {
        return Stream.empty();
    }
    var itemDatas = Stream.of(techniqueGroup.getItemData(), befundGroup.getItemData()).flatMap(List::stream).collect(toMap(ItemData::getItemOID, identity()));
    return Stream.of("ct", "roentgen", "us").filter(type -> contains(itemDatas.get("bildgebende_verfahren_" + type).getValue(), "410605003")).filter(type -> !(itemDatas.get("befund_bildgebender_verfahren_" + type).isEmpty())).flatMap(type -> {
        var diagnosticReport = createDiagnosticReport(itemDatas.get("befund_bildgebender_verfahren_" + type));
        var procedure = createProcedure(itemDatas.get("bildgebende_verfahren_" + type)).addReport(new Reference(format("%s/%s", DIAGNOSTICREPORT.toCode(), diagnosticReport.getId())));
        return Stream.of(diagnosticReport, procedure);
    });
}
Also used : FormData(de.difuture.uds.odm2fhir.odm.model.FormData) Item(de.difuture.uds.odm2fhir.fhir.mapper.Item) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) PROCEDURE(org.hl7.fhir.r4.model.codesystems.ResourceTypes.PROCEDURE) Reference(org.hl7.fhir.r4.model.Reference) LOINC(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.LOINC) Procedure(org.hl7.fhir.r4.model.Procedure) StringUtils.contains(org.apache.commons.lang3.StringUtils.contains) Collectors.toMap(java.util.stream.Collectors.toMap) COMPLETED(org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED) ItemData(de.difuture.uds.odm2fhir.odm.model.ItemData) DIAGNOSTICREPORT(org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT) DomainResource(org.hl7.fhir.r4.model.DomainResource) SNOMED_CT(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.SNOMED_CT) DIAGNOSTIC_REPORT_RADIOLOGY(de.difuture.uds.odm2fhir.fhir.util.NUMStructureDefinition.DIAGNOSTIC_REPORT_RADIOLOGY) String.format(java.lang.String.format) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) RADIOLOGY_PROCEDURES(de.difuture.uds.odm2fhir.fhir.util.NUMStructureDefinition.RADIOLOGY_PROCEDURES) DigestUtils.sha256Hex(org.apache.commons.codec.digest.DigestUtils.sha256Hex) StringUtils.equalsAny(org.apache.commons.lang3.StringUtils.equalsAny) Function.identity(java.util.function.Function.identity) DIAGNOSTIC_SERVICE_SECTION_ID(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.DIAGNOSTIC_SERVICE_SECTION_ID) FINAL(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.FINAL) Reference(org.hl7.fhir.r4.model.Reference)

Example 2 with ItemData

use of de.difuture.uds.odm2fhir.odm.model.ItemData in project odm2fhir by num-codex.

the class SOFAScore method createObservation.

private Observation createObservation(List<ItemData> itemDatas, ItemData sofaTotalScore, ItemData dateCoding) {
    var observation = (Observation) new Observation().addIdentifier(createIdentifier(OBSERVATION, sofaTotalScore).setType(OBI).setAssigner(getOrganizationReference())).setStatus(FINAL).setEffective(createDateTimeType(dateCoding)).addCategory(SURVEY).setCode(createCodeableConcept(createCoding(ECRF_PARAMETER_CODES, "06", "SOFA-Score")).setText("Sepsis-related organ failure assessment score")).setMeta(createMeta(NUMStructureDefinition.SOFA_SCORE));
    itemDatas.stream().map(ItemData::getValue).filter(StringUtils::isNotBlank).forEach(code -> observation.addComponent(new ObservationComponentComponent().setCode(createCodeableConcept(createCoding(SOFA_SCORE, chop(code), getDisplay(chop(code)))).setText(getDefinition(chop(code)))).setValue(createCodeableConcept(createCoding(SOFA_SCORE, code, getDisplay(code))).setText(getDefinition(code)))));
    if (sofaTotalScore.isEmpty()) {
        observation.setDataAbsentReason(UNKNOWN);
    } else {
        observation.setValue(new IntegerType().setValue(Integer.valueOf(sofaTotalScore.getValue())));
    }
    return observation;
}
Also used : IntegerType(org.hl7.fhir.r4.model.IntegerType) ObservationComponentComponent(org.hl7.fhir.r4.model.Observation.ObservationComponentComponent) Observation(org.hl7.fhir.r4.model.Observation) ItemData(de.difuture.uds.odm2fhir.odm.model.ItemData)

Example 3 with ItemData

use of de.difuture.uds.odm2fhir.odm.model.ItemData in project odm2fhir by num-codex.

the class BroadConsent method createConsent.

@SuppressWarnings("fallthrough")
private Consent createConsent(FormData formData) {
    var identifier = createIdentifier(CONSENT, formData.getItemData("miibc_consent_status"));
    var consent = (Consent) new Consent().addIdentifier(identifier).setDateTimeElement(createDateTimeType(formData.getItemData("miibc_dat_dok"))).addOrganization(getOrganizationReference()).setScope(RESEARCH).addCategory(createCodeableConcept(createCoding(LOINC, "57016-8", "Privacy policy acknowledgment Document"))).addPolicy(new ConsentPolicyComponent().setUri(POLICY)).setMeta(createMeta(GERMAN_CONSENT));
    switch(formData.getItemData("miibc_consent_status").getValue()) {
        case // agreed
        "1":
            consent.setStatus(ConsentState.ACTIVE);
            break;
        case // rejected
        "2":
            consent.setStatus(REJECTED);
            break;
        case // revoked
        "3":
            var revocationDateItem = formData.getItemData("miibc_w_dat_dok");
            switch(formData.getItemData("miibc_widerruf").getValue()) {
                case // fully revoked
                "1":
                    consent.setStatus(INACTIVE).setDateTimeElement(// revocation -> replace 'consentDate' by 'revocationDate'
                    createDateTimeType(revocationDateItem));
                    break;
                case // partly revoked
                "2":
                    // revocation -> replace 'consentDate' by 'revocationDate'
                    consent.setDateTimeElement(createDateTimeType(revocationDateItem));
                // not revoked
                case "3":
                case // unknown (REVOCATION-Status, not CONSENT-Status!)
                "4":
                    // default if not revoked
                    consent.setStatus(ConsentState.ACTIVE);
                    break;
            }
            break;
        case // unknown
        "4":
            // skip if general CONSENT-Status is 'unknown'
            return new Consent();
    }
    var mainProvisionComponent = new Consent.provisionComponent().setType(DENY);
    if (consent.getDateTime() != null) {
        mainProvisionComponent.setPeriod(new Period().setStart(consent.getDateTime()).setEnd(addYears(consent.getDateTime(), 30)));
    }
    if (ConsentState.ACTIVE == consent.getStatus()) {
        // add more Consent details only if consented/not fully revoked
        mainProvisionComponent.setProvision(ELEMENTS.stream().map(key -> "gee_" + key).map(formData::getItemData).filter(not(ItemData::isEmpty)).map(itemData -> {
            var specificAnswerItemName = itemData.getItemOID();
            var specificAnswerItemValue = itemData.getValue();
            var partProvisionComponent = new Consent.provisionComponent().addCode(createCodeableConcept(createCoding("urn:oid:" + BASE_OID, BASE_OID + "." + OIDS.get(removeStart(specificAnswerItemName, "gee_") + "_" + specificAnswerItemValue), specificAnswerItemName)));
            if (!mainProvisionComponent.getPeriod().isEmpty()) {
                var period = mainProvisionComponent.getPeriod().copy();
                if ("gee_krankenkassendaten_retro".equals(specificAnswerItemName)) {
                    period.setEnd(period.getStart()).setStart(addYears(period.getStart(), -5));
                } else if ("gee_krankenkassendaten_pro".equals(specificAnswerItemName)) {
                    period.setEnd(addYears(period.getStart(), 5));
                }
                partProvisionComponent.setPeriod(period);
            }
            switch(specificAnswerItemValue) {
                case // agreed
                "1":
                    partProvisionComponent.setType(PERMIT);
                    break;
                // rejected
                case "2":
                case // revoked
                "4":
                    partProvisionComponent.setType(DENY);
                    break;
                // unknown
                case "3":
            }
            return partProvisionComponent;
        }).collect(toList()));
    }
    return consent.setProvision(mainProvisionComponent);
}
Also used : ItemData(de.difuture.uds.odm2fhir.odm.model.ItemData) PERMIT(org.hl7.fhir.r4.model.Consent.ConsentProvisionType.PERMIT) INACTIVE(org.hl7.fhir.r4.model.Consent.ConsentState.INACTIVE) FormData(de.difuture.uds.odm2fhir.odm.model.FormData) ConsentPolicyComponent(org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent) Period(org.hl7.fhir.r4.model.Period) Consent(org.hl7.fhir.r4.model.Consent) CONSENT(org.hl7.fhir.r4.model.codesystems.ResourceTypes.CONSENT) Item(de.difuture.uds.odm2fhir.fhir.mapper.Item) DomainResource(org.hl7.fhir.r4.model.DomainResource) HashMap(java.util.HashMap) LOINC(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.LOINC) List(java.util.List) REJECTED(org.hl7.fhir.r4.model.Consent.ConsentState.REJECTED) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) ConsentState(org.hl7.fhir.r4.model.Consent.ConsentState) GERMAN_CONSENT(de.difuture.uds.odm2fhir.fhir.util.CommonStructureDefinition.GERMAN_CONSENT) Map(java.util.Map) DateUtils.addYears(org.apache.commons.lang3.time.DateUtils.addYears) Predicate.not(java.util.function.Predicate.not) StringUtils.removeStart(org.apache.commons.lang3.StringUtils.removeStart) DENY(org.hl7.fhir.r4.model.Consent.ConsentProvisionType.DENY) ConsentPolicyComponent(org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent) Consent(org.hl7.fhir.r4.model.Consent) Period(org.hl7.fhir.r4.model.Period) ItemData(de.difuture.uds.odm2fhir.odm.model.ItemData)

Aggregations

ItemData (de.difuture.uds.odm2fhir.odm.model.ItemData)3 Item (de.difuture.uds.odm2fhir.fhir.mapper.Item)2 LOINC (de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.LOINC)2 FormData (de.difuture.uds.odm2fhir.odm.model.FormData)2 List (java.util.List)2 Collectors.toList (java.util.stream.Collectors.toList)2 Stream (java.util.stream.Stream)2 DomainResource (org.hl7.fhir.r4.model.DomainResource)2 DIAGNOSTIC_SERVICE_SECTION_ID (de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.DIAGNOSTIC_SERVICE_SECTION_ID)1 SNOMED_CT (de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.SNOMED_CT)1 GERMAN_CONSENT (de.difuture.uds.odm2fhir.fhir.util.CommonStructureDefinition.GERMAN_CONSENT)1 DIAGNOSTIC_REPORT_RADIOLOGY (de.difuture.uds.odm2fhir.fhir.util.NUMStructureDefinition.DIAGNOSTIC_REPORT_RADIOLOGY)1 RADIOLOGY_PROCEDURES (de.difuture.uds.odm2fhir.fhir.util.NUMStructureDefinition.RADIOLOGY_PROCEDURES)1 String.format (java.lang.String.format)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Function.identity (java.util.function.Function.identity)1 Predicate.not (java.util.function.Predicate.not)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 DigestUtils.sha256Hex (org.apache.commons.codec.digest.DigestUtils.sha256Hex)1