Search in sources :

Example 91 with DateTime

use of org.hl7.elm.r1.DateTime in project odm2fhir by num-codex.

the class Apheresis method createProcedure.

private Procedure createProcedure(ItemData generalCoding, ItemData answerCoding) {
    var procedure = (Procedure) new Procedure().addIdentifier(createIdentifier(PROCEDURE, generalCoding)).setPerformed(// TODO Set actual DateTime value
    UNKNOWN_DATE_TIME).setCategory(createCodeableConcept(createCoding(SNOMED_CT, "277132007", "Therapeutic procedure (procedure)"))).setCode(createCodeableConcept(generalCoding).setText("Apheresis")).setMeta(createMeta(APHERESIS));
    createCodings(answerCoding).forEach(coding -> {
        if (ProcedureStatus.UNKNOWN.getSystem().equals(coding.getSystem())) {
            procedure.setStatus(ProcedureStatus.fromCode(coding.getCode()));
        } else {
            procedure.setPerformed((DateTimeType) new DateTimeType().addExtension(createExtension(coding)));
        }
    });
    return procedure;
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Procedure(org.hl7.fhir.r4.model.Procedure)

Example 92 with DateTime

use of org.hl7.elm.r1.DateTime in project odm2fhir by num-codex.

the class DialysisHemofiltration method createProcedure.

private Procedure createProcedure(ItemData generalCoding, ItemData answerCoding) {
    var procedure = (Procedure) new Procedure().addIdentifier(createIdentifier(PROCEDURE, generalCoding)).setPerformed(// TODO Set actual DateTime value
    UNKNOWN_DATE_TIME).setCategory(createCodeableConcept(createCoding(SNOMED_CT, "277132007", "Therapeutic procedure (procedure)"))).setCode(createCodeableConcept(generalCoding).setText("Dialysis")).setMeta(createMeta(DIALYSIS));
    createCodings(answerCoding).forEach(coding -> {
        if (ProcedureStatus.UNKNOWN.getSystem().equals(coding.getSystem())) {
            procedure.setStatus(ProcedureStatus.fromCode(coding.getCode()));
        } else {
            procedure.setPerformed((DateTimeType) new DateTimeType().addExtension(createExtension(coding)));
        }
    });
    return procedure;
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Procedure(org.hl7.fhir.r4.model.Procedure)

Example 93 with DateTime

use of org.hl7.elm.r1.DateTime in project odm2fhir by num-codex.

the class PronePosition method createProcedure.

private Procedure createProcedure(ItemData generalCoding, ItemData answerCoding) {
    var procedure = (Procedure) new Procedure().addIdentifier(createIdentifier(PROCEDURE, generalCoding)).setPerformed(// TODO Set actual DateTime value
    UNKNOWN_DATE_TIME).setCategory(createCodeableConcept(createCoding(SNOMED_CT, "225287004", "Procedures relating to positioning and support (procedure)"))).setCode(createCodeableConcept(generalCoding).setText("Prone position")).setMeta(createMeta(PRONE_POSITION));
    createCodings(answerCoding).forEach(coding -> {
        if (ProcedureStatus.UNKNOWN.getSystem().equals(coding.getSystem())) {
            procedure.setStatus(ProcedureStatus.fromCode(coding.getCode()));
        } else {
            procedure.setPerformed((DateTimeType) new DateTimeType().addExtension(createExtension(coding)));
        }
    });
    return procedure;
}
Also used : DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Procedure(org.hl7.fhir.r4.model.Procedure)

Example 94 with DateTime

use of org.hl7.elm.r1.DateTime in project odm2fhir by num-codex.

the class ChronicKidneyDiseases method createCondition.

private Condition createCondition(ItemData generalCoding, ItemData answerCoding, ItemData stageCoding) {
    var condition = (Condition) new Condition().setClinicalStatus(ACTIVE).setVerificationStatus(CONFIRMED).addIdentifier(createIdentifier(CONDITION, generalCoding)).setRecordedDateElement(// TODO Set actual DateTime value
    UNKNOWN_DATE_TIME).addCategory(createCodeableConcept(createCoding(SNOMED_CT, "394589003", "Nephrology (qualifier value)"))).setSeverity(createCodeableConcept(stageCoding)).setMeta(createMeta(CHRONIC_KIDNEY_DISEASES));
    var codeableConcept = new CodeableConcept();
    for (var coding : createCodings(answerCoding)) {
        switch(coding.getCode()) {
            case // NO
            "410594000":
                // remove clinicalStatus
                condition.setVerificationStatus(REFUTED).setClinicalStatus(null);
                updateCodeableConcept(codeableConcept, generalCoding);
                break;
            case // UNKNOWN
            "261665006":
                // remove verificationStatus and clinicalStatus
                condition.setVerificationStatus(null).setClinicalStatus(null).addModifierExtension(DATA_PRESENCE_UNKNOWN);
                updateCodeableConcept(codeableConcept, generalCoding);
                break;
            case // UNKNOWN
            "unknown":
                break;
            default:
                codeableConcept.addCoding(coding);
                break;
        }
    }
    return codeableConcept.isEmpty() ? new Condition() : condition.setCode(codeableConcept);
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 95 with DateTime

use of org.hl7.elm.r1.DateTime in project odm2fhir by num-codex.

the class HistoryOfTravel method createObservation.

private Observation createObservation(ItemData generalCoding, ItemData answerCoding, Map<String, ItemData> travelActivity) {
    var observation = (Observation) new Observation().addIdentifier(createIdentifier(OBSERVATION, travelActivity.get("country")).setType(OBI).setAssigner(getOrganizationReference())).setStatus(FINAL).setEffective(// TODO Set actual DateTime value
    UNKNOWN_DATE_TIME).addCategory(SOCIAL_HISTORY).setMeta(createMeta(HISTORY_OF_TRAVEL));
    var codeCodeableConcept = createCodeableConcept(generalCoding).setText("History of Travel");
    if (!codeCodeableConcept.isEmpty()) {
        observation.setCode(codeCodeableConcept);
    }
    var valueCodeableConcept = createCodeableConcept(answerCoding);
    if (!valueCodeableConcept.isEmpty()) {
        observation.setValue(valueCodeableConcept);
    }
    var startDate = travelActivity.get("start");
    if (!startDate.isEmpty()) {
        observation.addComponent(new ObservationComponentComponent().setCode(createCodeableConcept(createCoding(LOINC, "82752-7", "Date travel started")).setText("Travel start date")).setValue(createDateTimeType(startDate)));
    }
    var endDate = travelActivity.get("end");
    if (!endDate.isEmpty()) {
        observation.addComponent(new ObservationComponentComponent().setCode(createCodeableConcept(createCoding(LOINC, "91560-3", "Date of departure from travel destination")).setText("Travel end date")).setValue(createDateTimeType(endDate)));
    }
    var country = travelActivity.get("country");
    if (!country.isEmpty()) {
        var countryCoding = createCoding(country);
        countryCoding.setDisplay(new Locale("", countryCoding.getCode()).getDisplayCountry(ENGLISH));
        observation.addComponent(new ObservationComponentComponent().setCode(createCodeableConcept(createCoding(LOINC, "94651-7", "Country of travel")).setText("Country of travel")).setValue(createCodeableConcept(countryCoding).setText(countryCoding.getDisplay())));
    }
    var state = travelActivity.get("state");
    if (!state.isEmpty()) {
        var stateCoding = createCoding(state);
        stateCoding.setDisplay(STATES.getOrDefault(stateCoding.getCode(), stateCoding.getCode()));
        observation.addComponent(new ObservationComponentComponent().setCode(createCodeableConcept(createCoding(LOINC, "82754-3", "State of travel")).setText("State of travel")).setValue(createCodeableConcept(stateCoding).setText(stateCoding.getDisplay())));
    }
    var city = travelActivity.get("city");
    if (!city.isEmpty()) {
        observation.addComponent(new ObservationComponentComponent().setCode(createCodeableConcept(createCoding(LOINC, "94653-3", "City of travel")).setText("City of travel")).setValue(createStringType(city)));
    }
    // no Components added = no travel activity
    return observation.getComponent().isEmpty() ? new Observation() : observation;
}
Also used : Locale(java.util.Locale) ObservationComponentComponent(org.hl7.fhir.r4.model.Observation.ObservationComponentComponent) Observation(org.hl7.fhir.r4.model.Observation)

Aggregations

ArrayList (java.util.ArrayList)30 List (java.util.List)21 LinkedHashSet (java.util.LinkedHashSet)20 Test (org.junit.Test)18 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)16 FHIRException (org.hl7.fhir.exceptions.FHIRException)15 Before (org.junit.Before)11 Set (java.util.Set)10 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)9 Condition (org.hl7.fhir.r4.model.Condition)8 MergedList (org.hl7.fhir.utilities.MergedList)8 Date (java.util.Date)5 HashMap (java.util.HashMap)4 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)4 Period (org.hl7.fhir.r4.model.Period)4 Procedure (org.hl7.fhir.r4.model.Procedure)4 CodeType (org.hl7.fhir.r5.model.CodeType)4 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)4