ezmedicationinput 0.2.0 → 0.3.0

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 (86) hide show
  1. package/README.md +216 -18
  2. package/dist/adapters/canonical-course.d.ts +131 -0
  3. package/dist/adapters/r5-course.d.ts +27 -0
  4. package/dist/advice-locale-adapter.d.ts +24 -0
  5. package/dist/advice.d.ts +73 -6
  6. package/dist/body-site-grammar.d.ts +21 -2
  7. package/dist/body-site-lookup.d.ts +8 -0
  8. package/dist/body-site-spatial.d.ts +12 -2
  9. package/dist/body-site-target.d.ts +38 -3
  10. package/dist/canonical/compile.d.ts +98 -0
  11. package/dist/canonical/course.d.ts +388 -0
  12. package/dist/canonical/format-course.d.ts +38 -0
  13. package/dist/clause-tail-grammar.d.ts +2 -0
  14. package/dist/date-interpretation.d.ts +36 -2
  15. package/dist/dosage-course.d.ts +304 -30
  16. package/dist/event-timing-expression.d.ts +26 -1
  17. package/dist/execution/calendar.d.ts +107 -0
  18. package/dist/execution/engine.d.ts +11 -0
  19. package/dist/fhir-quantity-operator.d.ts +89 -0
  20. package/dist/fhir-translations.d.ts +5 -6
  21. package/dist/fhir.d.ts +119 -14
  22. package/dist/format.d.ts +106 -5
  23. package/dist/hpsg/constructions.d.ts +35 -8
  24. package/dist/hpsg/defaults.d.ts +2 -0
  25. package/dist/hpsg/lexical-classes.d.ts +196 -24
  26. package/dist/hpsg/method-lexicon.d.ts +3 -0
  27. package/dist/hpsg/procedural-context.d.ts +48 -5
  28. package/dist/hpsg/projection.d.ts +32 -1
  29. package/dist/hpsg/quantity-lexicon.d.ts +51 -0
  30. package/dist/hpsg/rule-context.d.ts +172 -7
  31. package/dist/hpsg/rules/clinical-quantity-rules.d.ts +16 -7
  32. package/dist/hpsg/rules/condition-rules.d.ts +13 -3
  33. package/dist/hpsg/rules/core-rules.d.ts +8 -2
  34. package/dist/hpsg/rules/instruction-rules.d.ts +2 -0
  35. package/dist/hpsg/rules/prn-rules.d.ts +12 -1
  36. package/dist/hpsg/rules/site-rules.d.ts +10 -1
  37. package/dist/hpsg/rules/timing-rules.d.ts +116 -22
  38. package/dist/hpsg/segmenter.d.ts +2 -2
  39. package/dist/hpsg/signature.d.ts +54 -7
  40. package/dist/hpsg/timing-lexicon.d.ts +18 -2
  41. package/dist/hpsg/unification.d.ts +3 -1
  42. package/dist/i18n.d.ts +37 -1
  43. package/dist/index.cjs +83231 -52284
  44. package/dist/index.d.ts +26 -9
  45. package/dist/index.js +83222 -52284
  46. package/dist/instruction-action-locale-adapter.d.ts +92 -5
  47. package/dist/instruction-action-parser.d.ts +43 -0
  48. package/dist/instruction-action-terminology.d.ts +44 -3
  49. package/dist/instruction-concept-terminology.d.ts +20 -1
  50. package/dist/instruction-graph-fhir.d.ts +10 -2
  51. package/dist/instruction-graph-ownership.d.ts +96 -0
  52. package/dist/instruction-graph.d.ts +68 -49
  53. package/dist/ir.d.ts +1 -1
  54. package/dist/lexer/lex.d.ts +5 -1
  55. package/dist/lexer/locale.d.ts +14 -0
  56. package/dist/lexer/locales/en.d.ts +11 -0
  57. package/dist/lexer/surface-segmenter.d.ts +1 -1
  58. package/dist/lexer/surface.d.ts +4 -1
  59. package/dist/lexer/token-types.d.ts +6 -0
  60. package/dist/locale-detection.d.ts +5 -0
  61. package/dist/locales/clause/en.d.ts +14 -0
  62. package/dist/locales/course/en.d.ts +20 -0
  63. package/dist/locales/course/th.d.ts +12 -0
  64. package/dist/localization.d.ts +76 -0
  65. package/dist/localized-timing.d.ts +1 -1
  66. package/dist/maps.d.ts +44 -10
  67. package/dist/medication-condition.d.ts +72 -11
  68. package/dist/parser-state.d.ts +12 -2
  69. package/dist/parser.d.ts +5 -3
  70. package/dist/prn.d.ts +13 -2
  71. package/dist/regimen/coordination-scope.d.ts +13 -1
  72. package/dist/regimen/grammar.d.ts +18 -1
  73. package/dist/regimen/parallel-course.d.ts +13 -42
  74. package/dist/regimen/planner.d.ts +2 -3
  75. package/dist/regimen/regimen.d.ts +8 -2
  76. package/dist/relation-terminology.d.ts +1 -0
  77. package/dist/schedule.d.ts +14 -10
  78. package/dist/snomed.d.ts +3 -0
  79. package/dist/suggest-locale-adapter.d.ts +15 -0
  80. package/dist/symptom-terminology.d.ts +5 -1
  81. package/dist/timing-summary.d.ts +114 -1
  82. package/dist/types.d.ts +627 -61
  83. package/dist/unit-lexicon.d.ts +4 -1
  84. package/dist/utils/text.d.ts +3 -0
  85. package/dist/utils/units.d.ts +22 -0
  86. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,7 +1,23 @@
