Skip to content

Commit

Permalink
feat: added direct link to kf in formularium
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Bollen authored and Casper Bollen committed May 10, 2024
1 parent d166058 commit de7816b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Client/MUI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ module Icons =
<PsychologyIcon />
"""

let CalculateIcon = JSX.jsx """
import CalculateIcon from '@mui/icons-material/Calculate';
<CalculateIcon/>
"""



type Color = {|
Expand Down
1 change: 1 addition & 0 deletions src/Client/Views/Prescribe.fs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ module Prescribe =
<Button
size="small"
onClick={fun () -> setModalOpen true; (sc, ord) |> props.selectOrder}
startIcon={Mui.Icons.CalculateIcon}
>{Terms.Edit |> getTerm "bewerken"}</Button>
</CardActions>
</Card>
Expand Down
47 changes: 46 additions & 1 deletion src/Informedica.GenForm.Lib/DoseRule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module DoseRule =

open System
open MathNet.Numerics

open FSharp.Data
open FSharp.Data.JsonExtensions

open Informedica.Utils.Lib
open Informedica.Utils.Lib.BCL
open Informedica.GenCore.Lib.Ranges
Expand Down Expand Up @@ -186,6 +190,39 @@ module DoseRule =
)


// get all medications from Kinderformularium
let kinderFormUrl = "https://www.kinderformularium.nl/geneesmiddelen.json"

let private _medications () =
let replace =
[
"Ergocalciferol / fytomenadion / retinol / tocoferol (Vitamine A/D/E/K)",
"ergocalciferol-fytomenadion-retinol-tocoferol-vitamine-adek"

"Natriumdocusaat (al dan niet i.c.m. sorbitol)",
"natriumdocusaat-al-dan-niet-icm-sorbitol"
]
let res = JsonValue.Load(kinderFormUrl)
[ for v in res do
{|
id = (v?id.AsString())
generic = (v?generic_name.AsString()).Trim().ToLower()
|}
]
|> List.distinct


let getKFMedications = Memoization.memoize _medications


let getLink gen =
getKFMedications ()
|> List.tryFind (fun m -> m.generic = gen)
|> Option.map (fun m ->
$"[Kinderformularium](https://www.kinderformularium.nl/geneesmiddel/{m.id}/{m.generic})"
)


/// See for use of anonymous record in
/// fold: https://github.com/dotnet/fsharp/issues/6699
let toMarkdown (rules : DoseRule array) =
Expand Down Expand Up @@ -244,11 +281,19 @@ module DoseRule =
("", rules |> Array.groupBy _.DoseType)
||> Array.fold (fun acc (dt, ds) ->
let pedForm =
let link =
ds
|> Array.tryHead
|> Option.bind (fun dr ->
dr.Generic |> getLink
)
|> Option.defaultValue "*Kinderformularium*"

ds
|> Array.map _.ScheduleText
|> Array.distinct
|> function
| [| s |] -> $"\n\n*Kinderformularium*: {s}"
| [| s |] -> $"\n\n{link}: {s}"
| _ -> ""

ds
Expand Down
3 changes: 2 additions & 1 deletion src/Informedica.GenForm.Lib/paket.references
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Unquote
MathNet.Numerics.FSharp
FParsec
FSharp.Core
FSharp.Core
FSharp.Data

0 comments on commit de7816b

Please sign in to comment.