Skip to content

Add interactions#211

Merged
halcwb merged 6 commits intoinformedica:masterfrom
halcwb:add-interactions
Mar 23, 2026
Merged

Add interactions#211
halcwb merged 6 commits intoinformedica:masterfrom
halcwb:add-interactions

Conversation

@halcwb
Copy link
Collaborator

@halcwb halcwb commented Mar 23, 2026

This pull request introduces a new F# library, Informedica.GenINTERACT.Lib, for drug interaction checking, and integrates it into the solution. The library provides types, data loading, interaction checking logic, and a public API, along with scripts and tests for validation. Additionally, the solution and client app are updated to recognize and begin integrating this new functionality.

Key changes:

1. Addition of the drug interaction checking library

  • Added new project Informedica.GenINTERACT.Lib to the solution, including its project file, dependencies, and solution references. (GenPRES.sln, src/Informedica.GenINTERACT.Lib/Informedica.GenINTERACT.Lib.fsproj, src/Informedica.GenINTERACT.Lib/paket.references) [1] [2] [3]
  • Implemented core modules: Types.fs (domain and serialization types), Interactions.fs (interaction logic), Data.fs (data loading and transformation), and Api.fs (public API). (src/Informedica.GenINTERACT.Lib/Types.fs, src/Informedica.GenINTERACT.Lib/Interactions.fs, src/Informedica.GenINTERACT.Lib/Data.fs, src/Informedica.GenINTERACT.Lib/Api.fs) [1] [2] [3] [4]
  • Added scripts for loading and testing the library, including unit tests for the interaction logic. (src/Informedica.GenINTERACT.Lib/Scripts/load.fsx, src/Informedica.GenINTERACT.Lib/Scripts/Interactions.fsx) [1] [2]

2. Solution and project structure updates

  • Registered the new library in the solution file, including build configurations and solution folder placement. (GenPRES.sln) [1] [2]

3. Initial client application integration

  • Extended the client app's Elmish model and message types to include drug interaction checking state and messages. (src/Informedica.GenPRES.Client/App.fs) [1] [2] [3]
  • Added handling for loading and updating interaction results in the Elmish update function. (src/Informedica.GenPRES.Client/App.fs)

These changes lay the foundation for drug interaction checking within the application, providing a reusable library, associated tests, and the beginnings of client-side integration.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 23, 2026

Greptile Summary

This PR introduces Informedica.GenINTERACT.Lib, a new F# library for drug–drug interaction checking, and wires it end-to-end into the GenPRES application (shared types, server ports/adapters, client Elmish model, and a new Views.Interactions page). The overall architecture follows established patterns in the codebase and the feature is functionally complete.

Key changes:

  • New GenINTERACT.Lib library: Types.fs, Data.fs, Interactions.fs, Api.fs for loading and checking drug interactions from a JSON cache.
  • New InteractionPort and server adapter implementations (both direct and agent-based) for serving interaction checks.
  • New Views.Interactions Elmish component with drug input, treatment-plan import, and result table.
  • DrugInteraction shared type added; Interactions: DrugInteraction[] field added to OrderPlan (currently always [||] and unused by the active code path).
  • Bundled bug fix: swapped Name/Indication argument order in two OrderScenario.create calls in ServerApi.Mappers.fs.

Issues to address:

  • tupelizeInteractions_ uses Array.contains inside Array.fold for deduplication, giving O(n²) first-run cost; a HashSet would be more efficient.
  • Table column headers and the "no interactions" message in Views/Interactions.fs are hardcoded Dutch strings, bypassing the localization system.
  • OrderPlan.Interactions is never populated and appears to be dead code.
  • The Data.JSON path computation and DrugInteraction mapping are duplicated between ServerApi.Adapters.fs and ServerApi.AgentAdapters.fs.

Confidence Score: 4/5

  • PR is safe to merge; all issues are non-blocking style/cleanup items with no risk to existing functionality.
  • The feature is complete and correctly integrated end-to-end. The four flagged issues (O(n²) dedup, hardcoded strings, unused OrderPlan field, duplicated adapter helpers) are P2 suggestions — none break the primary path or pose a reliability/security risk. The memoization layer mitigates the performance concern for repeated calls in practice. A 4/5 reflects one small concrete fix (localization) worth doing before wider rollout.
  • src/Informedica.GenINTERACT.Lib/Interactions.fs (dedup performance), src/Informedica.GenPRES.Client/Views/Interactions.fs (hardcoded strings)

