@ecrvs/opencrvs-toolkit 1.8.1-rc.9775e4e → 1.8.1-rc.a2d23b7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1897,6 +1897,1192 @@ var import_zod23 = require("zod");
1897
1897
  // ../commons/src/events/FieldTypeMapping.ts
1898
1898
  var import_zod22 = require("zod");
1899
1899
 
1900
+ // ../commons/src/conditionals/abbreviation.ts
1901
+ var medicalAbbreviations = [
1902
+ {
1903
+ code: "AAA",
1904
+ label: "Abdominal Aortic Aneurysm"
1905
+ },
1906
+ {
1907
+ code: "ABLA",
1908
+ label: "Acute Blood Loss Anemia"
1909
+ },
1910
+ {
1911
+ code: "ACS",
1912
+ label: "Acute Coronary Syndrome"
1913
+ },
1914
+ {
1915
+ code: "ADD",
1916
+ label: "Acute Demyelinating Disease"
1917
+ },
1918
+ {
1919
+ code: "ADF",
1920
+ label: "Aorto Duodenal Fistula"
1921
+ },
1922
+ {
1923
+ code: "ADHD",
1924
+ label: "Attention Deficit Hyperactivity Disorder"
1925
+ },
1926
+ {
1927
+ code: "AE",
1928
+ label: "Acute Exacerbation"
1929
+ },
1930
+ {
1931
+ code: "AF",
1932
+ label: "Atrial Fibrillation"
1933
+ },
1934
+ {
1935
+ code: "A-FIB",
1936
+ label: "Atrial Fibrillation"
1937
+ },
1938
+ {
1939
+ code: "AFL",
1940
+ label: "Atrial Flutter"
1941
+ },
1942
+ {
1943
+ code: "AFL",
1944
+ label: "Alcoholic Fatty Liver"
1945
+ },
1946
+ {
1947
+ code: "AGE",
1948
+ label: "Acute Gastroenteritis"
1949
+ },
1950
+ {
1951
+ code: "AGN",
1952
+ label: "Acute Glomerunephritis"
1953
+ },
1954
+ {
1955
+ code: "AHA",
1956
+ label: "Acquired Haemolytic Anemia"
1957
+ },
1958
+ {
1959
+ code: "AHCVD",
1960
+ label: "Arteriosclerotic Hypertensive Cardiovascular Disease"
1961
+ },
1962
+ {
1963
+ code: "AHD",
1964
+ label: "Atherosclerotic Heart Disease"
1965
+ },
1966
+ {
1967
+ code: "AI",
1968
+ label: "Aortic Insufficiency"
1969
+ },
1970
+ {
1971
+ code: "AIHD",
1972
+ label: "Acute Ischaemic Heart Disease"
1973
+ },
1974
+ {
1975
+ code: "AKA",
1976
+ label: "Above Knee Amputation"
1977
+ },
1978
+ {
1979
+ code: "AKI",
1980
+ label: "Acute Kidney Injury"
1981
+ },
1982
+ {
1983
+ code: "ALD",
1984
+ label: "Alcohol Liver Disease"
1985
+ },
1986
+ {
1987
+ code: "ALL",
1988
+ label: "Acute Lymphocytic Leukemia"
1989
+ },
1990
+ {
1991
+ code: "ALS",
1992
+ label: "Amyotrophic Lateral Sclerosis"
1993
+ },
1994
+ {
1995
+ code: "AMI",
1996
+ label: "Acute Myocardial Infarction"
1997
+ },
1998
+ {
1999
+ code: "AML",
2000
+ label: "Acute Myeloid Leukemia"
2001
+ },
2002
+ {
2003
+ code: "AML",
2004
+ label: "Acute Myelogeneous Leukemia"
2005
+ },
2006
+ {
2007
+ code: "AMML",
2008
+ label: "Acute Myelomonocytic Leukemia"
2009
+ },
2010
+ {
2011
+ code: "APAS",
2012
+ label: "Antiphospolipid Antibody Syndrome"
2013
+ },
2014
+ {
2015
+ code: "APCD",
2016
+ label: "Acquired Prothrombin Complex Deficiency"
2017
+ },
2018
+ {
2019
+ code: "APUD",
2020
+ label: "Acute Peptic Ulcer Disease"
2021
+ },
2022
+ {
2023
+ code: "ARDS",
2024
+ label: "Acute Respiratory Distress Syndrome"
2025
+ },
2026
+ {
2027
+ code: "ARF",
2028
+ label: "Acute Renal Failure"
2029
+ },
2030
+ {
2031
+ code: "ARF",
2032
+ label: "Acute Respiratory Failure"
2033
+ },
2034
+ {
2035
+ code: "AS",
2036
+ label: "Aortic Stenosis"
2037
+ },
2038
+ {
2039
+ code: "ASCVD",
2040
+ label: "Atherosclerotic Cardiovascular Disease"
2041
+ },
2042
+ {
2043
+ code: "ASD",
2044
+ label: "Atrial Septal Defect"
2045
+ },
2046
+ {
2047
+ code: "ASH",
2048
+ label: "Acute Subdural Hematoma"
2049
+ },
2050
+ {
2051
+ code: "ASHD",
2052
+ label: "Arteriosclerotic Heart Disease"
2053
+ },
2054
+ {
2055
+ code: "ASHF",
2056
+ label: "Acute Systolic Heart Failure"
2057
+ },
2058
+ {
2059
+ code: "ATN",
2060
+ label: "Acute Tubular Nephritis"
2061
+ },
2062
+ {
2063
+ code: "AUB",
2064
+ label: "Abnormal Uterine Bleeding"
2065
+ },
2066
+ {
2067
+ code: "AURI",
2068
+ label: "Acute Upper Respiratory Infection"
2069
+ },
2070
+ {
2071
+ code: "AV",
2072
+ label: "Atrioventricular Malformation"
2073
+ },
2074
+ {
2075
+ code: "AV FISTULA",
2076
+ label: "Arteriovenous Fistula"
2077
+ },
2078
+ {
2079
+ code: "AVD",
2080
+ label: "Atrioventricular Dissociation"
2081
+ },
2082
+ {
2083
+ code: "BA",
2084
+ label: "Bronchial Asthma"
2085
+ },
2086
+ {
2087
+ code: "BAIAE",
2088
+ label: "Bronchial Asthma In Acute Exacerbation"
2089
+ },
2090
+ {
2091
+ code: "BBB",
2092
+ label: "Bundle Branch Block"
2093
+ },
2094
+ {
2095
+ code: "BEV",
2096
+ label: "Bleeding Esophageal Varices"
2097
+ },
2098
+ {
2099
+ code: "BFC",
2100
+ label: "Benign Febrile Convulsion"
2101
+ },
2102
+ {
2103
+ code: "BG",
2104
+ label: "Basal Ganglia"
2105
+ },
2106
+ {
2107
+ code: "BKA",
2108
+ label: "Below Knee Amputation"
2109
+ },
2110
+ {
2111
+ code: "BPH",
2112
+ label: "Benign Prostatic Hypertrophy"
2113
+ },
2114
+ {
2115
+ code: "BPN",
2116
+ label: "Bronchopnuemonia"
2117
+ },
2118
+ {
2119
+ code: "BPUD",
2120
+ label: "Bleeding Peptic Ulcer Disease"
2121
+ },
2122
+ {
2123
+ code: "CA",
2124
+ label: "Carcinoma / Cancer"
2125
+ },
2126
+ {
2127
+ code: "CABG",
2128
+ label: "Coronary Artery Bypass Graft"
2129
+ },
2130
+ {
2131
+ code: "CAD",
2132
+ label: "Coronary Artery Disease"
2133
+ },
2134
+ {
2135
+ code: "CAP",
2136
+ label: "Community Acquired Pneumonia"
2137
+ },
2138
+ {
2139
+ code: "CBD STONE",
2140
+ label: "Common Bile Duct"
2141
+ },
2142
+ {
2143
+ code: "CD",
2144
+ label: "Cardiac Dysrhythmia"
2145
+ },
2146
+ {
2147
+ code: "CF",
2148
+ label: "Cystic Fibrosis"
2149
+ },
2150
+ {
2151
+ code: "CGN",
2152
+ label: "Chronic Glomerulonephritis"
2153
+ },
2154
+ {
2155
+ code: "CHD",
2156
+ label: "Congenital Heart Disease"
2157
+ },
2158
+ {
2159
+ code: "CHF",
2160
+ label: "Congestive Heart Failure"
2161
+ },
2162
+ {
2163
+ code: "CHVD",
2164
+ label: "Chronic Hypertensive Vascular Disease"
2165
+ },
2166
+ {
2167
+ code: "CIHD",
2168
+ label: "Chronic Ischaemic Heart Disease"
2169
+ },
2170
+ {
2171
+ code: "CKD",
2172
+ label: "Chronic Kidney Disease"
2173
+ },
2174
+ {
2175
+ code: "CLD",
2176
+ label: "Chronic Liver Disease"
2177
+ },
2178
+ {
2179
+ code: "CLL",
2180
+ label: "Chronic Lymphocytic Leukemia"
2181
+ },
2182
+ {
2183
+ code: "CML",
2184
+ label: "Chronic Myelogenous Leukaemia"
2185
+ },
2186
+ {
2187
+ code: "CNS",
2188
+ label: "Central Nervous System"
2189
+ },
2190
+ {
2191
+ code: "CNS INFECTION",
2192
+ label: "Central Nervous System Infection"
2193
+ },
2194
+ {
2195
+ code: "COPD",
2196
+ label: "Chronic Obstructive Pulmonary Disease"
2197
+ },
2198
+ {
2199
+ code: "CPA",
2200
+ label: "Cardiopulmonary Arrest"
2201
+ },
2202
+ {
2203
+ code: "CPC OF THE LIVER",
2204
+ label: "Chronic Passive Congestion Of The Liver"
2205
+ },
2206
+ {
2207
+ code: "CRA",
2208
+ label: "Cardiorespiratory Arrest"
2209
+ },
2210
+ {
2211
+ code: "CRF",
2212
+ label: "Chronic Renal Failure"
2213
+ },
2214
+ {
2215
+ code: "CRF",
2216
+ label: "Cardiorespiratory Failure"
2217
+ },
2218
+ {
2219
+ code: "CRI",
2220
+ label: "Chronic Renal Insufficiency"
2221
+ },
2222
+ {
2223
+ code: "CS",
2224
+ label: "Cesarean Section"
2225
+ },
2226
+ {
2227
+ code: "CSHF",
2228
+ label: "Chronic Systolic Heart Failure"
2229
+ },
2230
+ {
2231
+ code: "CTS",
2232
+ label: "Carpal Tunnel Syndrome"
2233
+ },
2234
+ {
2235
+ code: "CVA",
2236
+ label: "Cerebrovascular Accident"
2237
+ },
2238
+ {
2239
+ code: "CVD",
2240
+ label: "Cardiovascular Disease"
2241
+ },
2242
+ {
2243
+ code: "CVD",
2244
+ label: "Cerebrovascular Disease"
2245
+ },
2246
+ {
2247
+ code: "CVS",
2248
+ label: "Cardiovascular System"
2249
+ },
2250
+ {
2251
+ code: "DCIS",
2252
+ label: "Ductal Carcinoma In Situ"
2253
+ },
2254
+ {
2255
+ code: "DCM",
2256
+ label: "Dilated Cardiomyopathy"
2257
+ },
2258
+ {
2259
+ code: "DF",
2260
+ label: "Dengue Fever"
2261
+ },
2262
+ {
2263
+ code: "DHF",
2264
+ label: "Dengue Haemorrhagic Fever"
2265
+ },
2266
+ {
2267
+ code: "DHN",
2268
+ label: "Dehydration"
2269
+ },
2270
+ {
2271
+ code: "DIC",
2272
+ label: "Disseminated Intravascular Coagulation"
2273
+ },
2274
+ {
2275
+ code: "DISH",
2276
+ label: "Diffuse Idiopathic Skeletal Hyperostosis"
2277
+ },
2278
+ {
2279
+ code: "DKA",
2280
+ label: "Diabetic Ketoacidosis"
2281
+ },
2282
+ {
2283
+ code: "DKD",
2284
+ label: "Diabetic Kidney Disease"
2285
+ },
2286
+ {
2287
+ code: "DM",
2288
+ label: "Diabetes Mellitus"
2289
+ },
2290
+ {
2291
+ code: "DM 2",
2292
+ label: "Diabetes Mellitus Type II"
2293
+ },
2294
+ {
2295
+ code: "DM1",
2296
+ label: "Diabetes Mellitus Type I"
2297
+ },
2298
+ {
2299
+ code: "DOA",
2300
+ label: "Dead On Arrival"
2301
+ },
2302
+ {
2303
+ code: "DVT",
2304
+ label: "Deep Venous Thrombosis"
2305
+ },
2306
+ {
2307
+ code: "ECV",
2308
+ label: "Extra Cellular Volume"
2309
+ },
2310
+ {
2311
+ code: "EF",
2312
+ label: "Ejection Fraction"
2313
+ },
2314
+ {
2315
+ code: "ESRD",
2316
+ label: "End Stage Renal Disease"
2317
+ },
2318
+ {
2319
+ code: "FTT",
2320
+ label: "Failure To Thrive"
2321
+ },
2322
+ {
2323
+ code: "GDM",
2324
+ label: "Gestational Diabetes Mellitus"
2325
+ },
2326
+ {
2327
+ code: "GERD",
2328
+ label: "Gastroesophageal Reflux Disease"
2329
+ },
2330
+ {
2331
+ code: "GPN",
2332
+ label: "Glomerulonephritis"
2333
+ },
2334
+ {
2335
+ code: "GSW",
2336
+ label: "Gunshot Wound"
2337
+ },
2338
+ {
2339
+ code: "GTC",
2340
+ label: "Generalized Tonic Clonic Seizure"
2341
+ },
2342
+ {
2343
+ code: "GTN",
2344
+ label: "Glyceryl Trinitrate"
2345
+ },
2346
+ {
2347
+ code: "HACVD",
2348
+ label: "Hypertensive Atherosclerotic Cardiovascular Disease"
2349
+ },
2350
+ {
2351
+ code: "HAP",
2352
+ label: "Healthcare Associated Pneumonia"
2353
+ },
2354
+ {
2355
+ code: "HAP",
2356
+ label: "Hospital Acquired Pneumonia"
2357
+ },
2358
+ {
2359
+ code: "HASCVD",
2360
+ label: "Hypertensive Atherosclerotic Cardiovascular Disease"
2361
+ },
2362
+ {
2363
+ code: "HCVD",
2364
+ label: "Hypertensive Cardiovascular Disease"
2365
+ },
2366
+ {
2367
+ code: "HD",
2368
+ label: "Heart Disease"
2369
+ },
2370
+ {
2371
+ code: "HELLP",
2372
+ label: "Hemolysis Elevated Liver Emzymes & Low Platelet Count"
2373
+ },
2374
+ {
2375
+ code: "HGE",
2376
+ label: "Haemorrhage"
2377
+ },
2378
+ {
2379
+ code: "HHD",
2380
+ label: "Hypertensive Heart Disease"
2381
+ },
2382
+ {
2383
+ code: "HHS",
2384
+ label: "Hyperglycaemic Hyperosmolar State"
2385
+ },
2386
+ {
2387
+ code: "HIE",
2388
+ label: "Hypoxic Ischemic Encephalopathy"
2389
+ },
2390
+ {
2391
+ code: "HMD",
2392
+ label: "Hyaline Membrane Disease"
2393
+ },
2394
+ {
2395
+ code: "HPN",
2396
+ label: "Hypertension"
2397
+ },
2398
+ {
2399
+ code: "HPNNS",
2400
+ label: "Hypertensive Nephrosclerosis"
2401
+ },
2402
+ {
2403
+ code: "HPV",
2404
+ label: "Human Papilloma Virus"
2405
+ },
2406
+ {
2407
+ code: "HRAD",
2408
+ label: "Hyperactive Airway Disease"
2409
+ },
2410
+ {
2411
+ code: "HSV",
2412
+ label: "Herpes Simplex Virus"
2413
+ },
2414
+ {
2415
+ code: "HTN",
2416
+ label: "Hypertension"
2417
+ },
2418
+ {
2419
+ code: "IBD",
2420
+ label: "Inflammatory Bowel Disease"
2421
+ },
2422
+ {
2423
+ code: "IBS",
2424
+ label: "Irritable Bowel Syndrome"
2425
+ },
2426
+ {
2427
+ code: "ICH",
2428
+ label: "Intracerebral Hemmorhage"
2429
+ },
2430
+ {
2431
+ code: "ICMP",
2432
+ label: "Ischemic Cardiomyopathy"
2433
+ },
2434
+ {
2435
+ code: "ICP",
2436
+ label: "Idiopathic Thrombocytopenic Purpura"
2437
+ },
2438
+ {
2439
+ code: "IDA",
2440
+ label: "Iron Deficiency Anemia"
2441
+ },
2442
+ {
2443
+ code: "IDCA",
2444
+ label: "Infiltrating Ductal Carcinoma"
2445
+ },
2446
+ {
2447
+ code: "IDDM",
2448
+ label: "Insulin Dependent Diabetic Mellitus"
2449
+ },
2450
+ {
2451
+ code: "IED",
2452
+ label: "Improvise Explosive Device (Undetermined Intent)"
2453
+ },
2454
+ {
2455
+ code: "IHD",
2456
+ label: "Ischemic Heart Disease"
2457
+ },
2458
+ {
2459
+ code: "ITP",
2460
+ label: "Idiopatic Thrombocytopenic Purpura"
2461
+ },
2462
+ {
2463
+ code: "IUFD",
2464
+ label: "Intrauterine Fetal Demise, Death"
2465
+ },
2466
+ {
2467
+ code: "IUGR",
2468
+ label: "Intrauterine Growth Retardation"
2469
+ },
2470
+ {
2471
+ code: "IVH",
2472
+ label: "Intraventricular Hemorrhage"
2473
+ },
2474
+ {
2475
+ code: "LCIS",
2476
+ label: "Lobular Carcinoma In Situ"
2477
+ },
2478
+ {
2479
+ code: "LGIB",
2480
+ label: "Lower Gastrointerstinal Bleeding"
2481
+ },
2482
+ {
2483
+ code: "LVD",
2484
+ label: "Left Ventricular Dysfunction"
2485
+ },
2486
+ {
2487
+ code: "LVH",
2488
+ label: "Left Ventricle Hypertrophy"
2489
+ },
2490
+ {
2491
+ code: "MDF",
2492
+ label: "Multiple Dysfunction Failure"
2493
+ },
2494
+ {
2495
+ code: "MDR TB",
2496
+ label: "Multi Drug Resistant Tuberculosis"
2497
+ },
2498
+ {
2499
+ code: "MI",
2500
+ label: "Myocardial Infarction"
2501
+ },
2502
+ {
2503
+ code: "MOD",
2504
+ label: "Multi Organ Dysfunction"
2505
+ },
2506
+ {
2507
+ code: "MOF",
2508
+ label: "Multiple Organ Failure"
2509
+ },
2510
+ {
2511
+ code: "MPD",
2512
+ label: "Myeloproliferative Disease"
2513
+ },
2514
+ {
2515
+ code: "MPI",
2516
+ label: "Multiple Physical Injury"
2517
+ },
2518
+ {
2519
+ code: "MR",
2520
+ label: "Mitral Regurgitation"
2521
+ },
2522
+ {
2523
+ code: "MRSA",
2524
+ label: "Methicillin Resistant Staphylococcus Aureus"
2525
+ },
2526
+ {
2527
+ code: "MS",
2528
+ label: "Multiple Sclerosis"
2529
+ },
2530
+ {
2531
+ code: "MVA",
2532
+ label: "Motor-Vehicle Accident"
2533
+ },
2534
+ {
2535
+ code: "MVP",
2536
+ label: "Mitral Valve Prolapse"
2537
+ },
2538
+ {
2539
+ code: "MVR",
2540
+ label: "Fast Venticular Response"
2541
+ },
2542
+ {
2543
+ code: "NAFL",
2544
+ label: "Non Alcoholic Fatty Liver"
2545
+ },
2546
+ {
2547
+ code: "NASH",
2548
+ label: "Non Alcoholic Steato Hepatitis"
2549
+ },
2550
+ {
2551
+ code: "NHL",
2552
+ label: "Non-Hodgkins Lymphoma"
2553
+ },
2554
+ {
2555
+ code: "NIDDM",
2556
+ label: "Non Insulin Dependent Diabetes Mellitus"
2557
+ },
2558
+ {
2559
+ code: "NIF",
2560
+ label: "Not In Failure"
2561
+ },
2562
+ {
2563
+ code: "NOS",
2564
+ label: "Not Otherwise Specified"
2565
+ },
2566
+ {
2567
+ code: "NSAID",
2568
+ label: "Non Steroidal Anti-Inflammatory Drugs"
2569
+ },
2570
+ {
2571
+ code: "NSD",
2572
+ label: "Normal Spontaneous Delivery"
2573
+ },
2574
+ {
2575
+ code: "NSTEMI",
2576
+ label: "Non-St Elevation Myocardial Infarction"
2577
+ },
2578
+ {
2579
+ code: "NSTEMI",
2580
+ label: "Non Segment St Elevation Myocardial Infarction"
2581
+ },
2582
+ {
2583
+ code: "OU",
2584
+ label: "Obstructive Uropathy"
2585
+ },
2586
+ {
2587
+ code: "PAOD",
2588
+ label: "Peripheral Artery Occlusive Disease"
2589
+ },
2590
+ {
2591
+ code: "PCA",
2592
+ label: "Pontine Cerebrovascular Accident"
2593
+ },
2594
+ {
2595
+ code: "PCAP",
2596
+ label: "Pediatric Community Acquired Pneumonia"
2597
+ },
2598
+ {
2599
+ code: "PDA",
2600
+ label: "Patent Ductus Arteriosus"
2601
+ },
2602
+ {
2603
+ code: "PDSTB",
2604
+ label: "Presumptive Drug Sensitive Tuberculosis"
2605
+ },
2606
+ {
2607
+ code: "PICAI",
2608
+ label: "Paroxismal Internal Carotid Artery Infarction"
2609
+ },
2610
+ {
2611
+ code: "PID",
2612
+ label: "Pelvic Inflammatory Disease"
2613
+ },
2614
+ {
2615
+ code: "PIH",
2616
+ label: "Pregnancy Induced Hypertension"
2617
+ },
2618
+ {
2619
+ code: "PPH",
2620
+ label: "Primary Pulmonary Hypertension"
2621
+ },
2622
+ {
2623
+ code: "PPHN",
2624
+ label: "Persistent Pulmonary Hypertension Of The Newborn"
2625
+ },
2626
+ {
2627
+ code: "PSGN",
2628
+ label: "Poststreptococcal Glomerulonephritis"
2629
+ },
2630
+ {
2631
+ code: "PTB",
2632
+ label: "Pulmonary Tuberculosis"
2633
+ },
2634
+ {
2635
+ code: "PTE",
2636
+ label: "Pulmonary Thromboembolism"
2637
+ },
2638
+ {
2639
+ code: "PUD",
2640
+ label: "Peptic Ulcer Disease"
2641
+ },
2642
+ {
2643
+ code: "RCMP",
2644
+ label: "Restricted Cardiomyopathy"
2645
+ },
2646
+ {
2647
+ code: "RDS",
2648
+ label: "Respiratory Distress Syndrome"
2649
+ },
2650
+ {
2651
+ code: "RHD",
2652
+ label: "Rheumatic Heart Disease"
2653
+ },
2654
+ {
2655
+ code: "RIA",
2656
+ label: "Ruptured Intracranial Aneurysm"
2657
+ },
2658
+ {
2659
+ code: "RMCA",
2660
+ label: "Right Medial Cerebral Artery"
2661
+ },
2662
+ {
2663
+ code: "RSV",
2664
+ label: "Respiratory Syncytial Virus"
2665
+ },
2666
+ {
2667
+ code: "RTA",
2668
+ label: "Road-Traffic Accident"
2669
+ },
2670
+ {
2671
+ code: "RTC",
2672
+ label: "Road Traffic Crash"
2673
+ },
2674
+ {
2675
+ code: "RTI",
2676
+ label: "Respiratory Tract Infection"
2677
+ },
2678
+ {
2679
+ code: "RVR",
2680
+ label: "Rapid Ventricular Response"
2681
+ },
2682
+ {
2683
+ code: "SAH",
2684
+ label: "Subarachnoid Haemorrhage"
2685
+ },
2686
+ {
2687
+ code: "SARS",
2688
+ label: "Severe Acute Respiratory Syndrome"
2689
+ },
2690
+ {
2691
+ code: "SDC",
2692
+ label: "Sudden Cardiac Death"
2693
+ },
2694
+ {
2695
+ code: "SIDS",
2696
+ label: "Sudden Infant Death Syndrome"
2697
+ },
2698
+ {
2699
+ code: "SIHD",
2700
+ label: "Severe Ischemic Heart Disease"
2701
+ },
2702
+ {
2703
+ code: "SIRS",
2704
+ label: "Systemic Inflammatory Response Syndrome"
2705
+ },
2706
+ {
2707
+ code: "SLE",
2708
+ label: "Systemic Lupus Erythematosus"
2709
+ },
2710
+ {
2711
+ code: "SMI",
2712
+ label: "Silent Mocardial Ischaemia"
2713
+ },
2714
+ {
2715
+ code: "SOL",
2716
+ label: "Space Occupying Lesion"
2717
+ },
2718
+ {
2719
+ code: "SRMI",
2720
+ label: "Stress-Related Mucosal Injury"
2721
+ },
2722
+ {
2723
+ code: "SSPE",
2724
+ label: "Sub Sclerosis Panencephalitis"
2725
+ },
2726
+ {
2727
+ code: "SSS",
2728
+ label: "Sick Sinus Syndrome"
2729
+ },
2730
+ {
2731
+ code: "SSSS",
2732
+ label: "Staphylococcal Scalded Skin Syndrome"
2733
+ },
2734
+ {
2735
+ code: "STD",
2736
+ label: "Sexually Transmitted Disease"
2737
+ },
2738
+ {
2739
+ code: "STEMI",
2740
+ label: "St-Elevation Myocardial Infarction"
2741
+ },
2742
+ {
2743
+ code: "SW",
2744
+ label: "Stab Wound"
2745
+ },
2746
+ {
2747
+ code: "TAHBSO",
2748
+ label: "Total Abdominal Hysterectomy And Bilateral Salpingo-Oophorectomy"
2749
+ },
2750
+ {
2751
+ code: "TB",
2752
+ label: "Tuberculosis"
2753
+ },
2754
+ {
2755
+ code: "TBI",
2756
+ label: "Traumatic Brain Injury"
2757
+ },
2758
+ {
2759
+ code: "TIA",
2760
+ label: "Transient Ischemic Attack"
2761
+ },
2762
+ {
2763
+ code: "TIA",
2764
+ label: "Tuberculosis"
2765
+ },
2766
+ {
2767
+ code: "TOF",
2768
+ label: "Tetralogy Of Fallot"
2769
+ },
2770
+ {
2771
+ code: "TR",
2772
+ label: "Tricuspid Regurgitation"
2773
+ },
2774
+ {
2775
+ code: "TVA",
2776
+ label: "Tricuspid Valve Atresia"
2777
+ },
2778
+ {
2779
+ code: "UGIB",
2780
+ label: "Upper Gastrointestinal Bleeding"
2781
+ },
2782
+ {
2783
+ code: "URTI",
2784
+ label: "Upper Respiratory Tract Infection'"
2785
+ },
2786
+ {
2787
+ code: "URI",
2788
+ label: "Urinary Tract Infection"
2789
+ },
2790
+ {
2791
+ code: "VA",
2792
+ label: "Vehicular Accident"
2793
+ },
2794
+ {
2795
+ code: "VAP",
2796
+ label: "Ventilator Acquired Pnuemonia"
2797
+ },
2798
+ {
2799
+ code: "VC",
2800
+ label: "Vehicular Crush"
2801
+ },
2802
+ {
2803
+ code: "VF",
2804
+ label: "Ventricular Fibrillation"
2805
+ },
2806
+ {
2807
+ code: "V-FIB",
2808
+ label: "Ventricular Fibrillation"
2809
+ },
2810
+ {
2811
+ code: "VHD",
2812
+ label: "Valvular Heart Disease"
2813
+ },
2814
+ {
2815
+ code: "VSD",
2816
+ label: "Ventricular Septal Defect"
2817
+ },
2818
+ {
2819
+ code: "VT",
2820
+ label: "Venous Thromboembolism"
2821
+ },
2822
+ {
2823
+ code: "VTACH",
2824
+ label: "Ventricular Tachycardia"
2825
+ }
2826
+ ];
2827
+
2828
+ // ../commons/src/conditionals/ill-defined.ts
2829
+ var illDefinedConditions = [
2830
+ "cardiac death",
2831
+ "cardiac arrest",
2832
+ "cardiac failure",
2833
+ "heart failure",
2834
+ "ventricular failure",
2835
+ "hypotension",
2836
+ "respiratory failure",
2837
+ "tachycardia",
2838
+ "bradycardia",
2839
+ "palpitations",
2840
+ "pulseless",
2841
+ "abnormal heart beat",
2842
+ "benign and innocent cardiac murmurs",
2843
+ "cardiac sounds",
2844
+ "gangrene",
2845
+ "elevated blood-pressure",
2846
+ "low blood-pressure",
2847
+ "epistaxis",
2848
+ "haemorrhage from throat",
2849
+ "haemoptysis",
2850
+ "haemorrhage in respiratory passages",
2851
+ "cough",
2852
+ "dyspnoea",
2853
+ "stridor",
2854
+ "wheezing",
2855
+ "periodic breathing",
2856
+ "hyperventilation",
2857
+ "mouth breathing",
2858
+ "hiccough",
2859
+ "sneezing",
2860
+ "abnormalities of breathing",
2861
+ "throat pain",
2862
+ "chest pain",
2863
+ "precordial pain",
2864
+ "asphyxia",
2865
+ "pleurisy",
2866
+ "respiratory arrest",
2867
+ "abnormal sputum",
2868
+ "acute abdomen",
2869
+ "upper abdomen pain",
2870
+ "pelvic pain",
2871
+ "lower abdomen pain",
2872
+ "abdominal pain",
2873
+ "nausea and vomiting",
2874
+ "heartburn",
2875
+ "dysphagia",
2876
+ "flatulence",
2877
+ "incontinence",
2878
+ "hepatomegaly",
2879
+ "splenomegaly",
2880
+ "hyperbilurubinaemia",
2881
+ "jaundice",
2882
+ "ascites",
2883
+ "swelling, mass, lump ",
2884
+ "abnormal bowel sounds",
2885
+ "peristalsis",
2886
+ "abdominal rigidity",
2887
+ "change in bowel habit",
2888
+ "faecal abnormalities",
2889
+ "halitosis",
2890
+ "disturbances of skin sensation",
2891
+ "anaesthesia of skin",
2892
+ "hypoaesthesia of skin",
2893
+ "paraesthesia of skin",
2894
+ "hyperaesthesia",
2895
+ "rash, skin eruption",
2896
+ "skin eruption",
2897
+ "swelling, mass and lump",
2898
+ "cyanosis",
2899
+ "pallor",
2900
+ "flushing",
2901
+ "spontaneous ecchymoses",
2902
+ "changes in skin texture",
2903
+ "abnormal head movements",
2904
+ "tremor",
2905
+ "cramp and spasm",
2906
+ "fasciculation",
2907
+ "abnormal involuntary movements",
2908
+ "ataxic gait",
2909
+ "paralytic gait",
2910
+ "difficulty in walking",
2911
+ "immobility",
2912
+ "abnormalities of gait and mobility",
2913
+ "lack of coordination",
2914
+ "ataxia",
2915
+ "tetany",
2916
+ "meningismus",
2917
+ "abnormal reflex",
2918
+ "abnormal posture",
2919
+ "clicking hip",
2920
+ "tendency to fall",
2921
+ "pain associated with micturition",
2922
+ "dysuria",
2923
+ "vesical tenesmus",
2924
+ "painful micturition",
2925
+ "haematuria",
2926
+ "urinary incontinence",
2927
+ "retention of urine",
2928
+ "anuria and oliguria",
2929
+ "polyuria",
2930
+ "urethral discharge",
2931
+ "symptoms and signs involving urinary system",
2932
+ "extravasation of urine",
2933
+ "difficulties with micturition",
2934
+ "extrarenal uraemia",
2935
+ "somnolence",
2936
+ "stupor",
2937
+ "coma",
2938
+ "disorientation",
2939
+ "anterograde amnesia",
2940
+ "retrograde amnesia",
2941
+ "other amnesia",
2942
+ "dizziness and giddiness",
2943
+ "disturbances of smell and taste",
2944
+ "anosmia",
2945
+ "parosmia",
2946
+ "parageusia",
2947
+ "auditory hallucinations",
2948
+ "visual hallucinations",
2949
+ "other hallucinations",
2950
+ "hallucinations",
2951
+ "nervousness",
2952
+ "restlessness and agitation",
2953
+ "unhappiness",
2954
+ "demoralization and apathy",
2955
+ "irritability and anger",
2956
+ "hostility",
2957
+ "physical violence",
2958
+ "emotional shock and stress",
2959
+ "low level of personal hygiene",
2960
+ "bizarre personal appearance",
2961
+ "strange and inexplicable behaviour",
2962
+ "overactivity",
2963
+ "slowness and poor responsiveness",
2964
+ "suspiciousness and evasiveness",
2965
+ "verbosity and circumstantial detail obscuring reason for contact",
2966
+ "dysphasia and aphasia",
2967
+ "dysarthria and anarthria",
2968
+ "other and unspecified speech disturbances",
2969
+ "dyslexia and other symbolic dysfunctions",
2970
+ "dyslexia and alexia",
2971
+ "agnosia",
2972
+ "apraxia",
2973
+ "voice disturbances",
2974
+ "dysphonia",
2975
+ "aphonia",
2976
+ "hypernasality and hyponasality",
2977
+ "other and unspecified voice disturbances",
2978
+ "fever",
2979
+ "drug-induced fever",
2980
+ "other specified fever",
2981
+ "headache",
2982
+ "pain",
2983
+ "malaise and fatigue",
2984
+ "senility",
2985
+ "syncope and collapse",
2986
+ "convulsions",
2987
+ "shock",
2988
+ "enlarged lymph nodes",
2989
+ "systemic inflammatory response syndrome",
2990
+ "hypothermia",
2991
+ "dry mouth",
2992
+ "clubbing of fingers",
2993
+ "elevated erythrocyte sedimentation rate",
2994
+ "abnormal plasma viscosity",
2995
+ "abnormality of red blood cells",
2996
+ "abnormality of white blood cells",
2997
+ "elevated blood glucose level",
2998
+ "abnormal glucose tolerance test",
2999
+ "hyperglycaemia",
3000
+ "abnormal serum enzyme levels",
3001
+ "elevation of levels of transaminase and lactic acid dehydrogenase [ldh]",
3002
+ "abnormal levels of other serum enzymes",
3003
+ // 'laboratory evidence of human immunodeficiency virus [hiv]',
3004
+ "raised antibody titre",
3005
+ "abnormal reaction to tuberculin test",
3006
+ "false-positive serological test for syphilis",
3007
+ "abnormality of albumin",
3008
+ "abnormality of globulin",
3009
+ "abnormality of alphafetoprotein",
3010
+ "abnormalities of plasma proteins",
3011
+ "alcohol in blood",
3012
+ "opiate drug in blood",
3013
+ "cocaine in blood",
3014
+ "hallucinogen in blood",
3015
+ "drugs of addictive potential in blood",
3016
+ "psychotropic drug in blood",
3017
+ "steroid agent in blood",
3018
+ "abnormal level of heavy metals in blood",
3019
+ "abnormal level of blood mineral",
3020
+ "isolated proteinuria",
3021
+ "glycosuria",
3022
+ "chyluria",
3023
+ "myoglobinuria",
3024
+ "biliuria",
3025
+ "haemoglobinuria",
3026
+ "acetonuria",
3027
+ "abnormal urine levels",
3028
+ "abnormal findings in urine",
3029
+ "abnormal findings in cerebrospinal fluid",
3030
+ "abnormal findings in specimens from respiratory organs and thorax",
3031
+ "abnormal findings in specimens from digestive organs and abdominal cavity",
3032
+ "abnormal findings in specimens from male genital organs",
3033
+ "abnormal findings in specimens from female genital organs",
3034
+ "abnormal findings in specimens from other organs, systems and tissues",
3035
+ "space-occupying lesion",
3036
+ "abnormal findings in lung",
3037
+ "abnormal findings in breast",
3038
+ "abnormal findings in skull and head",
3039
+ "abnormal findings in heart and coronary circulation",
3040
+ "abnormal findings in liver and biliary tract",
3041
+ "abnormal findings in digestive tract",
3042
+ "abnormal findings on diagnostic imaging of urinary organs",
3043
+ "abnormal findings on diagnostic imaging of other abdominal regions",
3044
+ "abnormal findings on diagnostic imaging of limbs",
3045
+ "abnormal findings on diagnostic imaging of other parts of musculoskeletal system",
3046
+ "abnormal findings on diagnostic imaging of other specified body structures",
3047
+ "Abnormal results of function studies",
3048
+ "sudden adult death syndrome",
3049
+ "sudden unexplained nocturnal death",
3050
+ "death occurring less than 24 hours",
3051
+ "unattended death",
3052
+ "found dead",
3053
+ "unspecified cause of mortality",
3054
+ "unknown",
3055
+ // 'undetermined',
3056
+ "natural death",
3057
+ "cause indeterminant",
3058
+ "cause never determined",
3059
+ "cause not determined",
3060
+ "cause not found",
3061
+ "cause not known",
3062
+ "cause uncertain",
3063
+ // 'cause undetermined',
3064
+ "cause unknown",
3065
+ "causes indeterminant",
3066
+ "causes never determined",
3067
+ "causes not determined",
3068
+ "causes not found",
3069
+ "causes not known",
3070
+ "unknown cause of mortality",
3071
+ "etiology unknown",
3072
+ // 'natural cause undetermined',
3073
+ "not known",
3074
+ // 'origin undetermined',
3075
+ "uncertain cause",
3076
+ "uncertain etiology",
3077
+ // 'undetermined cause',
3078
+ // 'undetermined etiology',
3079
+ "natural cause",
3080
+ "natural disease",
3081
+ "unknown origin",
3082
+ "unknown cause",
3083
+ "unknown specific cause"
3084
+ ];
3085
+
1900
3086
  // ../commons/src/conditionals/validate.ts
