ezmedicationinput 0.1.42 → 0.1.44

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.
Files changed (46) hide show
  1. package/README.md +31 -1
  2. package/dist/advice-rules.json +772 -0
  3. package/dist/advice-terminology.json +104 -0
  4. package/dist/advice.d.ts +16 -0
  5. package/dist/advice.js +1375 -0
  6. package/dist/event-trigger.d.ts +14 -0
  7. package/dist/event-trigger.js +501 -0
  8. package/dist/fhir-translations.d.ts +5 -0
  9. package/dist/fhir-translations.js +117 -0
  10. package/dist/fhir.d.ts +6 -4
  11. package/dist/fhir.js +566 -134
  12. package/dist/format.d.ts +5 -2
  13. package/dist/format.js +581 -219
  14. package/dist/i18n.d.ts +4 -2
  15. package/dist/i18n.js +725 -197
  16. package/dist/index.d.ts +0 -1
  17. package/dist/index.js +221 -169
  18. package/dist/internal-types.d.ts +5 -5
  19. package/dist/ir.d.ts +4 -0
  20. package/dist/ir.js +178 -0
  21. package/dist/lexer/lex.d.ts +2 -0
  22. package/dist/lexer/lex.js +401 -0
  23. package/dist/lexer/meaning.d.ts +71 -0
  24. package/dist/lexer/meaning.js +619 -0
  25. package/dist/lexer/surface.d.ts +2 -0
  26. package/dist/lexer/surface.js +62 -0
  27. package/dist/lexer/token-types.d.ts +36 -0
  28. package/dist/lexer/token-types.js +19 -0
  29. package/dist/maps.d.ts +6 -12
  30. package/dist/maps.js +793 -247
  31. package/dist/parser-state.d.ts +101 -0
  32. package/dist/parser-state.js +441 -0
  33. package/dist/parser.d.ts +7 -7
  34. package/dist/parser.js +3598 -1974
  35. package/dist/prn.d.ts +4 -0
  36. package/dist/prn.js +59 -0
  37. package/dist/schedule.js +230 -32
  38. package/dist/site-phrases.d.ts +35 -0
  39. package/dist/site-phrases.js +344 -0
  40. package/dist/timing-summary.d.ts +25 -0
  41. package/dist/timing-summary.js +138 -0
  42. package/dist/types.d.ts +248 -32
  43. package/dist/types.js +49 -1
  44. package/dist/utils/text.d.ts +3 -0
  45. package/dist/utils/text.js +48 -0
  46. package/package.json +1 -1
package/README.md CHANGED
@@ -139,6 +139,8 @@ Use either helper depending on your source:
139
139
 
140
140
  - `formatParseBatch(batch, style?, separator?)` when you already have `parseSig` output.
141
141
  - `formatSigBatch(dosages, style?, { separator })` when you have an array of FHIR `Dosage` entries.
142
+ - `formatSig(dosage, style?, options?)` / `fromFhirDosage(dosage, options?)` when you want
143
+ locale-aware long-text rendering controls for a single dosage.
142
144
 
143
145
  ```ts
144
146
  import { formatParseBatch, formatSigBatch, parseSig } from "ezmedicationinput";
@@ -152,6 +154,31 @@ const shortFromFhir = formatSigBatch(batch.items.map((item) => item.fhir), "shor
152
154
  // => same combined short sig text
153
155
  ```
154
156
 
157
+ Formatting options:
158
+
159
+ - `locale`: selects the registered localization, such as `"en"` or `"th"`.
160
+ - `i18n`: overrides or augments the registered localization callbacks.
161
+ - `groupMealTimingsByRelation`: compacts repeated meal relation phrases when all
162
+ meal anchors share the same relation.
163
+ Example EN: `after breakfast, lunch and dinner`
164
+ Example TH: `หลังอาหารเช้า กลางวัน และเย็น`
165
+ - `includeTimesPerDaySummary`: prepends a daily count when the formatter can
166
+ safely infer one from explicit daily anchors and no cadence already exists.
167
+ Example EN: `three times daily after breakfast, lunch and dinner`
168
+ Example TH: `วันละ 3 ครั้ง หลังอาหารเช้า กลางวัน และเย็น`
169
+
170
+ Notes:
171
+
172
+ - `groupMealTimingsByRelation` only applies to homogeneous specific meal anchors
173
+ (`before breakfast/lunch/dinner`, `after breakfast/lunch/dinner`, or `with breakfast/lunch/dinner`).
174
+ When additional non-meal daily anchors exist, the formatter groups the meal
175
+ subset and leaves the extra anchors explicit.
176
+ Example EN: `before breakfast, lunch and dinner and at bedtime`
177
+ Example TH: `ก่อนอาหารเช้า กลางวัน และเย็น และก่อนนอน`
178
+ - `includeTimesPerDaySummary` is independent from meal grouping. It counts
179
+ explicit daily anchors only when no `frequency`, `timingCode`, interval, or
180
+ day-of-week cadence is already present.
181
+
155
182
  ### Sig (directions) suggestions
156
183
 
157
184
  Use `suggestSig` to drive autocomplete experiences while the clinician is
@@ -280,7 +307,7 @@ const result = await parseSigAsync("apply to {left temple} nightly", {
280
307
  text: "Scalp"
281
308
  },
282
309
  {
283
- coding: { system: "http://snomed.info/sct", code: "280447003", display: "Temple region of head" },
310
+ coding: { system: "http://snomed.info/sct", code: "450721000", display: "Temple region structure" },
284
311
  text: "Temple"
285
312
  }
286
313
  ];
@@ -348,6 +375,9 @@ You can specify the number of times (total count) the medication is supposed to
348
375
  combinations (e.g. `1x3` → breakfast/lunch/dinner). This also respects
349
376
  `context.mealRelation` when provided and only applies to schedules with four
350
377
  or fewer daily doses.
378
+ - `smartMealExpansionScope`: optional include/exclude overrides for route codes
379
+ and dosage forms. When omitted, smart meal expansion uses the built-in
380
+ default heuristic. Exclusions take precedence over includes.
351
381
  - `enableMealDashSyntax`: when `true`, enables shorthand meal-dose patterns
352
382
  such as `1-0-1`, `1-0-1 pc`, `10-12-0 ac`, and `1-0-0-1 ac`. The parser
353
383
  expands them into multiple dosage clauses aligned to breakfast/lunch/dinner