Skip to content

Commit

Permalink
BS-239 | Mani, Vijay | Updated dose units and added alert type attrib…
Browse files Browse the repository at this point in the history
…ute to cdss card and updated test cases (#7)

* BS-239 | Mani, Vijay | Updated dose units and added alert type attribute to cdss card and updated test cases

* BS-239 | Mani, Vijay | updated Actuation mapper and dose template
  • Loading branch information
manimaarans authored and sivareddyp committed Oct 20, 2023
1 parent 8b43b14 commit a5e5379
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/main/java/org/snomed/cdsservice/model/CDSCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ public class CDSCard {

private CDSReference referenceCondition;

public CDSCard(String uuid, String summary, String detail, CDSIndicator indicator, CDSSource source, List<CDSReference> referenceMedications, CDSReference referenceCondition) {
private final String alertType;

public CDSCard(String uuid, String summary, String detail, CDSIndicator indicator, CDSSource source, List<CDSReference> referenceMedications, CDSReference referenceCondition, String alertType) {
this.uuid = uuid;
this.summary = summary;
this.detail = detail;
this.indicator = indicator;
this.source = source;
this.referenceMedications = referenceMedications;
this.referenceCondition = referenceCondition;
this.alertType = alertType;
}

public String getUuid() {
Expand Down Expand Up @@ -75,6 +78,10 @@ public void setReferenceCondition(CDSReference referenceCondition) {
}

public CDSCard cloneCard() {
return new CDSCard(uuid, summary, detail, indicator, source, referenceMedications, referenceCondition);
return new CDSCard(uuid, summary, detail, indicator, source, referenceMedications, referenceCondition, alertType);
}

public String getAlertType() {
return alertType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

@Service
public class HelloCDSService extends CDSService {
private static final String CONTRAINDICATION_ALERT_TYPE = "Contraindication";


public HelloCDSService() {
super("hello-test");
Expand All @@ -19,7 +21,7 @@ public HelloCDSService() {
@Override
public List<CDSCard> call(CDSRequest cdsRequest) {
CDSCard card = new CDSCard("22e982b7-4786-4afe-9f67-5af8266363f6",
"Hello! The CDS Service is working.", null, CDSIndicator.info, new CDSSource("http://example.com"), null, null);
"Hello! The CDS Service is working.", null, CDSIndicator.info, new CDSSource("http://example.com"), null, null, CONTRAINDICATION_ALERT_TYPE);
card.setDetail("This is an example card from the 'hello-test' CDS Service.");
return List.of(card);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
public class MedicationCombinationRuleLoaderService {

private final Logger logger = LoggerFactory.getLogger(getClass());
private static final String CONTRAINDICATION_ALERT_TYPE = "Contraindication";

@Value("${rules.medication-medication.tsv}")
private String tsvPath;
Expand Down Expand Up @@ -80,7 +81,7 @@ public List<CDSTrigger> loadTriggers() throws ServiceException {
medication2SnomedCode = medication2SnomedCode.substring(medication2SnomedCode.indexOf("|")).trim();
}

CDSCard cdsCard = new CDSCard(uuid, cardSummary, cardDetail, CDSIndicator.valueOf(cardIndicator), new CDSSource(source, sourceLink), null, null);
CDSCard cdsCard = new CDSCard(uuid, cardSummary, cardDetail, CDSIndicator.valueOf(cardIndicator), new CDSSource(source, sourceLink), null, null, CONTRAINDICATION_ALERT_TYPE);
Collection<Coding> medication1Codings = tsClient.expandValueSet(SnomedValueSetUtil.getSNOMEDValueSetURI(medication1SnomedCode));
Collection<Coding> medication2Codings = tsClient.expandValueSet(SnomedValueSetUtil.getSNOMEDValueSetURI(medication2SnomedCode));
logger.info("Created trigger {} / {}", medication1Label, medication2Label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

@Service
public class MedicationConditionRuleLoaderService {
private static final String CONTRAINDICATION_ALERT_TYPE = "Contraindication";


@Value("${rules.medication-condition.spreadsheet}")
private String spreadsheetPath;
Expand Down Expand Up @@ -150,7 +152,7 @@ public List<CDSTrigger> loadTriggers() throws ServiceException {
}
}
if (rowNumber > 1 && !Strings.isNullOrEmpty(source) && medicationSnomedCode != null && conditionSnomedCode != null) {
CDSCard cdsCard = new CDSCard(uuid, cardSummary, cardDetail, CDSIndicator.valueOf(cardIndicator), new CDSSource(source, sourceLink), null, null);
CDSCard cdsCard = new CDSCard(uuid, cardSummary, cardDetail, CDSIndicator.valueOf(cardIndicator), new CDSSource(source, sourceLink), null, null, CONTRAINDICATION_ALERT_TYPE);
Collection<Coding> medicationCodings = tsClient.expandValueSet(SnomedValueSetUtil.getSNOMEDValueSetURI(medicationSnomedCode));
Collection<Coding> conditionCodings = tsClient.expandValueSet(SnomedValueSetUtil.getSNOMEDValueSetURI(conditionSnomedCode));
logger.info("Created trigger {} / {}", medicationLabel, conditionLabel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class SnomedMedicationDefinedDailyDoseService {
public static final String WARNING = "warning";
public static final String INFO = "info";
private static final String NEW_LINE = "\n";
private static final String HIGH_DOSAGE_ALERT_TYPE = "High Dosage";

@Autowired
private FHIRTerminologyServerClient tsClient;
Expand Down Expand Up @@ -292,7 +293,7 @@ void composeDosageAlerts(Map<String, AggregatedMedicationsBySubstance> aggregate
String cardSummaryMsg = String.format(getCardSummaryTemplate(), substanceName, getDynamicDecimalPlace(prescribedDosageFactor));
String cardDetailMsg = getCardDetailsInMarkDown(aggregatedMedicationsBySubstanceEntry.getValue(), prescribedDosageFactor);
String atcUrl = getAtcUrl(aggregatedMedicationsBySubstanceEntry);
CDSCard cdsCard = new CDSCard(randomUuid.toString(), cardSummaryMsg, cardDetailMsg, CDSIndicator.valueOf(alertLevelIndicator), new CDSSource("WHO ATC DDD", atcUrl), aggregatedMedicationsBySubstanceEntry.getValue().getReferenceList(), null);
CDSCard cdsCard = new CDSCard(randomUuid.toString(), cardSummaryMsg, cardDetailMsg, CDSIndicator.valueOf(alertLevelIndicator), new CDSSource("WHO ATC DDD", atcUrl), aggregatedMedicationsBySubstanceEntry.getValue().getReferenceList(), null, HIGH_DOSAGE_ALERT_TYPE);
cards.add(cdsCard);
}
}
Expand Down Expand Up @@ -377,7 +378,7 @@ private void composeDosageByRoute(Map<String, DosageComparisonByRoute> dosageMap
DosageComparisonByRoute dosageComparisonByRouteValue = dosageInfo.getValue();
PrescribedDailyDose aggregatedDailyDosage = dosageComparisonByRouteValue.getTotalPrescribedDailyDose();
SubstanceDefinedDailyDose substanceDefinedDailyDose = dosageComparisonByRouteValue.getSubstanceDefinedDailyDose();
sb.append(new UnorderedList<>(List.of(dosageComparisonByRouteValue.getRouteOfAdministration(), new UnorderedList<>(List.of("Prescribed daily dose : " + aggregatedDailyDosage.getQuantity() + aggregatedDailyDosage.getUnit(), "Recommended average daily dose : " + substanceDefinedDailyDose.dose() + substanceDefinedDailyDose.unit(), "Prescribed amount is " + getDecimalPlace(aggregatedDailyDosage.getQuantity() / substanceDefinedDailyDose.dose()) + " times over the average daily dose"))))).append(NEW_LINE).append(NEW_LINE);
sb.append(new UnorderedList<>(List.of(dosageComparisonByRouteValue.getRouteOfAdministration(), new UnorderedList<>(List.of("Prescribed daily dose : " + getDecimalPlace(aggregatedDailyDosage.getQuantity()) + aggregatedDailyDosage.getUnit(), "Recommended average daily dose : " + substanceDefinedDailyDose.dose() + substanceDefinedDailyDose.unit(), "Prescribed amount is " + getDecimalPlace(aggregatedDailyDosage.getQuantity() / substanceDefinedDailyDose.dose()) + " times over the average daily dose"))))).append(NEW_LINE).append(NEW_LINE);
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/snomed/cdsservice/util/UnitConversion.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public enum UnitConversion {
UL_UL("uL", "uL", 1.0),
TABLET_TABLET("Tablet", "Tablet", 1.0),
TABLET_CAPSULE("Tablet", "Capsule", 1.0),
CAPSULE_CAPSULE("Capsule", "Capsule", 1.0);
CAPSULE_CAPSULE("Capsule", "Capsule", 1.0),
PUFF_ACTUATION("Actuation", "Actuation", 1.0),
SPOONFUL_SPOONFUL("Spoonful", "Spoonful", 1.0),
DROP_DROP("Drop", "Drop", 1.0);


private static final Map<String, Double> BY_UNIT = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
@SpringBootTest
class MedicationOrderSelectCDSServiceTest {

private static final String CONTRAINDICATION_ALERT_TYPE = "Contraindication";
private static final String HIGH_DOSAGE_ALERT_TYPE = "High Dosage";

@MockBean
private MedicationConditionRuleLoaderService ruleLoaderService;

Expand All @@ -59,7 +62,7 @@ void setMockOutput() {
CDSIndicator.warning,
new CDSSource("Wikipedia"),
Stream.of(new CDSReference(Collections.singletonList(new CDSCoding("http://snomed.info/sct", "1145419005")))).collect(Collectors.toList()),
new CDSReference(Collections.singletonList(new CDSCoding("http://snomed.info/sct", "197321007")))));
new CDSReference(Collections.singletonList(new CDSCoding("http://snomed.info/sct", "197321007"))), CONTRAINDICATION_ALERT_TYPE));
service.setMedicationOrderSelectTriggers(List.of(trigger));
}

Expand All @@ -81,6 +84,7 @@ public void shouldReturnAlert_WhenDrugAndConditionIsContraindicated() throws IOE
assertEquals("The use of Atorvastatin is contraindicated when the patient has Disease of liver.", cdsCard.getDetail());
assertEquals("1145419005", cdsCard.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertEquals("197321007", cdsCard.getReferenceCondition().getCoding().get(0).getCode());
assertEquals(CONTRAINDICATION_ALERT_TYPE, cdsCard.getAlertType());
}


Expand All @@ -102,6 +106,7 @@ public void shouldReturnOverDoseWarningAlert_WhenPrescribedDailyDoseExceedsMaxim
assertTrue( cdsCard.getDetail().contains("Conclusion : Combined prescribed amount is 6.00 times the average daily dose."));
assertEquals("1145419005", cdsCard.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertTrue(cdsCard.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=C10AA05"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard.getAlertType());
}

@Test
Expand All @@ -122,6 +127,7 @@ public void shouldReturnOverDoseInfoAlert_WhenPrescribedDailyDoseExceedsAcceptab
assertTrue( cdsCard.getDetail().contains("Conclusion : Combined prescribed amount is 2.50 times the average daily dose."));
assertEquals("1145419005", cdsCard.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertTrue(cdsCard.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=C10AA05"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard.getAlertType());
}
@Test
public void shouldNotReturnOverDoseAlert_WhenPrescribedDailyDoseIsWithinAcceptableThresholdFactor() throws IOException {
Expand Down Expand Up @@ -153,6 +159,7 @@ public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFac
assertTrue( cdsCard.getDetail().contains("Conclusion : Combined prescribed amount is 12.00 times the average daily dose."));
assertEquals("1145419005", cdsCard.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertTrue(cdsCard.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=C10AA05"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard.getAlertType());
}
@Test
public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFactor_ForFrequencyPeriodUnitInHours() throws IOException {
Expand All @@ -172,6 +179,7 @@ public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFac
assertTrue( cdsCard.getDetail().contains("Conclusion : Combined prescribed amount is 12.00 times the average daily dose."));
assertEquals("1145419005", cdsCard.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertTrue(cdsCard.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=C10AA05"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard.getAlertType());
}
@Test
public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFactor_ForFrequencyPeriodUnitInWeeks() throws IOException {
Expand All @@ -191,6 +199,7 @@ public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFac
assertTrue( cdsCard.getDetail().contains("Conclusion : Combined prescribed amount is 5.00 times the average daily dose."));
assertEquals("1145419005", cdsCard.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertTrue(cdsCard.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=C10AA05"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard.getAlertType());
}
@Test
public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFactor_ForFrequencyPeriodUnitInMonths() throws IOException {
Expand All @@ -210,6 +219,7 @@ public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFac
assertTrue( cdsCard.getDetail().contains("Conclusion : Combined prescribed amount is 5.00 times the average daily dose."));
assertEquals("1145419005", cdsCard.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertTrue(cdsCard.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=C10AA05"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard.getAlertType());
}


Expand All @@ -230,13 +240,15 @@ public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFac
assertTrue( cdsCard1.getDetail().contains("Conclusion : Combined prescribed amount is 96.00 times the average daily dose."));
assertEquals("408051007", cdsCard1.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertTrue(cdsCard1.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=C09AA05"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard1.getAlertType());

CDSCard cdsCard2 = cards.get(1);
assertEquals("The amount of Ranitidine prescribed is 40 times the average daily dose.", cdsCard2.getSummary());
assertEquals(CDSIndicator.warning, cdsCard2.getIndicator());
assertTrue( cdsCard2.getDetail().contains("Conclusion : Combined prescribed amount is 40.00 times the average daily dose."));
assertEquals("782087002", cdsCard2.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertTrue(cdsCard2.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=A02BA02"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard2.getAlertType());
}

@Test
Expand All @@ -260,6 +272,7 @@ public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFac
assertEquals("317249006", cdsCard.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertEquals("782087002", cdsCard.getReferenceMedications().get(1).getCoding().get(0).getCode());
assertTrue(cdsCard.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=A02BA02"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard.getAlertType());
}

@Test
Expand All @@ -283,6 +296,7 @@ public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFac
assertEquals("317249006", cdsCard.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertEquals("782087002", cdsCard.getReferenceMedications().get(1).getCoding().get(0).getCode());
assertTrue(cdsCard.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=A02BA02"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard.getAlertType());
}

@Test
Expand All @@ -304,6 +318,7 @@ public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFac
assertEquals("433216006", cdsCard1.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertEquals(1, cdsCard1.getReferenceMedications().size());
assertTrue(cdsCard1.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=M04AB01"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard1.getAlertType());

CDSCard cdsCard2 = cards.get(1);
assertEquals("The amount of Colchicine prescribed is 6 times the average daily dose.", cdsCard2.getSummary());
Expand All @@ -312,6 +327,7 @@ public void shouldReturnOverDoseAlert_WhenPrescribedDailyDoseExceedsThresholdFac
assertEquals("433216006", cdsCard2.getReferenceMedications().get(0).getCoding().get(0).getCode());
assertEquals(1, cdsCard2.getReferenceMedications().size());
assertTrue(cdsCard2.getSource().getUrl().contains("https://www.whocc.no/atc_ddd_index/?code=M04AC01"));
assertEquals(HIGH_DOSAGE_ALERT_TYPE, cdsCard2.getAlertType());

}
}

0 comments on commit a5e5379

Please sign in to comment.