From 8b43b1496d54cfb91a0e99cc51d82265c602d983 Mon Sep 17 00:00:00 2001 From: Kai Kewley Date: Thu, 5 Oct 2023 16:14:26 +0100 Subject: [PATCH] Package refactoring. --- .../model/DosageComparisonByRoute.java | 2 +- .../service/{ => hello}/HelloCDSService.java | 3 +- ...edicationCombinationRuleLoaderService.java | 9 +- .../MedicationConditionRuleLoaderService.java | 3 +- .../MedicationOrderSelectCDSService.java} | 8 +- .../MedicationDoseFormsLoaderService.java | 7 +- ...omedMedicationDefinedDailyDoseService.java | 112 ++++++++++-------- .../dose/SubstanceDefinedDailyDose.java | 5 + .../service/model/ManyToOneMapEntry.java | 31 +---- .../model/SubstanceDefinedDailyDose.java | 32 ----- .../tsclient/FHIRTerminologyServerClient.java | 1 - .../service/units/TimeConversionUtil.java | 36 ------ .../CdsServiceApplicationTests.java | 4 +- ... MedicationOrderSelectCDSServiceTest.java} | 7 +- 14 files changed, 92 insertions(+), 168 deletions(-) rename src/main/java/org/snomed/cdsservice/service/{ => hello}/HelloCDSService.java (88%) rename src/main/java/org/snomed/cdsservice/service/{ => medication}/MedicationCombinationRuleLoaderService.java (93%) rename src/main/java/org/snomed/cdsservice/service/{ => medication}/MedicationConditionRuleLoaderService.java (98%) rename src/main/java/org/snomed/cdsservice/service/{MedicationOrderSelectService.java => medication/MedicationOrderSelectCDSService.java} (95%) rename src/main/java/org/snomed/cdsservice/service/{ => medication/dose}/MedicationDoseFormsLoaderService.java (96%) rename src/main/java/org/snomed/cdsservice/service/{ => medication/dose}/SnomedMedicationDefinedDailyDoseService.java (95%) create mode 100644 src/main/java/org/snomed/cdsservice/service/medication/dose/SubstanceDefinedDailyDose.java delete mode 100644 src/main/java/org/snomed/cdsservice/service/model/SubstanceDefinedDailyDose.java delete mode 100644 src/main/java/org/snomed/cdsservice/service/units/TimeConversionUtil.java rename src/test/java/org/snomed/cdsservice/service/{MedicationOrderSelectServiceTest.java => MedicationOrderSelectCDSServiceTest.java} (98%) diff --git a/src/main/java/org/snomed/cdsservice/model/DosageComparisonByRoute.java b/src/main/java/org/snomed/cdsservice/model/DosageComparisonByRoute.java index 1edc348..e38eeb5 100644 --- a/src/main/java/org/snomed/cdsservice/model/DosageComparisonByRoute.java +++ b/src/main/java/org/snomed/cdsservice/model/DosageComparisonByRoute.java @@ -1,6 +1,6 @@ package org.snomed.cdsservice.model; -import org.snomed.cdsservice.service.model.SubstanceDefinedDailyDose; +import org.snomed.cdsservice.service.medication.dose.SubstanceDefinedDailyDose; public class DosageComparisonByRoute { PrescribedDailyDose totalPrescribedDailyDose; diff --git a/src/main/java/org/snomed/cdsservice/service/HelloCDSService.java b/src/main/java/org/snomed/cdsservice/service/hello/HelloCDSService.java similarity index 88% rename from src/main/java/org/snomed/cdsservice/service/HelloCDSService.java rename to src/main/java/org/snomed/cdsservice/service/hello/HelloCDSService.java index 7bee2b8..9009c9b 100644 --- a/src/main/java/org/snomed/cdsservice/service/HelloCDSService.java +++ b/src/main/java/org/snomed/cdsservice/service/hello/HelloCDSService.java @@ -1,9 +1,10 @@ -package org.snomed.cdsservice.service; +package org.snomed.cdsservice.service.hello; import org.snomed.cdsservice.model.CDSCard; import org.snomed.cdsservice.model.CDSIndicator; import org.snomed.cdsservice.model.CDSSource; import org.snomed.cdsservice.rest.pojo.CDSRequest; +import org.snomed.cdsservice.service.CDSService; import org.springframework.stereotype.Service; import java.util.List; diff --git a/src/main/java/org/snomed/cdsservice/service/MedicationCombinationRuleLoaderService.java b/src/main/java/org/snomed/cdsservice/service/medication/MedicationCombinationRuleLoaderService.java similarity index 93% rename from src/main/java/org/snomed/cdsservice/service/MedicationCombinationRuleLoaderService.java rename to src/main/java/org/snomed/cdsservice/service/medication/MedicationCombinationRuleLoaderService.java index f056f10..13caaa2 100644 --- a/src/main/java/org/snomed/cdsservice/service/MedicationCombinationRuleLoaderService.java +++ b/src/main/java/org/snomed/cdsservice/service/medication/MedicationCombinationRuleLoaderService.java @@ -1,4 +1,4 @@ -package org.snomed.cdsservice.service; +package org.snomed.cdsservice.service.medication; import com.google.common.base.Strings; import org.hl7.fhir.r4.model.Coding; @@ -10,6 +10,7 @@ import org.snomed.cdsservice.model.CDSSource; import org.snomed.cdsservice.model.CDSTrigger; import org.snomed.cdsservice.model.MedicationInterationCDSTrigger; +import org.snomed.cdsservice.service.ServiceException; import org.snomed.cdsservice.service.tsclient.FHIRTerminologyServerClient; import org.snomed.cdsservice.util.SnomedValueSetUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -71,11 +72,11 @@ public List loadTriggers() throws ServiceException { continue; } - if (medication1SnomedCode != null && medication1SnomedCode.contains("|") && !medication1SnomedCode.startsWith("ECL=")) { + if (medication1SnomedCode.contains("|") && !medication1SnomedCode.startsWith("ECL=")) { medication1SnomedCode = medication1SnomedCode.substring(medication1SnomedCode.indexOf("|")).trim(); } - if (medication2SnomedCode != null && medication2SnomedCode.contains("|") && !medication2SnomedCode.startsWith("ECL=")) { + if (medication2SnomedCode.contains("|") && !medication2SnomedCode.startsWith("ECL=")) { medication2SnomedCode = medication2SnomedCode.substring(medication2SnomedCode.indexOf("|")).trim(); } @@ -92,4 +93,4 @@ public List loadTriggers() throws ServiceException { } return triggers; } -} \ No newline at end of file +} diff --git a/src/main/java/org/snomed/cdsservice/service/MedicationConditionRuleLoaderService.java b/src/main/java/org/snomed/cdsservice/service/medication/MedicationConditionRuleLoaderService.java similarity index 98% rename from src/main/java/org/snomed/cdsservice/service/MedicationConditionRuleLoaderService.java rename to src/main/java/org/snomed/cdsservice/service/medication/MedicationConditionRuleLoaderService.java index 675f4c7..ddae703 100644 --- a/src/main/java/org/snomed/cdsservice/service/MedicationConditionRuleLoaderService.java +++ b/src/main/java/org/snomed/cdsservice/service/medication/MedicationConditionRuleLoaderService.java @@ -1,4 +1,4 @@ -package org.snomed.cdsservice.service; +package org.snomed.cdsservice.service.medication; import com.google.common.base.Strings; import org.apache.poi.ss.usermodel.Cell; @@ -14,6 +14,7 @@ import org.snomed.cdsservice.model.CDSSource; import org.snomed.cdsservice.model.CDSTrigger; import org.snomed.cdsservice.model.MedicationConditionCDSTrigger; +import org.snomed.cdsservice.service.ServiceException; import org.snomed.cdsservice.service.tsclient.FHIRTerminologyServerClient; import org.snomed.cdsservice.util.SnomedSpreadsheetUtil; import org.snomed.cdsservice.util.SnomedValueSetUtil; diff --git a/src/main/java/org/snomed/cdsservice/service/MedicationOrderSelectService.java b/src/main/java/org/snomed/cdsservice/service/medication/MedicationOrderSelectCDSService.java similarity index 95% rename from src/main/java/org/snomed/cdsservice/service/MedicationOrderSelectService.java rename to src/main/java/org/snomed/cdsservice/service/medication/MedicationOrderSelectCDSService.java index a138f3c..5c7e67f 100644 --- a/src/main/java/org/snomed/cdsservice/service/MedicationOrderSelectService.java +++ b/src/main/java/org/snomed/cdsservice/service/medication/MedicationOrderSelectCDSService.java @@ -1,4 +1,4 @@ -package org.snomed.cdsservice.service; +package org.snomed.cdsservice.service.medication; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.parser.IParser; @@ -10,6 +10,8 @@ import org.snomed.cdsservice.model.CDSReference; import org.snomed.cdsservice.model.CDSTrigger; import org.snomed.cdsservice.rest.pojo.CDSRequest; +import org.snomed.cdsservice.service.*; +import org.snomed.cdsservice.service.medication.dose.SnomedMedicationDefinedDailyDoseService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.server.ResponseStatusException; @@ -21,7 +23,7 @@ import java.util.stream.Stream; @Service -public class MedicationOrderSelectService extends CDSService { +public class MedicationOrderSelectCDSService extends CDSService { @Autowired private FhirContext fhirContext; @@ -39,7 +41,7 @@ public class MedicationOrderSelectService extends CDSService { private List drugDrugInteractionTriggers; - public MedicationOrderSelectService() { + public MedicationOrderSelectCDSService() { super("medication-order-select"); setPrefetch(Map.of( "patient", "Patient/{{context.patientId}}", diff --git a/src/main/java/org/snomed/cdsservice/service/MedicationDoseFormsLoaderService.java b/src/main/java/org/snomed/cdsservice/service/medication/dose/MedicationDoseFormsLoaderService.java similarity index 96% rename from src/main/java/org/snomed/cdsservice/service/MedicationDoseFormsLoaderService.java rename to src/main/java/org/snomed/cdsservice/service/medication/dose/MedicationDoseFormsLoaderService.java index e3ef06c..836fd75 100644 --- a/src/main/java/org/snomed/cdsservice/service/MedicationDoseFormsLoaderService.java +++ b/src/main/java/org/snomed/cdsservice/service/medication/dose/MedicationDoseFormsLoaderService.java @@ -1,8 +1,9 @@ -package org.snomed.cdsservice.service; +package org.snomed.cdsservice.service.medication.dose; import org.hl7.fhir.r4.model.Coding; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.snomed.cdsservice.service.ServiceException; import org.snomed.cdsservice.service.model.ManyToOneMapEntry; import org.snomed.cdsservice.service.tsclient.FHIRTerminologyServerClient; import org.snomed.cdsservice.util.SnomedValueSetUtil; @@ -64,11 +65,11 @@ public List loadDoseFormMap() throws ServiceException { throw new ServiceException(format("Failed to expand value set '%s'", valueSetURI), e); } } - mapEntries.sort(Comparator.comparing(ManyToOneMapEntry::getMapPriority)); + mapEntries.sort(Comparator.comparing(ManyToOneMapEntry::mapPriority)); return mapEntries; } catch (Exception e) { throw new ServiceException(format("Failed to load SNOMED CT Manufactured dose form to ATC route of administration - dynamic map %s.", tsvPath), e); } } -} \ No newline at end of file +} diff --git a/src/main/java/org/snomed/cdsservice/service/SnomedMedicationDefinedDailyDoseService.java b/src/main/java/org/snomed/cdsservice/service/medication/dose/SnomedMedicationDefinedDailyDoseService.java similarity index 95% rename from src/main/java/org/snomed/cdsservice/service/SnomedMedicationDefinedDailyDoseService.java rename to src/main/java/org/snomed/cdsservice/service/medication/dose/SnomedMedicationDefinedDailyDoseService.java index dc66d8f..f3f95c1 100644 --- a/src/main/java/org/snomed/cdsservice/service/SnomedMedicationDefinedDailyDoseService.java +++ b/src/main/java/org/snomed/cdsservice/service/medication/dose/SnomedMedicationDefinedDailyDoseService.java @@ -1,4 +1,4 @@ -package org.snomed.cdsservice.service; +package org.snomed.cdsservice.service.medication.dose; import jakarta.annotation.PostConstruct; import net.steppschuh.markdowngenerator.list.UnorderedList; @@ -9,8 +9,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.snomed.cdsservice.model.*; +import org.snomed.cdsservice.service.ArgumentAssertionUtil; +import org.snomed.cdsservice.service.ServiceException; +import org.snomed.cdsservice.service.medication.dose.MedicationDoseFormsLoaderService; import org.snomed.cdsservice.service.model.ManyToOneMapEntry; -import org.snomed.cdsservice.service.model.SubstanceDefinedDailyDose; +import org.snomed.cdsservice.service.medication.dose.SubstanceDefinedDailyDose; import org.snomed.cdsservice.service.tsclient.ConceptParameters; import org.snomed.cdsservice.service.tsclient.FHIRTerminologyServerClient; import org.snomed.cdsservice.service.tsclient.SnomedConceptNormalForm; @@ -46,18 +49,19 @@ public class SnomedMedicationDefinedDailyDoseService { public static final String ATTRIBUTE_HAS_CONCENTRATION_STRENGTH_NUMERATOR_UNIT = "733725009"; public static final String ATTRIBUTE_HAS_CONCENTRATION_STRENGTH_DENOMINATOR_VALUE = "1142137007"; public static final String ATTRIBUTE_HAS_CONCENTRATION_STRENGTH_DENOMINATOR_UNIT = "733722007"; + public static final String WARNING = "warning"; public static final String INFO = "info"; private static final String NEW_LINE = "\n"; - private final Map> substanceDDD = new HashMap<>(); - private final Logger logger = LoggerFactory.getLogger(getClass()); - @Value("${rules.medication-substance-daily-doses.tsv}") - private String tsvPath; + @Autowired private FHIRTerminologyServerClient tsClient; + @Autowired private MedicationDoseFormsLoaderService doseFormsLoaderService; - private List doseFormsManySnomedToOneAtcCodeMap; + + @Value("${rules.medication-substance-daily-doses.tsv}") + private String tsvPath; @Value("${acceptable-daily-dose-threshold-factor}") private String acceptableDailyDoseThresholdFactor; @Value("${maximum-daily-dose-threshold-factor}") @@ -67,6 +71,47 @@ public class SnomedMedicationDefinedDailyDoseService { @Value("${who.atc.url-template}") private String atcUrlTemplate; + private List doseFormsManySnomedToOneAtcCodeMap; + private final Map> substanceDDD = new HashMap<>(); + private final Logger logger = LoggerFactory.getLogger(getClass()); + + @PostConstruct + public void init() throws ServiceException { + doseFormsManySnomedToOneAtcCodeMap = doseFormsLoaderService.loadDoseFormMap(); + + logger.info("Loading SNOMED CT Substance Defined Daily Dose information"); + try (BufferedReader reader = new BufferedReader(new FileReader(tsvPath))) { + String expectedHeader = "atc_code\tatc_name\tsnomed_code\tsnomed_label\tddd\tuom\tadm_r\tnote"; + String header = reader.readLine(); + if (!expectedHeader.equals(header)) { + throw new ServiceException(format("SNOMED Substance DDD file does not have the expected header. " + "Expected: '%s', Actual: '%s'", expectedHeader, header)); + } + + String line; + int row = 1; + try { + while ((line = reader.readLine()) != null) { + row++; + // Columns and indexes + // atc_code atc_name snomed_code snomed_label ddd uom adm_r note + // 0 1 2 3 4 5 6 7 + String[] values = line.split("\t"); + String substanceSnomedCode = values[2]; + float dose = Float.parseFloat(values[4]); + String unit = values[5]; + String atcRouteOfAdministrationCode = values[6]; + String atcCode = values[0]; + substanceDDD.computeIfAbsent(substanceSnomedCode, i -> new ArrayList<>()).add(new SubstanceDefinedDailyDose(atcRouteOfAdministrationCode, dose, unit, atcCode)); + } + } catch (NumberFormatException e) { + throw new ServiceException(format("Failed to read SNOMED Substance DDDs from tab separated file. " + "Number format error while reading row %s", row), e); + } + } catch (Exception e) { + throw new ServiceException("Failed to read SNOMED Substance DDDs from tab separated file", e); + } + logger.info("Doses loaded for {} substances.", substanceDDD.size()); + } + public List checkMedications(List medicationRequests) { List cards = new ArrayList<>(); Map aggregatedMedicationsBySubstanceMap = new HashMap<>(); @@ -103,9 +148,9 @@ public List checkMedications(List medicationRequests String atcRouteOfAdministrationCode = null; String routeOfAdministrationLabel = null; for (ManyToOneMapEntry manyToOneMapEntry : doseFormsManySnomedToOneAtcCodeMap) { - if (manyToOneMapEntry.getSourceCodes().contains(manufacturedDoseForm)) { - atcRouteOfAdministrationCode = manyToOneMapEntry.getTargetCode(); - routeOfAdministrationLabel = manyToOneMapEntry.getLabel() != null ? manyToOneMapEntry.getLabel() : atcRouteOfAdministrationCode; + if (manyToOneMapEntry.sourceCodes().contains(manufacturedDoseForm)) { + atcRouteOfAdministrationCode = manyToOneMapEntry.targetCode(); + routeOfAdministrationLabel = manyToOneMapEntry.label() != null ? manyToOneMapEntry.label() : atcRouteOfAdministrationCode; } } if (atcRouteOfAdministrationCode == null) { @@ -188,7 +233,7 @@ private void aggregateMedicationsBySubstance(Map sub return null; } DosageComparisonByRoute dosageComparisonByRoute = dosageInfoEntry.get().getValue(); - return MessageFormat.format(atcUrlTemplate, dosageComparisonByRoute.getSubstanceDefinedDailyDose().getAtcCode()); + return MessageFormat.format(atcUrlTemplate, dosageComparisonByRoute.getSubstanceDefinedDailyDose().atcCode()); } private String getAlertIndicator(double prescribedDosageFactor) { @@ -275,7 +320,7 @@ private String getAlertIndicator(double prescribedDosageFactor) { private Double getPrescribedDosageFactor(Map dosageComparisonByRouteMap) { Double prescribedDosageFactor = Double.valueOf(0); for (var eachRoute : dosageComparisonByRouteMap.entrySet()) { - prescribedDosageFactor = prescribedDosageFactor + (eachRoute.getValue().getTotalPrescribedDailyDose().getQuantity() / eachRoute.getValue().getSubstanceDefinedDailyDose().getDose()); + prescribedDosageFactor = prescribedDosageFactor + (eachRoute.getValue().getTotalPrescribedDailyDose().getQuantity() / eachRoute.getValue().getSubstanceDefinedDailyDose().dose()); } return prescribedDosageFactor; } @@ -311,43 +356,6 @@ private PrescribedDailyDose getPrescribedDailyDoseInUnitOfDDD(Double inputStreng return new PrescribedDailyDose(prescribedDailyDoseQuantity, targetStrengthUnit); } - @PostConstruct - public void init() throws ServiceException { - doseFormsManySnomedToOneAtcCodeMap = doseFormsLoaderService.loadDoseFormMap(); - - logger.info("Loading SNOMED CT Substance Defined Daily Dose information"); - try (BufferedReader reader = new BufferedReader(new FileReader(tsvPath))) { - String expectedHeader = "atc_code\tatc_name\tsnomed_code\tsnomed_label\tddd\tuom\tadm_r\tnote"; - String header = reader.readLine(); - if (!expectedHeader.equals(header)) { - throw new ServiceException(format("SNOMED Substance DDD file does not have the expected header. " + "Expected: '%s', Actual: '%s'", expectedHeader, header)); - } - - String line; - int row = 1; - try { - while ((line = reader.readLine()) != null) { - row++; - // Columns and indexes - // atc_code atc_name snomed_code snomed_label ddd uom adm_r note - // 0 1 2 3 4 5 6 7 - String[] values = line.split("\t"); - String substanceSnomedCode = values[2]; - float dose = Float.parseFloat(values[4]); - String unit = values[5]; - String atcRouteOfAdministrationCode = values[6]; - String atcCode = values[0]; - substanceDDD.computeIfAbsent(substanceSnomedCode, i -> new ArrayList<>()).add(new SubstanceDefinedDailyDose(atcRouteOfAdministrationCode, dose, unit, atcCode)); - } - } catch (NumberFormatException e) { - throw new ServiceException(format("Failed to read SNOMED Substance DDDs from tab separated file. " + "Number format error while reading row %s", row), e); - } - } catch (Exception e) { - throw new ServiceException("Failed to read SNOMED Substance DDDs from tab separated file", e); - } - logger.info("Doses loaded for {} substances.", substanceDDD.size()); - } - private String getCardSummaryTemplate() { return cardSummaryTemplate; } @@ -369,7 +377,7 @@ private void composeDosageByRoute(Map 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.getDose() + substanceDefinedDailyDose.getUnit(), "Prescribed amount is " + getDecimalPlace(aggregatedDailyDosage.getQuantity() / substanceDefinedDailyDose.getDose()) + " 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 : " + 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); } } diff --git a/src/main/java/org/snomed/cdsservice/service/medication/dose/SubstanceDefinedDailyDose.java b/src/main/java/org/snomed/cdsservice/service/medication/dose/SubstanceDefinedDailyDose.java new file mode 100644 index 0000000..b210ea8 --- /dev/null +++ b/src/main/java/org/snomed/cdsservice/service/medication/dose/SubstanceDefinedDailyDose.java @@ -0,0 +1,5 @@ +package org.snomed.cdsservice.service.medication.dose; + +public record SubstanceDefinedDailyDose(String atcRouteOfAdministration, float dose, String unit, String atcCode) { + +} diff --git a/src/main/java/org/snomed/cdsservice/service/model/ManyToOneMapEntry.java b/src/main/java/org/snomed/cdsservice/service/model/ManyToOneMapEntry.java index 9025c2d..b2dd294 100644 --- a/src/main/java/org/snomed/cdsservice/service/model/ManyToOneMapEntry.java +++ b/src/main/java/org/snomed/cdsservice/service/model/ManyToOneMapEntry.java @@ -2,35 +2,6 @@ import java.util.Set; -public class ManyToOneMapEntry { - - private final Set sourceCodes; - private final String targetCode; - private final int mapPriority; - private final String label; - - public ManyToOneMapEntry(Set sourceCodes, String targetCode, int mapPriority, String label) { - this.sourceCodes = sourceCodes; - this.targetCode = targetCode; - this.mapPriority = mapPriority; - this.label = label; - } - - - public Set getSourceCodes() { - return sourceCodes; - } - - public String getTargetCode() { - return targetCode; - } - - public int getMapPriority() { - return mapPriority; - } - - public String getLabel() { - return label; - } +public record ManyToOneMapEntry(Set sourceCodes, String targetCode, int mapPriority, String label) { } diff --git a/src/main/java/org/snomed/cdsservice/service/model/SubstanceDefinedDailyDose.java b/src/main/java/org/snomed/cdsservice/service/model/SubstanceDefinedDailyDose.java deleted file mode 100644 index 261a535..0000000 --- a/src/main/java/org/snomed/cdsservice/service/model/SubstanceDefinedDailyDose.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.snomed.cdsservice.service.model; - -public class SubstanceDefinedDailyDose { - - private final String atcRouteOfAdministration; - private final float dose; - private final String unit; - private final String atcCode; - - - public SubstanceDefinedDailyDose(String atcRouteOfAdministration, float dose, String unit, String atcCode) { - this.dose = dose; - this.unit = unit; - this.atcRouteOfAdministration = atcRouteOfAdministration; - this.atcCode = atcCode; - } - - public String getAtcRouteOfAdministration() { - return atcRouteOfAdministration; - } - - public float getDose() { - return dose; - } - - public String getUnit() { - return unit; - } - public String getAtcCode() { - return atcCode; - } -} diff --git a/src/main/java/org/snomed/cdsservice/service/tsclient/FHIRTerminologyServerClient.java b/src/main/java/org/snomed/cdsservice/service/tsclient/FHIRTerminologyServerClient.java index a90aaa6..84418da 100644 --- a/src/main/java/org/snomed/cdsservice/service/tsclient/FHIRTerminologyServerClient.java +++ b/src/main/java/org/snomed/cdsservice/service/tsclient/FHIRTerminologyServerClient.java @@ -3,7 +3,6 @@ import ca.uhn.fhir.context.FhirContext; import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Parameters; -import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.snomed.cdsservice.model.CDSCoding; diff --git a/src/main/java/org/snomed/cdsservice/service/units/TimeConversionUtil.java b/src/main/java/org/snomed/cdsservice/service/units/TimeConversionUtil.java deleted file mode 100644 index ac8bb05..0000000 --- a/src/main/java/org/snomed/cdsservice/service/units/TimeConversionUtil.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.snomed.cdsservice.service.units; - -import org.hl7.fhir.r4.model.Timing; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -public class TimeConversionUtil { - - public static BigDecimal convertPeriodUnitToDay(BigDecimal period, Timing.UnitsOfTime unitOfTime) { - switch (unitOfTime) { - case A -> { - return period.divide(new BigDecimal(365), RoundingMode.HALF_EVEN); - } - case MO -> { - return period.divide(new BigDecimal(28), RoundingMode.HALF_EVEN); - } - case WK -> { - return period.divide(new BigDecimal(7), RoundingMode.HALF_EVEN); - } - case H -> { - return period.multiply(new BigDecimal(24)); - } - case MIN -> { - return period.multiply(new BigDecimal(24 * 60)); - } - case S -> { - return period.multiply(new BigDecimal(24 * 60 * 60)); - } - default -> { - return period; - } - } - } - -} diff --git a/src/test/java/org/snomed/cdsservice/CdsServiceApplicationTests.java b/src/test/java/org/snomed/cdsservice/CdsServiceApplicationTests.java index ff7373c..7f3e447 100644 --- a/src/test/java/org/snomed/cdsservice/CdsServiceApplicationTests.java +++ b/src/test/java/org/snomed/cdsservice/CdsServiceApplicationTests.java @@ -1,8 +1,8 @@ package org.snomed.cdsservice; import org.junit.jupiter.api.Test; -import org.snomed.cdsservice.service.MedicationConditionRuleLoaderService; -import org.snomed.cdsservice.service.MedicationCombinationRuleLoaderService; +import org.snomed.cdsservice.service.medication.MedicationConditionRuleLoaderService; +import org.snomed.cdsservice.service.medication.MedicationCombinationRuleLoaderService; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; diff --git a/src/test/java/org/snomed/cdsservice/service/MedicationOrderSelectServiceTest.java b/src/test/java/org/snomed/cdsservice/service/MedicationOrderSelectCDSServiceTest.java similarity index 98% rename from src/test/java/org/snomed/cdsservice/service/MedicationOrderSelectServiceTest.java rename to src/test/java/org/snomed/cdsservice/service/MedicationOrderSelectCDSServiceTest.java index 23d2453..0ad6c83 100644 --- a/src/test/java/org/snomed/cdsservice/service/MedicationOrderSelectServiceTest.java +++ b/src/test/java/org/snomed/cdsservice/service/MedicationOrderSelectCDSServiceTest.java @@ -11,6 +11,9 @@ import org.snomed.cdsservice.model.CDSTrigger; import org.snomed.cdsservice.model.MedicationConditionCDSTrigger; import org.snomed.cdsservice.rest.pojo.CDSRequest; +import org.snomed.cdsservice.service.medication.MedicationCombinationRuleLoaderService; +import org.snomed.cdsservice.service.medication.MedicationConditionRuleLoaderService; +import org.snomed.cdsservice.service.medication.MedicationOrderSelectCDSService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; @@ -28,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @SpringBootTest -class MedicationOrderSelectServiceTest { +class MedicationOrderSelectCDSServiceTest { @MockBean private MedicationConditionRuleLoaderService ruleLoaderService; @@ -37,7 +40,7 @@ class MedicationOrderSelectServiceTest { private MedicationCombinationRuleLoaderService medicationRuleLoaderService; @Autowired - private MedicationOrderSelectService service; + private MedicationOrderSelectCDSService service; @BeforeEach void setMockOutput() {