diff --git a/src/main/groovy/RxTermsToFHIR.groovy b/src/main/groovy/RxTermsToFHIR.groovy index 8e9e49e..cfb01b3 100644 --- a/src/main/groovy/RxTermsToFHIR.groovy +++ b/src/main/groovy/RxTermsToFHIR.groovy @@ -159,7 +159,7 @@ Closure readRxNormConceptsFile = { } } } - + return true } cpcRxnConso.close() @@ -221,6 +221,7 @@ Closure readRxNormRelationshipsFile = { break } } + return true } cpcRxnRel.close() @@ -270,6 +271,7 @@ Closure readRxNormAttributesFile = { break } } + return true } cpcRxnSat.close() @@ -372,21 +374,21 @@ Closure getAmount = { Map scdcAttributes -> return amount } -Closure> getIngredientComponent = { String scdc_rxCui, boolean forMedicationKnowledge -> +Closure> getIngredientComponent = { String scdc_rxCui, boolean forMedicationKnowledge -> Set ing_rxCuis = hasIngredient.get(scdc_rxCui) - return ing_rxCuis.collect { ing_rxCui -> + return ing_rxCuis.findResults { ing_rxCui -> CodeableConcept ingredient = ingredients.get(ing_rxCui) + BackboneElement component = null + if (ingredient) { String substanceId = "rxNorm-$ing_rxCui" // use rxNorm- as resource ID Substance substance = substances.get(substanceId) - BackboneElement component - if (forMedicationKnowledge) { component = new MedicationKnowledge.MedicationKnowledgeIngredientComponent() @@ -411,22 +413,22 @@ Closure> getIngredientComponent = { String scdc_rxCui, boo component.setIsActive(true) } - - return component } + return component } } Closure setIngredientComponent = { String rxCui, Medication med, MedicationKnowledge medKnowledge -> - List medIngredientComponents = getIngredientComponent(rxCui, false) + List medIngredientComponents = + getIngredientComponent(rxCui, false) as List medIngredientComponents.each { med.addIngredient(it) } List medKnowledgeIngredientComponents = - getIngredientComponent(rxCui, true) + getIngredientComponent(rxCui, true) as List medKnowledgeIngredientComponents.each { medKnowledge.addIngredient(it)