Search in sources :

Example 86 with CD

use of org.hl7.v3.CD in project eCRNow by drajer-health.

the class FhirGeneratorUtilsTest method getCodeableConceptTest.

@Test
public void getCodeableConceptTest() {
    CodeableConcept cd = FhirGeneratorUtils.getCodeableConcept("TestValue", "123456", "Covid-19");
    assertNotNull(cd);
    assertEquals("Covid-19", cd.getText());
    assertEquals("Covid-19", cd.getCoding().get(0).getDisplay());
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 87 with CD

use of org.hl7.v3.CD in project eCRNow by drajer-health.

the class FhirGeneratorUtilsTest method getCodingTest.

@Test
public void getCodingTest() {
    Coding cd = FhirGeneratorUtils.getCoding("TestValue", "123456", "Covid-19");
    assertNotNull(cd);
    assertEquals("Covid-19", cd.getDisplay());
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.Test)

Example 88 with CD

use of org.hl7.v3.CD in project eCRNow by drajer-health.

the class CdaProblemGenerator method addTriggerCodes.

public static String addTriggerCodes(LaunchDetails details, Condition cond, Pair<Date, TimeZone> onset, Pair<Date, TimeZone> abatement) {
    StringBuilder sb = new StringBuilder();
    logger.debug("Adding Trigger Code Reason for Problem Observation");
    PatientExecutionState state = null;
    state = ApplicationUtils.getDetailStatus(details);
    List<MatchedTriggerCodes> mtcs = state.getMatchTriggerStatus().getMatchedCodes();
    for (MatchedTriggerCodes mtc : mtcs) {
        // Add each code as an entry relationship observation
        CodeableConcept cd = cond.getCode();
        List<CodeableConcept> cds = new ArrayList<>();
        if (cd != null)
            cds.add(cd);
        Set<String> matchedCodesFromCc = mtc.hasMatchedTriggerCodesFromCodeableConcept("Condition", cds);
        if (matchedCodesFromCc != null && !matchedCodesFromCc.isEmpty()) {
            logger.debug(" Matched Codes from Codeable Concept is not empty, size = {}", matchedCodesFromCc.size());
            // Add the Problem Observation
            sb.append(CdaGeneratorUtils.getXmlForEntryRelationship(CdaGeneratorConstants.ENTRY_REL_RSON_CODE));
            sb.append(CdaGeneratorUtils.getXmlForActWithNegationInd(CdaGeneratorConstants.OBS_ACT_EL_NAME, CdaGeneratorConstants.OBS_CLASS_CODE, CdaGeneratorConstants.MOOD_CODE_DEF, "false", true));
            sb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.PROB_OBS_TEMPLATE_ID));
            sb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.PROB_OBS_TEMPLATE_ID, CdaGeneratorConstants.PROB_OBS_TEMPALTE_ID_EXT));
            sb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.TRIGGER_CODE_PROB_OBS_TEMPLATE_ID, CdaGeneratorConstants.TRIGGER_CODE_PROB_OBS_TEMPLATE_ID_EXT));
            sb.append(CdaGeneratorUtils.getXmlForII(details.getAssigningAuthorityId(), cond.getId()));
            sb.append(CdaGeneratorUtils.getXmlForCDWithoutEndTag(CdaGeneratorConstants.CODE_EL_NAME, CdaGeneratorConstants.DIAGNOSIS_SNOMED, CdaGeneratorConstants.SNOMED_CODESYSTEM_OID, CdaGeneratorConstants.SNOMED_CODESYSTEM_NAME, CdaGeneratorConstants.DIAGNOSIS_DISPLAY_NAME));
            sb.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.TRANSLATION_EL_NAME, CdaGeneratorConstants.DIAGNOSIS_LOINC, CdaGeneratorConstants.LOINC_CODESYSTEM_OID, CdaGeneratorConstants.LOINC_CODESYSTEM_NAME, CdaGeneratorConstants.DIAGNOSIS_DISPLAY_NAME));
            sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.CODE_EL_NAME));
            sb.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.STATUS_CODE_EL_NAME, CdaGeneratorConstants.COMPLETED_STATUS));
            sb.append(CdaGeneratorUtils.getXmlForIVLWithTS(CdaGeneratorConstants.EFF_TIME_EL_NAME, onset, abatement, true));
            // Split the system and code.
            matchedCodesFromCc.stream().filter(Objects::nonNull).findFirst().ifPresent(matchCode -> {
                logger.debug("Starting to add trigger code that was matched {}", matchCode);
                String[] parts = matchCode.split("\\|");
                logger.debug("Parts [0] = {}", parts[0]);
                Pair<String, String> csd = CdaGeneratorConstants.getCodeSystemFromUrl(parts[0]);
                logger.debug("Retrieved CSD Values");
                logger.debug("Retrieved CSD Values {}, {}", csd.getValue0(), csd.getValue1());
                // Add Value SEt and ValueSEt Version
                String vs = CdaGeneratorConstants.RCTC_OID;
                String vsVersion = ActionRepo.getInstance().getRctcVersion();
                logger.debug("Retrieved RCTC Values: Vs {}, vsVersion {}", vs, vsVersion);
                sb.append(CdaGeneratorUtils.getXmlForValueCDWithValueSetAndVersion(parts[1], csd.getValue0(), csd.getValue1(), vs, vsVersion, ""));
                logger.debug("Constructed Value CD");
            });
            // End Tag for Entry Relationship
            sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.OBS_ACT_EL_NAME));
            sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.ENTRY_REL_EL_NAME));
        } else {
            logger.debug("Not adding matched Trigger codes as they are not present");
        }
    }
    return sb.toString();
}
Also used : PatientExecutionState(com.drajer.eca.model.PatientExecutionState) ArrayList(java.util.ArrayList) Objects(java.util.Objects) MatchedTriggerCodes(com.drajer.eca.model.MatchedTriggerCodes) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 89 with CD

