ezmedicationinput 0.1.54 → 0.1.56
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 +111 -25
- package/dist/advice.d.ts +1 -0
- package/dist/body-site-grammar.d.ts +3 -1
- package/dist/event-timing-expression.d.ts +8 -0
- package/dist/fhir.d.ts +10 -1
- package/dist/hpsg/constructions.d.ts +6 -0
- package/dist/hpsg/defaults.d.ts +1 -0
- package/dist/hpsg/feature-structure.d.ts +5 -0
- package/dist/hpsg/lexical-classes.d.ts +70 -7
- package/dist/hpsg/method-lexicon.d.ts +14 -14
- package/dist/hpsg/procedural-context.d.ts +10 -0
- package/dist/hpsg/rules/condition-rules.d.ts +4 -0
- package/dist/hpsg/rules/core-rules.d.ts +2 -0
- package/dist/hpsg/rules/instruction-rules.d.ts +1 -0
- package/dist/hpsg/rules/prn-rules.d.ts +11 -0
- package/dist/hpsg/rules/timing-rules.d.ts +28 -0
- package/dist/hpsg/segmenter.d.ts +2 -1
- package/dist/hpsg/signature.d.ts +54 -2
- package/dist/hpsg/type-system.d.ts +48 -0
- package/dist/i18n.d.ts +2 -0
- package/dist/index.cjs +25759 -9747
- package/dist/index.d.ts +11 -0
- package/dist/index.js +25720 -9744
- package/dist/instruction-action-terminology.d.ts +29 -0
- package/dist/instruction-concept-terminology.d.ts +26 -0
- package/dist/instruction-graph-fhir.d.ts +4 -0
- package/dist/instruction-graph.d.ts +23 -0
- package/dist/instruction-semantic-resolver.d.ts +4 -0
- package/dist/ir.d.ts +1 -0
- package/dist/lexer/locale.d.ts +8 -0
- package/dist/lexer/token-types.d.ts +2 -0
- package/dist/localized-timing.d.ts +1 -0
- package/dist/maps.d.ts +2 -8
- package/dist/parser-state.d.ts +16 -0
- package/dist/prn.d.ts +1 -0
- package/dist/relation-terminology.d.ts +101 -0
- package/dist/stable-structure.d.ts +1 -0
- package/dist/symptom-terminology.d.ts +12 -0
- package/dist/timing-summary.d.ts +2 -0
- package/dist/types.d.ts +284 -4
- package/package.json +6 -2
package/dist/types.d.ts
CHANGED
|
@@ -305,8 +305,9 @@ export interface FhirPeriod {
|
|
|
305
305
|
start?: string;
|
|
306
306
|
end?: string;
|
|
307
307
|
}
|
|
308
|
-
export interface FhirTimingRepeat {
|
|
308
|
+
export interface FhirTimingRepeat extends FhirElement {
|
|
309
309
|
count?: number;
|
|
310
|
+
countMax?: number;
|
|
310
311
|
boundsDuration?: FhirQuantity;
|
|
311
312
|
boundsPeriod?: FhirPeriod;
|
|
312
313
|
boundsRange?: FhirRange;
|
|
@@ -318,6 +319,7 @@ export interface FhirTimingRepeat {
|
|
|
318
319
|
dayOfWeek?: FhirDayOfWeek[];
|
|
319
320
|
timeOfDay?: string[];
|
|
320
321
|
when?: EventTiming[];
|
|
322
|
+
/** Exact event offset in minutes. */
|
|
321
323
|
offset?: number;
|
|
322
324
|
}
|
|
323
325
|
export interface FhirTiming {
|
|
@@ -383,6 +385,12 @@ export interface MedicationContext {
|
|
|
383
385
|
}
|
|
384
386
|
export interface FormatOptions {
|
|
385
387
|
locale?: "en" | "th" | string;
|
|
388
|
+
/**
|
|
389
|
+
* `normalized` favors compact natural wording. `roundtrip` stays human-readable
|
|
390
|
+
* but emits explicit attachment/route cues so parse -> realize -> parse can
|
|
391
|
+
* preserve canonical semantics. Defaults to `normalized`.
|
|
392
|
+
*/
|
|
393
|
+
realizationMode?: "normalized" | "roundtrip";
|
|
386
394
|
i18n?: SigTranslationConfig;
|
|
387
395
|
/**
|
|
388
396
|
* Collapses repeated meal relation phrases into a grouped phrase when all
|
|
@@ -395,6 +403,8 @@ export interface FormatOptions {
|
|
|
395
403
|
* schedule (for example, "three times daily" or "วันละ 3 ครั้ง").
|
|
396
404
|
*/
|
|
397
405
|
includeTimesPerDaySummary?: boolean;
|
|
406
|
+
/** Thai long-text site placement. `natural` uses route-sensitive Thai word order; `trailing` preserves the legacy trailing site phrase. */
|
|
407
|
+
sitePlacement?: "natural" | "trailing";
|
|
398
408
|
}
|
|
399
409
|
export interface FormatBatchOptions extends FormatOptions {
|
|
400
410
|
/**
|
|
@@ -422,6 +432,10 @@ export interface BodySiteDefinition {
|
|
|
422
432
|
spatialRelation?: BodySiteSpatialRelation;
|
|
423
433
|
routeHint?: RouteCode;
|
|
424
434
|
administrationTargetCount?: number;
|
|
435
|
+
/** Optional surface used when the dose applies independently to each target. */
|
|
436
|
+
perTargetText?: string;
|
|
437
|
+
/** Locale-specific per-target surface, e.g. Thai `รูจมูกข้างละ`. */
|
|
438
|
+
perTargetI18n?: Record<string, string>;
|
|
425
439
|
/** Optional translations for different locales (e.g., { "th": "ตา" }) */
|
|
426
440
|
i18n?: Record<string, string>;
|
|
427
441
|
/**
|
|
@@ -438,9 +452,16 @@ export interface CodeableConceptDefinition {
|
|
|
438
452
|
/** Optional translations for different locales (e.g., { "th": "ปวด" }) */
|
|
439
453
|
i18n?: Record<string, string>;
|
|
440
454
|
}
|
|
441
|
-
export interface
|
|
455
|
+
export interface SymptomDefinition extends CodeableConceptDefinition {
|
|
456
|
+
/** Locale-specific surface proposition used after a conditional such as Thai `เมื่อ`. */
|
|
457
|
+
conditionI18n?: Record<string, string>;
|
|
458
|
+
}
|
|
459
|
+
/** Backward-compatible PRN view of the shared symptom terminology. */
|
|
460
|
+
export interface PrnReasonDefinition extends SymptomDefinition {
|
|
442
461
|
}
|
|
443
462
|
export interface AdditionalInstructionDefinition extends CodeableConceptDefinition {
|
|
463
|
+
/** Locale-specific suffix appended directly to the administration verb. */
|
|
464
|
+
verbSuffixI18n?: Record<string, string>;
|
|
444
465
|
}
|
|
445
466
|
export declare enum AdvicePolarity {
|
|
446
467
|
Affirm = "affirm",
|
|
@@ -466,11 +487,18 @@ export declare enum AdviceRelation {
|
|
|
466
487
|
Before = "before",
|
|
467
488
|
After = "after",
|
|
468
489
|
During = "during",
|
|
490
|
+
Between = "between",
|
|
469
491
|
Then = "then",
|
|
470
492
|
Until = "until",
|
|
471
493
|
For = "for",
|
|
472
494
|
In = "in",
|
|
473
|
-
|
|
495
|
+
Into = "into",
|
|
496
|
+
On = "on",
|
|
497
|
+
To = "to",
|
|
498
|
+
If = "if",
|
|
499
|
+
Unless = "unless",
|
|
500
|
+
When = "when",
|
|
501
|
+
While = "while"
|
|
474
502
|
}
|
|
475
503
|
export declare enum AdviceArgumentRole {
|
|
476
504
|
Theme = "theme",
|
|
@@ -480,6 +508,10 @@ export declare enum AdviceArgumentRole {
|
|
|
480
508
|
Activity = "activity",
|
|
481
509
|
Material = "material",
|
|
482
510
|
Site = "site",
|
|
511
|
+
Destination = "destination",
|
|
512
|
+
Result = "result",
|
|
513
|
+
Container = "container",
|
|
514
|
+
Manner = "manner",
|
|
483
515
|
Amount = "amount",
|
|
484
516
|
Duration = "duration",
|
|
485
517
|
Time = "time",
|
|
@@ -490,6 +522,14 @@ export interface AdviceArgument {
|
|
|
490
522
|
text: string;
|
|
491
523
|
normalized?: string;
|
|
492
524
|
conceptId?: string;
|
|
525
|
+
coding?: FhirCoding;
|
|
526
|
+
codings?: FhirCoding[];
|
|
527
|
+
i18n?: Record<string, string>;
|
|
528
|
+
quantity?: {
|
|
529
|
+
value?: number;
|
|
530
|
+
range?: CanonicalDoseRange;
|
|
531
|
+
unit?: string;
|
|
532
|
+
};
|
|
493
533
|
span?: TextRange;
|
|
494
534
|
}
|
|
495
535
|
export interface AdviceFrame {
|
|
@@ -499,12 +539,27 @@ export interface AdviceFrame {
|
|
|
499
539
|
predicate: {
|
|
500
540
|
lemma: string;
|
|
501
541
|
semanticClass?: string;
|
|
542
|
+
display?: string;
|
|
543
|
+
i18n?: Record<string, string>;
|
|
544
|
+
/** Persisted realization profile so caller-owned actions remain deterministic after parse/FHIR round-trip. */
|
|
545
|
+
realizer?: MedicationInstructionActionRealizer;
|
|
546
|
+
realizerConfig?: {
|
|
547
|
+
thaiFallbackObject?: string;
|
|
548
|
+
thaiSuppressActivityConcepts?: string[];
|
|
549
|
+
thaiSuppressSiteConcepts?: string[];
|
|
550
|
+
thaiImplicitMedicationObject?: boolean;
|
|
551
|
+
englishDirectSiteObject?: boolean;
|
|
552
|
+
};
|
|
553
|
+
/** Internal/custom action coding followed by any trustworthy external mappings. */
|
|
554
|
+
codings?: FhirCoding[];
|
|
502
555
|
};
|
|
503
556
|
relation?: AdviceRelation;
|
|
504
557
|
args: AdviceArgument[];
|
|
505
558
|
span: TextRange;
|
|
506
559
|
sourceText: string;
|
|
507
560
|
sequenceIndex?: number;
|
|
561
|
+
origin?: "grammar" | "semantic-resolver";
|
|
562
|
+
confidence?: number;
|
|
508
563
|
coding?: FhirCoding;
|
|
509
564
|
}
|
|
510
565
|
export interface TextRange {
|
|
@@ -640,6 +695,144 @@ export interface SmartMealExpansionScope {
|
|
|
640
695
|
*/
|
|
641
696
|
excludeDosageForms?: string[];
|
|
642
697
|
}
|
|
698
|
+
export type MedicationInstructionActionArgumentParser = "default" | "container-activity" | "theme-destination-amount" | "object-amount-material" | "amount-duration" | "object-duration" | "object-time" | "mix-substance" | "result" | "site" | "site-relation" | "duration" | "bare-duration" | "preposed-duration" | "duration-activity" | "activity";
|
|
699
|
+
export type MedicationInstructionActionRealizer = "default" | "source-faithful" | "container-activity" | "theme-destination-amount" | "mix-substance" | "result" | "site-relation" | "object-amount-material" | "prime" | "amount-duration" | "object-duration" | "object-time" | "separable-object-relation" | "relation-duration" | "leave-duration" | "duration" | "duration-activity" | "activity";
|
|
700
|
+
export interface MedicationInstructionActionContextualCodingRule {
|
|
701
|
+
whenArgument: {
|
|
702
|
+
role?: AdviceArgumentRole;
|
|
703
|
+
conceptId?: string;
|
|
704
|
+
codingCode?: string;
|
|
705
|
+
normalized?: string;
|
|
706
|
+
};
|
|
707
|
+
coding: FhirCoding;
|
|
708
|
+
}
|
|
709
|
+
export interface MedicationInstructionActionDefinition {
|
|
710
|
+
/** Stable semantic action code. */
|
|
711
|
+
code: string;
|
|
712
|
+
semanticClass: string;
|
|
713
|
+
display: string;
|
|
714
|
+
/** Alternate human-readable labels keyed by BCP-47-ish language tag. */
|
|
715
|
+
i18n?: Record<string, string>;
|
|
716
|
+
/** Unambiguous parser-safe labels used only for semantic round-trip realization. */
|
|
717
|
+
roundtripI18n?: Record<string, string>;
|
|
718
|
+
/** Surface forms that should resolve to this action. */
|
|
719
|
+
aliases?: string[];
|
|
720
|
+
/** Discontinuous surface forms such as Thai `เอา X ออก` (remove X). */
|
|
721
|
+
separableAliases?: Array<{
|
|
722
|
+
lead: string;
|
|
723
|
+
particle: string;
|
|
724
|
+
}>;
|
|
725
|
+
/** Whether this is a procedural action rather than ordinary administration advice. */
|
|
726
|
+
procedural?: boolean;
|
|
727
|
+
/** Declarative argument grammar family used by the instruction graph. */
|
|
728
|
+
argumentParser?: MedicationInstructionActionArgumentParser;
|
|
729
|
+
/** Declarative realization family used by English/Thai graph generation. */
|
|
730
|
+
realizer?: MedicationInstructionActionRealizer;
|
|
731
|
+
argumentParserConfig?: {
|
|
732
|
+
primaryConcepts?: string[];
|
|
733
|
+
secondaryConcepts?: string[];
|
|
734
|
+
implicitMatchedConcept?: string;
|
|
735
|
+
implicitMatchedRole?: AdviceArgumentRole;
|
|
736
|
+
};
|
|
737
|
+
realizerConfig?: {
|
|
738
|
+
thaiFallbackObject?: string;
|
|
739
|
+
thaiSuppressActivityConcepts?: string[];
|
|
740
|
+
/** Thai can omit selected site concepts already lexicalized by the verb (e.g. สระผม + hair). */
|
|
741
|
+
thaiSuppressSiteConcepts?: string[];
|
|
742
|
+
/** Thai can omit an otherwise generic medication object for this action (e.g. รับประทานหลังอาหาร). */
|
|
743
|
+
thaiImplicitMedicationObject?: boolean;
|
|
744
|
+
/** English realizes the anatomical site as the verb's direct object instead of `to/at <site>`. */
|
|
745
|
+
englishDirectSiteObject?: boolean;
|
|
746
|
+
};
|
|
747
|
+
continuationLicenses?: Array<{
|
|
748
|
+
candidateAction: string;
|
|
749
|
+
previousConcepts?: string[];
|
|
750
|
+
previousKinds?: Array<"NUMBER" | "NUMBER_RANGE">;
|
|
751
|
+
nextConcepts?: string[];
|
|
752
|
+
}>;
|
|
753
|
+
continuationAfterRelations?: string[];
|
|
754
|
+
/** Preferred relation semantic classes used to resolve lexically ambiguous relation surfaces. */
|
|
755
|
+
preferredRelationSemanticClasses?: string[];
|
|
756
|
+
/** Exact coding for FHIR Dosage.method when this action can head administration. */
|
|
757
|
+
administrationMethod?: FhirCoding;
|
|
758
|
+
/** Route candidate licensed by the action surface itself (e.g. take -> oral). */
|
|
759
|
+
verbRouteHint?: RouteCode;
|
|
760
|
+
/** Exact route that overrides the ordinary verb route candidate for the method head. */
|
|
761
|
+
methodRouteOverride?: RouteCode;
|
|
762
|
+
/** Do not project the action's verb route hint from the method head. */
|
|
763
|
+
suppressMethodRouteHint?: boolean;
|
|
764
|
+
/** Marks surfaces that establish topical/application context for site grammar. */
|
|
765
|
+
applicationVerb?: boolean;
|
|
766
|
+
/** Extra exact codings licensed by a typed semantic argument. */
|
|
767
|
+
contextualCodings?: MedicationInstructionActionContextualCodingRule[];
|
|
768
|
+
/** A method-capable procedural action that may serve as the primary administration head. */
|
|
769
|
+
primaryAdministrationHead?: boolean;
|
|
770
|
+
/** Semantically light verb that yields to an immediately following stronger administration head. */
|
|
771
|
+
supportVerb?: boolean;
|
|
772
|
+
/** Positive action whose condition belongs to safety/instruction scope, not PRN administration scope. */
|
|
773
|
+
safetyScopeTarget?: boolean;
|
|
774
|
+
acceptsAmount?: boolean;
|
|
775
|
+
/** Whether an amount argument on this action defines the medication dose. */
|
|
776
|
+
definesDose?: boolean;
|
|
777
|
+
/** Optional primary coding when an institution owns the action terminology. */
|
|
778
|
+
coding?: FhirCoding;
|
|
779
|
+
/** Exact external terminology mappings; never fuzzy/approximate mappings. */
|
|
780
|
+
externalCodings?: FhirCoding[];
|
|
781
|
+
}
|
|
782
|
+
export interface MedicationInstructionActionInput extends Partial<MedicationInstructionActionDefinition> {
|
|
783
|
+
semanticClass?: string;
|
|
784
|
+
}
|
|
785
|
+
export interface MedicationInstructionConceptDefinition {
|
|
786
|
+
code: string;
|
|
787
|
+
role: AdviceArgumentRole;
|
|
788
|
+
display: string;
|
|
789
|
+
i18n?: Record<string, string>;
|
|
790
|
+
aliases?: string[];
|
|
791
|
+
coding?: FhirCoding;
|
|
792
|
+
externalCodings?: FhirCoding[];
|
|
793
|
+
}
|
|
794
|
+
export interface MedicationInstructionConceptInput extends Partial<MedicationInstructionConceptDefinition> {
|
|
795
|
+
role?: AdviceArgumentRole;
|
|
796
|
+
}
|
|
797
|
+
export interface InstructionSemanticArgumentProposal {
|
|
798
|
+
/** Typed argument role the resolver believes this phrase fills. */
|
|
799
|
+
role: AdviceArgumentRole;
|
|
800
|
+
/** Range relative to the opaque source span supplied in the resolver request. */
|
|
801
|
+
range: TextRange;
|
|
802
|
+
/** Registered instruction concept or body-site surface/code. */
|
|
803
|
+
concept?: string;
|
|
804
|
+
/** Explicit quantity, still validated against the parser's unit terminology. */
|
|
805
|
+
quantity?: {
|
|
806
|
+
value?: number;
|
|
807
|
+
low?: number;
|
|
808
|
+
high?: number;
|
|
809
|
+
unit?: string;
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
export interface InstructionSemanticActionProposal {
|
|
813
|
+
/** Registered instruction action surface/code. */
|
|
814
|
+
action: string;
|
|
815
|
+
/** Range relative to the opaque source span supplied in the resolver request. */
|
|
816
|
+
range: TextRange;
|
|
817
|
+
polarity?: AdvicePolarity;
|
|
818
|
+
/** Resolver confidence only; it never bypasses deterministic validation. */
|
|
819
|
+
confidence?: number;
|
|
820
|
+
args?: InstructionSemanticArgumentProposal[];
|
|
821
|
+
}
|
|
822
|
+
export interface InstructionSemanticResolution {
|
|
823
|
+
actions: InstructionSemanticActionProposal[];
|
|
824
|
+
}
|
|
825
|
+
export interface InstructionSemanticResolverRequest {
|
|
826
|
+
inputText: string;
|
|
827
|
+
sourceText: string;
|
|
828
|
+
/** Absolute range of sourceText within inputText. */
|
|
829
|
+
range: TextRange;
|
|
830
|
+
locale?: string;
|
|
831
|
+
context?: MedicationContext | null;
|
|
832
|
+
/** Read-only semantic context produced before learned enrichment. */
|
|
833
|
+
existingGraph: CanonicalInstructionGraph;
|
|
834
|
+
}
|
|
835
|
+
export type InstructionSemanticResolver = (request: InstructionSemanticResolverRequest) => InstructionSemanticResolution | null | undefined | Promise<InstructionSemanticResolution | null | undefined>;
|
|
643
836
|
export interface ParseOptions extends FormatOptions {
|
|
644
837
|
/**
|
|
645
838
|
* Optional medication context that assists with default unit inference.
|
|
@@ -648,6 +841,24 @@ export interface ParseOptions extends FormatOptions {
|
|
|
648
841
|
context?: MedicationContext | null;
|
|
649
842
|
routeMap?: Record<string, RouteCode>;
|
|
650
843
|
unitMap?: Record<string, string>;
|
|
844
|
+
/**
|
|
845
|
+
* Institution/application procedural vocabulary. Map keys are accepted
|
|
846
|
+
* surface forms; definitions may use any coding system and may add aliases.
|
|
847
|
+
* Unknown text still remains opaque rather than being guessed.
|
|
848
|
+
*/
|
|
849
|
+
instructionActionMap?: Record<string, MedicationInstructionActionInput>;
|
|
850
|
+
/**
|
|
851
|
+
* Institution/application argument vocabulary for substances, containers,
|
|
852
|
+
* results, activities, etc. Body sites still use the richer siteCodeMap.
|
|
853
|
+
*/
|
|
854
|
+
instructionConceptMap?: Record<string, MedicationInstructionConceptInput>;
|
|
855
|
+
/**
|
|
856
|
+
* Optional learned/remote semantic proposal providers. They are used only by
|
|
857
|
+
* parseSigAsync(), and only against spans the deterministic parser left opaque.
|
|
858
|
+
* Proposals are validated against registered action/concept/site/unit vocabularies
|
|
859
|
+
* before they can enter the canonical graph.
|
|
860
|
+
*/
|
|
861
|
+
instructionSemanticResolvers?: InstructionSemanticResolver | InstructionSemanticResolver[];
|
|
651
862
|
freqMap?: Record<string, {
|
|
652
863
|
timesPerDay?: number;
|
|
653
864
|
intervalHours?: number;
|
|
@@ -729,7 +940,13 @@ export interface ParseOptions extends FormatOptions {
|
|
|
729
940
|
*/
|
|
730
941
|
siteCodeSuggestionResolvers?: SiteCodeSuggestionResolver | SiteCodeSuggestionResolver[];
|
|
731
942
|
/**
|
|
732
|
-
* Optional
|
|
943
|
+
* Optional application/institution symptom vocabulary shared by conditions,
|
|
944
|
+
* PRN indications, HPSG symptom recognition, and suggestion surfaces.
|
|
945
|
+
*/
|
|
946
|
+
symptomMap?: Record<string, SymptomDefinition>;
|
|
947
|
+
/**
|
|
948
|
+
* Backward-compatible PRN-specific symptom overrides. When both maps define
|
|
949
|
+
* the same surface, this narrower PRN map takes precedence.
|
|
733
950
|
*/
|
|
734
951
|
prnReasonMap?: Record<string, PrnReasonDefinition>;
|
|
735
952
|
/**
|
|
@@ -778,9 +995,29 @@ export interface CanonicalMethodExpr {
|
|
|
778
995
|
coding?: FhirCoding;
|
|
779
996
|
evidence?: CanonicalEvidence[];
|
|
780
997
|
}
|
|
998
|
+
export interface CanonicalOccurrenceCapExpr {
|
|
999
|
+
max: number;
|
|
1000
|
+
period: number;
|
|
1001
|
+
periodUnit: FhirPeriodUnit;
|
|
1002
|
+
}
|
|
1003
|
+
export interface CanonicalActivityTimingExpr {
|
|
1004
|
+
relation: "before" | "after";
|
|
1005
|
+
activity: {
|
|
1006
|
+
text: string;
|
|
1007
|
+
i18n?: Record<string, string>;
|
|
1008
|
+
coding?: FhirCoding;
|
|
1009
|
+
};
|
|
1010
|
+
/** Exact offset from the activity in minutes. */
|
|
1011
|
+
offset?: number;
|
|
1012
|
+
/** Minimum offset from the activity in minutes. */
|
|
1013
|
+
offsetMin?: number;
|
|
1014
|
+
/** Maximum offset from the activity in minutes. */
|
|
1015
|
+
offsetMax?: number;
|
|
1016
|
+
}
|
|
781
1017
|
export interface CanonicalScheduleExpr {
|
|
782
1018
|
timingCode?: string;
|
|
783
1019
|
count?: number;
|
|
1020
|
+
countMax?: number;
|
|
784
1021
|
duration?: number;
|
|
785
1022
|
durationMax?: number;
|
|
786
1023
|
durationUnit?: FhirPeriodUnit;
|
|
@@ -789,9 +1026,17 @@ export interface CanonicalScheduleExpr {
|
|
|
789
1026
|
period?: number;
|
|
790
1027
|
periodMax?: number;
|
|
791
1028
|
periodUnit?: FhirPeriodUnit;
|
|
1029
|
+
/** Exact event offset in minutes, matching FHIR Timing.repeat.offset. */
|
|
1030
|
+
offset?: number;
|
|
1031
|
+
/** Minimum event offset in minutes when the source says “at least”. */
|
|
1032
|
+
offsetMin?: number;
|
|
1033
|
+
/** Maximum event offset in minutes when the source says “at most”. */
|
|
1034
|
+
offsetMax?: number;
|
|
792
1035
|
dayOfWeek?: FhirDayOfWeek[];
|
|
793
1036
|
when?: EventTiming[];
|
|
794
1037
|
timeOfDay?: string[];
|
|
1038
|
+
activityTiming?: CanonicalActivityTimingExpr[];
|
|
1039
|
+
occurrenceCap?: CanonicalOccurrenceCapExpr;
|
|
795
1040
|
evidence?: CanonicalEvidence[];
|
|
796
1041
|
}
|
|
797
1042
|
export interface CanonicalPrnReasonExpr {
|
|
@@ -799,6 +1044,8 @@ export interface CanonicalPrnReasonExpr {
|
|
|
799
1044
|
i18n?: Record<string, string>;
|
|
800
1045
|
coding?: FhirCoding;
|
|
801
1046
|
spatialRelation?: BodySiteSpatialRelation;
|
|
1047
|
+
/** Clinical trigger phase qualifying this PRN reason, e.g. symptom onset. */
|
|
1048
|
+
triggerPhase?: "onset";
|
|
802
1049
|
}
|
|
803
1050
|
export interface CanonicalPrnExpr {
|
|
804
1051
|
enabled: boolean;
|
|
@@ -808,10 +1055,39 @@ export interface CanonicalPrnExpr {
|
|
|
808
1055
|
}
|
|
809
1056
|
export interface CanonicalAdditionalInstructionExpr {
|
|
810
1057
|
text?: string;
|
|
1058
|
+
i18n?: Record<string, string>;
|
|
811
1059
|
coding?: FhirCoding;
|
|
812
1060
|
frames?: AdviceFrame[];
|
|
813
1061
|
evidence?: CanonicalEvidence[];
|
|
814
1062
|
}
|
|
1063
|
+
export interface CanonicalInstructionRelation {
|
|
1064
|
+
kind: AdviceRelation;
|
|
1065
|
+
fromActionIndex?: number;
|
|
1066
|
+
toActionIndex: number;
|
|
1067
|
+
text?: string;
|
|
1068
|
+
span?: TextRange;
|
|
1069
|
+
}
|
|
1070
|
+
export interface CanonicalInstructionCoverage {
|
|
1071
|
+
understoodCharacters: number;
|
|
1072
|
+
opaqueCharacters: number;
|
|
1073
|
+
ratio: number;
|
|
1074
|
+
complete: boolean;
|
|
1075
|
+
}
|
|
1076
|
+
export interface CanonicalInstructionGraph {
|
|
1077
|
+
/** Ordered, language-neutral procedural/administration actions. */
|
|
1078
|
+
actions: AdviceFrame[];
|
|
1079
|
+
/** Explicit temporal/conditional relationships between actions or source clauses. */
|
|
1080
|
+
relations?: CanonicalInstructionRelation[];
|
|
1081
|
+
/** Source span of the canonical primary administration head, when known. */
|
|
1082
|
+
primaryAdministrationSpan?: TextRange;
|
|
1083
|
+
/** Source fragments the parser deliberately did not assign semantics to. */
|
|
1084
|
+
opaqueSpans?: CanonicalSourceSpan[];
|
|
1085
|
+
coverage?: CanonicalInstructionCoverage;
|
|
1086
|
+
/** Exact original source represented by this graph. */
|
|
1087
|
+
sourceText: string;
|
|
1088
|
+
/** Source language when it can be determined without guessing. */
|
|
1089
|
+
sourceLocale?: string;
|
|
1090
|
+
}
|
|
815
1091
|
export interface CanonicalSourceSpan extends TextRange {
|
|
816
1092
|
text: string;
|
|
817
1093
|
tokenIndices?: number[];
|
|
@@ -834,6 +1110,7 @@ export interface CanonicalSigClause {
|
|
|
834
1110
|
schedule?: CanonicalScheduleExpr;
|
|
835
1111
|
prn?: CanonicalPrnExpr;
|
|
836
1112
|
patientInstruction?: string;
|
|
1113
|
+
instructionGraph?: CanonicalInstructionGraph;
|
|
837
1114
|
additionalInstructions?: CanonicalAdditionalInstructionExpr[];
|
|
838
1115
|
leftovers: CanonicalSourceSpan[];
|
|
839
1116
|
evidence: CanonicalEvidence[];
|
|
@@ -873,6 +1150,7 @@ export interface ParseNormalizedMeta {
|
|
|
873
1150
|
coding?: FhirCoding;
|
|
874
1151
|
};
|
|
875
1152
|
patientInstruction?: string;
|
|
1153
|
+
instructionGraph?: CanonicalInstructionGraph;
|
|
876
1154
|
prnReason?: ConceptSiteDetail;
|
|
877
1155
|
prnReasons?: ConceptSiteDetail[];
|
|
878
1156
|
additionalInstructions?: Array<{
|
|
@@ -999,6 +1277,8 @@ export interface NextDueDoseOptions {
|
|
|
999
1277
|
orderedAt?: Date | string;
|
|
1000
1278
|
limit?: number;
|
|
1001
1279
|
priorCount?: number;
|
|
1280
|
+
/** Actual prior administration timestamps used for per-period occurrence caps. */
|
|
1281
|
+
priorDoseTimes?: Array<Date | string>;
|
|
1002
1282
|
timeZone?: string;
|
|
1003
1283
|
eventClock?: EventClockMap;
|
|
1004
1284
|
mealOffsets?: MealOffsetMap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ezmedicationinput",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"description": "Parse concise medication sigs into FHIR R5 Dosage JSON",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"test:dist": "npm run build && vitest run test-dist",
|
|
19
19
|
"build": "tsup && tsc -p tsconfig.types.json",
|
|
20
|
-
"test": "vitest run --dir test"
|
|
20
|
+
"test": "vitest run --dir test",
|
|
21
|
+
"bench:torture": "npm run build && node bench/real-world-torture.mjs",
|
|
22
|
+
"bench:adversarial": "npm run build && node bench/adversarial.mjs",
|
|
23
|
+
"bench:roundtrip": "npm run build && node bench/roundtrip.mjs",
|
|
24
|
+
"bench:suggest": "npm run build && node --expose-gc bench/suggest.mjs"
|
|
21
25
|
},
|
|
22
26
|
"files": [
|
|
23
27
|
"dist"
|