Data Schemas
Relevant source files
The following files were used as context for generating this wiki page:The medical calculators application relies on a set of well-defined TypeScript interfaces to ensure type safety and structure for all data. These schemas define the shape of inputs for each calculator, the structure of the calculation results, and the format of static data like medication information and internationalization (i18n) strings. This approach creates a clear data contract between UI components, calculation logic, and data sources.
The primary location for shared type definitions is src/types/index.ts, but some complex calculators define their data structures directly within their respective component files. Static data, such as the pediatric medication database, has its own dedicated file in the src/data/ directory.
Core Calculator Schemas
The application defines distinct input and result interfaces for each calculator, ensuring that each component receives the data it expects and produces a predictable output structure.
Sources: src/types/index.ts, src/calculators/PediatricDoseCalculator.tsx:8-13, src/calculators/BloodGasAnalysisCalculator.tsx:7-80, src/calculators/InfusionTherapyCalculator.tsx:6-48
General Data Flow
The diagram below illustrates the typical data flow for a calculator, where a component takes an Inputs object and produces a Result object.
This diagram shows how user input is structured via an Input interface, processed by the calculator's logic, and then structured into a Result interface for display.
Pediatric Dose Calculator Schema
This schema defines the inputs required for calculating a pediatric medication dose and the structure of the resulting recommendation.
Sources: src/types/index.ts:24-49, src/calculators/PediatricDoseCalculator.tsx:8-21
PediatricDoseInputs Interface
| Field | Type | Description |
|---|---|---|
age | number | null | Age of the child in years. |
weight | number | null | Weight of the child in kilograms. |
height | number | null | Height of the child in centimeters (optional, for BSA calculation). |
medication | string | The name of the medication being calculated. |
indication | string | The reason for administering the medication. |
route | 'oral' | 'iv' | 'im' | 'sc' | The route of administration. |
Sources: src/types/index.ts:24-31
PediatricDoseResult Interface
| Field | Type | Description |
|---|---|---|
isSafe | boolean | Indicates if the calculated dose is considered safe. |
isContraindicated | boolean | Indicates if the medication is contraindicated. |
contraindicationReason | string | The reason for contraindication, if applicable. |
recommendedDose | number | The calculated single dose. |
doseUnit | string | The unit for the recommended dose (e.g., 'mg'). |
frequency | string | The recommended frequency of administration. |
totalDailyDose | number | The total calculated dose for a 24-hour period. |
bsa | number | undefined | Calculated Body Surface Area, if height is provided. |
warnings | string[] | An array of important warnings related to the medication. |
notes | string[] | An array of supplementary notes. |
Sources: src/types/index.ts:33-49
Blood Gas Analysis Schema
This calculator uses complex, locally-defined interfaces for its inputs and results due to the high number of parameters involved in blood gas interpretation.
Sources: src/calculators/BloodGasAnalysisCalculator.tsx:7-80
BloodGasData (Input) Interface
This interface captures all patient data required for a full blood gas analysis, including electrolytes, vitals, and optional parameters for advanced calculations like osmolar gap.
| Field | Type | Description |
|---|---|---|
ph | number | null | Blood pH. |
pco2 | number | null | Partial pressure of carbon dioxide. |
hco3 | number | null | Bicarbonate level. |
pao2 | number | null | Partial pressure of oxygen. |
na | number | null | Sodium level. |
cl | number | null | Chloride level. |
k | number | null | Potassium level. |
sampleType | 'arterial' | 'venous' | Type of blood sample. |
albumin | number | null | Albumin level for corrected anion gap. |
glucose | number | null | Glucose level for osmolar gap calculation. |
bun | number | null | Blood Urea Nitrogen for osmolar gap. |
urineNa | number | null | Urine sodium for urine anion gap. |
hemoglobin | number | null | Hemoglobin for Base Excess calculation. |
oxygenSaturation | number | null | Oxygen saturation for Base Excess calculation. |
Sources: src/calculators/BloodGasAnalysisCalculator.tsx:7-32
BloodGasResult (Output) Interface
The result is a deeply nested object containing calculated values, interpretations, and treatment advice.
The diagram below shows the nested structure of the BloodGasResult interface.
Infusion Therapy Schema
This schema is used for the Infusion Therapy Calculator, which determines fluid requirements for a patient.
Sources: src/types/index.ts:114-159, src/calculators/InfusionTherapyCalculator.tsx:6-48
InfusionTherapyInputs Interface
This interface contains a comprehensive set of patient parameters, from basic demographics to specific clinical conditions like burns or sepsis.
Sources: src/types/index.ts:114-141
InfusionTherapyResult Interface
The result object provides calculated fluid volumes and rates, along with structured recommendations for solutions and monitoring.
The diagram below shows the relationship between the main result and its arrays of recommendations.
Sources: src/types/index.ts:143-159
Pediatric Medication Database Schema
The application uses a static array, pediatricMedicationsDatabase, as its source for medication data. The structure of each object in this array is defined by the PediatricMedication interface.
Sources: src/types/index.ts:51-68, src/data/pediatricMedications.ts
PediatricMedication Interface
This diagram shows the schema for a single medication entry, including its nested dosing methods.
This ER diagram illustrates the structure of a PediatricMedication object and its one-to-many relationship with DosingMethod objects.
Sources: src/types/index.ts:51-68
DosingMethod Type
The type property within the DosingMethod interface is an enum that determines the calculation strategy.
type Value | Description |
|---|---|
weight | Dose is calculated based on patient weight (e.g., mg/kg). |
age | Dose is calculated based on patient age. |
fixed | A fixed dose is used, regardless of age or weight. |
bsa | Dose is calculated based on Body Surface Area. |
Sources: src/types/index.ts:52-57
Internationalization (i18n) Schema
The application supports multiple languages using a schema defined in src/i18n/translations.ts.
Translations Interface
The Translations interface defines a key-value map where each key corresponds to a piece of text in the UI. The translations object then provides the string values for each supported language ('en', 'ru', 'uk').
Sources: src/i18n/translations.ts:3-315
// src/i18n/translations.ts
export type Language = 'en' | 'ru' | 'uk';
export interface Translations {
// Navigation
home: string;
potassium: string;
wounds: string;
// ... more keys
// Calculator specific
currentPotassiumLevel: string;
patientWeight: string;
// ... more keys
}
Sources: src/i18n/translations.ts:1-315
This structure is then populated for each language. For example, data for specific UI elements like select options is defined in other files and adheres to this key-based approach.
Sources: src/i18n/antibioticOptions.ts