diff --git a/docs/clqms_database.dbml b/docs/clqms_database.dbml new file mode 100644 index 0000000..edd357c --- /dev/null +++ b/docs/clqms_database.dbml @@ -0,0 +1,640 @@ +// CLQMS Database Schema +// Generated from app/Models/ directory +// Database Markup Language (DBML) for dbdiagram.io and other tools + +// ============================================ +// TABLE 1: Patient Management +// ============================================ + +Table patient { + InternalPID int [pk, increment] + PatientID varchar(255) + AlternatePID varchar(255) + Prefix varchar(50) + NameFirst varchar(255) + NameMiddle varchar(255) + NameMaiden varchar(255) + NameLast varchar(255) + Suffix varchar(50) + NameAlias varchar(255) + Sex varchar(10) + Birthdate datetime + PlaceOfBirth varchar(255) + Street_1 varchar(255) + Street_2 varchar(255) + Street_3 varchar(255) + City varchar(100) + Province varchar(100) + ZIP varchar(20) + Country varchar(100) + EmailAddress1 varchar(255) + EmailAddress2 varchar(255) + Phone varchar(50) + MobilePhone varchar(50) + AccountNumber varchar(100) + Race varchar(50) + MaritalStatus varchar(50) + Religion varchar(50) + Ethnic varchar(50) + Citizenship varchar(100) + DeathIndicator boolean + TimeOfDeath datetime + Custodian int [ref: > patient.InternalPID] + LinkTo int [ref: > patient.InternalPID] + CreateDate datetime [not null] + DelDate datetime +} + +Table patidt { + PatIdtID int [pk, increment] + InternalPID int [not null, ref: > patient.InternalPID] + IdentifierType varchar(100) + Identifier varchar(255) + EffectiveDate datetime + ExpirationDate datetime + CreateDate datetime [not null] + DelDate datetime +} + +Table patcom { + PatComID int [pk, increment] + InternalPID int [not null, ref: > patient.InternalPID] + Comment text + CreateDate datetime [not null] + EndDate datetime +} + +Table patatt { + PatAttID int [pk, increment] + InternalPID int [not null, ref: > patient.InternalPID] + UserID int + Address text + CreateDate datetime [not null] + DelDate datetime +} + +// ============================================ +// TABLE 2: Visit Management +// ============================================ + +Table patvisit { + InternalPVID int [pk, increment] + InternalPID int [not null, ref: > patient.InternalPID] + EpisodeID int + PVID varchar(100) + CreateDate datetime [not null] + EndDate datetime + ArchivedDate datetime + DelDate datetime +} + +Table patvisitadt { + PVADTID int [pk, increment] + InternalPVID int [not null, ref: > patvisit.InternalPVID] + LocationID int [ref: > location.LocationID] + ADTCode varchar(50) + AttDoc varchar(255) + RefDoc varchar(255) + AdmDoc varchar(255) + CnsDoc varchar(255) + CreateDate datetime [not null] + EndDate datetime + ArchivedDate datetime + DelDate datetime +} + +Table patdiag { + InternalPVID int [pk, increment] + InternalPVID int [not null, ref: > patvisit.InternalPVID] + InternalPID int [not null, ref: > patient.InternalPID] + DiagCode varchar(50) + Diagnosis varchar(255) + CreateDate datetime [not null] + EndDate datetime + ArchivedDate datetime + DelDate datetime +} + +// ============================================ +// TABLE 3: Organization Structure +// ============================================ + +Table account { + AccountID int [pk, increment] + AccountName varchar(255) + Initial varchar(50) + Street_1 varchar(255) + Street_2 varchar(255) + Street_3 varchar(255) + City varchar(100) + Province varchar(100) + ZIP varchar(20) + Country varchar(100) + AreaCode varchar(20) + EmailAddress1 varchar(255) + EmailAddress2 varchar(255) + Phone varchar(50) + Fax varchar(50) + Parent int [ref: > account.AccountID] + CreateDate datetime [not null] + EndDate datetime +} + +Table site { + SiteID int [pk, increment] + AccountID int [not null, ref: > account.AccountID] + Parent int [ref: > site.SiteID] + SiteTypeID int + SiteClassID int + SiteCode varchar(50) + SiteName varchar(255) + ME varchar(50) + CreateDate datetime [not null] + EndDate datetime +} + +Table department { + DepartmentID int [pk, increment] + DisciplineID int [ref: > discipline.DisciplineID] + SiteID int [ref: > site.SiteID] + DepartmentCode varchar(50) + DepartmentName varchar(255) + CreateDate datetime [not null] + EndDate datetime +} + +Table discipline { + DisciplineID int [pk, increment] + SiteID int [ref: > site.SiteID] + Parent int [ref: > discipline.DisciplineID] + DisciplineCode varchar(50) + DisciplineName varchar(255) + CreateDate datetime [not null] + EndDate datetime +} + +Table workstation { + WorkstationID int [pk, increment] + DepartmentID int [ref: > department.DepartmentID] + LinkTo int [ref: > workstation.WorkstationID] + EquipmentID int + WorkstationCode varchar(50) + WorkstationName varchar(255) + Type varchar(50) + Enable boolean + CreateDate datetime [not null] + EndDate datetime +} + +// ============================================ +// TABLE 4: Location Management +// ============================================ + +Table location { + LocationID int [pk, increment] + SiteID int [not null, ref: > site.SiteID] + Parent int [ref: > location.LocationID] + LocCode varchar(50) + LocFull varchar(255) + Description text + LocType varchar(50) + CreateDate datetime [not null] + EndDate datetime +} + +Table locationaddress { + LocationID int [pk, ref: > location.LocationID] + Province int [ref: > areageo.AreaGeoID] + City int [ref: > areageo.AreaGeoID] + Street1 varchar(255) + Street2 varchar(255) + PostCode varchar(20) + GeoLocationSystem varchar(50) + GeoLocationData text + Phone varchar(50) + Email varchar(255) + CreateDate datetime [not null] + EndDate datetime +} + +Table areageo { + AreaGeoID int [pk, increment] + Parent int [ref: > areageo.AreaGeoID] + AreaCode varchar(50) + Class varchar(50) + AreaName varchar(255) +} + +// ============================================ +// TABLE 5: Test Management +// ============================================ + +Table testdefsite { + TestSiteID int [pk, increment] + SiteID int [not null, ref: > site.SiteID] + TestSiteCode varchar(50) + TestSiteName varchar(255) + TestType varchar(50) // TEST, PARAM, CALC, GROUP, TITLE + Description text + SeqScr int + SeqRpt int + IndentLeft int + FontStyle varchar(50) + VisibleScr boolean + VisibleRpt boolean + CountStat boolean + CreateDate datetime [not null] + StartDate datetime + EndDate datetime +} + +Table testdeftech { + TestTechID int [pk, increment] + TestSiteID int [not null, ref: > testdefsite.TestSiteID] + DisciplineID int [ref: > discipline.DisciplineID] + DepartmentID int [ref: > department.DepartmentID] + VSet int + ResultType varchar(50) // NM, TX, DT, TM, VS, HL7 + RefType varchar(50) // NUM, TXT, VSET + ReqQty decimal(10,4) + ReqQtyUnit varchar(20) + Unit1 varchar(50) + Factor decimal(10,6) + Unit2 varchar(50) + Decimal int + CollReq text + Method varchar(255) + ExpectedTAT int + CreateDate datetime [not null] + EndDate datetime +} + +Table testdefcal { + TestCalID int [pk, increment] + TestSiteID int [not null, ref: > testdefsite.TestSiteID] + DisciplineID int [ref: > discipline.DisciplineID] + DepartmentID int [ref: > department.DepartmentID] + FormulaInput varchar(500) + FormulaCode text + RefType varchar(50) + Unit1 varchar(50) + Factor decimal(10,6) + Unit2 varchar(50) + Decimal int + Method varchar(255) + CreateDate datetime [not null] + EndDate datetime +} + +Table testdefgrp { + TestGrpID int [pk, increment] + TestSiteID int [not null, ref: > testdefsite.TestSiteID] + Member int [ref: > testdefsite.TestSiteID] + CreateDate datetime [not null] + EndDate datetime +} + +Table testmap { + TestMapID int [pk, increment] + TestSiteID int [not null, ref: > testdefsite.TestSiteID] + ConDefID int [ref: > containerdef.ConDefID] + HostType varchar(50) + HostID varchar(100) + HostDataSource varchar(100) + HostTestCode varchar(100) + HostTestName varchar(255) + ClientType varchar(50) + ClientID varchar(100) + ClientDataSource varchar(100) + ClientTestCode varchar(100) + ClientTestName varchar(255) + CreateDate datetime [not null] + EndDate datetime +} + +// ============================================ +// TABLE 6: Reference Ranges +// ============================================ + +Table refnum { + RefNumID int [pk, increment] + SiteID int [not null, ref: > site.SiteID] + TestSiteID int [not null, ref: > testdefsite.TestSiteID] + SpcType varchar(50) + Sex varchar(10) + Criteria varchar(255) + AgeStart int + AgeEnd int + NumRefType varchar(50) // NR, CR + RangeType varchar(50) // LL-UL, LL, UL, ABS + LowSign varchar(5) + Low decimal(15,5) + HighSign varchar(5) + High decimal(15,5) + Display varchar(50) + Flag varchar(10) + Interpretation text + Notes text + CreateDate datetime [not null] + StartDate datetime + EndDate datetime +} + +Table reftxt { + RefTxtID int [pk, increment] + SiteID int [not null, ref: > site.SiteID] + TestSiteID int [not null, ref: > testdefsite.TestSiteID] + SpcType varchar(50) + Sex varchar(10) + Criteria varchar(255) + AgeStart int + AgeEnd int + TxtRefType varchar(50) // TX, VS + RefTxt text + Flag varchar(10) + Notes text + CreateDate datetime [not null] + StartDate datetime + EndDate datetime +} + +Table refvset { + RefVSetID int [pk, increment] + SiteID int [not null, ref: > site.SiteID] + TestSiteID int [not null, ref: > testdefsite.TestSiteID] + SpcType varchar(50) + Sex varchar(10) + AgeStart int + AgeEnd int + RefTxt varchar(255) + CreateDate datetime [not null] + EndDate datetime +} + +Table refthold { + RefTHoldID int [pk, increment] + SiteID int [not null, ref: > site.SiteID] + TestSiteID int [not null, ref: > testdefsite.TestSiteID] + SpcType varchar(50) + Sex varchar(10) + AgeStart int + AgeEnd int + Threshold decimal(15,5) + BelowTxt text + AboveTxt text + GrayzoneLow decimal(15,5) + GrayzoneHigh decimal(15,5) + GrayzoneTxt text + CreateDate datetime [not null] + EndDate datetime +} + +// ============================================ +// TABLE 7: Specimen Management +// ============================================ + +Table specimen { + InternalSID int [pk, increment] + SID varchar(17) [not null, unique] + SiteID int [not null, ref: > site.SiteID] + OrderID varchar(13) + ConDefID int [ref: > containerdef.ConDefID] + Parent int [ref: > specimen.InternalSID] + Qty decimal(10,4) + Unit varchar(20) + GenerateBy varchar(100) + SchDateTime datetime + CreateDate datetime [not null] + EndDate datetime + ArchiveDate datetime +} + +Table specimenstatus { + SpcStaID int [pk, increment] + SID varchar(17) [not null, ref: > specimen.SID] + OrderID varchar(13) + CurrSiteID int [ref: > site.SiteID] + CurrLocID int [ref: > location.LocationID] + UserID int + SpcAct varchar(50) + ActRes varchar(50) + SpcStatus varchar(50) + Qty decimal(10,4) + Unit varchar(20) + SpcCon varchar(50) + Comment text + Origin varchar(100) + GeoLocationSystem varchar(50) + GeoLocationData text + DIDType varchar(50) + DID varchar(100) + CreateDate datetime [not null] + EndDate datetime + ArchiveDate datetime +} + +Table specimencollection { + SpcColID int [pk, increment] + SpcStaID int [not null, ref: > specimenstatus.SpcStaID] + SpRole varchar(50) + ColMethod varchar(50) + BodySite varchar(50) + CntSize varchar(50) + FastingVolume decimal(10,4) + ColStart datetime + ColEnd datetime + CreateDate datetime [not null] + EndDate datetime + ArchiveDate datetime +} + +Table specimenprep { + SpcPrpID int [pk, increment] + SpcStaID int [not null, ref: > specimenstatus.SpcStaID] + Description text + Method varchar(255) + Additive varchar(100) + AddQty decimal(10,4) + AddUnit varchar(20) + PrepStart datetime + PrepEnd datetime + CreateDate datetime [not null] + EndDate datetime + ArchiveDate datetime +} + +Table containerdef { + ConDefID int [pk, increment] + SiteID int [not null, ref: > site.SiteID] + ConCode varchar(50) + ConName varchar(255) + ConDesc text + Additive varchar(100) + ConClass varchar(50) + Color varchar(50) + CreateDate datetime [not null] + EndDate datetime +} + +// ============================================ +// TABLE 8: Order Management +// ============================================ + +Table ordertest { + InternalOID int [pk, increment] + OrderID varchar(13) [not null, unique] + PlacerID varchar(100) + InternalPID int [not null, ref: > patient.InternalPID] + SiteID int [ref: > site.SiteID] + PVADTID int [ref: > patvisitadt.PVADTID] + ReqApp varchar(100) + Priority varchar(50) + TrnDate datetime + EffDate datetime + CreateDate datetime [not null] + EndDate datetime + ArchiveDate datetime + DelDate datetime +} + +Table patres { + ResultID int [pk, increment] + SiteID int [ref: > site.SiteID] + OrderID varchar(13) + InternalSID int [ref: > specimen.InternalSID] + SID varchar(17) + SampleID varchar(100) + TestSiteID int [ref: > testdefsite.TestSiteID] + WorkstationID int [ref: > workstation.WorkstationID] + EquipmentID int + RefNumID int [ref: > refnum.RefNumID] + RefTxtID int [ref: > reftxt.RefTxtID] + TestSiteCode varchar(50) + AspCnt int + Result text + SampleType varchar(50) + ResultDateTime datetime + CreateDate datetime [not null] + EndDate datetime + ArchiveDate datetime + DelDate datetime +} + +// ============================================ +// TABLE 9: Contact Management +// ============================================ + +Table contact { + ContactID int [pk, increment] + NameFirst varchar(255) + NameLast varchar(255) + Title varchar(100) + Initial varchar(50) + Birthdate datetime + EmailAddress1 varchar(255) + EmailAddress2 varchar(255) + Phone varchar(50) + MobilePhone1 varchar(50) + MobilePhone2 varchar(50) + Specialty varchar(100) + SubSpecialty varchar(100) + CreateDate datetime [not null] + EndDate datetime +} + +Table contactdetail { + ContactDetID int [pk, increment] + ContactID int [not null, ref: > contact.ContactID] + SiteID int [ref: > site.SiteID] + OccupationID int [ref: > occupation.OccupationID] + ContactCode varchar(50) + ContactEmail varchar(255) + JobTitle varchar(100) + Department varchar(100) + ContactStartDate datetime + ContactEndDate datetime +} + +Table medicalspecialty { + SpecialtyID int [pk, increment] + Parent int [ref: > medicalspecialty.SpecialtyID] + SpecialtyText varchar(255) + Title varchar(100) + CreateDate datetime [not null] + EndDate datetime +} + +Table occupation { + OccupationID int [pk, increment] + OccCode varchar(50) + OccText varchar(255) + Description text + CreateDate datetime [not null] +} + +// ============================================ +// TABLE 10: Value Sets +// ============================================ + +Table valuesetdef { + VSetID int [pk, increment] + SiteID int [not null, ref: > site.SiteID] + VSName varchar(255) + VSDesc text + CreateDate datetime [not null] + EndDate datetime +} + +Table valueset { + VID int [pk, increment] + SiteID int [not null, ref: > site.SiteID] + VSetID int [not null, ref: > valuesetdef.VSetID] + VCategory varchar(100) + VOrder int + VValue varchar(255) + VDesc varchar(255) + CreateDate datetime [not null] + EndDate datetime +} + +// ============================================ +// TABLE 11: System / Counter +// ============================================ + +Table counter { + CounterID int [pk, increment] + CounterValue bigint + CounterStart bigint + CounterEnd bigint + CounterReset varchar(50) + CreateDate datetime [not null] + EndDate datetime +} + +Table edgeres { + EdgeResID int [pk, increment] + SiteID int [ref: > site.SiteID] + InstrumentID int + SampleID varchar(100) + PatientID varchar(100) + Payload text + Status varchar(50) + AutoProcess boolean + ProcessedAt datetime + ErrorMessage text + CreateDate datetime [not null] + EndDate datetime + ArchiveDate datetime + DelDate datetime +} + +Table zones { + id int [pk, increment] + name varchar(255) + code varchar(50) + type varchar(50) + description text + status varchar(50) + created_at datetime + updated_at datetime +} diff --git a/docs/test-types-reference.md b/docs/test-types-reference.md deleted file mode 100644 index 899acb5..0000000 --- a/docs/test-types-reference.md +++ /dev/null @@ -1,417 +0,0 @@ -# ๐Ÿ“‹ 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 โ”‚ -โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ -``` - ---- - -## ๐Ÿงช 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 -``` - ---- - -## ๐Ÿ“ 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 | - -### Icons - -| Type | Icon | Unicode | -|------|------|---------| -| TEST | ๐Ÿงซ | `\u{1F9EB}` | -| PARAM | ๐Ÿ“Š | `\u{1F4CA}` | -| CALC | ๐Ÿงฎ | `\u{1F9EE}` | -| GROUP | ๐Ÿ“ฆ | `\u{1F4E6}` | - ---- - -## ๐Ÿ”Œ 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 -โ”œโ”€โ”€ 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 - -- [ ] 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` - diff --git a/src/app.css b/src/app.css index 857ebe7..a1b1a15 100644 --- a/src/app.css +++ b/src/app.css @@ -37,23 +37,41 @@ --color-error: oklch(60% 0.25 25); --color-error-content: oklch(98% 0.01 25); - /* Border radius */ - --radius-selector: 0.5rem; - --radius-field: 0.375rem; - --radius-box: 0.5rem; + /* Border radius - smaller for compact look */ + --radius-selector: 0.25rem; + --radius-field: 0.25rem; + --radius-box: 0.375rem; - /* Base sizes */ - --size-selector: 0.25rem; - --size-field: 0.25rem; + /* Base sizes - reduced for compact UI */ + --size-selector: 0.2rem; + --size-field: 0.2rem; /* Border size */ --border: 1px; /* Effects */ - --depth: 1; + --depth: 0; --noise: 0; } +/* Global compact utility classes */ +@layer utilities { + /* Compact spacing */ + .compact-y { @apply space-y-3; } + .compact-gap { @apply gap-3; } + .compact-p { @apply p-4; } + .compact-py { @apply py-3; } + .compact-px { @apply px-3; } + + /* Compact form elements */ + .compact-input { @apply input-sm; } + .compact-btn { @apply btn-sm; } + .compact-select { @apply select-sm; } + + /* Compact cards */ + .compact-card { @apply p-4; } +} + @theme { /* Custom color helpers */ --color-emerald-50: #ecfdf5; diff --git a/src/lib/api/tests.js b/src/lib/api/tests.js index cd275b5..461d401 100644 --- a/src/lib/api/tests.js +++ b/src/lib/api/tests.js @@ -32,9 +32,24 @@ export async function createTest(data) { // Type-specific fields Unit: data.Unit, Formula: data.Formula, + // Technical Config + ResultType: data.ResultType, + RefType: data.RefType, + SpcType: data.SpcType, + ReqQty: data.ReqQty, + ReqQtyUnit: data.ReqQtyUnit, + Unit1: data.Unit1, + Factor: data.Factor, + Unit2: data.Unit2, + Decimal: data.Decimal, + CollReq: data.CollReq, + Method: data.Method, + ExpectedTAT: data.ExpectedTAT, // Reference ranges (only for TEST and CALC) refnum: data.refnum, reftxt: data.reftxt, + refvset: data.refvset, + refthold: data.refthold, }; return post('/api/tests', payload); } @@ -54,9 +69,24 @@ export async function updateTest(data) { // Type-specific fields Unit: data.Unit, Formula: data.Formula, + // Technical Config + ResultType: data.ResultType, + RefType: data.RefType, + SpcType: data.SpcType, + ReqQty: data.ReqQty, + ReqQtyUnit: data.ReqQtyUnit, + Unit1: data.Unit1, + Factor: data.Factor, + Unit2: data.Unit2, + Decimal: data.Decimal, + CollReq: data.CollReq, + Method: data.Method, + ExpectedTAT: data.ExpectedTAT, // Reference ranges (only for TEST and CALC) refnum: data.refnum, reftxt: data.reftxt, + refvset: data.refvset, + refthold: data.refthold, }; return patch('/api/tests', payload); } diff --git a/src/lib/components/DataTable.svelte b/src/lib/components/DataTable.svelte index 85ab52f..07dfa29 100644 --- a/src/lib/components/DataTable.svelte +++ b/src/lib/components/DataTable.svelte @@ -64,7 +64,7 @@
- +
{#each columns as column} diff --git a/src/lib/components/Modal.svelte b/src/lib/components/Modal.svelte index 6f40ae5..284e9fc 100644 --- a/src/lib/components/Modal.svelte +++ b/src/lib/components/Modal.svelte @@ -7,6 +7,7 @@ * @property {string} [title] - Modal title * @property {string} [size] - Modal size (sm, md, lg, xl, full) * @property {boolean} [closable] - Whether modal can be closed by clicking backdrop + * @property {'center' | 'top'} [position] - Modal position (center or top) * @property {Function} [onClose] - Callback when modal is closed * @property {import('svelte').Snippet} [children] - Modal content * @property {import('svelte').Snippet} [footer] - Modal footer @@ -18,6 +19,7 @@ title = '', size = 'md', closable = true, + position = 'center', onClose = null, children, footer, @@ -33,12 +35,12 @@ }; const widthStyles = { - sm: 'max-width: 400px;', - md: 'max-width: 500px;', - lg: 'max-width: 800px;', - xl: 'max-width: 1200px;', + sm: 'max-width: 350px;', + md: 'max-width: 450px;', + lg: 'max-width: 700px;', + xl: 'max-width: 1000px;', full: 'max-width: 100%; width: 100%; height: 100%;', - wide: 'max-width: 90vw; width: 1200px;', + wide: 'max-width: 90vw; width: 1000px;', }; /** @@ -77,7 +79,7 @@ -