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.
Files changed (41) hide show
  1. package/README.md +111 -25
  2. package/dist/advice.d.ts +1 -0
  3. package/dist/body-site-grammar.d.ts +3 -1
  4. package/dist/event-timing-expression.d.ts +8 -0
  5. package/dist/fhir.d.ts +10 -1
  6. package/dist/hpsg/constructions.d.ts +6 -0
  7. package/dist/hpsg/defaults.d.ts +1 -0
  8. package/dist/hpsg/feature-structure.d.ts +5 -0
  9. package/dist/hpsg/lexical-classes.d.ts +70 -7
  10. package/dist/hpsg/method-lexicon.d.ts +14 -14
  11. package/dist/hpsg/procedural-context.d.ts +10 -0
  12. package/dist/hpsg/rules/condition-rules.d.ts +4 -0
  13. package/dist/hpsg/rules/core-rules.d.ts +2 -0
  14. package/dist/hpsg/rules/instruction-rules.d.ts +1 -0
  15. package/dist/hpsg/rules/prn-rules.d.ts +11 -0
  16. package/dist/hpsg/rules/timing-rules.d.ts +28 -0
  17. package/dist/hpsg/segmenter.d.ts +2 -1
  18. package/dist/hpsg/signature.d.ts +54 -2
  19. package/dist/hpsg/type-system.d.ts +48 -0
  20. package/dist/i18n.d.ts +2 -0
  21. package/dist/index.cjs +25759 -9747
  22. package/dist/index.d.ts +11 -0
  23. package/dist/index.js +25720 -9744
  24. package/dist/instruction-action-terminology.d.ts +29 -0
  25. package/dist/instruction-concept-terminology.d.ts +26 -0
  26. package/dist/instruction-graph-fhir.d.ts +4 -0
  27. package/dist/instruction-graph.d.ts +23 -0
  28. package/dist/instruction-semantic-resolver.d.ts +4 -0
  29. package/dist/ir.d.ts +1 -0
  30. package/dist/lexer/locale.d.ts +8 -0
  31. package/dist/lexer/token-types.d.ts +2 -0
  32. package/dist/localized-timing.d.ts +1 -0
  33. package/dist/maps.d.ts +2 -8
  34. package/dist/parser-state.d.ts +16 -0
  35. package/dist/prn.d.ts +1 -0
  36. package/dist/relation-terminology.d.ts +101 -0
  37. package/dist/stable-structure.d.ts +1 -0
  38. package/dist/symptom-terminology.d.ts +12 -0
  39. package/dist/timing-summary.d.ts +2 -0
  40. package/dist/types.d.ts +284 -4
  41. package/package.json +6 -2
@@ -1,21 +1,34 @@
1
- import { CanonicalDoseRange, CanonicalAdditionalInstructionExpr, BodySiteSpatialRelation, EventTiming, FhirCoding, FhirDayOfWeek, FhirPeriodUnit, FhirPrimitiveElement, RouteCode, PrnReasonLookupRequest, SiteCodeLookupRequest } from "../types";
1
+ import { AdviceFrame, AdviceRelation, CanonicalDoseRange, CanonicalAdditionalInstructionExpr, CanonicalActivityTimingExpr, CanonicalOccurrenceCapExpr, BodySiteSpatialRelation, EventTiming, FhirCoding, FhirDayOfWeek, FhirPeriodUnit, FhirPrimitiveElement, RouteCode, PrnReasonLookupRequest, SiteCodeLookupRequest } from "../types";
2
2
  import { Token } from "../parser-state";
3
- export type HpsgType = "sign" | "word-sign" | "phrase-sign" | "clause-sign" | "method-sign" | "route-sign" | "site-sign" | "dose-sign" | "schedule-sign" | "prn-sign" | "instruction-sign" | "connector-sign";
3
+ import type { HpsgFeatureNode } from "./type-system";
4
+ export type HpsgType = "sign" | "word-sign" | "phrase-sign" | "headed-phrase" | "head-complement-phrase" | "head-adjunct-phrase" | "head-marker-phrase" | "procedure-sequence-phrase" | "conditional-instruction-phrase" | "coordination-phrase" | "clause-sign" | "administration-clause" | "method-sign" | "route-sign" | "site-sign" | "dose-sign" | "schedule-sign" | "prn-sign" | "instruction-sign" | "conditional-sign" | "adjustment-sign" | "connector-sign";
4
5
  export interface HpsgEvidence {
5
6
  rule: string;
6
7
  tokenIndices: number[];
7
8
  }
