feat(fhir): add FHIR medication interface implementation plan script#215
feat(fhir): add FHIR medication interface implementation plan script#215
Conversation
Co-authored-by: halcwb <683631+halcwb@users.noreply.github.com> Agent-Logs-Url: https://github.com/informedica/GenPRES/sessions/2414b85b-c4e0-4b07-bb7a-4f2ded4a8294
Co-authored-by: halcwb <683631+halcwb@users.noreply.github.com> Agent-Logs-Url: https://github.com/informedica/GenPRES/sessions/2414b85b-c4e0-4b07-bb7a-4f2ded4a8294
halcwb
left a comment
There was a problem hiding this comment.
Rename:
- RateUnit1 to RateFormUnit
- RateUnit2 to RateTimeUnit
Note: try to match names with the existing naming policy in the code base and data structures.
The current implementation assumes knowledge about dosing but that is not in the scenarios. Only the following can be provided:
- Component Orderable Quantities
- Ordererable Dose Quantity and/or
- Orderable Dose Rate and/or
- Schedule Frequency
Everything else is derived by lookup or calculation.
For the reconstruction of the OrderScenario type the following is provided:
- Patient data
- Indication
- Route
- Shape
- Dose type
The code should reflect this.
…ve hardcoded dosing knowledge Co-authored-by: halcwb <683631+halcwb@users.noreply.github.com> Agent-Logs-Url: https://github.com/informedica/GenPRES/sessions/88fb1713-6692-41d3-aaa6-a4b2fd7fb287
Done in b2ad01b.
|
halcwb
left a comment
There was a problem hiding this comment.
Investigate how GenPRES can translate the FIHR data from and to a scenario and how a scenario then can be translated to a medication and order scenario and vice versa. Look at the official FHIR documentation.
…nal translation, all spec scenarios Co-authored-by: halcwb <683631+halcwb@users.noreply.github.com> Agent-Logs-Url: https://github.com/informedica/GenPRES/sessions/88a3340d-6a54-45d9-b098-a445c37c0329
Done in 1665770. Step 8 is now a full FHIR R4 investigation: F# types mirroring the official FHIR R4 resources (with documentation links):
G-Standard/FHIR constants and mappings:
Bidirectional translation:
All 11 spec scenarios (6.1–6.11 including reconstitution, TPN, enteral feeding) are now defined and run through the round-trip demonstration. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Greptile SummaryThis PR adds a script-only implementation plan (
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[FHIR MedicationRequest\nR4 Resource] -->|fromFhirMedicationRequest| B[FhirScenario\nPatient / Route / Shape / DoseType\nProducts / AdminQty / Schema]
B -->|Build Patient| C[Patient record\nweight / height / age / gender]
B -->|Build Filter| D[Filter\nIndication / Route / Shape / DoseType]
C --> E[OrderContext.create\n+ getScenarios]
D --> E
E -->|ZIndex / GenFORM lookup| F[OrderScenario\nConcentrations & Dose Limits]
B -->|Apply orderable quantities\n& schedule from FHIR| F
F -->|Order.solveMinMax| G[Solved Order]
G -->|toFhirMedicationRequest| H[FHIR MedicationRequest\nR4 Resource]
H -->|Round-trip check| A
Reviews (1): Last reviewed commit: "Merge branch 'master' into copilot/add-f..." | Re-trigger Greptile |
- Add FhirExpectoTests.fsx: Expecto test scaffolding for the FHIR bidirectional translation layer — 6 test suites covering FhirSystems constants, RouteMapping round-trips, PeriodUnitMapping round-trips, inferDoseType logic, and toFhirMedicationRequest / fromFhirMedicationRequest round-trips for all 11 scenarios defined in ImplementationPlan.fsx - Update CHANGELOG [Unreleased] with 24 March 2026 commits: FHIR implementation plan script (PR informedica#215), UI interactions improvements (PR informedica#216), fix select-all in treatment plan (PR informedica#217), Fantomas exclusions fix (PR informedica#218, informedica#219) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Scripts-only implementation plan for the FHIR-based medication interface described in
docs/mdr/interface/genpres_interface_specification.md, demonstrating how FHIR R4 scenarios map to GenPRES orders via theOrderContextlookup mechanism and vice versa.Author checklist
Reviewer checklist
What's in the scripts
src/Informedica.FHIR.Lib/Scripts/load.fsx— standard bootstrap for FSI; references GenUNITS, GenCORE, GenSOLVER, GenFORM, ZIndex, GenORDER DLLs.src/Informedica.FHIR.Lib/Scripts/ImplementationPlan.fsx— walks all 8 steps of the issue, covering spec scenarios 6.1–6.11:FhirScenario,ScenarioProduct,AdministrationSchema) for all spec scenarios 6.1–6.11, including reconstitution (6.8, 6.9), TPN (6.10), and enteral feeding (6.11).AdministrationSchemausesRateFormUnit(numerator) andRateTimeUnit(denominator). EachFhirScenariocontains only what a FHIR resource directly provides: patient context, indication, route, shape, dose type, component orderable quantities, dose rate, and schedule frequency.ZIndex.GenericProduct.get []filtered by generic name; notes that spec GPK codes are placeholders. Concentrations and dose limits are derived from ZIndex results, not hardcoded.ValueUnitconstruction for the four directly-available FHIR data categories: component orderable quantities, orderable dose quantity, orderable dose rate, and schedule frequency.OrderScenariofrom FHIR context viaOrderContext: builds aPatientfrom scenario patient data, setsFilterwith indication/route/shape/dose type, callsOrderContext.create+getScenarios. Concentrations and dose limits come from ZIndex/GenFORM lookup — not hardcoded.Order.solveMinMaxon the retrieved scenario; prints order table.fromFhirMedicationRequestandtoFhirMedicationRequest).Informedica.FHIR.Lib.fsprojupdated to surface both scripts as<None>items.Key design principle
A FHIR scenario provides only four categories of data that feed directly into the order:
productsblockadministrationblockschemarate (RateFormUnit/RateTimeUnit)schemapatternEverything else (concentrations, dose limits, product structure) is derived by ZIndex/GenFORM lookup via
OrderContext.getScenarios, using the filter inputs: patient data, indication, route, shape, and dose type.FHIR R4 bidirectional translation (Step 8)
Step 8 is a full investigation of the official FHIR R4 resource structure:
FhirMedicationRequest,FhirMedication,FhirDosage,FhirTiming,FhirTimingRepeat,FhirQuantity,FhirRatio,FhirCodeableConceptFhirSystemsmodule: G-Standard OIDs — GPK (urn:oid:2.16.840.1.113883.2.4.4.7), route thesaurus 9, form thesaurus 10, UCUMRouteMapping: G-Standard route code ↔ GenPRES route namePeriodUnitMapping: FHIRh/d/wk↔ GenPRESuur/dag/weekinferDoseType: infers Once/OnceTimed/Discontinuous/Timed/Continuous from the FHIR timing/rate structurefromFhirMedicationRequest: FHIR MedicationRequest →FhirScenario(drivesOrderContextfilter +getScenariosto look up ZIndex rules)toFhirMedicationRequest:FhirScenario→ FHIR MedicationRequest with GPK coding, G-Standard route,doseAndRate.rateRatio(usingRateFormUnit/RateTimeUnit),timing.repeat, and containedMedicationwith ingredientsOfficial FHIR R4 documentation references included:
https://hl7.org/fhir/R4/medicationrequest.htmlhttps://hl7.org/fhir/R4/medication.htmlhttps://hl7.org/fhir/R4/dosage.htmlhttps://hl7.org/fhir/R4/datatypes.html#TimingOriginal prompt
⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.