use of org.hl7.v3.CD in project eCRNow by drajer-health.

the class CdaFhirUtilities method getCodingForValidCodeSystems.

public static List<Coding> getCodingForValidCodeSystems(List<CodeableConcept> cds) {
    List<Coding> codes = new ArrayList<>();
    if (cds != null && !cds.isEmpty()) {
        for (CodeableConcept cd : cds) {
            List<Coding> codings = cd.getCoding();
            if (codings != null && !codings.isEmpty()) {
                logger.debug(" Coding .size = {} ", codings.size());
                for (Coding code : codings) {
                    logger.debug(" Getting CodeSystem for Url {} ", code.getSystem());
                    Pair<String, String> csd = CdaGeneratorConstants.getCodeSystemFromUrl(code.getSystem());
                    logger.debug(" Received CodeSystem {} and {}", csd.getValue0(), csd.getValue1());
                    if (!StringUtils.isEmpty(csd.getValue0())) {
                        codes.add(code);
                    }
                }
            // for all codings
            }
        // codings not empy
        }
    // for all codeable concepts
    }
    return codes;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 90 with CD

use of org.hl7.v3.CD in project eCRNow by drajer-health.

the class CdaFhirUtilities method getXmlForTypeForCodeSystem.

public static String getXmlForTypeForCodeSystem(Type dt, String elName, Boolean valFlag, String codeSystemUrl, Boolean csOptional) {
    String val = "";
    if (dt != null) {
        if (dt instanceof Coding) {
            Coding cd = (Coding) dt;
            List<Coding> cds = new ArrayList<>();
            cds.add(cd);
            if (!valFlag)
                val += getCodingXmlForCodeSystem(cds, elName, codeSystemUrl, csOptional, "");
            else
                val += getCodingXmlForValueForCodeSystem(cds, elName, codeSystemUrl, csOptional);
        } else if (dt instanceof CodeableConcept) {
            CodeableConcept cd = (CodeableConcept) dt;
            List<Coding> cds = cd.getCoding();
            if (!valFlag)
                val += getCodingXmlForCodeSystem(cds, elName, codeSystemUrl, csOptional, "");
            else
                val += getCodingXmlForValueForCodeSystem(cds, elName, codeSystemUrl, csOptional);
        } else {
            if (!valFlag)
                val += CdaGeneratorUtils.getXmlForNullCD(elName, CdaGeneratorConstants.NF_NI);
            else
                val += CdaGeneratorUtils.getNFXMLForValue(CdaGeneratorConstants.NF_NI);
        }
        logger.debug("Printing the class name {}", dt.getClass());
        return val;
    }
    if (!valFlag)
        val += CdaGeneratorUtils.getXmlForNullCD(elName, CdaGeneratorConstants.NF_NI);
    else
        val += CdaGeneratorUtils.getNFXMLForValue(CdaGeneratorConstants.NF_NI);
    return val;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

ArrayList (java.util.ArrayList)24 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 Coding (org.hl7.fhir.r4.model.Coding)10 ValueSet (org.hl7.fhir.r5.model.ValueSet)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)9 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 CD (net.ihe.gazelle.hl7v3.datatypes.CD)7 CS (net.ihe.gazelle.hl7v3.datatypes.CS)7 II (net.ihe.gazelle.hl7v3.datatypes.II)7 TS (net.ihe.gazelle.hl7v3.datatypes.TS)7 MCCIMT000100UV01Device (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device)7 MCCIMT000100UV01Receiver (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver)7 MCCIMT000100UV01Sender (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender)7 Identifier (org.hl7.fhir.r4.model.Identifier)7 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)7 IOException (java.io.IOException)6 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)6 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)5