1
+ import { formatCanonicalCourse as formatNativeCourse, formatCanonicalAdministration as formatNativeAdministration } from "./canonical/format-course";
2
+ import type { CanonicalCourse, CanonicalAdministration } from "./canonical/course";
3
+ /** Internal native import/projection helpers. Existing .fhir / .fhirNext fields retain
4
+ * their established versions; canonical is the internal source of meaning. */
5
+ export type { CanonicalCourse, CanonicalStage, CanonicalAdministration, CanonicalRecurrence, CanonicalTiming, CanonicalBoundary, CanonicalAmount, CanonicalDoseLimit, CanonicalMeasure, CanonicalRange, CanonicalRatio, CanonicalScheduleInput, CanonicalSupplyOptions } from "./canonical/course";
6
+ export { importCanonicalCourse } from "./adapters/canonical-course";
7
+ /** Apply the same normalized default as the other public formatting entry points. */
8
+ export declare function formatCanonicalAdministration(administration: CanonicalAdministration, style?: "short" | "long", options?: FormatOptions, compiled?: ReadonlyMap<CanonicalAdministration, CanonicalSigClause>, authored?: Parameters<typeof formatNativeAdministration>[4], stageSafety?: Parameters<typeof formatNativeAdministration>[5]): string;
9
+ /** Decode interchange annotations at the public boundary; native composition
10
+ * receives only the selected authored display text and retains the source. */
11
+ export declare function formatCanonicalCourse(course: CanonicalCourse, style?: "short" | "long", options?: FormatBatchOptions, compiled?: ReadonlyMap<CanonicalAdministration, CanonicalSigClause>, authored?: Parameters<typeof formatNativeCourse>[4]): string;
12
+ export declare function projectCanonicalCourse(course: CanonicalCourse, options?: ParseOptions): {
13
+ fhir: FhirDosage[];
14
+ fhirNext: FhirR6DosageInstruction;
15
+ };
1
16
  import { toFhirR5Dosages as toFhirR5DosagesInternal } from "./dosage-course";
2
- import { FhirDosage, EzDosage, FhirR6DosageDetails, FormatBatchOptions, FormatOptions, LintBatchResult, ParseBatchResult, ParseOptions, ParseResult } from "./types";
17
+ import { FhirDosage, EzDosage, FhirR6DosageInstruction, FhirR6DosageInstructionInput, FormatBatchOptions, FormatOptions, LintBatchResult, ParseBatchResult, ParseOptions, ParseResult, CanonicalSigClause } from "./types";
3
18
  export { TIMING_FREQUENCY_MIN_EXTENSION_URL, TIMING_OFFSET_MIN_EXTENSION_URL, TIMING_OFFSET_MAX_EXTENSION_URL, TIMING_OFFSET_EXACT_EXTENSION_URL, TIMING_ACTIVITY_WINDOW_EXTENSION_URL, TIMING_OCCURRENCE_CAP_EXTENSION_URL, TIMING_EVENT_CALENDAR_SOURCE_EXTENSION_URL, PRN_TRIGGER_PHASE_EXTENSION_URL, INFUSION_CARRIER_MATERIAL_EXTENSION_URL, buildInfusionCarrierMaterialStructureDefinition, getTimingOccurrenceCap } from "./fhir";
4
19
  export { suggestSig } from "./suggest";
