ezmedicationinput 0.1.43 → 0.1.45

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.
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMealTimingGroup = getMealTimingGroup;
4
- exports.inferDailyOccurrenceCount = inferDailyOccurrenceCount;
5
- const types_1 = require("./types");
6
- const MEAL_TIMING_DETAILS = {
7
- [types_1.EventTiming["Before Breakfast"]]: { relation: "before", meal: "breakfast" },
8
- [types_1.EventTiming["Before Lunch"]]: { relation: "before", meal: "lunch" },
9
- [types_1.EventTiming["Before Dinner"]]: { relation: "before", meal: "dinner" },
10
- [types_1.EventTiming["After Breakfast"]]: { relation: "after", meal: "breakfast" },
11
- [types_1.EventTiming["After Lunch"]]: { relation: "after", meal: "lunch" },
12
- [types_1.EventTiming["After Dinner"]]: { relation: "after", meal: "dinner" },
13
- [types_1.EventTiming.Breakfast]: { relation: "with", meal: "breakfast" },
14
- [types_1.EventTiming.Lunch]: { relation: "with", meal: "lunch" },
15
- [types_1.EventTiming.Dinner]: { relation: "with", meal: "dinner" }
16
- };
17
- const MEAL_ORDER = {
18
- breakfast: 0,
19
- lunch: 1,
20
- dinner: 2
21
- };
22
- const INFERABLE_DAILY_EVENT_TIMINGS = new Set([
23
- types_1.EventTiming["Before Sleep"],
24
- types_1.EventTiming["Before Breakfast"],
25
- types_1.EventTiming["Before Lunch"],
26
- types_1.EventTiming["Before Dinner"],
27
- types_1.EventTiming["After Breakfast"],
28
- types_1.EventTiming["After Lunch"],
29
- types_1.EventTiming["After Dinner"],
30
- types_1.EventTiming.Breakfast,
31
- types_1.EventTiming.Lunch,
32
- types_1.EventTiming.Dinner,
33
- types_1.EventTiming.Morning,
34
- types_1.EventTiming["Early Morning"],
35
- types_1.EventTiming["Late Morning"],
36
- types_1.EventTiming.Noon,
37
- types_1.EventTiming.Afternoon,
38
- types_1.EventTiming["Early Afternoon"],
39
- types_1.EventTiming["Late Afternoon"],
40
- types_1.EventTiming.Evening,
41
- types_1.EventTiming["Early Evening"],
42
- types_1.EventTiming["Late Evening"],
43
- types_1.EventTiming.Night,
44
- types_1.EventTiming.Wake,
45
- types_1.EventTiming["After Sleep"]
46
- ]);
47
- function uniqueValues(values) {
48
- const seen = new Set();
49
- const result = [];
50
- for (const value of values) {
51
- if (!seen.has(value)) {
52
- seen.add(value);
53
- result.push(value);
54
- }
55
- }
56
- return result;
57
- }
58
- function getMealTimingGroup(when, options) {
59
- if (!(options === null || options === void 0 ? void 0 : options.groupMealTimingsByRelation)) {
60
- return undefined;
61
- }
62
- const uniqueWhen = uniqueValues(when);
63
- if (uniqueWhen.length < 2) {
64
- return undefined;
65
- }
66
- let relation;
67
- const meals = [];
68
- const groupedCodes = [];
69
- let sawFirstMeal = false;
70
- for (let i = 0; i < uniqueWhen.length; i += 1) {
71
- const code = uniqueWhen[i];
72
- const detail = MEAL_TIMING_DETAILS[code];
73
- if (!detail) {
74
- if (sawFirstMeal) {
75
- break;
76
- }
77
- continue;
78
- }
79
- if (!sawFirstMeal) {
80
- sawFirstMeal = true;
81
- }
82
- if (!relation) {
83
- relation = detail.relation;
84
- }
85
- else if (relation !== detail.relation) {
86
- break;
87
- }
88
- meals.push(detail.meal);
89
- groupedCodes.push(code);
90
- }
91
- if (groupedCodes.length < 2) {
92
- return undefined;
93
- }
94
- for (let i = 1; i < meals.length; i += 1) {
95
- const current = meals[i];
96
- let j = i - 1;
97
- while (j >= 0 && MEAL_ORDER[meals[j]] > MEAL_ORDER[current]) {
98
- meals[j + 1] = meals[j];
99
- j -= 1;
100
- }
101
- meals[j + 1] = current;
102
- }
103
- if (!relation) {
104
- return undefined;
105
- }
106
- return {
107
- relation,
108
- meals,
109
- codes: groupedCodes
110
- };
111
- }
112
- function inferDailyOccurrenceCount(internal, options) {
113
- var _a;
114
- if (!(options === null || options === void 0 ? void 0 : options.includeTimesPerDaySummary)) {
115
- return undefined;
116
- }
117
- if (internal.frequency !== undefined || internal.frequencyMax !== undefined || internal.timingCode) {
118
- return undefined;
119
- }
120
- if (internal.period !== undefined || internal.periodMax !== undefined || internal.periodUnit !== undefined) {
121
- return undefined;
122
- }
123
- if (internal.dayOfWeek.length > 0) {
124
- return undefined;
125
- }
126
- const uniqueWhen = uniqueValues(internal.when);
127
- for (let i = 0; i < uniqueWhen.length; i += 1) {
128
- if (!INFERABLE_DAILY_EVENT_TIMINGS.has(uniqueWhen[i])) {
129
- return undefined;
130
- }
131
- }
132
- const uniqueTimes = uniqueValues((_a = internal.timeOfDay) !== null && _a !== void 0 ? _a : []);
133
- const occurrences = uniqueWhen.length + uniqueTimes.length;
134
- if (occurrences === 0) {
135
- return undefined;
136
- }
137
- return occurrences;
138
- }
package/dist/types.js DELETED
@@ -1,228 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RouteCode = exports.FhirDayOfWeek = exports.FhirPeriodUnit = exports.SNOMEDCTRouteCodes = exports.EventTiming = void 0;
4
- /**
5
- * Follows https://build.fhir.org/valueset-event-timing.html
6
- * Real-world event relating to the schedule.
7
- */
8
- var EventTiming;
9
- (function (EventTiming) {
10
- EventTiming["Before Sleep"] = "HS";
11
- EventTiming["Wake"] = "WAKE";
12
- EventTiming["Meal"] = "C";
13
- EventTiming["Breakfast"] = "CM";
14
- EventTiming["Lunch"] = "CD";
15
- EventTiming["Dinner"] = "CV";
16
- EventTiming["Before Meal"] = "AC";
17
- EventTiming["Before Breakfast"] = "ACM";
18
- EventTiming["Before Lunch"] = "ACD";
19
- EventTiming["Before Dinner"] = "ACV";
20
- EventTiming["After Meal"] = "PC";
21
- EventTiming["After Breakfast"] = "PCM";
22
- EventTiming["After Lunch"] = "PCD";
23
- EventTiming["After Dinner"] = "PCV";
24
- EventTiming["Morning"] = "MORN";
25
- EventTiming["Early Morning"] = "MORN.early";
26
- EventTiming["Late Morning"] = "MORN.late";
27
- EventTiming["Noon"] = "NOON";
28
- EventTiming["Afternoon"] = "AFT";
29
- EventTiming["Early Afternoon"] = "AFT.early";
30
- EventTiming["Late Afternoon"] = "AFT.late";
31
- EventTiming["Evening"] = "EVE";
32
- EventTiming["Early Evening"] = "EVE.early";
33
- EventTiming["Late Evening"] = "EVE.late";
34
- EventTiming["Night"] = "NIGHT";
35
- EventTiming["After Sleep"] = "PHS";
36
- EventTiming["Immediate"] = "IMD";
37
- })(EventTiming || (exports.EventTiming = EventTiming = {}));
38
- /**
39
- * SNOMED CT route codes aligned with the official "route of administration values" value set.
40
- * Keeping the enumeration exhaustive ensures downstream consumers can rely on strong typing.
41
- */
42
- var SNOMEDCTRouteCodes;
43
- (function (SNOMEDCTRouteCodes) {
44
- SNOMEDCTRouteCodes["Topical route"] = "6064005";
45
- SNOMEDCTRouteCodes["Otic route"] = "10547007";
46
- SNOMEDCTRouteCodes["Intra-articular route"] = "12130007";
47
- SNOMEDCTRouteCodes["Per vagina"] = "16857009";
48
- SNOMEDCTRouteCodes["Oral route"] = "26643006";
49
- SNOMEDCTRouteCodes["Subcutaneous route"] = "34206005";
50
- SNOMEDCTRouteCodes["Per rectum"] = "37161004";
51
- SNOMEDCTRouteCodes["Intraluminal route"] = "37737002";
52
- SNOMEDCTRouteCodes["Sublingual route"] = "37839007";
53
- SNOMEDCTRouteCodes["Intraperitoneal route"] = "38239002";
54
- SNOMEDCTRouteCodes["Transdermal route"] = "45890007";
55
- SNOMEDCTRouteCodes["Nasal route"] = "46713006";
56
- SNOMEDCTRouteCodes["Intravenous route"] = "47625008";
57
- SNOMEDCTRouteCodes["Buccal route"] = "54471007";
58
- SNOMEDCTRouteCodes["Ophthalmic route"] = "54485002";
59
- SNOMEDCTRouteCodes["Intra-arterial route"] = "58100008";
60
- SNOMEDCTRouteCodes["Intramedullary route"] = "60213007";
61
- SNOMEDCTRouteCodes["Intrauterine route"] = "62226000";
62
- SNOMEDCTRouteCodes["Intrathecal route"] = "72607000";
63
- SNOMEDCTRouteCodes["Intramuscular route"] = "78421000";
64
- SNOMEDCTRouteCodes["Urethral route"] = "90028008";
65
- SNOMEDCTRouteCodes["Gastrostomy route"] = "127490009";
66
- SNOMEDCTRouteCodes["Jejunostomy route"] = "127491008";
67
- SNOMEDCTRouteCodes["Nasogastric route"] = "127492001";
68
- SNOMEDCTRouteCodes["Dental use"] = "372449004";
69
- SNOMEDCTRouteCodes["Endocervical use"] = "372450004";
70
- SNOMEDCTRouteCodes["Endosinusial use"] = "372451000";
71
- SNOMEDCTRouteCodes["Endotracheopulmonary use"] = "372452007";
72
- SNOMEDCTRouteCodes["Extra-amniotic use"] = "372453002";
73
- SNOMEDCTRouteCodes["Gastroenteral use"] = "372454008";
74
- SNOMEDCTRouteCodes["Gingival use"] = "372457001";
75
- SNOMEDCTRouteCodes["Intraamniotic use"] = "372458006";
76
- SNOMEDCTRouteCodes["Intrabursal use"] = "372459003";
77
- SNOMEDCTRouteCodes["Intracardiac use"] = "372460008";
78
- SNOMEDCTRouteCodes["Intracavernous use"] = "372461007";
79
- SNOMEDCTRouteCodes["Intracervical route (qualifier value)"] = "372462000";
80
- SNOMEDCTRouteCodes["Intracoronary use"] = "372463005";
81
- SNOMEDCTRouteCodes["Intradermal use"] = "372464004";
82
- SNOMEDCTRouteCodes["Intradiscal use"] = "372465003";
83
- SNOMEDCTRouteCodes["Intralesional use"] = "372466002";
84
- SNOMEDCTRouteCodes["Intralymphatic use"] = "372467006";
85
- SNOMEDCTRouteCodes["Intraocular use"] = "372468001";
86
- SNOMEDCTRouteCodes["Intrapleural use"] = "372469009";
87
- SNOMEDCTRouteCodes["Intrasternal use"] = "372470005";
88
- SNOMEDCTRouteCodes["Intravesical use"] = "372471009";
89
- SNOMEDCTRouteCodes["Ocular route (qualifier value)"] = "372472002";
90
- SNOMEDCTRouteCodes["Oromucosal use"] = "372473007";
91
- SNOMEDCTRouteCodes["Periarticular use"] = "372474001";
92
- SNOMEDCTRouteCodes["Perineural use"] = "372475000";
93
- SNOMEDCTRouteCodes["Subconjunctival use"] = "372476004";
94
- SNOMEDCTRouteCodes["Transmucosal route (qualifier value)"] = "404815008";
95
- SNOMEDCTRouteCodes["Intratracheal route (qualifier value)"] = "404818005";
96
- SNOMEDCTRouteCodes["Intrabiliary route (qualifier value)"] = "404819002";
97
- SNOMEDCTRouteCodes["Epidural route (qualifier value)"] = "404820008";
98
- SNOMEDCTRouteCodes["Suborbital route (qualifier value)"] = "416174007";
99
- SNOMEDCTRouteCodes["Caudal route (qualifier value)"] = "417070009";
100
- SNOMEDCTRouteCodes["Intraosseous route (qualifier value)"] = "417255000";
101
- SNOMEDCTRouteCodes["Intrathoracic route (qualifier value)"] = "417950001";
102
- SNOMEDCTRouteCodes["Enteral route (qualifier value)"] = "417985001";
103
- SNOMEDCTRouteCodes["Intraductal route (qualifier value)"] = "417989007";
104
- SNOMEDCTRouteCodes["Intratympanic route (qualifier value)"] = "418091004";
105
- SNOMEDCTRouteCodes["Intravenous central route (qualifier value)"] = "418114005";
106
- SNOMEDCTRouteCodes["Intramyometrial route (qualifier value)"] = "418133000";
107
- SNOMEDCTRouteCodes["Gastro-intestinal stoma route (qualifier value)"] = "418136008";
108
- SNOMEDCTRouteCodes["Colostomy route (qualifier value)"] = "418162004";
109
- SNOMEDCTRouteCodes["Periurethral route (qualifier value)"] = "418204005";
110
- SNOMEDCTRouteCodes["Intracoronal route (qualifier value)"] = "418287000";
111
- SNOMEDCTRouteCodes["Retrobulbar route (qualifier value)"] = "418321004";
112
- SNOMEDCTRouteCodes["Intracartilaginous route (qualifier value)"] = "418331006";
113
- SNOMEDCTRouteCodes["Intravitreal route (qualifier value)"] = "418401004";
114
- SNOMEDCTRouteCodes["Intraspinal route (qualifier value)"] = "418418000";
115
- SNOMEDCTRouteCodes["Orogastric route (qualifier value)"] = "418441008";
116
- SNOMEDCTRouteCodes["Transurethral route (qualifier value)"] = "418511008";
117
- SNOMEDCTRouteCodes["Intratendinous route (qualifier value)"] = "418586008";
118
- SNOMEDCTRouteCodes["Intracorneal route (qualifier value)"] = "418608002";
119
- SNOMEDCTRouteCodes["Oropharyngeal route (qualifier value)"] = "418664002";
120
- SNOMEDCTRouteCodes["Peribulbar route (qualifier value)"] = "418722009";
121
- SNOMEDCTRouteCodes["Nasojejunal route (qualifier value)"] = "418730005";
122
- SNOMEDCTRouteCodes["Fistula route (qualifier value)"] = "418743005";
123
- SNOMEDCTRouteCodes["Surgical drain route (qualifier value)"] = "418813001";
124
- SNOMEDCTRouteCodes["Intracameral route (qualifier value)"] = "418821007";
125
- SNOMEDCTRouteCodes["Paracervical route (qualifier value)"] = "418851001";
126
- SNOMEDCTRouteCodes["Intrasynovial route (qualifier value)"] = "418877009";
127
- SNOMEDCTRouteCodes["Intraduodenal route (qualifier value)"] = "418887008";
128
- SNOMEDCTRouteCodes["Intracisternal route (qualifier value)"] = "418892005";
129
- SNOMEDCTRouteCodes["Intratesticular route (qualifier value)"] = "418947002";
130
- SNOMEDCTRouteCodes["Intracranial route (qualifier value)"] = "418987007";
131
- SNOMEDCTRouteCodes["Tumour cavity route"] = "419021003";
132
- SNOMEDCTRouteCodes["Paravertebral route (qualifier value)"] = "419165009";
133
- SNOMEDCTRouteCodes["Intrasinal route (qualifier value)"] = "419231003";
134
- SNOMEDCTRouteCodes["Transcervical route (qualifier value)"] = "419243002";
135
- SNOMEDCTRouteCodes["Subtendinous route (qualifier value)"] = "419320008";
136
- SNOMEDCTRouteCodes["Intraabdominal route (qualifier value)"] = "419396008";
137
- SNOMEDCTRouteCodes["Subgingival route (qualifier value)"] = "419601003";
138
- SNOMEDCTRouteCodes["Intraovarian route (qualifier value)"] = "419631009";
139
- SNOMEDCTRouteCodes["Ureteral route (qualifier value)"] = "419684008";
140
- SNOMEDCTRouteCodes["Peritendinous route (qualifier value)"] = "419762003";
141
- SNOMEDCTRouteCodes["Intrabronchial route (qualifier value)"] = "419778001";
142
- SNOMEDCTRouteCodes["Intraprostatic route (qualifier value)"] = "419810008";
143
- SNOMEDCTRouteCodes["Submucosal route (qualifier value)"] = "419874009";
144
- SNOMEDCTRouteCodes["Surgical cavity route (qualifier value)"] = "419894000";
145
- SNOMEDCTRouteCodes["Ileostomy route (qualifier value)"] = "419954003";
146
- SNOMEDCTRouteCodes["Intravenous peripheral route (qualifier value)"] = "419993007";
147
- SNOMEDCTRouteCodes["Periosteal route (qualifier value)"] = "420047004";
148
- SNOMEDCTRouteCodes["Esophagostomy route"] = "420163009";
149
- SNOMEDCTRouteCodes["Urostomy route (qualifier value)"] = "420168000";
150
- SNOMEDCTRouteCodes["Laryngeal route (qualifier value)"] = "420185003";
151
- SNOMEDCTRouteCodes["Intrapulmonary route (qualifier value)"] = "420201002";
152
- SNOMEDCTRouteCodes["Mucous fistula route (qualifier value)"] = "420204005";
153
- SNOMEDCTRouteCodes["Nasoduodenal route (qualifier value)"] = "420218003";
154
- SNOMEDCTRouteCodes["Body cavity route"] = "420254004";
155
- SNOMEDCTRouteCodes["A route that begins within a non-pathologic hollow cavity, such as that of the abdominal cavity or uterus."] = "420254004";
156
- SNOMEDCTRouteCodes["Intraventricular route - cardiac (qualifier value)"] = "420287000";
157
- SNOMEDCTRouteCodes["Intracerebroventricular route (qualifier value)"] = "420719007";
158
- SNOMEDCTRouteCodes["Percutaneous route (qualifier value)"] = "428191002";
159
- SNOMEDCTRouteCodes["Interstitial route (qualifier value)"] = "429817007";
160
- SNOMEDCTRouteCodes["Intraesophageal route (qualifier value)"] = "445752009";
161
- SNOMEDCTRouteCodes["Intragingival route (qualifier value)"] = "445754005";
162
- SNOMEDCTRouteCodes["Intravascular route (qualifier value)"] = "445755006";
163
- SNOMEDCTRouteCodes["Intradural route (qualifier value)"] = "445756007";
164
- SNOMEDCTRouteCodes["Intragastric route (qualifier value)"] = "445768003";
165
- SNOMEDCTRouteCodes["Intrapericardial route (qualifier value)"] = "445771006";
166
- SNOMEDCTRouteCodes["Intralingual route (qualifier value)"] = "445913005";
167
- SNOMEDCTRouteCodes["Intrahepatic route (qualifier value)"] = "445941009";
168
- SNOMEDCTRouteCodes["Conjunctival route (qualifier value)"] = "446105004";
169
- SNOMEDCTRouteCodes["Intraepicardial route (qualifier value)"] = "446407004";
170
- SNOMEDCTRouteCodes["Transendocardial route (qualifier value)"] = "446435000";
171
- SNOMEDCTRouteCodes["Transplacental route (qualifier value)"] = "446442000";
172
- SNOMEDCTRouteCodes["Intracerebral route (qualifier value)"] = "446540005";
173
- SNOMEDCTRouteCodes["Intraileal route (qualifier value)"] = "447026006";
174
- SNOMEDCTRouteCodes["Periodontal route (qualifier value)"] = "447052000";
175
- SNOMEDCTRouteCodes["Peridural route (qualifier value)"] = "447080003";
176
- SNOMEDCTRouteCodes["Lower respiratory tract route (qualifier value)"] = "447081004";
177
- SNOMEDCTRouteCodes["Intramammary route (qualifier value)"] = "447121004";
178
- SNOMEDCTRouteCodes["Intratumor route (qualifier value)"] = "447122006";
179
- SNOMEDCTRouteCodes["Transtympanic route (qualifier value)"] = "447227007";
180
- SNOMEDCTRouteCodes["Transtracheal route (qualifier value)"] = "447229005";
181
- SNOMEDCTRouteCodes["Respiratory tract route (qualifier value)"] = "447694001";
182
- SNOMEDCTRouteCodes["Digestive tract route (qualifier value)"] = "447964005";
183
- SNOMEDCTRouteCodes["Intraepidermal route (qualifier value)"] = "448077001";
184
- SNOMEDCTRouteCodes["Intrajejunal route (qualifier value)"] = "448491004";
185
- SNOMEDCTRouteCodes["Intracolonic route (qualifier value)"] = "448492006";
186
- SNOMEDCTRouteCodes["Cutaneous route (qualifier value)"] = "448598008";
187
- SNOMEDCTRouteCodes["Arteriovenous fistula route (qualifier value)"] = "697971008";
188
- SNOMEDCTRouteCodes["Intraneural route (qualifier value)"] = "711360002";
189
- SNOMEDCTRouteCodes["Intramural route (qualifier value)"] = "711378007";
190
- SNOMEDCTRouteCodes["Extracorporeal route (qualifier value)"] = "714743009";
191
- SNOMEDCTRouteCodes["Infiltration route (qualifier value)"] = "718329006";
192
- SNOMEDCTRouteCodes["Epilesional route (qualifier value)"] = "764723001";
193
- SNOMEDCTRouteCodes["Extracorporeal hemodialysis route (qualifier value)"] = "766790006";
194
- SNOMEDCTRouteCodes["Intradialytic route"] = "876824003";
195
- SNOMEDCTRouteCodes["Intracatheter instillation route (qualifier value)"] = "1078280005";
196
- SNOMEDCTRouteCodes["Suprachoroidal route"] = "1254769004";
197
- SNOMEDCTRouteCodes["Intracorporus cavernosum route (qualifier value)"] = "1259221004";
198
- SNOMEDCTRouteCodes["Sublesional route (qualifier value)"] = "1611000175109";
199
- SNOMEDCTRouteCodes["Intestinal route (qualifier value)"] = "58731000052100";
200
- SNOMEDCTRouteCodes["Intraglandular route (qualifier value)"] = "58751000052109";
201
- SNOMEDCTRouteCodes["Intracholangiopancreatic route"] = "58761000052107";
202
- SNOMEDCTRouteCodes["Intraportal route"] = "58771000052103";
203
- SNOMEDCTRouteCodes["Peritumoral route (qualifier value)"] = "58811000052103";
204
- SNOMEDCTRouteCodes["Posterior juxtascleral route (qualifier value)"] = "58821000052106";
205
- SNOMEDCTRouteCodes["Subretinal route (qualifier value)"] = "58831000052108";
206
- SNOMEDCTRouteCodes["Sublabial use"] = "66621000052103";
207
- })(SNOMEDCTRouteCodes || (exports.SNOMEDCTRouteCodes = SNOMEDCTRouteCodes = {}));
208
- var FhirPeriodUnit;
209
- (function (FhirPeriodUnit) {
210
- FhirPeriodUnit["Second"] = "s";
211
- FhirPeriodUnit["Minute"] = "min";
212
- FhirPeriodUnit["Hour"] = "h";
213
- FhirPeriodUnit["Day"] = "d";
214
- FhirPeriodUnit["Week"] = "wk";
215
- FhirPeriodUnit["Month"] = "mo";
216
- FhirPeriodUnit["Year"] = "a";
217
- })(FhirPeriodUnit || (exports.FhirPeriodUnit = FhirPeriodUnit = {}));
218
- var FhirDayOfWeek;
219
- (function (FhirDayOfWeek) {
220
- FhirDayOfWeek["Monday"] = "mon";
221
- FhirDayOfWeek["Tuesday"] = "tue";
222
- FhirDayOfWeek["Wednesday"] = "wed";
223
- FhirDayOfWeek["Thursday"] = "thu";
224
- FhirDayOfWeek["Friday"] = "fri";
225
- FhirDayOfWeek["Saturday"] = "sat";
226
- FhirDayOfWeek["Sunday"] = "sun";
227
- })(FhirDayOfWeek || (exports.FhirDayOfWeek = FhirDayOfWeek = {}));
228
- exports.RouteCode = SNOMEDCTRouteCodes;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.arrayIncludes = arrayIncludes;
4
- function arrayIncludes(values, target) {
5
- for (let index = 0; index < values.length; index += 1) {
6
- if (values[index] === target) {
7
- return true;
8
- }
9
- }
10
- return false;
11
- }
@@ -1,2 +0,0 @@
1
- export declare function enumEntries<T extends Record<string, string | number>>(enumeration: T): Array<[keyof T, T[keyof T]]>;
2
- export declare function enumValues<T extends Record<string, string | number>>(enumeration: T): Array<T[keyof T]>;
@@ -1,7 +0,0 @@
1
- import { objectEntries, objectValues } from "./object";
2
- export function enumEntries(enumeration) {
3
- return objectEntries(enumeration);
4
- }
5
- export function enumValues(enumeration) {
6
- return objectValues(enumeration);
7
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.objectEntries = objectEntries;
4
- exports.objectValues = objectValues;
5
- exports.objectFromEntries = objectFromEntries;
6
- function objectEntries(value) {
7
- const entries = [];
8
- for (const key in value) {
9
- if (Object.prototype.hasOwnProperty.call(value, key)) {
10
- const typedKey = key;
11
- entries.push([typedKey, value[typedKey]]);
12
- }
13
- }
14
- return entries;
15
- }
16
- function objectValues(value) {
17
- const values = [];
18
- for (const key in value) {
19
- if (Object.prototype.hasOwnProperty.call(value, key)) {
20
- values.push(value[key]);
21
- }
22
- }
23
- return values;
24
- }
25
- function objectFromEntries(entries) {
26
- const result = {};
27
- for (let index = 0; index < entries.length; index += 1) {
28
- const entry = entries[index];
29
- const key = entry[0];
30
- const value = entry[1];
31
- result[key] = value;
32
- }
33
- return result;
34
- }
@@ -1,149 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseStrength = parseStrength;
4
- exports.parseStrengthIntoRatio = parseStrengthIntoRatio;
5
- const units_1 = require("./units");
6
- const maps_1 = require("../maps");
7
- const array_1 = require("./array");
8
- /**
9
- * High-level strength parser that returns the most appropriate FHIR representation.
10
- */
11
- function parseStrength(strength, context) {
12
- var _a, _b, _c;
13
- const ratio = parseStrengthIntoRatio(strength, context);
14
- if (!ratio)
15
- return {};
16
- if (((_a = ratio.denominator) === null || _a === void 0 ? void 0 : _a.value) === 1 && (((_b = ratio.denominator) === null || _b === void 0 ? void 0 : _b.unit) === "unit" || !((_c = ratio.denominator) === null || _c === void 0 ? void 0 : _c.unit))) {
17
- return { strengthQuantity: ratio.numerator };
18
- }
19
- return { strengthRatio: ratio };
20
- }
21
- /**
22
- * Internal helper to parse a strength string into a FHIR Ratio.
23
- */
24
- function parseStrengthIntoRatio(strength, context) {
25
- var _a, _b, _c, _d, _e;
26
- const parts = strength.split("+").map((p) => p.trim());
27
- let totalMgPerMlOrG = 0;
28
- let hasVolume = false;
29
- let hasWeightDenominator = false;
30
- let targetNumUnit;
31
- let targetDenUnit;
32
- let targetDenValue;
33
- for (const part of parts) {
34
- const ratio = parseSingleStrengthPart(part, context);
35
- if (!ratio || !((_a = ratio.numerator) === null || _a === void 0 ? void 0 : _a.value) || ratio.numerator.value === 0)
36
- continue;
37
- const nUnit = ratio.numerator.unit;
38
- const dUnit = ((_b = ratio.denominator) === null || _b === void 0 ? void 0 : _b.unit) || "unit";
39
- const dCat = (0, units_1.getUnitCategory)(dUnit);
40
- // Save target units from the first part
41
- if (!targetNumUnit)
42
- targetNumUnit = nUnit;
43
- if (!targetDenUnit)
44
- targetDenUnit = dUnit;
45
- if (targetDenValue === undefined)
46
- targetDenValue = (_c = ratio.denominator) === null || _c === void 0 ? void 0 : _c.value;
47
- const nValue = ratio.numerator.value;
48
- const dValue = (_e = (_d = ratio.denominator) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : 1;
49
- const nFactor = (0, units_1.getBaseUnitFactor)(nUnit);
50
- const dFactor = (dCat === "volume" || dCat === "mass") ? (0, units_1.getBaseUnitFactor)(dUnit) : 1;
51
- totalMgPerMlOrG += (nValue * nFactor) / (dValue * dFactor);
52
- if (dCat === "volume")
53
- hasVolume = true;
54
- if (dCat === "mass")
55
- hasWeightDenominator = true;
56
- }
57
- if (totalMgPerMlOrG === 0)
58
- return null;
59
- const isComposite = parts.length > 1;
60
- const resultNumUnit = isComposite ? "mg" : (targetNumUnit || "mg");
61
- let resultDenUnit = targetDenUnit || "unit";
62
- if (isComposite) {
63
- if (hasVolume)
64
- resultDenUnit = "mL";
65
- else if (hasWeightDenominator)
66
- resultDenUnit = "g";
67
- else
68
- resultDenUnit = "unit";
69
- }
70
- const resultDenValue = isComposite ? 1 : (targetDenValue !== null && targetDenValue !== void 0 ? targetDenValue : 1);
71
- const denCat = (0, units_1.getUnitCategory)(resultDenUnit);
72
- const dBaseFactor = (denCat === "volume" || denCat === "mass")
73
- ? (0, units_1.getBaseUnitFactor)(resultDenUnit)
74
- : 1;
75
- const totalBaseDenominatorValue = resultDenValue * dBaseFactor;
76
- const totalNumeratorMg = totalMgPerMlOrG * totalBaseDenominatorValue;
77
- const finalNumValue = totalNumeratorMg / (0, units_1.getBaseUnitFactor)(resultNumUnit);
78
- return {
79
- numerator: { value: finalNumValue, unit: resultNumUnit },
80
- denominator: { value: resultDenValue, unit: resultDenUnit }
81
- };
82
- }
83
- function isSolidDosageForm(form) {
84
- const normalized = form.toLowerCase().trim();
85
- // 1. Get the default unit for this form
86
- let unit = maps_1.DEFAULT_UNIT_BY_NORMALIZED_FORM[normalized];
87
- if (!unit) {
88
- const mapped = maps_1.KNOWN_DOSAGE_FORMS_TO_DOSE[normalized];
89
- if (mapped) {
90
- unit = maps_1.DEFAULT_UNIT_BY_NORMALIZED_FORM[mapped];
91
- }
92
- }
93
- // 2. Identify if it's explicitly a liquid/gas unit
94
- const liquidUnits = ["ml", "spray", "puff", "drop"];
95
- if (unit) {
96
- const u = unit.toLowerCase();
97
- if ((0, array_1.arrayIncludes)(liquidUnits, u))
98
- return false;
99
- // Any other mapped unit (g, tab, cap, etc.) is considered solid for % purpose
100
- return true;
101
- }
102
- // 3. Keyword-based heuristics as fallback
103
- const solidKeywords = [
104
- "tablet", "capsule", "patch", "cream", "ointment", "gel", "paste",
105
- "suppositor", "powder", "lozenge", "patch", "stick", "implant",
106
- "piece", "granule", "lozenge", "pessary"
107
- ];
108
- for (let i = 0; i < solidKeywords.length; i++) {
109
- if (normalized.indexOf(solidKeywords[i]) !== -1)
110
- return true;
111
- }
112
- return false;
113
- }
114
- function parseSingleStrengthPart(part, context) {
115
- var _a, _b;
116
- const p = part.trim();
117
- // 1. Percentage
118
- const percentMatch = p.match(/^(\d+(?:\.\d+)?)\s*%$/);
119
- if (percentMatch) {
120
- const isSolid = (context === null || context === void 0 ? void 0 : context.dosageForm) && isSolidDosageForm(context.dosageForm);
121
- return {
122
- numerator: { value: parseFloat(percentMatch[1]), unit: "g" },
123
- denominator: { value: 100, unit: isSolid ? "g" : "mL" }
124
- };
125
- }
126
- // 2. Ratio
127
- const ratioMatch = p.match(/^(\d+(?:\.\d+)?)\s*([a-zA-Z0-9%]+)?\s*\/\s*(\d+(?:\.\d+)?)?\s*([a-zA-Z0-9%]+)$/);
128
- if (ratioMatch) {
129
- return {
130
- numerator: {
131
- value: parseFloat(ratioMatch[1]),
132
- unit: ((_a = ratioMatch[2]) === null || _a === void 0 ? void 0 : _a.trim()) || "mg"
133
- },
134
- denominator: {
135
- value: ratioMatch[3] ? parseFloat(ratioMatch[3]) : 1,
136
- unit: (_b = ratioMatch[4]) === null || _b === void 0 ? void 0 : _b.trim()
137
- }
138
- };
139
- }
140
- // 3. Simple Quantity
141
- const quantityMatch = p.match(/^(\d+(?:\.\d+)?)\s*([a-zA-Z0-9%]+)$/);
142
- if (quantityMatch) {
143
- return {
144
- numerator: { value: parseFloat(quantityMatch[1]), unit: quantityMatch[2].trim() },
145
- denominator: { value: 1, unit: "unit" }
146
- };
147
- }
148
- return null;
149
- }
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VOLUME_UNITS = exports.MASS_UNITS = void 0;
4
- exports.getUnitCategory = getUnitCategory;
5
- exports.getBaseUnitFactor = getBaseUnitFactor;
6
- exports.convertValue = convertValue;
7
- exports.MASS_UNITS = {
8
- kg: 1000000,
9
- g: 1000,
10
- mg: 1,
11
- mcg: 0.001,
12
- ug: 0.001,
13
- microg: 0.001,
14
- ng: 0.000001
15
- };
16
- exports.VOLUME_UNITS = {
17
- l: 1000,
18
- dl: 100,
19
- ml: 1,
20
- ul: 0.001,
21
- microl: 0.001,
22
- cm3: 1,
23
- tsp: 5,
24
- tbsp: 15
25
- };
26
- function getUnitCategory(unit) {
27
- if (!unit)
28
- return "other";
29
- const u = unit.toLowerCase();
30
- if (exports.MASS_UNITS[u] !== undefined)
31
- return "mass";
32
- if (exports.VOLUME_UNITS[u] !== undefined)
33
- return "volume";
34
- return "other";
35
- }
36
- function getBaseUnitFactor(unit) {
37
- var _a, _b;
38
- if (!unit)
39
- return 1;
40
- const u = unit.toLowerCase();
41
- return (_b = (_a = exports.MASS_UNITS[u]) !== null && _a !== void 0 ? _a : exports.VOLUME_UNITS[u]) !== null && _b !== void 0 ? _b : 1;
42
- }
43
- function convertValue(value, fromUnit, toUnit, strength) {
44
- const f = fromUnit.toLowerCase();
45
- const t = toUnit.toLowerCase();
46
- if (f === t)
47
- return value;
48
- const fCat = getUnitCategory(f);
49
- const tCat = getUnitCategory(t);
50
- // 1. Same category conversion
51
- if (fCat === tCat && fCat !== "other") {
52
- const fFactor = getBaseUnitFactor(f);
53
- const tFactor = getBaseUnitFactor(t);
54
- return (value * fFactor) / tFactor;
55
- }
56
- // 2. Cross-category conversion using strength
57
- if (strength && ((fCat === "mass" && tCat === "volume") || (fCat === "volume" && tCat === "mass"))) {
58
- const numUnit = strength.numerator.unit.toLowerCase();
59
- const denUnit = strength.denominator.unit.toLowerCase();
60
- const numCat = getUnitCategory(numUnit);
61
- const denCat = getUnitCategory(denUnit);
62
- if (numCat !== denCat && numCat !== "other" && denCat !== "other") {
63
- const massSide = numCat === "mass" ? strength.numerator : strength.denominator;
64
- const volSide = numCat === "volume" ? strength.numerator : strength.denominator;
65
- // Normalize bridge to base units (mg/mL)
66
- const bridgeDensity = (massSide.value * getBaseUnitFactor(massSide.unit)) / (volSide.value * getBaseUnitFactor(volSide.unit));
67
- if (fCat === "mass") {
68
- // Mass to Volume: value_mg / density_mg_per_ml
69
- const valueMg = value * getBaseUnitFactor(fromUnit);
70
- const valueMl = valueMg / bridgeDensity;
71
- return valueMl / getBaseUnitFactor(toUnit);
72
- }
73
- else {
74
- // Volume to Mass: value_ml * density_mg_per_ml
75
- const valueMl = value * getBaseUnitFactor(fromUnit);
76
- const valueMg = valueMl * bridgeDensity;
77
- return valueMg / getBaseUnitFactor(toUnit);
78
- }
79
- }
80
- }
81
- return null;
82
- }