Important Files Changed

Filename Overview
src/Informedica.GenINTERACT.Lib/Types.fs Defines domain types (DrugClass, Interaction, DrugInteraction, Check) and cache/serialization types (CacheClass, CacheInteraction, InteractionData); clean type design with clear separation between domain and serialization concerns.
src/Informedica.GenINTERACT.Lib/Interactions.fs Core interaction-checking logic; deduplication in tupelizeInteractions_ uses O(n²) Array.contains inside Array.fold — could be slow on large datasets before the memoization cache warms up.
src/Informedica.GenINTERACT.Lib/Data.fs Loads interaction data from JSON (either supplied string or hardcoded fallback path) and transforms it into the domain Interaction list; straightforward and correct.
src/Informedica.GenINTERACT.Lib/Api.fs Thin public API surface; correctly composes Data.cacheToInteractions with Interactions.check.
src/Informedica.GenPRES.Client/Views/Interactions.fs New Elmish-driven UI view for drug interaction checking; contains hardcoded Dutch strings in table headers and "no interactions found" message that bypass the localization system.
src/Informedica.GenPRES.Client/App.fs Extends Elmish model/messages/update to wire CheckInteractions and LoadInteractionsResult; integration looks correct and consistent with existing patterns.
src/Informedica.GenPRES.Shared/Types.fs Adds DrugInteraction shared type and an Interactions field to OrderPlan; the OrderPlan.Interactions field is initialized to [] but never populated in server handlers — appears to be dead code.
src/Informedica.GenPRES.Server/ServerApi.Adapters.fs Implements the InteractionPort with direct async file-read and mapping; path computation and DrugInteraction mapping logic is duplicated from AgentAdapters.fs.
src/Informedica.GenPRES.Server/ServerApi.AgentAdapters.fs Implements the InteractionPort via a dedicated Agent; contains the same path-resolution and mapping helpers as ServerApi.Adapters.fs — a good candidate for consolidation into a shared helper.
src/Informedica.GenPRES.Server/ServerApi.Command.fs Adds InteractionCmd dispatch branch that calls env.interaction.checkInteractions and wraps the result into InteractionResp; correct and minimal.
src/Informedica.GenPRES.Server/ServerApi.Ports.fs Adds InteractionPort type and wires it into AppEnv; clean and consistent with the existing port pattern.
src/Informedica.GenPRES.Server/ServerApi.Mappers.fs Fixes swapped Name/Indication argument order in two OrderScenario.create calls — an unrelated bug fix bundled with the feature.

Sequence Diagram

sequenceDiagram
    participant UI as Views.Interactions (Client)
    participant App as App.fs (Elmish)
    participant Shared as Shared.Api
    participant Cmd as ServerApi.Command
    participant Port as InteractionPort
    participant Lib as GenINTERACT.Lib.Api
    participant Data as Data.JSON

    UI->>App: CheckInteractions drugNames
    App->>Shared: InteractionCmd(CheckInteractions drugs)
    Shared->>Cmd: handle InteractionCmd
    Cmd->>Port: env.interaction.checkInteractions drugs
    Port->>Data: read Data.JSON (if exists)
    Port->>Lib: Api.checkInteractions json drugs
    Lib->>Lib: Data.cacheToInteractions json
    Lib->>Lib: Interactions.tupelizeInteractions (memoized)
    Lib->>Lib: Interactions.check drugNames pairs
    Lib-->>Port: DrugInteraction list
    Port-->>Cmd: Result<DrugInteraction list, string[]>
    Cmd-->>Shared: InteractionsChecked(interactions[]) wrapped in InteractionResp
    Shared-->>App: LoadInteractionsResult(Finished(Ok msg))
    App->>App: processOk → InteractionResp → Resolved interactions
    App-->>UI: state.Interactions = Resolved interactions
Loading

Fix All in Claude Code

