Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ dotnet test tests/Informedica.GenUNITS.Tests/
- Resource loading and tests: `src/Informedica.GenForm.Lib/Api.fs` and `tests/`
- Sheet parsers: `Mapping.fs`, `Product.fs`, `DoseRule.fs`, `SolutionRule.fs`, `RenalRule.fs`
- Unit and BigRational helpers: `src/Informedica.GenUnits.Lib/ValueUnit.fs`
- Sheet documentation: `docs/mdr/design-history/0003-resource-requirements.md`
- Sheet documentation: the `Data` record types in `src/Informedica.GenFORM.Lib/Types.fs` (one record per sheet, columns documented on the fields), with the column names enforced by the `ColumnContract` tests in `tests/Informedica.GenFORM.Tests/Tests.fs`

**Important:** an opt-in strategy is used in the `.gitignore` file — you have to specifically define what should be included instead of the other way around!

Expand Down
2 changes: 1 addition & 1 deletion .github/prompts/add-dose-rule.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Add or modify a medication rule (dose rule, solution rule, product, etc.) in Gen

## Steps

1. **Understand the sheet structure** — read `docs/mdr/design-history/0003-resource-requirements.md` to find the relevant sheet and column names.
1. **Understand the sheet structure** — read the matching `Data` record in `src/Informedica.GenFORM.Lib/Types.fs` (its XML summary names the sheet and parser; the field comments carry column names, units and encodings) and the declared column lists in `DoseRuleToDataTests.ColumnContract` (`tests/Informedica.GenFORM.Tests/Tests.fs`).

2. **Locate the parser** — find the corresponding module:
- Dose rules → `src/Informedica.GenForm.Lib/DoseRule.fs`
Expand Down
29 changes: 18 additions & 11 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ dotnet test
- `dotnet run list` - Show all available build targets
- `dotnet run Build` - Build the solution
- `dotnet run Bundle` - Create production bundle
- `dotnet run CheckVersions` - Proves that every project shipped in GenPRES.sln reports the same version as the repo-root Directory.Build.props
- `dotnet run Clean` - Clean build artifacts
- `dotnet run DockerBuild` - Builds the Docker image, version-labelled from `Directory.Build.props`
- `dotnet run DockerRun` - Runs a Docker container
- `dotnet run Format` - Uses Fantomas to format F# code
- `dotnet run MarkdownLint` - Runs the mark down linter
- `dotnet run RestoreClient` - Runs the client npm restore process
- Access the application at `http://localhost:5173`

### Testing
Expand Down Expand Up @@ -87,17 +93,18 @@ dotnet test tests/Informedica.GenUNITS.Tests/
## Key Code Locations

- F# libraries under `src/`
- Tests: `tests/` (Expecto + FsCheck). Look for BigRational and ValueUnit tests.
- Resource loading and tests: `src/Informedica.GenForm.Lib/Api.fs` and `tests/`
- Sheet parsers: `Mapping.fs`, `Product.fs`, `DoseRule.fs`, `SolutionRule.fs`, `RenalRule.fs`
- Tests: `tests/` (uses Expecto + FsCheck).
- Resource loading: `src/Informedica.GenForm.Lib/Api.fs`
- Resource parsers: `Mapping.fs`, `Product.fs`, `DoseRuleData.fs`, `SolutionRule.fs`, `RenalRule.fs`
- Unit and BigRational helpers: `src/Informedica.GenUnits.Lib/ValueUnit.fs`
- Sheet documentation: `docs/mdr/design-history/0003-resource-requirements.md`
- Sheet documentation: the `Data` record types in `src/Informedica.GenFORM.Lib/Types.fs` (one record per sheet, columns documented on the fields), with the column names enforced by the `ColumnContract` tests in `tests/Informedica.GenFORM.Tests/Tests.fs`

**Important:** an opt-in strategy is used in the `.gitignore` file — you have to specifically define what should be included instead of the other way around!
The same applies to the docker ignore file.

## Configuration Architecture

- All medication rules and constraints stored in Google Spreadsheets
- All medication rules and constraints (currently) stored in Google Spreadsheets
- Downloaded as CSV and parsed dynamically
- `GENPRES_URL_ID` environment variable controls which spreadsheet to use
- Local cache files provide offline medication data access
Expand All @@ -110,12 +117,12 @@ dotnet test tests/Informedica.GenUNITS.Tests/

## Resource Loading Pattern

- Docs with sheet specs: `docs/mdr/design-history/0003-resource-requirements.md`.
- Check `0003-resource-requirements.md` for expected sheet and column names.
- Sheet specs live in code: each sheet has a record in the `Data` module of `src/Informedica.GenFORM.Lib/Types.fs`, whose XML summary names the sheet and the parser and whose field comments carry the column name (where it differs), unit, separator and boolean spelling.
- Check that record — and the declared column lists in `DoseRuleToDataTests.ColumnContract` (`tests/Informedica.GenFORM.Tests/Tests.fs`) — for expected sheet and column names.
- Resources are loaded from Google Sheets via `Web.getDataFromSheet dataUrlId "SheetName"`.
- Mapping helper functions use `Csv.getStringColumn` / `Csv.getFloatOptionColumn` and call getString/getFloat-style delegates.
- The central `ResourceConfig` (in `Api.fs`) expects functions returning `GenFormResult<'T>` (alias for `Result<'T, Message list>`). Use the `*Result` variants where present (e.g., `Mapping.getRouteMapping` or `Mapping.getRouteMappingResult`) and wrap with `delay` when the signature expects a `unit -> GenFormResult<_>`.
- To add/modify sheet mappings: adjust the mapper in the corresponding module (e.g., `Product.Reconstitution.get`, `DoseRule.get`) and update `0003-resource-requirements.md` to reflect column names.
- To add/modify sheet mappings: adjust the mapper in the corresponding module (e.g., `Product.Reconstitution.parseReconstitution`, `DoseRuleData.parseDoseRuleData`), update the field comments on the matching `Data` record, and update the declared column list in the column-contract test.
- Update the mapper to read columns by name using the `get` delegate (e.g., `let get = getColumn row in get "Generic"`), parse with `BigRational.toBrs` / `getFloat` as appropriate.
- If adding optional numeric columns, use `getFloatOptionColumn` and `Option.bind BigRational.fromFloat`.

Expand Down Expand Up @@ -381,7 +388,7 @@ FSI's `#load` directive resolves relative paths from its *include path*, **not**

## Safety, MDR and Documentation

- This project targets clinical medication workflows. Any change that affects dosing, rules, parsing, or resource mapping must include: unit tests, changelog entry, and an update to `docs/mdr/design-history/0003-resource-requirements.md` if spreadsheet columns or semantics changed.
- This project targets clinical medication workflows. Any change that affects dosing, rules, parsing, or resource mapping must include: unit tests, a changelog entry, and if spreadsheet columns or semantics changed — updated field comments on the corresponding `Data` record in `GenFORM.Lib/Types.fs` plus an updated column-contract test.
- Add notes to CONTRIBUTING.md if the change introduces a new external dependency or changes deployment behavior.

## AI/LLM Usage Policy
Expand All @@ -401,7 +408,7 @@ Contributors must also disclose when code submitted in a pull request is **vibe
- [ ] Small, focused change with < 300 LOC modified when possible.
- [ ] Add or update unit tests covering the change.
- [ ] Ensure `dotnet run servertests` passes locally for affected projects.
- [ ] Update `0003-resource-requirements.md` if spreadsheet column names or semantics change.
- [ ] Update the `Data` record comments and the column-contract test if spreadsheet column names or semantics change.
- [ ] Use conventional commit message with scope and short description.

## Related Documentation
Expand All @@ -412,4 +419,4 @@ Contributors must also disclose when code submitted in a pull request is **vibe
- Architecture: [ARCHITECTURE.md](ARCHITECTURE.md)
- Development setup: [DEVELOPMENT.md](DEVELOPMENT.md)
- Contributing: [CONTRIBUTING.md](CONTRIBUTING.md)
- Domain model: `docs/domain/core-domain.md`
- Domain model: [Core Domain Model](docs/domain/core-domain.md)
16 changes: 8 additions & 8 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ At the start of each session, read these documents for full project context.

### Project governance and workflow

@AGENTS.md
@DEVELOPMENT.md
@CONTRIBUTING.md
- @AGENTS.md
- @DEVELOPMENT.md
- @CONTRIBUTING.md

### Coding standards

@.github/instructions/fsharp-coding.instructions.md
@.github/instructions/fsharp-code-formatting.instructions.md
@.github/instructions/commit-message.instructions.md
- @.github/instructions/fsharp-coding.instructions.md
- @.github/instructions/fsharp-code-formatting.instructions.md
- @.github/instructions/commit-message.instructions.md

### Domain documentation

@docs/domain/core-domain.md
@docs/domain/gensolver-from-orders-to-quantitative-solutions.md
- @docs/domain/core-domain.md
- @docs/domain/gensolver-from-orders-to-quantitative-solutions.md

### Architecture and data

