Skip to content

[Repo Assist] feat(genorder): prototype YAML serialization for Medication.toString / fromString#356

Merged
halcwb merged 1 commit into
masterfrom
repo-assist/feat-355-medication-yaml-f4cb11769f17788e
May 18, 2026
Merged

[Repo Assist] feat(genorder): prototype YAML serialization for Medication.toString / fromString#356
halcwb merged 1 commit into
masterfrom
repo-assist/feat-355-medication-yaml-f4cb11769f17788e

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated contribution from Repo Assist.

AI disclosure: Generated by Repo Assist (automated AI assistant). The code is a script prototype that must be reviewed and verified by the human maintainer before migrating into source files.

Summary

Prototypes the YAML-compatible Medication.toString / fromString requested in #355.

Adds src/Informedica.GenORDER.Lib/Scripts/MedicationYaml.fsx — a script-only implementation per the project's script-only code policy. No .fs source files are modified; migration is left to the maintainer.

What the script contains

  • Medication.yamlToString — emits a valid YAML document:

    • 2-space indentation (no tabs)
    • Components and Substances as YAML block sequences (- Name: ...)
    • All scalar values double-quoted to prevent YAML special-character issues
    • Reuses existing helpers: ValueUnit.toStringDecimalEngShortWithoutGroup, MinMax.toString, DoseLimit.toString, SolutionLimit.toString
  • Medication.yamlFromString — parses the YAML using YamlDotNet 15.3.0:

    • Extracts fields from YamlMappingNode / YamlSequenceNode
    • Reuses all existing Parser.* helpers for value parsing
    • Returns Result<Medication, string list> with aggregated, field-prefixed errors
  • Expecto round-trip tests covering all Scenarios.fs fixtures: pcmSupp, amfo, morfCont, pcmDrink, cotrim, tpn, tpnComplete, fullMedication

Migration steps (for the maintainer)

Once the script is verified via dotnet fsi MedicationYaml.fsx:

  1. Replace Medication.toString body in Medication.fs with yamlToString.
  2. Replace Parser.fromString in Medication.fs with yamlFromString.
  3. Wire YamlDotNet via Paket:
    # paket.dependencies
    nuget YamlDotNet >= 15.3.0 lowest_matching: true
    # src/Informedica.GenORDER.Lib/paket.references
    YamlDotNet
    
  4. Add a note in CONTRIBUTING.md under External Dependencies:
    YamlDotNet (>= 15.3.0) — standard YAML parsing in Medication.fromString.
  5. Move the Expecto round-trip tests from the script into tests/Informedica.GenORDER.Tests/.
  6. Run dotnet run ServerTests and dotnet run Format before merging.

Test Status

Script prototype only — not compiled by CI. Round-trip tests run via dotnet fsi MedicationYaml.fsx (requires a prior dotnet build GenPRES.sln). Existing CI tests are unaffected.

Closes #355

Generated by Repo Assist for issue #355 · ● 25M ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@f2c5cf1e4af58e09a93ba0703c6bf084711b265f

…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-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 18, 2026

Greptile Summary

This PR adds a single script prototype MedicationYaml.fsx that explores YAML-compatible Medication.toString / fromString serialization using YamlDotNet 15.3.0 and Expecto round-trip tests. No production .fs files are modified; migration is left entirely to the maintainer.

  • Adds yamlToString (block-sequence YAML emitter) and yamlFromString (YamlDotNet-based parser returning Result<Medication, string list>) as a shadowed Medication module inside the script.
  • Includes Expecto round-trip tests covering all Scenarios.fs fixtures (pcmSupp, amfo, morfCont, pcmDrink, cotrim, tpn, tpnComplete, fullMedication).
  • Per the project's established policy, .fsx script files are out of scope for formal code review; the meaningful review opportunity arrives when the implementation is migrated into Medication.fs.

Confidence Score: 4/5

Safe 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 .fsx script that does not participate in the build or CI pipeline. The risk to the existing codebase is essentially zero. The only consideration is whether this prototype is accurate enough to serve as a reliable migration guide — that judgment belongs to the maintainer who will run it via dotnet fsi.

No production files are changed. MedicationYaml.fsx is the only file and warrants a quick sanity-run via dotnet fsi before the maintainer begins migration.

Important Files Changed

Filename Overview
src/Informedica.GenORDER.Lib/Scripts/MedicationYaml.fsx New script-only prototype for YAML serialization/deserialization of Medication; per project policy .fsx files are excluded from formal code review — no production .fs source files are modified.

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
Loading

Reviews (1): Last reviewed commit: "feat(genorder): prototype YAML serializa..." | Re-trigger Greptile

Comment thread src/Informedica.GenORDER.Lib/Scripts/MedicationYaml.fsx
@halcwb halcwb merged commit bfa9c22 into master May 18, 2026
9 checks passed
@halcwb halcwb deleted the repo-assist/feat-355-medication-yaml-f4cb11769f17788e branch May 18, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change the medication to string to full yaml compatible

1 participant