use of org.hl7.v3.CD in project eCRNow by drajer-health.
the class CdaFhirUtilities method getCodeableConceptDisplayForCodeSystem.
public static String getCodeableConceptDisplayForCodeSystem(List<CodeableConcept> cds, String codeSystemUrl, Boolean csOptional) {
String anyCdDisplay = "";
Pair<String, Boolean> disp = null;
if (cds != null && !cds.isEmpty()) {
for (CodeableConcept cd : cds) {
disp = getCodeableConceptDisplayForCodeSystem(cd, codeSystemUrl, csOptional);
if (!StringUtils.isEmpty(disp.getValue0())) {
// Found a display
break;
}
// If display is at the Codeable Concept level, use it in case we don't find anything else
if (cd != null && !StringUtils.isEmpty(cd.getText())) {
anyCdDisplay = cd.getText();
}
}
}
if (disp != null && !StringUtils.isEmpty(disp.getValue0()))
return disp.getValue0();
else if (!StringUtils.isEmpty(anyCdDisplay))
return anyCdDisplay;
else
return CdaGeneratorConstants.UNKNOWN_VALUE;
}
use of org.hl7.v3.CD in project eCRNow by drajer-health.
the class CdaFhirUtilities method getStringForType.
public static String getStringForType(Type dt) {
if (dt != null) {
StringBuilder val = new StringBuilder();
if (dt instanceof Coding) {
Coding cd = (Coding) dt;
val.append(getStringForCoding(cd));
} else if (dt instanceof CodeableConcept) {
CodeableConcept cd = (CodeableConcept) dt;
if (!StringUtils.isEmpty(cd.getText())) {
val.append(cd.getText());
} else {
List<Coding> cds = cd.getCoding();
Boolean first = true;
for (Coding c : cds) {
if (!first) {
val.append(CdaGeneratorConstants.SPACE).append(CdaGeneratorConstants.PIPE).append(CdaGeneratorConstants.SPACE);
}
first = false;
val.append(getStringForCoding(c));
}
}
} else if (dt instanceof Quantity) {
Quantity qt = (Quantity) dt;
val.append(getStringForQuantity(qt));
} else if (dt instanceof DateTimeType) {
DateTimeType d = (DateTimeType) dt;
val.append(d.getValueAsString());
} else if (dt instanceof Timing) {
logger.debug("Found an instance of timing for creating string ");
Timing t = (Timing) (dt);
if (t.getRepeat() != null && t.getRepeat().getBounds() != null) {
logger.debug("Found the bounds element for creating string ");
String v = getStringForType(t.getRepeat().getBounds());
val.append(v);
}
} else if (dt instanceof Period) {
Period pt = (Period) dt;
logger.debug("Found the Period element for creating string");
if (pt.getStart() != null && pt.getEnd() != null) {
val.append(pt.getStart().toString()).append(CdaGeneratorConstants.PIPE).append(pt.getEnd().toString());
} else if (pt.getStart() != null) {
val.append(pt.getStart().toString());
} else {
val.append(CdaGeneratorConstants.UNKNOWN_VALUE);
}
} else if (dt instanceof CodeType) {
CodeType cd = (CodeType) dt;
val.append(cd.getValue());
} else if (dt instanceof StringType) {
StringType st = (StringType) dt;
val.append(st.getValue());
}
logger.debug("Printing the class name {} and value {}", dt.getClass(), val);
return val.toString();
}
return CdaGeneratorConstants.UNKNOWN_VALUE;
}
use of org.hl7.v3.CD in project eCRNow by drajer-health.
the class CdaFhirUtilities method getXmlForCodeableConceptWithCDAndValueSetAndVersion.
public static String getXmlForCodeableConceptWithCDAndValueSetAndVersion(String elementName, String code, String codeSystem, String codeSystemName, String valueSet, String valuesetVersion, CodeableConcept cc, String csUrl, String contentRef) {
StringBuilder retval = new StringBuilder();
StringBuilder translations = new StringBuilder();
Boolean foundCodings = false;
if (cc != null) {
String dispName = cc.getText();
List<Coding> cds = cc.getCoding();
if (cds != null && !cds.isEmpty()) {
for (Coding cd : cds) {
if (cd.getCode() != null && !cd.getCode().isEmpty() && code.contentEquals(cd.getCode()) && csUrl.contentEquals(cd.getSystem()) && !foundCodings) {
logger.debug(" Found a Coding that matches the CodeSystem and Code {} : {} ", codeSystem, code);
if (cd.getDisplay() != null && !cd.getDisplay().isEmpty())
dispName = cd.getDisplay();
if (elementName.contentEquals(CdaGeneratorConstants.CODE_EL_NAME)) {
retval.append(CdaGeneratorUtils.getXmlForCDWithValueSetAndVersionWihoutEndTag(elementName, code, codeSystem, codeSystemName, valueSet, valuesetVersion, dispName));
if (!contentRef.isEmpty())
retval.append(CdaGeneratorUtils.getXmlForOriginalTextWithReference(contentRef));
} else if (elementName.contentEquals(CdaGeneratorConstants.VAL_EL_NAME)) {
retval.append(CdaGeneratorUtils.getXmlForValueCDWithValueSetAndVersionWihoutEndTag(elementName, code, codeSystem, codeSystemName, valueSet, valuesetVersion, dispName));
}
foundCodings = true;
} else {
Pair<String, String> csd = CdaGeneratorConstants.getCodeSystemFromUrl(cd.getSystem());
if (!csd.getValue0().isEmpty() && !csd.getValue1().isEmpty()) {
if (cd.getDisplay() != null && !cd.getDisplay().isEmpty())
dispName = cd.getDisplay();
// Create Translations.
translations.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.TRANSLATION_EL_NAME, cd.getCode(), csd.getValue0(), csd.getValue1(), dispName));
}
}
}
}
}
if (foundCodings) {
retval.append(translations.toString());
retval.append(CdaGeneratorUtils.getXmlForEndElement(elementName));
} else {
String dispName = "";
if (cc != null && cc.getText() != null && !cc.getText().isEmpty())
dispName = cc.getText();
if (elementName.contentEquals(CdaGeneratorConstants.CODE_EL_NAME)) {
retval.append(CdaGeneratorUtils.getXmlForCDWithValueSetAndVersion(CdaGeneratorConstants.CODE_EL_NAME, code, CdaGeneratorConstants.LOINC_CODESYSTEM_OID, CdaGeneratorConstants.LOINC_CODESYSTEM_NAME, CdaGeneratorConstants.RCTC_OID, ActionRepo.getInstance().getRctcVersion(), dispName, contentRef));
} else if (elementName.contentEquals(CdaGeneratorConstants.VAL_EL_NAME)) {
retval.append(CdaGeneratorUtils.getXmlForValueCDWithValueSetAndVersion(code, CdaGeneratorConstants.LOINC_CODESYSTEM_OID, CdaGeneratorConstants.LOINC_CODESYSTEM_NAME, CdaGeneratorConstants.RCTC_OID, ActionRepo.getInstance().getRctcVersion(), dispName));
}
}
return retval.toString();
}
use of org.hl7.v3.CD in project eCRNow by drajer-health.
the class FhirGeneratorUtils method getCoding.
public static Coding getCoding(String system, String code, String display) {
Coding cd = null;
if (system != null && code != null && !StringUtils.isEmpty(system) && !StringUtils.isEmpty(code)) {
cd = new Coding();
cd.setSystem(system);
cd.setCode(code);
if (!StringUtils.isEmpty(display))
cd.setDisplay(display);
}
return cd;
}
use of org.hl7.v3.CD in project nia-patient-switching-standard-adaptor by NHSDigital.
the class MedicationMapper method createMedication.
public Medication createMedication(RCMRMT030101UK04Consumable consumable) {
if (hasManufacturedMaterial(consumable)) {
CD code = consumable.getManufacturedProduct().getManufacturedMaterial().getCode();
if (!medicationMapperContext.contains(code)) {
Medication medication = new Medication();
medication.setId(medicationMapperContext.getMedicationId(code));
medication.setMeta(generateMeta(MEDICATION_URL));
medication.setCode(codeableConceptMapper.mapToCodeableConceptForMedication(code));
return medication;
}
}
return null;
}
Aggregations