From ac0ffb679a69c0fb98f2849611aef6976ca5a37f Mon Sep 17 00:00:00 2001
From: mahdahar <89adham@gmail.com>
Date: Wed, 18 Feb 2026 07:12:45 +0700
Subject: [PATCH] Add comprehensive test types and reference types
documentation
- Document TEST, PARAM, CALC, and GROUP test type categories
- Include usage examples and frontend display guidance
- Provide quick reference card for developers
- Covers standard lab tests, components, calculations, and panels
---
docs/test-types-reference.md | 434 +++++++++++++++++++++++++++++++++++
1 file changed, 434 insertions(+)
create mode 100644 docs/test-types-reference.md
diff --git a/docs/test-types-reference.md b/docs/test-types-reference.md
new file mode 100644
index 0000000..bda2fc0
--- /dev/null
+++ b/docs/test-types-reference.md
@@ -0,0 +1,434 @@
+# ๐ Test Types & Reference Types Guide
+
+> **Quick Overview**: This guide helps you understand the different types of tests and how to display them in the frontend.
+
+---
+
+## ๐ฏ What Are Test Types?
+
+Think of test types as "categories" that determine how a test behaves and what information it needs.
+
+### Quick Reference Card
+
+```
+โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโ
+โ Type โ Use This For... โ Example โ
+โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโค
+โ TEST โ Standard lab tests โ Blood Glucose, CBC โ
+โ PARAM โ Components of a test โ WBC count (in CBC) โ
+โ CALC โ Formula-based results โ BMI, eGFR โ
+โ GROUP โ Panels/batteries โ Lipid Panel, CMP โ
+โ TITLE โ Section headers โ "Hematology Results" โ
+โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโ
+```
+
+---
+
+## ๐งช Detailed Test Types
+
+### 1. TEST - Standard Laboratory Test
+**Icon**: ๐งซ **Color**: Blue
+
+Use this for regular tests that have:
+- Reference ranges (normal values)
+- Units (mg/dL, mmol/L, etc.)
+- Collection requirements
+
+**Example**: Blood Glucose, Hemoglobin, Cholesterol
+
+**What to Display**:
+- Test code and name
+- Reference range
+- Units
+- Collection instructions
+- Expected turnaround time
+
+---
+
+### 2. PARAM - Parameter
+**Icon**: ๐ **Color**: Light Blue
+
+Use this for individual components within a larger test.
+
+**Example**:
+- Complete Blood Count (GROUP) contains:
+ - WBC (PARAM)
+ - RBC (PARAM)
+ - Hemoglobin (PARAM)
+
+**What to Display**:
+- Same as TEST, but shown indented under parent
+- Often part of a GROUP
+
+---
+
+### 3. CALC - Calculated Test
+**Icon**: ๐งฎ **Color**: Purple
+
+Use this for tests computed from other test results using formulas.
+
+**Example**:
+- BMI (calculated from height & weight)
+- eGFR (calculated from creatinine, age, etc.)
+
+**What to Display**:
+- Formula description
+- Input parameters (which tests feed into this)
+- Result value
+- Reference range (if applicable)
+
+**Special Fields**:
+- `FormulaInput` - What values go in?
+- `FormulaCode` - How is it calculated?
+
+---
+
+### 4. GROUP - Group Test (Panel/Battery)
+**Icon**: ๐ฆ **Color**: Green
+
+Use this to bundle multiple related tests together.
+
+**Example**:
+- Lipid Panel (GROUP) contains:
+ - Total Cholesterol (PARAM)
+ - HDL (PARAM)
+ - LDL (PARAM)
+ - Triglycerides (PARAM)
+
+**What to Display**:
+- Group name
+- List of member tests
+- Individual results for each member
+
+**Structure**:
+```
+๐ฆ Lipid Panel (GROUP)
+ โโโ Total Cholesterol (PARAM): 180 mg/dL
+ โโโ HDL (PARAM): 55 mg/dL
+ โโโ LDL (PARAM): 110 mg/dL
+ โโโ Triglycerides (PARAM): 150 mg/dL
+```
+
+---
+
+### 5. TITLE - Section Header
+**Icon**: ๐ **Color**: Gray
+
+Use this for organizing tests into sections on reports.
+
+**Example**: "Hematology", "Chemistry", "Urinalysis"
+
+**What to Display**:
+- Just the title text
+- No results or values
+- Used for organization only
+
+---
+
+## ๐ Reference Types Explained
+
+Reference types tell you **how to interpret the results** - what "normal" looks like.
+
+### Choose Your Reference Type:
+
+```
+ โโโโโโโโโโโโโโโโโโโโโโโโ
+ โ Reference Type? โ
+ โโโโโโโโโโโโฌโโโโโโโโโโโโ
+ โ
+ โโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
+ โ โ โ
+ Numbers? Text values? Threshold?
+ โ โ โ
+ โโโโโโโโผโโโโโโโ โโโโโโโโผโโโโโโโ โโโโโโโโผโโโโโโโ
+ โ NMRC โ โ TEXT โ โ THOLD โ
+ โ (Numeric) โ โ (Text) โ โ (Threshold) โ
+ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ
+ โ โ โ
+ โโโโโโโโผโโโโโโโ โโโโโโโโผโโโโโโโ โโโโโโโโผโโโโโโโ
+ โ RANGE โ โ Free โ โ Positive/ โ
+ โ (Min-Max) โ โ Text โ โ Negative โ
+ โ OR โ โ OR โ โ OR โ
+ โ THOLD โ โ VSET โ โ < > = โ
+ โ (Threshold) โ โ (Dropdown) โ โ cutoff โ
+ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
+```
+
+### Reference Type Details
+
+| Type | Visual | Example |
+|------|--------|---------|
+| **NMRC** - Numeric Range | `70 - 100 mg/dL` | Blood glucose: 70-100 mg/dL |
+| **TEXT** - Text Value | `"Normal"` or `"Positive"` | Urinalysis: "Clear", "Cloudy" |
+| **THOLD** - Threshold | `> 60` or `< 5.5` | eGFR: > 60 (normal) |
+| **VSET** - Value Set | Dropdown options | Organism: [E.coli, Staph, etc.] |
+
+---
+
+## ๐จ Frontend Display Patterns
+
+### Pattern 1: Test List View
+
+```javascript
+// When showing a list of tests
+function renderTestCard(test) {
+ const typeIcon = getIcon(test.TestType);
+ const typeColor = getColor(test.TestType);
+
+ return `
+
+ ${typeIcon}
+
${test.TestSiteName}
+ ${test.TestTypeLabel}
+ ${test.TestSiteCode}
+
+ `;
+}
+```
+
+### Pattern 2: Reference Range Display
+
+```javascript
+// Show reference range based on type
+function renderReferenceRange(test) {
+ switch(test.RefType) {
+ case 'NMRC':
+ return `${test.MinValue} - ${test.MaxValue} ${test.Unit}`;
+
+ case 'TEXT':
+ return test.ReferenceText || 'See report';
+
+ case 'THOLD':
+ return `${test.ThresholdOperator} ${test.ThresholdValue}`;
+
+ case 'VSET':
+ return 'Select from list';
+ }
+}
+```
+
+### Pattern 3: Group Test Expansion
+
+```javascript
+// Expandable group test
+function renderGroupTest(test) {
+ return `
+
+
+
+ ${test.testdefgrp.map(member => renderTestRow(member)).join('')}
+
+
+ `;
+}
+```
+
+---
+
+## ๐๏ธ Data Structure Visualization
+
+### Test Hierarchy
+
+```
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+โ TEST DEFINITION โ
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
+โ TestSiteID: 12345 โ
+โ TestSiteCode: GLUC โ
+โ TestSiteName: Glucose โ
+โ TestType: TEST โ
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
+โ ๐ Additional Info (loaded based on TestType): โ
+โ โ
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
+โ โ TestDefTech (for TEST/PARAM) โ โ
+โ โ - DisciplineID, DepartmentID โ โ
+โ โ - ResultType, RefType โ โ
+โ โ - Unit, Method, ExpectedTAT โ โ
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
+โ โ
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
+โ โ TestDefCal (for CALC) โ โ
+โ โ - FormulaInput, FormulaCode โ โ
+โ โ - RefType, Unit, Decimal โ โ
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
+โ โ
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
+โ โ TestDefGrp (for GROUP) โ โ
+โ โ - Array of member tests โ โ
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
+โ โ
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
+โ โ TestMap (for ALL types) โ โ
+โ โ - Mapping to external systems โ โ
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+```
+
+---
+
+## ๐ก Common Scenarios
+
+### Scenario 1: Creating a Simple Test
+
+**Need**: Add "Hemoglobin" test
+**Choose**: TEST type with NMRC reference
+
+```javascript
+const hemoglobin = {
+ TestSiteCode: 'HGB',
+ TestSiteName: 'Hemoglobin',
+ TestType: 'TEST',
+ testdeftech: {
+ RefType: 'NMRC',
+ Unit: 'g/dL',
+ // Reference range: 12-16 g/dL
+ }
+};
+```
+
+### Scenario 2: Creating a Panel
+
+**Need**: "Complete Blood Count" with multiple components
+**Choose**: GROUP type with PARAM children
+
+```javascript
+const cbc = {
+ TestSiteCode: 'CBC',
+ TestSiteName: 'Complete Blood Count',
+ TestType: 'GROUP',
+ testdefgrp: [
+ { TestSiteCode: 'WBC', TestType: 'PARAM' },
+ { TestSiteCode: 'RBC', TestType: 'PARAM' },
+ { TestSiteCode: 'HGB', TestType: 'PARAM' },
+ { TestSiteCode: 'PLT', TestType: 'PARAM' }
+ ]
+};
+```
+
+### Scenario 3: Calculated Result
+
+**Need**: BMI from height and weight
+**Choose**: CALC type with formula
+
+```javascript
+const bmi = {
+ TestSiteCode: 'BMI',
+ TestSiteName: 'Body Mass Index',
+ TestType: 'CALC',
+ testdefcal: {
+ FormulaInput: 'HEIGHT,WEIGHT',
+ FormulaCode: 'WEIGHT / ((HEIGHT/100) * (HEIGHT/100))',
+ RefType: 'NMRC',
+ Unit: 'kg/mยฒ'
+ }
+};
+```
+
+---
+
+## ๐จ Visual Style Guide
+
+### Color Coding
+
+| Type | Primary Color | Background | Usage |
+|------|---------------|------------|-------|
+| TEST | `#0066CC` | `#E6F2FF` | Main test cards |
+| PARAM | `#3399FF` | `#F0F8FF` | Component rows |
+| CALC | `#9933CC` | `#F5E6FF` | Calculated fields |
+| GROUP | `#00AA44` | `#E6F9EE` | Expandable panels |
+| TITLE | `#666666` | `#F5F5F5` | Section headers |
+
+### Icons
+
+| Type | Icon | Unicode |
+|------|------|---------|
+| TEST | ๐งซ | `\u{1F9EB}` |
+| PARAM | ๐ | `\u{1F4CA}` |
+| CALC | ๐งฎ | `\u{1F9EE}` |
+| GROUP | ๐ฆ | `\u{1F4E6}` |
+| TITLE | ๐ | `\u{1F4CC}` |
+
+---
+
+## ๐ Quick API Reference
+
+### Fetch Tests
+
+```javascript
+// Get all tests for a site
+GET /api/tests?siteId=123
+
+// Get specific test type
+GET /api/tests?testType=GROUP
+
+// Search tests
+GET /api/tests?search=glucose
+
+// Get single test with details
+GET /api/tests/12345
+```
+
+### Value Set Helpers
+
+```javascript
+// Get human-readable labels
+const labels = {
+ testType: valueSet.getLabel('test_type', test.TestType),
+ refType: valueSet.getLabel('reference_type', test.RefType),
+ resultType: valueSet.getLabel('result_type', test.ResultType)
+};
+
+// Get dropdown options
+const testTypes = valueSet.get('test_type');
+// Returns: [{value: "TEST", label: "Test"}, ...]
+```
+
+---
+
+## ๐ Value Set File Locations
+
+```
+app/Libraries/Data/
+โโโ test_type.json # TEST, PARAM, CALC, GROUP, TITLE
+โโโ reference_type.json # NMRC, TEXT, THOLD, VSET
+โโโ result_type.json # NMRIC, RANGE, TEXT, VSET
+โโโ numeric_ref_type.json # RANGE, THOLD
+โโโ text_ref_type.json # VSET, TEXT
+```
+
+---
+
+## โ
Checklist for Frontend Developers
+
+- [ ] Show correct icon for each test type
+- [ ] Display reference ranges based on RefType
+- [ ] Handle GROUP tests as expandable panels
+- [ ] Show TITLE tests as section headers
+- [ ] Display CALC formulas when available
+- [ ] Use ValueSet labels for all coded fields
+- [ ] Respect VisibleScr/VisibleRpt flags
+- [ ] Handle soft-deleted tests (EndDate check)
+
+---
+
+## ๐ Need Help?
+
+**Q: When do I use PARAM vs TEST?**
+A: Use PARAM for sub-components of a GROUP. Use TEST for standalone tests.
+
+**Q: What's the difference between NMRC and THOLD?**
+A: NMRC shows a range (70-100). THOLD shows a threshold (> 60 or < 5.5).
+
+**Q: Can a GROUP contain other GROUPs?**
+A: Yes! Groups can be nested (though typically only 1-2 levels deep).
+
+**Q: How do I know which details to fetch?**
+A: Check `TestType` first, then look for the corresponding property:
+- TEST/PARAM โ `testdeftech`
+- CALC โ `testdefcal`
+- GROUP โ `testdefgrp`
+- All types โ `testmap`
+