@glion/annotate-profile-fields 0.26.0 → 0.27.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Rethink Health
3
+ Copyright (c) 2023 Rethink Health, SUARL
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,SAAS;QACjB,mDAAmD;QACnD,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,iDAAiD;QACjD,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACxB,yEAAyE;QACzE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,6CAA6C;QAC7C,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;QACtC,qEAAqE;QACrE,WAAW,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;QAC3C,6DAA6D;QAC7D,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,6CAA6C;QAC7C,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,0DAA0D;QAC1D,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,qCAAqC;QACrC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CA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ANGED
@@ -12,12 +12,13 @@ import { SKIP, visit } from "@glion/util-visit";
12
12
  const hl7v2AnnotateProfileFields = () => (tree, file) => {
13
13
  const ctx = file.data.profile;
14
14
  if (!ctx) return tree;
15
- visit(tree, "field", (node, ancestors, info) => {
16
- const segment = ancestors.at(-1);
17
- if (segment?.type !== "segment") return SKIP;
18
- const profile = ctx.fields.get(segment.name)?.bySequence.get(info.sequence);
19
- if (!profile) return SKIP;
20
- Object.assign(node.data ??= {}, profile);
15
+ visit(tree, "segment", (segment) => {
16
+ const fields = ctx.fields.get(segment.name);
17
+ if (!fields) return SKIP;
18
+ for (const [sequence, profile] of fields.bySequence) {
19
+ const field = segment.children[sequence - 1];
20
+ if (field) Object.assign(field.data ??= {}, profile);
21
+ }
21
22
  return SKIP;
22
23
  });
23
24
  return tree;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers VFile DataMap augmentation\nimport type { ProfileContext } from \"@glion/annotate-profile-context\";\nimport type { Root, Segment } from \"@glion/ast\";\nimport type { FieldRepetitions } from \"@glion/profiles\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport type { Optionality } from \"@glion/utils\";\nimport type { Plugin } from \"unified\";\nimport type { VFile } from \"vfile\";\n\ndeclare module \"@glion/ast\" {\n interface FieldData {\n /** Position of this field in its segment (SEQ). */\n sequence?: number | undefined;\n /** Field identifier (e.g., \"MSH-9\", \"PID-3\"). */\n id?: string | undefined;\n /** Human-readable field name from the profile (e.g., \"Patient Name\"). */\n name?: string | undefined;\n /** HL7v2 optionality of this field (OPT). */\n optionality?: Optionality | undefined;\n /** Most occurrences this field may have (RP/#), or `\"unbounded\"`. */\n repetitions?: FieldRepetitions | undefined;\n /** Datatype ID for this field (e.g., \"XPN\", \"ST\", \"CWE\"). */\n datatype?: string | undefined;\n /** Maximum allowed length for this field. */\n maxLength?: number | undefined;\n /** Table reference for coded fields (e.g., \"HL70001\"). */\n table?: string | undefined;\n /** HL7 specification item number. */\n item?: string | undefined;\n }\n}\n\n/**\n * Unified plugin that annotates Field nodes with profile metadata.\n *\n * Reads field definitions from `file.data.fields` (populated by\n * `@glion/annotate-profile-context`) and copies each field's profile, as\n * the profile gives it, onto `field.data`.\n *\n * Unknown segments (Z-segments) and unsupported versions are silently skipped.\n */\nexport const hl7v2AnnotateProfileFields: Plugin<[], Root, Root> =\n () => (tree: Root, file: VFile) => {\n const ctx = file.data.profile;\n if (!ctx) {\n return tree;\n }\n\n // Annotate each field with its profile\n visit(tree, \"field\", (node, ancestors, info) => {\n const segment = ancestors.at(-1) as Segment | undefined;\n if (segment?.type !== \"segment\") {\n return SKIP;\n }\n\n const profile = ctx.fields\n .get(segment.name)\n ?.bySequence.get(info.sequence);\n if (!profile) {\n return SKIP;\n }\n\n Object.assign((node.data ??= {}), profile);\n return SKIP;\n });\n\n return tree;\n };\n\nexport default hl7v2AnnotateProfileFields;\n"],"mappings":";;;;;;;;;;;AAyCA,MAAa,oCACJ,MAAY,SAAgB;CACjC,MAAM,MAAM,KAAK,KAAK;AACtB,KAAI,CAAC,IACH,QAAO;AAIT,OAAM,MAAM,UAAU,MAAM,WAAW,SAAS;EAC9C,MAAM,UAAU,UAAU,GAAG,GAAG;AAChC,MAAI,SAAS,SAAS,UACpB,QAAO;EAGT,MAAM,UAAU,IAAI,OACjB,IAAI,QAAQ,KAAK,EAChB,WAAW,IAAI,KAAK,SAAS;AACjC,MAAI,CAAC,QACH,QAAO;AAGT,SAAO,OAAQ,KAAK,SAAS,EAAE,EAAG,QAAQ;AAC1C,SAAO;GACP;AAEF,QAAO"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers VFile DataMap augmentation\nimport type { ProfileContext } from \"@glion/annotate-profile-context\";\nimport type { Root } from \"@glion/ast\";\nimport type { FieldRepetitions } from \"@glion/profiles\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport type { Optionality } from \"@glion/utils\";\nimport type { Plugin } from \"unified\";\nimport type { VFile } from \"vfile\";\n\ndeclare module \"@glion/ast\" {\n interface FieldData {\n /** Position of this field in its segment (SEQ). */\n sequence?: number | undefined;\n /** Field identifier (e.g., \"MSH-9\", \"PID-3\"). */\n id?: string | undefined;\n /** Human-readable field name from the profile (e.g., \"Patient Name\"). */\n name?: string | undefined;\n /** HL7v2 optionality of this field (OPT). */\n optionality?: Optionality | undefined;\n /** Most occurrences this field may have (RP/#), or `\"unbounded\"`. */\n repetitions?: FieldRepetitions | undefined;\n /** Datatype ID for this field (e.g., \"XPN\", \"ST\", \"CWE\"). */\n datatype?: string | undefined;\n /** Maximum allowed length for this field. */\n maxLength?: number | undefined;\n /** Table reference for coded fields (e.g., \"HL70001\"). */\n table?: string | undefined;\n /** HL7 specification item number. */\n item?: string | undefined;\n }\n}\n\n/**\n * Unified plugin that annotates Field nodes with profile metadata.\n *\n * Reads field definitions from `file.data.fields` (populated by\n * `@glion/annotate-profile-context`) and copies each field's profile, as\n * the profile gives it, onto `field.data`.\n *\n * Unknown segments (Z-segments) and unsupported versions are silently skipped.\n */\nexport const hl7v2AnnotateProfileFields: Plugin<[], Root, Root> =\n () => (tree: Root, file: VFile) => {\n const ctx = file.data.profile;\n if (!ctx) {\n return tree;\n }\n\n visit(tree, \"segment\", (segment) => {\n const fields = ctx.fields.get(segment.name);\n if (!fields) {\n return SKIP;\n }\n\n for (const [sequence, profile] of fields.bySequence) {\n const field = segment.children[sequence - 1];\n if (field) {\n Object.assign((field.data ??= {}), profile);\n }\n }\n return SKIP;\n });\n\n return tree;\n };\n\nexport default hl7v2AnnotateProfileFields;\n"],"mappings":";;;;;;;;;;;AAyCA,MAAa,oCACJ,MAAY,SAAgB;CACjC,MAAM,MAAM,KAAK,KAAK;AACtB,KAAI,CAAC,IACH,QAAO;AAGT,OAAM,MAAM,YAAY,YAAY;EAClC,MAAM,SAAS,IAAI,OAAO,IAAI,QAAQ,KAAK;AAC3C,MAAI,CAAC,OACH,QAAO;AAGT,OAAK,MAAM,CAAC,UAAU,YAAY,OAAO,YAAY;GACnD,MAAM,QAAQ,QAAQ,SAAS,WAAW;AAC1C,OAAI,MACF,QAAO,OAAQ,MAAM,SAAS,EAAE,EAAG,QAAQ;;AAG/C,SAAO;GACP;AAEF,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glion/annotate-profile-fields",
3
- "version": "0.26.0",
3
+ "version": "0.27.1",
4
4
  "description": "Unified plugin to annotate HL7v2 field nodes with profile metadata",
5
5
  "keywords": [
6
6
  "annotate",
@@ -39,9 +39,9 @@
39
39
  "dependencies": {
40
40
  "unified": "11.0.5",
41
41
  "vfile": "6.0.3",
42
- "@glion/util-visit": "0.26.0",
43
- "@glion/ast": "0.26.0",
44
- "@glion/utils": "0.26.0"
42
+ "@glion/ast": "0.27.1",
43
+ "@glion/util-visit": "0.27.1",
44
+ "@glion/utils": "0.27.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "25.6.0",
@@ -50,13 +50,13 @@
50
50
  "tsdown": "0.21.10",
51
51
  "typescript": "6.0.3",
52
52
  "vitest": "4.1.11",
53
- "@glion/builder": "0.26.0",
53
+ "@glion/builder": "0.27.1",
54
54
  "@glion/check-readme": "0.18.0",
55
- "@glion/annotate-profile-context": "0.26.0",
56
- "@glion/parser": "0.26.0",
57
- "@glion/profiles": "0.26.0",
58
- "@glion/testing": "0.18.0",
59
- "@glion/tsconfig": "0.18.0"
55
+ "@glion/annotate-profile-context": "0.27.1",
56
+ "@glion/parser": "0.27.1",
57
+ "@glion/profiles": "0.27.1",
58
+ "@glion/tsconfig": "0.18.0",
59
+ "@glion/testing": "0.18.0"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=22"