1901
3087
  var ajv = new import__.default({
1902
3088
  $data: true,
@@ -1949,21 +3135,142 @@ ajv.addKeyword({
1949
3135
  ajv.addKeyword({
1950
3136
  keyword: "sumOf",
1951
3137
  type: "object",
1952
- schemaType: "array",
3138
+ schemaType: "object",
1953
3139
  errors: true,
1954
- $data: true,
1955
- validate(schema) {
1956
- if (!Array.isArray(schema) || schema.length !== 3) {
3140
+ validate(schema, data) {
3141
+ const { sum, field1, field2: field22 } = schema;
3142
+ const total = data?.[sum];
3143
+ const num1 = data?.[field1];
3144
+ const num2 = data?.[field22];
3145
+ if (typeof total !== "number" || typeof num1 !== "number" || typeof num2 !== "number") {
1957
3146
  return true;
1958
3147
  }
1959
- const [a, b, c] = schema;
1960
- if ([a, b, c].some((v) => typeof v !== "number")) {
3148
+ const valid = total === num1 + num2;
3149
+ return valid;
3150
+ }
3151
+ });
3152
+ ajv.addKeyword({
3153
+ keyword: "isAbbreviation",
3154
+ type: "string",
3155
+ schemaType: "boolean",
3156
+ errors: true,
3157
+ validate(schema, data) {
3158
+ if (!schema) return true;
3159
+ if (typeof data !== "string") {
1961
3160
  return true;
1962
3161
  }
1963
- const valid = a === b + c;
1964
- return valid;
3162
+ const items = data.split(",").map((item) => item.replace(/\./g, "").trim().toUpperCase());
3163
+ const foundAbbreviation = items.filter(
3164
+ (item) => medicalAbbreviations.some((abbr) => abbr.code.toUpperCase() === item)
3165
+ );
3166
+ if (foundAbbreviation.length && foundAbbreviation.length > 0) {
3167
+ return false;
3168
+ }
3169
+ return true;
3170
+ }
3171
+ });
3172
+ ajv.addKeyword({
3173
+ keyword: "isIllDefined",
3174
+ type: "object",
3175
+ schemaType: "object",
3176
+ errors: true,
3177
+ validate(schema, data) {
3178
+ const { fields, threshold } = schema;
3179
+ if (!data || typeof data !== "object") return true;
3180
+ const causesOfDeath = fields.flatMap(
3181
+ (field3) => (data?.[field3] || "").split(",").map((v) => v.trim()).filter(Boolean)
3182
+ ).filter((val, index, self) => self.indexOf(val) === index);
3183
+ if (causesOfDeath.length === 0) return true;
3184
+ let hasNonIllDefined = false;
3185
+ for (const term of causesOfDeath) {
3186
+ const results = fuzzySearch(term, illDefinedConditions, threshold).filter(
3187
+ (entry) => entry.score >= 0 && entry.score < threshold
3188
+ );
3189
+ if (results.length === 0) {
3190
+ hasNonIllDefined = true;
3191
+ break;
3192
+ }
3193
+ }
3194
+ return hasNonIllDefined;
1965
3195
  }
1966
3196
  });
3197
+ function levenshtein(a, b) {
3198
+ const tmp = [];
3199
+ for (let i = 0; i <= a.length; i++) {
3200
+ tmp[i] = [i];
3201
+ }
3202
+ for (let j = 0; j <= b.length; j++) {
3203
+ tmp[0][j] = j;
3204
+ }
3205
+ for (let i = 1; i <= a.length; i++) {
3206
+ for (let j = 1; j <= b.length; j++) {
3207
+ tmp[i][j] = Math.min(
3208
+ tmp[i - 1][j] + 1,
3209
+ // deletion
3210
+ tmp[i][j - 1] + 1,
3211
+ // insertion
3212
+ tmp[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)
3213
+ // substitution
3214
+ );
3215
+ }
3216
+ }
3217
+ return tmp[a.length][b.length];
3218
+ }
3219
+ function fuzzySearch(query, list, threshold, limit = 3) {
3220
+ const COMMON_WORDS = /* @__PURE__ */ new Set([
3221
+ "failure",
3222
+ "disease",
3223
+ "syndrome",
3224
+ "acute",
3225
+ // 'chronic',
3226
+ "unspecified",
3227
+ // 'undetermine',
3228
+ "shock"
3229
+ ]);
3230
+ const normalize = (str) => str.toLowerCase().replace(/[^\w\s]/g, "").trim();
3231
+ const tokenize = (str) => normalize(str).split(/\s+/).filter((w) => w.length >= 3);
3232
+ const queryWords = tokenize(query);
3233
+ if (queryWords.length === 0) return [];
3234
+ const results = [];
3235
+ for (const item of list) {
3236
+ const itemWords = tokenize(item);
3237
+ if (normalize(query) === normalize(item)) {
3238
+ results.push({ item, score: 0 });
3239
+ break;
3240
+ }
3241
+ let totalScore = 0;
3242
+ let matchCount = 0;
3243
+ let largeMismatchFound = false;
3244
+ for (const qWord of queryWords) {
3245
+ let bestScore = Infinity;
3246
+ for (const iWord of itemWords) {
3247
+ const dist = levenshtein(qWord, iWord);
3248
+ const normDist = dist / Math.max(qWord.length, iWord.length);
3249
+ if (normDist < bestScore) bestScore = normDist;
3250
+ }
3251
+ if (bestScore !== Infinity) {
3252
+ const weight = COMMON_WORDS.has(qWord) ? 0.5 : 1;
3253
+ totalScore += bestScore * weight;
3254
+ matchCount++;
3255
+ if (bestScore > 0.4) {
3256
+ largeMismatchFound = true;
3257
+ totalScore += 0.5;
3258
+ }
3259
+ }
3260
+ }
3261
+ if (matchCount > 0) {
3262
+ const avgScore = totalScore / matchCount;
3263
+ if (largeMismatchFound) {
3264
+ results.push({ item, score: avgScore + 0.5 });
3265
+ } else {
3266
+ if (avgScore <= threshold) {
3267
+ results.push({ item, score: avgScore });
3268
+ }
3269
+ }
3270
+ }
3271
+ }
3272
+ return results.sort((a, b) => a.score - b.score).slice(0, limit);
3273
+ }
1967
3274
 
1968
3275
  // ../commons/src/utils.ts
1969
3276
  var z24 = __toESM(require("zod"));
@@ -2364,11 +3671,40 @@ function createFieldConditionals(fieldId) {
2364
3671
  [field2Id]: { type: "number" }
2365
3672
  },
2366
3673
  required: [fieldId, field1Id, field2Id],
2367
- sumOf: [
2368
- { $data: `/$form/${fieldId}` },
2369
- { $data: `/$form/${field1Id}` },
2370
- { $data: `/$form/${field2Id}` }
2371
- ]
3674
+ sumOf: {
3675
+ sum: fieldId,
3676
+ field1: field1Id,
3677
+ field2: field2Id
3678
+ }
3679
+ });
3680
+ },
3681
+ isAbbreviation() {
3682
+ return defineFormConditional({
3683
+ type: "object",
3684
+ properties: {
3685
+ [fieldId]: { type: "string", isAbbreviation: true }
3686
+ },
3687
+ required: [fieldId]
3688
+ });
3689
+ },
3690
+ isIllDefined(causesOfDeathFields, threshold) {
3691
+ const fieldIds = causesOfDeathFields.map((field3) => field3.$$field);
3692
+ const properties = fieldIds.reduce(
3693
+ (acc, field3) => {
3694
+ acc[field3] = { type: "string" };
3695
+ return acc;
3696
+ },
3697
+ {}
3698
+ );
3699
+ return defineFormConditional({
3700
+ type: "object",
3701
+ properties,
3702
+ // required: fieldIds,
3703
+ // Custom keyword or config (if used by your validator)
3704
+ isIllDefined: {
3705
+ fields: fieldIds,
3706
+ threshold
3707
+ }
2372
3708
  });
2373
3709
  },
2374
3710
  /**
@@ -2434,12 +3770,12 @@ function createFieldConditionals(fieldId) {
2434
3770
  },
2435
3771
  required: [fieldId]
2436
3772
  }),
2437
- isValidEnglishName: () => defineFormConditional({
3773
+ isValidEnglishName: (isRequiredField = true) => defineFormConditional({
2438
3774
  type: "object",
2439
3775
  properties: {
2440
3776
  [fieldId]: {
2441
3777
  type: "string",
2442
- minLength: 1,
3778
+ ...isRequiredField && { minLength: 1 },
2443
3779
  pattern: "^[\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*( [\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*)*$",
2444
3780
  description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
2445
3781
  }