Skip to content

Commit

Permalink
chore: print unique scenarios, removing duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Bollen authored and Casper Bollen committed Feb 17, 2024
1 parent e5776f6 commit 81873ea
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions src/Informedica.GenOrder.Lib/Api.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ namespace Informedica.GenOrder.Lib

module Api =


open Informedica.ZIndex.Lib
open MathNet.Numerics
open Informedica.Utils.Lib
open Informedica.Utils.Lib.BCL
Expand Down Expand Up @@ -100,7 +98,7 @@ module Api =
/// An array of Results, containing the Order and the PrescriptionRule.
/// </returns>
let evaluate logger (rule : PrescriptionRule) =
let rec solve sr pr =
let rec solve tryAgain sr pr =
pr
|> DrugOrder.createDrugOrder sr
|> DrugOrder.toOrderDto
Expand Down Expand Up @@ -184,12 +182,35 @@ module Api =
sbsts

Ok (ord, pr)
| Error (ord, m) -> Error (ord, pr, m)
| Error _ when tryAgain ->
{ pr with
DoseRule =
{ pr.DoseRule with
Shape = pr.DoseRule.Generic
Products =
[|
pr.DoseRule.DoseLimits
|> Array.map _.DoseLimitTarget
|> Array.map DoseRule.DoseLimit.substanceDoseLimitTargetToString
|> Array.filter String.notEmpty
|> Array.distinct
|> Product.create
pr.DoseRule.Generic
pr.DoseRule.Route
|]
DoseLimits =
pr.DoseRule .DoseLimits
|> Array.filter DoseRule.DoseLimit.isSubstanceLimit
}
}
|> solve false None
| Error (ord, m) ->
Error (ord, pr, m)

if rule.SolutionRules |> Array.isEmpty then [| solve None rule |]
if rule.SolutionRules |> Array.isEmpty then [| solve true None rule |]
else
rule.SolutionRules
|> Array.map (fun sr -> solve (Some sr) rule)
|> Array.map (fun sr -> solve true (Some sr) rule)


/// <summary>
Expand Down Expand Up @@ -329,6 +350,11 @@ module Api =
None
)
)
|> Array.distinctBy (fun pr ->
pr.Preparation,
pr.Prescription,
pr.Administration
)

| _ -> [||]
}
Expand Down

0 comments on commit 81873ea

Please sign in to comment.