[Repo Assist] feat(genorder): prototype YAML serialization for Medication.toString / fromString#356
Conversation
…fromString Adds Scripts/MedicationYaml.fsx as a script-only prototype per the script-only code policy for non-UI source files. The script shadows Informedica.GenOrder.Lib.Medication and provides: - yamlToString: emits a valid YAML document with 2-space indentation, block sequences for Components/Substances, and double-quoted scalars. - yamlFromString: parses the YAML using YamlDotNet and reuses all existing Parser.* helpers (parseDoseLimitOpt, parseMinMax, etc.). - Expecto round-trip tests covering all Scenarios.fs fixtures. Numeric formatting is unchanged; existing helpers (ValueUnit.toStringDecimalEngShortWithoutGroup, MinMax.toString, etc.) are reused via the shadowed module. Migration steps for the maintainer are documented in the script header. The actual Medication.fs change is left for human review as required by the script-only code policy. Closes #355 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Greptile SummaryThis PR adds a single script prototype
Confidence Score: 4/5Safe to merge as a script-only prototype; no production source files are touched and CI is unaffected. The change is entirely contained in a single No production files are changed. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Medication record] -->|yamlToString| B[YAML string]
B -->|yamlFromString| C{Parse result}
C -->|Ok| D[Medication record]
C -->|Error| E[string list of field-prefixed errors]
subgraph yamlToString
A1[Scalar fields - double-quoted] --> A2[Components block sequence]
A2 --> A3[Substances block sequence]
A3 --> B
end
subgraph yamlFromString
B1[YamlMappingNode root] --> B2[Extract scalar fields]
B2 --> B3[Extract Components sequence]
B3 --> B4[Extract Substances per component]
B4 --> B5[Reuse Parser.* helpers]
B5 --> C
end
F[Expecto round-trip tests] -->|all Scenarios.fs fixtures| A
D -->|assert equal to original| F
Reviews (1): Last reviewed commit: "feat(genorder): prototype YAML serializa..." | Re-trigger Greptile |
🤖 This is an automated contribution from Repo Assist.
Summary
Prototypes the YAML-compatible
Medication.toString/fromStringrequested in #355.Adds
src/Informedica.GenORDER.Lib/Scripts/MedicationYaml.fsx— a script-only implementation per the project's script-only code policy. No.fssource files are modified; migration is left to the maintainer.What the script contains
Medication.yamlToString— emits a valid YAML document:ComponentsandSubstancesas YAML block sequences (- Name: ...)ValueUnit.toStringDecimalEngShortWithoutGroup,MinMax.toString,DoseLimit.toString,SolutionLimit.toStringMedication.yamlFromString— parses the YAML using YamlDotNet 15.3.0:YamlMappingNode/YamlSequenceNodeParser.*helpers for value parsingResult<Medication, string list>with aggregated, field-prefixed errorsExpecto round-trip tests covering all
Scenarios.fsfixtures:pcmSupp,amfo,morfCont,pcmDrink,cotrim,tpn,tpnComplete,fullMedicationMigration steps (for the maintainer)
Once the script is verified via
dotnet fsi MedicationYaml.fsx:Medication.toStringbody inMedication.fswithyamlToString.Parser.fromStringinMedication.fswithyamlFromString.CONTRIBUTING.mdunder External Dependencies:YamlDotNet (>= 15.3.0)— standard YAML parsing inMedication.fromString.tests/Informedica.GenORDER.Tests/.dotnet run ServerTestsanddotnet run Formatbefore merging.Test Status
Script prototype only — not compiled by CI. Round-trip tests run via
dotnet fsi MedicationYaml.fsx(requires a priordotnet build GenPRES.sln). Existing CI tests are unaffected.Closes #355