20
+ export { EMA_QUANTITY_COMPARATOR_EXTENSION_URL, EMA_QUANTITY_OPERATOR_SYSTEM, FHIR_QUANTITY_COMPARATOR_SYSTEM, getEmaQuantityComparator } from "./fhir-quantity-operator";
5
21
  export { parseInstructionActions, realizeInstructionGraph } from "./instruction-graph";
6
22
  export { getInstructionActionLocaleAdapter, registerInstructionActionLocaleAdapter } from "./instruction-action-locale-adapter";
7
23
  export type { InstructionActionLocaleAdapter, InstructionActionRealizationInput } from "./instruction-action-locale-adapter";
@@ -15,7 +31,7 @@ export { listMedicationSurfaceSegmenters, registerIntlMedicationSurfaceSegmenter
15
31
  export type { MedicationSurfaceSegment, MedicationSurfaceSegmenter } from "./lexer/surface-segmenter";
16
32
  export { getSuggestLocaleAdapter, registerSuggestLocaleAdapter } from "./suggest-locale-adapter";
17
33
  export type { SuggestLocaleAdapter, SuggestLocaleLexemeResolver, SuggestLocaleUnitRoutePair } from "./suggest-locale-adapter";
18
- export { MEDICATION_INSTRUCTION_ACTION_SYSTEM, buildMedicationInstructionActionCodeSystem, getMedicationInstructionAction, listMedicationInstructionActions, resolveMedicationInstructionAction, resolveMedicationInstructionSequenceAction } from "./instruction-action-terminology";
34
+ export { MEDICATION_INSTRUCTION_ACTION_SYSTEM, buildMedicationInstructionActionCodeSystem, getMedicationInstructionAction, listMedicationInstructionActions, resolveMedicationInstructionActionWithCodeFallback as resolveMedicationInstructionAction, resolveMedicationInstructionSequenceAction } from "./instruction-action-terminology";
19
35
  export type { MedicationInstructionActionCodeSystem } from "./instruction-action-terminology";
20
36
  export { MEDICATION_INSTRUCTION_CONCEPT_SYSTEM, buildMedicationInstructionConceptCodeSystem, getMedicationInstructionConcept, listMedicationInstructionConcepts, resolveMedicationInstructionConcept } from "./instruction-concept-terminology";
21
37
  export type { MedicationInstructionConceptCodeSystem } from "./instruction-concept-terminology";
@@ -26,7 +42,7 @@ export type { AdviceRelationDefinition, AdviceRelationGrammarFeatures, BodySiteL
26
42
  export { MEDICATION_INSTRUCTION_GRAPH_EXTENSION_URL, buildInstructionGraphExtension, parseInstructionGraphExtension } from "./instruction-graph-fhir";
27
43
  export * from "./types";
28
44
  export { nextDueDoses, calculateTotalUnits, MedicationQuantityCalculationError } from "./schedule";
29
- export { toDosageDetails, toEzDosages, fromDosageDetails, getDosageCondition, setDosageCondition, getDosageExcludedDates, setDosageExcludedDates, getDosageExcludedWeekdays, setDosageExcludedWeekdays, DOSAGE_CONDITION_R5_URL, DOSAGE_EXCLUDED_DATES_R5_URL, DOSAGE_EXCLUDED_WEEKDAYS_R5_URL, DOSAGE_DETAILS_R5_URL, DOSAGE_ALTERNATIVE_CHOICE_URL, getDosageAlternativeChoice, setDosageAlternativeChoice, buildDosageAlternativeChoiceStructureDefinition } from "./dosage-course";
45
+ export { toDosageDetails, toEzDosages, fromDosageDetails, projectEditableR5Course, getDosageCondition, setDosageCondition, getDosageExcludedDates, setDosageExcludedDates, getDosageExcludedWeekdays, setDosageExcludedWeekdays, DOSAGE_CONDITION_R5_URL, DOSAGE_EXCLUDED_DATES_R5_URL, DOSAGE_EXCLUDED_WEEKDAYS_R5_URL, DOSAGE_DETAILS_R5_URL, DOSAGE_ALTERNATIVE_CHOICE_URL, getDosageAlternativeChoice, setDosageAlternativeChoice, buildDosageAlternativeChoiceStructureDefinition } from "./dosage-course";
30
46
  export type { DosageAlternativeChoice } from "./dosage-course";
31
47
  export { evaluateMedicationCondition } from "./medication-condition";
32
48
  export { parseStrength, parseStrengthIntoRatio, parseStrengthComponents } from "./utils/strength";
@@ -38,7 +54,7 @@ export { BODY_SITE_SPATIAL_RELATION_EXTENSION_URL, buildBodySiteSpatialRelationE
38
54
  export { SNOMED_CT_FINDING_SITE_ATTRIBUTE_CODE, SNOMED_CT_FINDING_SITE_ATTRIBUTE_DISPLAY, SNOMED_CT_BILATERAL_QUALIFIER_CODE, SNOMED_CT_BILATERAL_QUALIFIER_DISPLAY, SNOMED_CT_LATERALITY_ATTRIBUTE_CODE, SNOMED_CT_LATERALITY_ATTRIBUTE_DISPLAY, SNOMED_CT_LEFT_QUALIFIER_CODE, SNOMED_CT_LEFT_QUALIFIER_DISPLAY, SNOMED_CT_RIGHT_QUALIFIER_CODE, SNOMED_CT_RIGHT_QUALIFIER_DISPLAY, SNOMED_CT_TOPOGRAPHICAL_MODIFIER_CODE, SNOMED_CT_TOPOGRAPHICAL_MODIFIER_DISPLAY, SNOMED_SYSTEM } from "./snomed";
39
55
  export { buildSnomedBodySiteLateralityPostcoordinationCode, buildSnomedBodySiteTopographicalModifierPostcoordinationCode, buildSnomedFindingSiteCoding, buildSnomedFindingSitePostcoordinationCode, hasSnomedBodySiteLateralityPostcoordination, hasSnomedFindingSitePostcoordination, hasSnomedTopographicalModifierPostcoordination, parseSnomedBodySiteLateralityPostcoordinationCode, parseSnomedBodySiteTopographicalModifierPostcoordinationCode, parseSnomedFindingSitePostcoordinationCode } from "./snomed-postcoordination";
40
56
  export { getRegisteredSigLocalizations, registerSigLocalization, resolveSigLocalization, resolveSigTranslation } from "./i18n";
41
- export type { SigLocalization, SigLocalizationConfig, SigTranslation, SigTranslationConfig } from "./i18n";
57
+ export type { CourseLanguage, SigLocalization, SigLocalizationConfig, SigTranslation, SigTranslationConfig } from "./i18n";
42
58
  export { findMedicationDateListSpans, listMedicationDateResolvers, parseMedicationDateListAt, registerMedicationDateResolver } from "./date-interpretation";
43
59
  export { DEFAULT_BODY_SITE_SNOMED, DEFAULT_BODY_SITE_SNOMED_SOURCE, DEFAULT_ROUTE_SYNONYMS, DEFAULT_UNIT_BY_ROUTE, KNOWN_DOSAGE_FORMS_TO_DOSE } from './maps';
44
60
  /** The public strict R5 converter must carry the same in-memory FHIR contract
@@ -50,13 +66,14 @@ export declare function toFhirR5Dosages(input: Parameters<typeof toFhirR5Dosages
50
66
  export declare function parseSig(input: string, options?: ParseOptions): ParseBatchResult;
51
67
  export declare function lintSig(input: string, options?: ParseOptions): LintBatchResult;
52
68
  export declare function parseSigAsync(input: string, options?: ParseOptions): Promise<ParseBatchResult>;
53
- export declare function formatSig(input: FhirDosage | FhirR6DosageDetails | readonly EzDosage[], style?: "short" | "long", options?: FormatOptions): string;
69
+ export declare function formatSig(input: FhirDosage | FhirR6DosageInstructionInput | readonly EzDosage[] | CanonicalCourse | CanonicalAdministration, style?: "short" | "long", options?: FormatOptions): string;
54
70
  export declare function formatSigBatch(dosages: FhirDosage[], style?: "short" | "long", options?: FormatBatchOptions): string;
55
71
  export declare function formatParseBatch(batch: ParseBatchResult, style?: "short" | "long", separator?: string): string;
56
72
  /**
57
- * Load an R6 DosageDetails without reparsing a generated text instruction.
58
- * R5 component lowerings exist solely for per-clause provenance and formatting;
59
- * the original whole-course R6 object remains the primary FHIR output.
73
+ * Load the current R6 DosageInstruction without reparsing a generated text instruction.
74
+ * Native components are imported into the same clinical course the parser
75
+ * produces. R5 component rows are OUTPUT projections only, never interpreted
76
+ * or formatted back into native semantics.
60
77
  */
61
- export declare function fromFhir(dosageDetails: FhirR6DosageDetails, options?: FormatOptions): ParseBatchResult;
78
+ export declare function fromFhir(wire: FhirR6DosageInstructionInput, options?: FormatOptions): ParseBatchResult;
62
79
  export declare function fromFhirDosage(dosage: FhirDosage, options?: FormatOptions): ParseResult;