|
1 | 1 | module LabTestCategorization
|
2 | 2 | extend ActiveSupport::Concern
|
3 | 3 |
|
4 |
| - LAB_TEST_CATEGORIES = { |
5 |
| - 'Complete Blood Count' => { |
6 |
| - columns: ['Test', 'Method', 'Result', 'Unit', 'Biological Ref. Interval'], |
7 |
| - tests: [ |
8 |
| - 'Hemoglobin', |
9 |
| - 'RBC Count', |
10 |
| - 'Hematocrit', |
11 |
| - 'MCV', |
12 |
| - 'MCH', |
13 |
| - 'MCHC', |
14 |
| - 'RDW CV' |
15 |
| - ] |
16 |
| - }, |
17 |
| - 'Total WBC and Differential Count' => { |
18 |
| - columns: ['Test', 'Method', 'Result', 'Unit', 'Biological Ref. Interval'], |
19 |
| - tests: [ |
20 |
| - 'WBC Count', |
21 |
| - 'Neutrophils', |
22 |
| - 'Lymphocytes', |
23 |
| - 'Eosinophils', |
24 |
| - 'Monocytes', |
25 |
| - 'Basophils', |
26 |
| - 'Platelet Count', |
27 |
| - 'MPV', |
28 |
| - 'Neutrophil', |
29 |
| - 'Lymphocyte', |
30 |
| - 'Eosinophil', |
31 |
| - 'Monocyte', |
32 |
| - 'Basophil', |
33 |
| - 'Platelets', |
34 |
| - 'Mean Platelet Volume' |
35 |
| - ] |
36 |
| - }, |
37 |
| - 'Peripheral Smear Examination' => { |
38 |
| - columns: ['Test', 'Result'], |
39 |
| - tests: [ |
40 |
| - 'RBC Morphology', |
41 |
| - 'WBC Morphology', |
42 |
| - 'Platelets Morphology', |
43 |
| - 'Parasites', |
44 |
| - 'Erythrocyte Sedimentation Rate', |
45 |
| - 'ESR' |
46 |
| - ] |
47 |
| - }, |
48 |
| - 'Blood Group' => { |
49 |
| - columns: ['Test', 'Result', 'Unit', 'Biological Ref. Interval'], |
50 |
| - tests: [ |
51 |
| - 'ABO Type', |
52 |
| - 'Rh (D) Type', |
53 |
| - 'Blood Group', |
54 |
| - 'Rh Type' |
55 |
| - ] |
56 |
| - }, |
57 |
| - 'Lipid Profile' => { |
58 |
| - columns: ['Test', 'Result', 'Unit', 'Biological Ref. Interval'], |
59 |
| - tests: [ |
60 |
| - 'Cholesterol', |
61 |
| - 'Total Cholesterol', |
62 |
| - 'Triglyceride', |
63 |
| - 'HDL Cholesterol', |
64 |
| - 'Direct LDL', |
65 |
| - 'LDL Cholesterol', |
66 |
| - 'VLDL', |
67 |
| - 'CHOL/HDL Ratio', |
68 |
| - 'LDL/HDL Ratio' |
69 |
| - ] |
70 |
| - }, |
71 |
| - 'Biochemistry' => { |
72 |
| - columns: ['Test', 'Result', 'Unit', 'Biological Ref. Interval'], |
73 |
| - tests: [ |
74 |
| - 'Fasting Blood Sugar', |
75 |
| - 'HbA1c', |
76 |
| - 'Glycosylated Hemoglobin', |
77 |
| - 'Mean Blood Glucose', |
78 |
| - 'Microalbumin', |
79 |
| - 'Microalbumin (per urine volume)', |
80 |
| - 'Creatinine', |
81 |
| - 'Creatinine, Serum', |
82 |
| - 'Urea', |
83 |
| - 'Blood Urea Nitrogen', |
84 |
| - 'Uric Acid', |
85 |
| - 'Calcium', |
86 |
| - 'SGPT', |
87 |
| - 'SGOT', |
88 |
| - 'ALT', |
89 |
| - 'AST' |
90 |
| - ] |
91 |
| - }, |
92 |
| - 'Protein' => { |
93 |
| - columns: ['Test', 'Result', 'Unit', 'Biological Ref. Interval'], |
94 |
| - tests: [ |
95 |
| - 'Total Protein', |
96 |
| - 'Albumin', |
97 |
| - 'Globulin', |
98 |
| - 'A/G Ratio', |
99 |
| - 'AG Ratio', |
100 |
| - 'Total Bilirubin', |
101 |
| - 'Conjugated Bilirubin', |
102 |
| - 'Direct Bilirubin', |
103 |
| - 'Unconjugated Bilirubin', |
104 |
| - 'Indirect Bilirubin', |
105 |
| - 'Delta Bilirubin' |
106 |
| - ] |
107 |
| - }, |
108 |
| - 'Iron Studies' => { |
109 |
| - columns: ['Test', 'Result', 'Unit', 'Biological Ref. Interval'], |
110 |
| - tests: [ |
111 |
| - 'Iron', |
112 |
| - 'Serum Iron', |
113 |
| - 'Total Iron Binding Capacity', |
114 |
| - 'TIBC', |
115 |
| - 'Transferrin Saturation' |
116 |
| - ] |
117 |
| - }, |
118 |
| - 'Immunoassay' => { |
119 |
| - columns: ['Test', 'Result', 'Unit', 'Biological Ref. Interval'], |
120 |
| - tests: [ |
121 |
| - 'Homocysteine', |
122 |
| - 'Homocysteine, Serum', |
123 |
| - '25(OH) Vitamin D', |
124 |
| - 'Vitamin D', |
125 |
| - 'Vitamin B12', |
126 |
| - 'PSA', |
127 |
| - 'PSA-Prostate Specific Antigen', |
128 |
| - 'PSA-Prostate Specific Antigen, Total', |
129 |
| - 'IgE', |
130 |
| - 'HIV I & II Ab/Ag with P24 Ag', |
131 |
| - 'HBsAg' |
132 |
| - ] |
133 |
| - }, |
134 |
| - 'HB Electrophoresis By HPLC' => { |
135 |
| - columns: ['Test', 'Result', 'Unit', 'Biological Ref. Interval'], |
136 |
| - tests: [ |
137 |
| - 'Hb A', |
138 |
| - 'Hb A2', |
139 |
| - 'P2 Peak', |
140 |
| - 'P3 Peak', |
141 |
| - 'Foetal Hb', |
142 |
| - 'Interpretation' |
143 |
| - ] |
144 |
| - }, |
145 |
| - 'Bio-Rad CDM System' => { |
146 |
| - columns: ['Test', 'Result'], |
147 |
| - tests: [ |
148 |
| - 'F Concentration', |
149 |
| - 'A2 Concentration' |
150 |
| - ] |
151 |
| - }, |
152 |
| - 'Physical & Chemical Examination' => { |
153 |
| - columns: ['Test', 'Result', 'Unit', 'Biological Ref. Interval'], |
154 |
| - tests: [ |
155 |
| - 'Colour', |
156 |
| - 'Clearity', |
157 |
| - 'pH', |
158 |
| - 'Specific Gravity', |
159 |
| - 'Urine Glucose', |
160 |
| - 'Urine Protein', |
161 |
| - 'Bilirubin', |
162 |
| - 'Urobilinogen', |
163 |
| - 'Urine Ketone', |
164 |
| - 'Nitrite' |
165 |
| - ] |
166 |
| - }, |
167 |
| - 'Microscopic Examination' => { |
168 |
| - columns: ['Test', 'Result', 'Unit', 'Biological Ref. Interval'], |
169 |
| - tests: [ |
170 |
| - 'Pus Cells', |
171 |
| - 'Red Cells', |
172 |
| - 'Epithelial Cells', |
173 |
| - 'Casts', |
174 |
| - 'Crystals', |
175 |
| - 'Amorphous Material' |
176 |
| - ] |
177 |
| - } |
178 |
| - }.freeze |
179 |
| - |
180 |
| - TEST_METHODS = { |
181 |
| - 'Hemoglobin' => 'Colorimetric', |
182 |
| - 'WBC Count' => 'SF Cube cell analysis', |
183 |
| - 'RBC Count' => 'Electrical impedance', |
184 |
| - 'Hematocrit' => 'Calculated', |
185 |
| - 'MCV' => 'Derived', |
186 |
| - 'MCH' => 'Calculated', |
187 |
| - 'MCHC' => 'Calculated', |
188 |
| - 'RDW CV' => 'Calculated', |
189 |
| - 'Platelets' => 'Electrical impedance', |
190 |
| - 'HDL Cholesterol' => 'Direct measurement', |
191 |
| - 'LDL Cholesterol' => 'Calculated', |
192 |
| - 'VLDL' => 'Calculated', |
193 |
| - 'Triglycerides' => 'Enzymatic', |
194 |
| - 'Total Cholesterol' => 'Enzymatic', |
195 |
| - 'Glucose' => 'Hexokinase', |
196 |
| - 'HbA1c' => 'HPLC', |
197 |
| - 'Creatinine' => 'Jaffe method', |
198 |
| - 'Urea' => 'Urease', |
199 |
| - 'SGPT/ALT' => 'IFCC without P5P', |
200 |
| - 'SGOT/AST' => 'IFCC without P5P' |
201 |
| - }.freeze |
202 |
| - |
203 |
| - REFERENCE_RANGES = { |
204 |
| - 'WBC Count' => { min: 4000, max: 10000, unit: 'thousand/cmm' }, |
205 |
| - 'Hemoglobin' => { min: 13, max: 17, unit: 'g/dL' }, |
206 |
| - 'RBC Count' => { min: 4.5, max: 5.5, unit: 'million/cmm' }, |
207 |
| - 'Hematocrit' => { min: 40, max: 50, unit: '%' }, |
208 |
| - 'MCV' => { min: 83, max: 101, unit: 'fL' }, |
209 |
| - 'MCH' => { min: 27, max: 32, unit: 'pg' }, |
210 |
| - 'MCHC' => { min: 32, max: 36, unit: 'g/dL' }, |
211 |
| - 'RDW CV' => { min: 11.6, max: 14.0, unit: '%' }, |
212 |
| - 'Platelets' => { min: 150000, max: 450000, unit: '/cmm' }, |
213 |
| - 'HDL Cholesterol' => { min: 40, max: 60, unit: 'mg/dL' }, |
214 |
| - 'LDL Cholesterol' => { min: 0, max: 100, unit: 'mg/dL' }, |
215 |
| - 'Total Cholesterol' => { min: 0, max: 200, unit: 'mg/dL' }, |
216 |
| - 'Triglycerides' => { min: 0, max: 150, unit: 'mg/dL' }, |
217 |
| - 'Fasting Blood Sugar' => { min: 74, max: 106, unit: 'mg/dL' }, |
218 |
| - 'HbA1c' => { min: 4, max: 5.6, unit: '%' }, |
219 |
| - 'Total Protein' => { min: 6.4, max: 8.2, unit: 'g/dL' }, |
220 |
| - 'Albumin' => { min: 3.5, max: 5.2, unit: 'g/dL' }, |
221 |
| - 'Globulin' => { min: 2.3, max: 3.5, unit: 'g/dL' }, |
222 |
| - 'A/G Ratio' => { min: 1.2, max: 2.2, unit: 'ratio' }, |
223 |
| - 'Total Bilirubin' => { min: 0.3, max: 1.2, unit: 'mg/dL' }, |
224 |
| - 'Conjugated Bilirubin' => { min: 0.0, max: 0.3, unit: 'mg/dL' }, |
225 |
| - 'Direct Bilirubin' => { min: 0.0, max: 0.3, unit: 'mg/dL' }, |
226 |
| - 'Unconjugated Bilirubin' => { min: 0.2, max: 0.9, unit: 'mg/dL' }, |
227 |
| - 'Indirect Bilirubin' => { min: 0.2, max: 0.9, unit: 'mg/dL' }, |
228 |
| - 'Delta Bilirubin' => { min: 0.0, max: 0.2, unit: 'mg/dL' } |
229 |
| - }.freeze |
230 |
| - |
231 | 4 | def format_lab_results(lab_tests)
|
232 | 5 | Rails.logger.debug "\n=== STARTING LAB TEST PROCESSING ==="
|
233 | 6 | Rails.logger.debug "Total lab tests to process: #{lab_tests.size}"
|
|
0 commit comments