Design Decisions

Key design constraints, architectural rationale, tradeoffs, and extensibility notes for Toxicology.

👤 Rushikesh Sakharwade📅 Updated: May 7, 2026📁 Toxicology

Toxicology Design Decisions

Use this page to capture why the feature was built this way, not only what the code does.

Design Intent

Toxicology is designed around a prerequisite-master-data model. Before a lab can reliably configure toxicology behavior, it needs a stable catalog of drugs and controlled collections of those drugs.

The design premise:

toxicology configuration should be built on explicit drug, panel, and brand masters instead of ad hoc free-text setup.

Decision Stack

Key Design Constraints

ConstraintWhy it is realArchitectural consequence
Toxicology drugs need consistent metadataCut off, upper limit, sample type, test type, and unit affect interpretationDrug Master is the base source for toxicology setup
Panels and brands are collections, not standalone test factsThey depend on drugs already existingPanel and Brand flows require searchable drug selection
Panels and brands group drugs for different reasonsPanels group drugs for testing workflow; brands group drugs by drug brand contextSeparate Panel Master and Brand Master screens are maintained
Labs may need defaults and custom recordsSystem defaults reduce setup work, while custom records support lab-specific needsList tabs separate all/system/custom/disabled records
Master records can be operationally disabledRecords may need to stop being selectable without losing historyUI exposes disabled records and bulk/status actions

Architectural Rationale

1. Drug Master is the foundation

Drug records are created before panels and brands because both collections depend on selecting existing drugs.

Why this was preferred

  • avoids duplicate drug definitions inside every panel or brand,
  • keeps toxicology cut off, upper limit, sample type, and unit data in one catalog,
  • makes panel and brand setup easier to validate,
  • gives downstream workflows a stable drug identity to reference.

Alternative we did not choose

Alternative: let panels and brands define drugs inline

Why it was not chosen:

  • it would duplicate drug metadata,
  • updates would drift across collections,
  • validation would be harder,
  • reporting and downstream mapping would become less reliable.

2. Panel Master and Brand Master are separate collection concepts

Panels and brands both collect drugs, but they answer different operational questions.

CollectionQuestion it answers
PanelWhich drugs are grouped together for toxicology testing?
BrandWhich drugs are grouped based on drug brand context?

Keeping them separate makes the UI clearer and keeps backend relationships easier to reason about.

Tradeoffs

TradeoffBenefitCost / risk
Separate master screensClearer workflows for drugs, panels, and brandsUsers must understand setup order
System default and custom listsFaster onboarding while preserving lab-specific setupBackend must preserve record ownership/source semantics
Collection mappings instead of inline drug dataAvoids duplication and driftRequires drug records to exist first

Extensibility Notes

  • Add new toxicology metadata at the Drug Master layer when it describes an individual drug.
  • Add new grouping behavior at the Panel Master or Brand Master layer when it describes a collection.
  • Avoid duplicating drug metadata directly into panel/brand records unless it is a deliberate historical snapshot.
  • Document exact API paths and model names once the livehealthapp, crelio-app, and livehealth-frontend source paths are mapped.

On this page