Reviews (1): Last reviewed commit: "Merge branch 'master' into add-interacti..." | Re-trigger Greptile

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an initial drug-interaction checking capability to GenPRES by introducing a new F# library (Informedica.GenINTERACT.Lib), wiring it into the server command pipeline, and exposing a new Interactions page in the client UI.

Changes:

  • Added Informedica.GenINTERACT.Lib (types, JSON loading, interaction-checking logic, API) plus interaction dataset (data/cache/interactions/Data.JSON).
  • Extended the shared API/contracts and server ports/handlers to support InteractionCmd(CheckInteractions ...) and return interaction results.
  • Added an Interactions page and view in the client, including Elmish state/messages and navigation.

Reviewed changes

Copilot reviewed 27 out of 29 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/Informedica.GenPRES.Server.Tests/Tests.fs Updates stubs/fixtures to include the new interaction port and OrderPlan.Interactions field.
src/Informedica.GenPRES.Shared/Types.fs Adds DrugInteraction type and OrderPlan.Interactions.
src/Informedica.GenPRES.Shared/Scripts/Localization.fsx Adds translation entries for Terms.Interactions.
src/Informedica.GenPRES.Shared/Models.fs Ensures OrderPlan.create initializes Interactions.
src/Informedica.GenPRES.Shared/Localization.fs Adds Interactions to the Terms DU.
src/Informedica.GenPRES.Shared/Api.fs Adds InteractionCmd, InteractionResp, and associated DU cases.
src/Informedica.GenPRES.Server/ServerApi.Ports.fs Introduces InteractionPort and adds it to AppEnv.
src/Informedica.GenPRES.Server/ServerApi.Mappers.fs Minor mapper argument ordering adjustments (unrelated to interactions feature logic).
src/Informedica.GenPRES.Server/ServerApi.Command.fs Handles InteractionCmd(CheckInteractions ...) in the server command dispatcher.
src/Informedica.GenPRES.Server/ServerApi.AgentAdapters.fs Adds an agent-backed adapter to load/check interactions using the new library.
src/Informedica.GenPRES.Server/ServerApi.Adapters.fs Adds a non-agent interaction adapter implementation.
src/Informedica.GenPRES.Server/Informedica.GenPRES.Server.fsproj References the new Informedica.GenINTERACT.Lib project.
src/Informedica.GenPRES.Client/Views/Interactions.fs New Interactions UI view (drug input + results table).
src/Informedica.GenPRES.Client/Pages/GenPres.fs Adds Interactions page to navigation and routing.
src/Informedica.GenPRES.Client/MUI.fs Adds WarningAmber icon wrapper.
src/Informedica.GenPRES.Client/Informedica.GenPRES.Client.fsproj Includes the new Views/Interactions.fs in compilation.
src/Informedica.GenPRES.Client/Global.fs Adds Interactions to the global page enum + page title mapping.
src/Informedica.GenPRES.Client/App.fs Adds Elmish state/messages and API dispatch for interaction checking.
src/Informedica.GenINTERACT.Lib/Types.fs Defines interaction domain + cache/serialization DTOs.
src/Informedica.GenINTERACT.Lib/Scripts/load.fsx Script loader for interactive use.
src/Informedica.GenINTERACT.Lib/Scripts/Interactions.fsx Script-based interaction logic + tests (currently duplicates library logic).
src/Informedica.GenINTERACT.Lib/paket.references Adds required packages (Newtonsoft.Json).
src/Informedica.GenINTERACT.Lib/Interactions.fs Implements interaction tuple expansion + checking logic.
src/Informedica.GenINTERACT.Lib/Informedica.GenINTERACT.Lib.fsproj New project definition and file list.
src/Informedica.GenINTERACT.Lib/Data.fs JSON loading + transformation to domain interactions.
src/Informedica.GenINTERACT.Lib/Api.fs Public API entrypoint checkInteractions.
GenPRES.sln Registers the new library project in the solution.
data/cache/interactions/Data.JSON Adds interaction dataset used by the checker.
.gitignore Allows interaction cache JSON and new library folder to be committed.

@halcwb halcwb merged commit 3de3e0f into informedica:master Mar 23, 2026
3 checks passed
@halcwb halcwb deleted the add-interactions branch March 23, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants