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());
}
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());
}
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();
}
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;
}
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;
}
Aggregations