9
+ export type HpsgConstructionKind = "head-complement" | "head-adjunct" | "head-marker" | "procedure-sequence" | "conditional-instruction" | "coordination" | "administration-clause" | "generic";
10
+ export type HpsgConstructionOperation = "unify" | "scope";
11
+ export interface HpsgConstruction {
12
+ kind: HpsgConstructionKind;
13
+ operation?: HpsgConstructionOperation;
14
+ headSide?: "left" | "right";
15
+ leftType: HpsgType;
16
+ rightType: HpsgType;
17
+ }
8
18
  export interface HpsgMethodFeature {
9
19
  verb: string;
20
+ headClass?: "administration" | "procedure";
10
21
  text?: string;
11
22
  textElement?: FhirPrimitiveElement;
12
23
  coding?: FhirCoding;
13
24
  }
14
25
  export interface HpsgRouteFeature {
15
26
  code: RouteCode;
27
+ attachmentClass?: "administration" | "procedure";
16
28
  text?: string;
17
29
  }
18
30
  export interface HpsgSiteFeature {
31
+ attachmentClass?: "administration" | "procedure";
19
32
  text?: string;
20
33
  i18n?: Record<string, string>;
21
34
  source?: "abbreviation" | "text" | "selection" | "resolver";
@@ -26,9 +39,11 @@ export interface HpsgSiteFeature {
26
39
  export interface HpsgPrnFeature {
27
40
  enabled: true;
28
41
  reasonText?: string;
42
+ triggerPhase?: "onset";
29
43
  lookupRequest?: PrnReasonLookupRequest;
30
44
  reasons?: Array<{
31
45
  text: string;
46
+ triggerPhase?: "onset";
32
47
  lookupRequest?: PrnReasonLookupRequest;
33
48
  }>;
34
49
  lookupRequests?: PrnReasonLookupRequest[];
@@ -38,14 +53,36 @@ export interface HpsgInstructionFeature extends CanonicalAdditionalInstructionEx
38
53
  export interface HpsgPatientInstructionFeature {
39
54
  text: string;
40
55
  }
56
+ export interface HpsgConditionFeature {
57
+ relation: AdviceRelation;
58
+ text: string;
59
+ fullText: string;
60
+ sourceStart: number;
61
+ sourceEnd: number;
62
+ targetStart: number;
63
+ targetEnd: number;
64
+ safety: boolean;
65
+ frames: AdviceFrame[];
66
+ }
67
+ export interface HpsgScopedAdministrationFeature {
68
+ condition: HpsgConditionFeature;
69
+ head: HpsgSynsem["head"];
70
+ site?: HpsgSiteFeature;
71
+ prn?: HpsgPrnFeature;
72
+ instructions?: HpsgInstructionFeature[];
73
+ patientInstruction?: HpsgPatientInstructionFeature;
74
+ }
41
75
  export interface HpsgDoseFeature {
76
+ attachmentClass?: "administration" | "procedure";
42
77
  value?: number;
43
78
  range?: CanonicalDoseRange;
44
79
  unit?: string;
45
80
  }
46
81
  export interface HpsgScheduleFeature {
82
+ attachmentClass?: "administration" | "procedure";
47
83
  timingCode?: string;
48
84
  count?: number;
85
+ countMax?: number;
49
86
  duration?: number;
50
87
  durationMax?: number;
51
88
  durationUnit?: FhirPeriodUnit;
@@ -54,9 +91,14 @@ export interface HpsgScheduleFeature {
54
91
  period?: number;
55
92
  periodMax?: number;
56
93
  periodUnit?: FhirPeriodUnit;
94
+ offset?: number;
95
+ offsetMin?: number;
96
+ offsetMax?: number;
57
97
  when?: EventTiming[];
58
98
  dayOfWeek?: FhirDayOfWeek[];
59
99
  timeOfDay?: string[];
100
+ activityTiming?: CanonicalActivityTimingExpr[];
101
+ occurrenceCap?: CanonicalOccurrenceCapExpr;
60
102
  }
61
103
  export interface HpsgSynsem {
62
104
  head: {
@@ -73,6 +115,12 @@ export interface HpsgSynsem {
73
115
  };
74
116
  cont: {
75
117
  clauseKind?: "administration";
118
+ condition?: HpsgConditionFeature;
119
+ scopedAdministrations?: HpsgScopedAdministrationFeature[];
120
+ scopeClosed?: true;
121
+ };
122
+ nonlocal?: {
123
+ scopeRequirements?: HpsgConditionFeature[];
76
124
  };
77
125
  }
78
126
  export interface HpsgSign {
@@ -83,6 +131,10 @@ export interface HpsgSign {
83
131
  };
84
132
  tokens: Token[];
85
133
  synsem: HpsgSynsem;
134
+ /** Formal typed feature graph used by the HPSG constraint substrate. */
135
+ fs: HpsgFeatureNode;
136
+ /** Immediate phrase-construction provenance for non-lexical signs. */
137
+ construction?: HpsgConstruction;
86
138
  consumedTokenIndices: number[];
87
139
  siteTokenIndices?: number[];
88
140
  warnings?: string[];
@@ -0,0 +1,48 @@
1
+ export interface HpsgAppropriateFeature {
2
+ valueType: string;
3
+ required?: boolean;
4
+ }
5
+ export interface HpsgTypeDefinition {
6
+ name: string;
7
+ parents?: string[];
8
+ features?: Record<string, HpsgAppropriateFeature>;
9
+ }
10
+ export type HpsgFeatureValue = HpsgFeatureNode | HpsgFeatureAtom;
11
+ export interface HpsgFeatureNode {
12
+ kind: "node";
13
+ type: string;
14
+ features: Record<string, HpsgFeatureValue>;
15
+ }
16
+ export interface HpsgFeatureAtom {
17
+ kind: "atom";
18
+ type: "atom" | "string" | "number" | "boolean" | "json";
19
+ value: unknown;
20
+ }
21
+ export interface HpsgFeatureValidationIssue {
22
+ path: string;
23
+ message: string;
24
+ }
25
+ export interface HpsgUnificationResult {
26
+ value?: HpsgFeatureValue;
27
+ issues: HpsgFeatureValidationIssue[];
28
+ }
29
+ export declare class HpsgTypeSystem {
30
+ private readonly definitions;
31
+ private readonly subtypeCache;
32
+ private readonly appropriateCache;
33
+ private readonly compatibleTypeCache;
34
+ constructor(definitions?: HpsgTypeDefinition[]);
35
+ addType(definition: HpsgTypeDefinition): void;
36
+ hasType(type: string): boolean;
37
+ definition(type: string): HpsgTypeDefinition | undefined;
38
+ isSubtype(actual: string, expected: string): boolean;
39
+ mostSpecificCompatibleType(left: string, right: string): string | undefined;
40
+ appropriateFeatures(type: string): Record<string, HpsgAppropriateFeature>;
41
+ }
42
+ export declare function featureNode(type: string, features?: Record<string, HpsgFeatureValue>): HpsgFeatureNode;
43
+ export declare function featureAtom(value: unknown, type?: HpsgFeatureAtom["type"]): HpsgFeatureAtom;
44
+ export declare function validateFeatureStructureShallow(value: HpsgFeatureNode, typeSystem: HpsgTypeSystem, path?: string): HpsgFeatureValidationIssue[];
45
+ export declare function validateFeatureStructure(value: HpsgFeatureValue, typeSystem: HpsgTypeSystem, path?: string, visited?: Set<HpsgFeatureNode>): HpsgFeatureValidationIssue[];
46
+ export declare function unifyFeatureStructures(left: HpsgFeatureValue, right: HpsgFeatureValue, typeSystem: HpsgTypeSystem): HpsgUnificationResult;
47
+ export declare function canonicalFeatureStructure(value: HpsgFeatureValue): string;
48
+ export declare const HPSG_TYPE_SYSTEM: HpsgTypeSystem;
package/dist/i18n.d.ts CHANGED
@@ -5,6 +5,8 @@ export interface SigFormatContext {
5
5
  readonly defaultText: string;
6
6
  readonly groupMealTimingsByRelation: boolean;
7
7
  readonly includeTimesPerDaySummary: boolean;
8
+ readonly realizationMode: "normalized" | "roundtrip";
9
+ readonly sitePlacement: "natural" | "trailing";
8
10
  formatDefault(style: "short" | "long"): string;
9
11
  }
10
12
  export interface SigShortContext extends SigFormatContext {