Expand Down
2 changes: 1 addition & 1 deletion docs/data-extraction/doserule-extraction-flowchart.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,6 @@ Each pass writes a per-generic JSON dump to its `passNJsonDir`:
- `src/Informedica.GenFORM.Lib/DoseType.fs:46-98` — `DoseType.fromString` / `toDescription` (canonical `doseType` enum mirrored by Pass 2).
- `src/Informedica.GenFORM.Lib/DoseRule.fs` — `getFromGetData` / `getData` / `processDoseRuleData` / `mapToDoseRule` / `addDoseLimits` / `Print.toMarkdown` / `Print.printGenerics`; the production parser Pass 5 (§6.5) bridges into. `Resources.defaultResourceConfig` / `loadAllResourcesWithConfig` in `src/Informedica.GenFORM.Lib/Api.fs`.
- `data/sources/Rules/doserules.tsv` — final downstream typed-emit target (TBD, §8).
- [`docs/mdr/design-history/0003-resource-requirements.md`](../mdr/design-history/0003-resource-requirements.md) §9 — DoseRules sheet column spec, including the `IsAdult` column and its clearing invariant.
- [`src/Informedica.GenFORM.Lib/DoseRuleData.fs`](../../src/Informedica.GenFORM.Lib/DoseRuleData.fs) — `headers` (canonical DoseRules column order) and `parseDoseRuleData`; the `IsAdult` column and its clearing invariant are specified in [ADR-0021](../mdr/design-history/0021-isadult-patient-category-facet.md).
- [`docs/domain/genform-free-text-to-operational-rules.md`](../domain/genform-free-text-to-operational-rules.md) §3, §5, §6.1, §6.2, **Addendum C.2** (DoseRule field spec; canonical source for `Gender = male / female` etc.).
- [`docs/domain/core-domain.md`](../domain/core-domain.md) — OKRs and rule hierarchy.
3 changes: 1 addition & 2 deletions docs/discrepancies-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This document tracks remaining, actionable mismatches between:

- the current domain documents (especially `docs/domain/core-domain.md` and `docs/domain/genform-free-text-to-operational-rules.md`),
- the resource contract documentation (`docs/mdr/design-history/0003-resource-requirements.md`), and
- the resource contract, which since 2026-08-03 lives on the `Data` record types in `src/Informedica.GenFORM.Lib/Types.fs` rather than in a document, and
- the implemented types used at runtime and across the API boundary.

It intentionally focuses on discrepancies that matter for correctness, shared understanding, or API interoperability. Purely internal representation choices (e.g., using a richer unit type instead of a raw number) are not treated as discrepancies unless they contradict the domain docs.
Expand All @@ -17,7 +17,6 @@ It intentionally focuses on discrepancies that matter for correctness, shared un
- **Documentation**:
- `docs/domain/core-domain.md`
- `docs/domain/genform-free-text-to-operational-rules.md`
- `docs/mdr/design-history/0003-resource-requirements.md`
- **Implementation**:
- `src/Informedica.GenFORM.Lib/Types.fs`
- `src/Informedica.GenORDER.Lib/Types.fs`
Expand Down
5 changes: 3 additions & 2 deletions docs/mdr/design-history/0000-change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Maintain this document as a reverse-chronological log of significant design chan

| Date | ADR | Summary |
|------|-----|---------|
| 2026-08-03 | (retires ADR-0003, ADR-0012) | Spreadsheet column specification retired as a document; the sheet contract now lives on the `Data` record types in `GenFORM.Lib/Types.fs` and is enforced by column-contract tests. See issue #411 |
| 2026-04-30 | [ADR-0020](0020-fhir-r4-integration.md) | FHIR R4 EHR integration design proposed; stateless GenPRES with bidirectional MedicationRequest translation and G-Standard GPK coding |
| 2026-04-27 | [ADR-0019](0019-shared-clinical-calculations.md) | Shared library clinical calculations proposed; BSA, age, and renal eGFR formulas available to both server and client |
| 2026-04-26 | [ADR-0018](0018-nlp-dose-rule-extraction.md) | LLM-based dose-rule extraction pipeline proposed; multi-stage FSX pipeline with human review gate |
Expand All @@ -32,13 +33,13 @@ Maintain this document as a reverse-chronological log of significant design chan
| 2026-03-29 | [ADR-0013](0013-adr-template-based-navigation.md) | Template-based navigation to prescribe view accepted |
| 2026-03-28 | [ADR-0009](0009-mcp-server-architecture.md) | MCP server architecture proposed |
| 2026-03-25 | [ADR-0007](0007-clean-safe-architecture.md) | Clean SAFE architecture accepted (all 4 phases complete) |
| 2025-12-21 | [ADR-0012](0012-resource-verification.md) | Resource requirements verified against GenFORM implementation |
| 2025-12-21 | ADR-0012 (retired 2026-08-03) | Resource requirements verified against GenFORM implementation |
| 2026-03-01 | [ADR-0008](0008-agent-architecture.md) | Agent architecture proposed |
| 2024-01-01 | [ADR-0011](0011-universal-layout-overflow.md) | Universal layout overflow design accepted |
| 2024-01-01 | [ADR-0010](0010-analysis-solve-order-triggers.md) | Analysis of SolveOrder trigger paths |
| 2024-01-01 | [ADR-0006](0006-ui-order-view.md) | Quantitative order constraint navigation proposed |
| 2024-01-01 | [ADR-0005](0005-ui-nutrition-view.md) | Nutrition view layout proposed |
| 2024-01-01 | [ADR-0004](0004-ui-wireframes.md) | UI wireframes accepted |
| 2024-01-01 | [ADR-0003](0003-resource-requirements.md) | Resource requirements specification accepted |
| 2024-01-01 | ADR-0003 (retired 2026-08-03) | Resource requirements specification accepted |
| 2024-01-01 | [ADR-0001](0001-system-architecture.md) | System architecture accepted |
| 2021-12-02 | [ADR-0002](0002-state-of-affairs.md) | State of affairs documented |
Loading