ezmedicationinput 0.1.46 → 0.1.47

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.
package/README.md CHANGED
@@ -725,6 +725,35 @@ const result = calculateTotalUnits({
725
725
 
726
726
  It can also handle strength-based conversions (e.g. calculating how many 100mL bottles are needed for a 500mg TID dose of a 250mg/5mL suspension).
727
727
 
728
+ Natural SIG units are classified from `unit-terminology.json` instead of being treated as one physics-style unit enum. Parsed results expose `meta.normalized.unitKind` / `unitSemantics`, and callers can inspect the same vocabulary with `listDoseUnitTerminology()` or `getDoseUnitSemantics(unit)`.
729
+
730
+ ```ts
731
+ const parsed = parseSig("apply 2 FTU to face twice daily");
732
+
733
+ calculateTotalUnits({
734
+ dosage: parsed.fhir,
735
+ from: "2024-01-01T08:00:00Z",
736
+ durationValue: 7,
737
+ durationUnit: "d",
738
+ timeZone: "Asia/Bangkok"
739
+ });
740
+
741
+ // → { totalUnits: 28, totalApproximateQuantity: { value: 14, unit: "g", ... } }
742
+ ```
743
+
744
+ Built-in approximations are intentionally conservative and overridable. Current defaults include `FTU -> 0.5 g`, `drop -> 0.05 mL`, `pea-sized amount -> 0.25 mL`, and `shot glass -> 29.5735 mL`; product/device-specific labels should pass `context.unitApproximationMap` when a better value is known. Package-level phrases such as `half bottle` can also be bridged to the inner amount by setting `context.packageUnit`, `containerValue`, and `containerUnit`.
745
+
746
+ The terminology layer also classifies non-metric SIG units that should not be blindly converted:
747
+
748
+ - `body_area_proxy`: `palm`, `handprint`, `% BSA`
749
+ - `product_specific_amount`: `pea-sized amount`, `shot glass`, `finger length`, `dropperful`, `applicatorful`, `capful`, `scoop`
750
+ - `device_actuation`: `puff`, `spray`, `pump`, `actuation`, `click`
751
+ - `length_of_product`: `cm ribbon`, `inch ribbon`, `cm strip`, `cm line`, `inch line`
752
+ - `counted_presentation`: `patch`, `ring`, `vial`, `ampule`, `nebule`, `respule`, `packet`, `sachet`, `stick-pack`, and similar package/presentation units
753
+ - `infusion_rate`: `drop/min` / `gtt/min`, exposed as terminology but not parsed as `doseQuantity` until rate parsing and drop-factor conversion are modeled
754
+
755
+ `calculateTotalUnits` counts presentation units such as patches and rings as discrete administrations. It does not invent gram/mL conversions for puffs, pumps, applicatorfuls, capfuls, ribbons, body-area proxies, clicks, or release-rate products unless the caller supplies product-specific context.
756
+
728
757
  ### Strength parsing
729
758
 
730
759
  Use `parseStrength` to normalize medication strength strings into FHIR-compliant **Quantity** or **Ratio** structures. It understands percentages, ratios, and composite strengths.
package/dist/advice.d.ts CHANGED
@@ -13,4 +13,13 @@ export interface AdviceParseContext {
13
13
  }
14
14
  export declare function parseAdditionalInstructions(sourceText: string, span: TextRange, context?: AdviceParseContext): ParsedAdditionalInstruction[];
15
15
  export declare function findAdditionalInstructionDefinitionByCoding(system: string, code: string): AdditionalInstructionDefinition | undefined;
16
+ export declare const __test__: {
17
+ createDefinitionFromSource(source: {
18
+ system?: string;
19
+ code: string;
20
+ display: string;
21
+ text: string;
22
+ thai: string;
23
+ }): AdditionalInstructionDefinition;
24
+ };
16
25
  export declare function buildAdditionalInstructionFramesFromCoding(system: string, code: string, sourceText?: string, span?: TextRange): AdviceFrame[] | undefined;
@@ -5,6 +5,7 @@ type BodySiteFeatureKind = "nominal" | "partitive" | "locative";
5
5
  type CompoundDoseUnit = {
6
6
  head: string;
7
7
  tails: string[];
8
+ tailSequences?: string[][];
8
9
  unit: string;
9
10
  };
10
11
  export declare const SITE_ANCHORS: Set<string>;
@@ -44,6 +45,12 @@ export declare const SITE_ROUTE_HINTS_ALLOWED_IN_GRAMMAR: Set<import("../types")
44
45
  export declare const PRODUCT_METHOD_TEXT: Record<string, Partial<Record<string, string>>>;
45
46
  export declare const PRODUCT_METHOD_THAI: Record<string, string>;
46
47
  export declare const COMPOUND_DOSE_UNITS: CompoundDoseUnit[];
48
+ export declare const IMPLICIT_SINGLE_DOSE_UNITS: Set<string>;
49
+ export declare const PERCENT_BODY_AREA_UNITS: Map<string, string>;
50
+ export declare const DOSE_FRACTION_WORDS: Map<string, number>;
51
+ export declare const DOSE_FRACTION_DENOMINATOR_WORDS: Map<string, number>;
52
+ export declare const DOSE_NUMBER_WORDS: Map<string, number>;
53
+ export declare const DOSE_UNIT_CONNECTORS: Set<string>;
47
54
  export declare const MILLION_DOSE_MULTIPLIER_TOKENS: Set<string>;
48
55
  export declare const SCHEDULE_UNIT_SEPARATOR_TOKENS: Set<string>;
49
56
  export declare const COMPACT_LIST_SEPARATORS: Set<string>;
@@ -77,6 +84,7 @@ export declare const RANGE_CONNECTORS: Set<string>;
77
84
  export declare const DURATION_LEAD_TOKENS: Set<string>;
78
85
  export declare const INSTRUCTION_LEADING_SEPARATORS: Set<string>;
79
86
  export declare const INSTRUCTION_START_WORDS: Set<string>;
87
+ export declare const SITE_TRAILING_INSTRUCTION_WORDS: Set<string>;
80
88
  export declare const WORKFLOW_CONTINUATION_LICENSES: Set<string>;
81
89
  export declare const AS_NEEDED_LEAD_PHRASES: Set<string>;
82
90
  export declare const PRN_BREAKING_COORDINATORS: Set<string>;
@@ -2,6 +2,8 @@ import { FhirCoding } from "../types";
2
2
  export declare enum MethodAction {
3
3
  Administer = "administer",
4
4
  Apply = "apply",
5
+ Inhale = "inhale",
6
+ Inject = "inject",
5
7
  Insert = "insert",
6
8
  Instill = "instill",
7
9
  Spray = "spray",