use of org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent in project pathling by aehrc.
the class TestData method newMedication.
/**
* Returns a FHIR medication to be contained to a medication request for testing purposes.
*/
public static Medication newMedication() {
final Medication medication = new Medication();
medication.setId("test-med");
final MedicationIngredientComponent ingredient = new MedicationIngredientComponent();
final CodeableConcept item = new CodeableConcept();
item.addCoding().setSystem("test/ingredient/system").setCode("test-code");
ingredient.setItem(item);
medication.addIngredient(ingredient);
return medication;
}
use of org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent in project eCRNow by drajer-health.
the class CdaFhirUtilities method getStringForMedicationFromContainedResources.
public static String getStringForMedicationFromContainedResources(List<Resource> resources, String refId) {
Pair<String, Boolean> retVal = null;
for (Resource res : resources) {
logger.debug("res.getId {}", res.getId());
if (res.getId().contains(refId) && res instanceof Medication) {
logger.debug("Found a Contained Resource with Id {}", refId);
Medication cmed = (Medication) res;
if (cmed.getCode() != null) {
logger.debug("Found Contained Med Code");
retVal = getCodeableConceptDisplayForCodeSystem(cmed.getCode(), CdaGeneratorConstants.FHIR_RXNORM_URL, false);
}
if (retVal.getValue0().isEmpty()) {
logger.debug("Return Val is empty");
if (cmed.getIngredient() != null) {
logger.debug("Found ingredient");
List<MedicationIngredientComponent> ings = cmed.getIngredient();
for (MedicationIngredientComponent ing : ings) {
if (ing.getItem() instanceof CodeableConcept) {
logger.debug("Found a CC for Ingredient");
CodeableConcept cc = (CodeableConcept) ing.getItem();
retVal = getCodeableConceptDisplayForCodeSystem(cc, CdaGeneratorConstants.FHIR_RXNORM_URL, false);
break;
}
}
}
}
if (!retVal.getValue0().isEmpty())
return retVal.getValue0();
}
// Found id
}
return CdaGeneratorConstants.UNKNOWN_VALUE;
}
use of org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent in project bunsen by cerner.
the class TestData method newMedication.
/**
* Returns a new Medication for testing.
*
* @return a FHIR Medication for testing.
*/
public static Medication newMedication(String id) {
Medication medication = new Medication();
medication.setId(id);
CodeableConcept itemCodeableConcept = new CodeableConcept();
itemCodeableConcept.addCoding().setSystem("http://www.nlm.nih.gov/research/umls/rxnorm").setCode("103109").setDisplay("Vitamin E 3 MG Oral Tablet [Ephynal]").setUserSelected(true);
MedicationIngredientComponent ingredientComponent = new MedicationIngredientComponent();
ingredientComponent.setItem(itemCodeableConcept);
medication.addIngredient(ingredientComponent);
Reference itemReference = new Reference("test-item-reference");
MedicationPackageContentComponent medicationPackageContentComponent = new MedicationPackageContentComponent();
medicationPackageContentComponent.setItem(itemReference);
MedicationPackageComponent medicationPackageComponent = new MedicationPackageComponent();
medicationPackageComponent.addContent(medicationPackageContentComponent);
medication.setPackage(medicationPackageComponent);
return medication;
}
use of org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent in project eCRNow by drajer-health.
the class CdaMedicationGenerator method getValidMedicationRequests.
public static List<MedicationRequest> getValidMedicationRequests(R4FhirData data, List<Medication> cmeds) {
List<MedicationRequest> mr = new ArrayList<>();
if (data.getMedicationRequests() != null && !data.getMedicationRequests().isEmpty()) {
logger.debug("Total num of Medication Requests available for Patient {}", data.getMedicationRequests().size());
for (MedicationRequest m : data.getMedicationRequests()) {
if (m.getMedication() instanceof Reference) {
Reference med = (Reference) m.getMedication();
if (med.getReference().startsWith(CdaGeneratorConstants.FHIR_CONTAINED_REFERENCE)) {
// Check contained.
String refId = med.getReference().substring(1);
if (m.getContained() != null) {
List<Resource> meds = m.getContained();
for (Resource r : meds) {
logger.debug("starting to examine contained meds ");
if (r.getId().contains(refId) && r instanceof Medication) {
Medication cmed = (Medication) r;
if (cmed.getCode() != null && cmed.getCode().getCoding() != null && !cmed.getCode().getCoding().isEmpty() && CdaFhirUtilities.isCodingPresentForCodeSystem(cmed.getCode().getCoding(), CdaGeneratorConstants.FHIR_RXNORM_URL)) {
// Found the Medication that matters.
logger.debug("Adding Med Req - due to code ");
cmeds.add(cmed);
mr.add(m);
break;
}
// if code present
Boolean found = false;
// Check Ingredients also.
if (cmed.getIngredient() != null) {
List<MedicationIngredientComponent> ings = cmed.getIngredient();
for (MedicationIngredientComponent ing : ings) {
logger.debug("starting to examine contained ingredients ");
if (ing.getItem() instanceof CodeableConcept) {
CodeableConcept cc = (CodeableConcept) ing.getItem();
if (cc.getCoding() != null && !cc.getCoding().isEmpty() && CdaFhirUtilities.isCodingPresentForCodeSystem(cc.getCoding(), CdaGeneratorConstants.FHIR_RXNORM_URL)) {
logger.debug("Adding Med Req due to ingredient ");
cmeds.add(cmed);
mr.add(m);
found = true;
break;
}
// Code check.
}
// Ingredient is a Codeable Concept
}
// Ingredients present
}
if (found)
break;
}
// Found id
}
// For all resources
}
// contained present
} else // Contained reference
{
// Check the actual medication if desired in the future.
}
} else if (m.getMedication() instanceof CodeableConcept) {
CodeableConcept cc = (CodeableConcept) m.getMedication();
if (cc.getCoding() != null && !cc.getCoding().isEmpty() && CdaFhirUtilities.isCodingPresentForCodeSystem(cc.getCoding(), CdaGeneratorConstants.FHIR_RXNORM_URL)) {
logger.debug("Found a Medication Request with a RxNorm code");
mr.add(m);
}
}
}
} else {
logger.debug("No Valid Medication Requests in the bundle to process");
}
return mr;
}
use of org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent in project eCRNow by drajer-health.
the class CdaFhirUtilities method getXmlForMedicationTypeForCodeSystem.
public static String getXmlForMedicationTypeForCodeSystem(Type dt, String elName, Boolean valFlag, String codeSystemUrl, Boolean csOptional, DomainResource res) {
if (dt instanceof Reference) {
logger.debug("Found Medication of Type Reference within Domain Resource");
Reference med = (Reference) dt;
String codeXml = "";
if (med.getReference().startsWith(CdaGeneratorConstants.FHIR_CONTAINED_REFERENCE)) {
// Check contained.
String refId = med.getReference().substring(1);
logger.debug("Found Medication of Type Reference with Id {}", refId);
if (res.getContained() != null) {
logger.debug("Contained Elements Not null");
List<Resource> meds = res.getContained();
for (Resource r : meds) {
if (r.getId().contains(refId) && r instanceof Medication) {
logger.debug("Found Medication in contained resource");
Medication cmed = (Medication) r;
if (cmed.getCode() != null && cmed.getCode().getCoding() != null && !cmed.getCode().getCoding().isEmpty() && CdaFhirUtilities.isCodingPresentForCodeSystem(cmed.getCode().getCoding(), CdaGeneratorConstants.FHIR_RXNORM_URL)) {
logger.debug("Found Medication for code system in code element");
// Found the Medication that matters.
codeXml = getXmlForTypeForCodeSystem(cmed.getCode(), elName, valFlag, codeSystemUrl, csOptional);
} else // if code present
{
if (cmed.getIngredient() != null) {
logger.debug("Found Ingredients");
List<MedicationIngredientComponent> ings = cmed.getIngredient();
for (MedicationIngredientComponent ing : ings) {
if (ing.getItem() instanceof CodeableConcept) {
logger.debug("Found Ingredient which is coded");
CodeableConcept cc = (CodeableConcept) ing.getItem();
if (cc.getCoding() != null && !cc.getCoding().isEmpty() && CdaFhirUtilities.isCodingPresentForCodeSystem(cc.getCoding(), CdaGeneratorConstants.FHIR_RXNORM_URL)) {
codeXml = getXmlForTypeForCodeSystem(cc, elName, valFlag, codeSystemUrl, csOptional);
break;
}
}
}
}
}
}
// contained med
}
// for all contained resources
}
// contained present
} else // Contained reference
{
// Check the actual medication
}
return codeXml;
} else
return getXmlForTypeForCodeSystem(dt, elName, valFlag, codeSystemUrl, csOptional);
}
Aggregations