@precisa-saude/fhir 0.1.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 (72) hide show
  1. package/README.md +85 -0
  2. package/dist/biomarkers.cjs +67 -0
  3. package/dist/biomarkers.cjs.map +1 -0
  4. package/dist/biomarkers.d.cts +226 -0
  5. package/dist/biomarkers.d.ts +226 -0
  6. package/dist/biomarkers.js +67 -0
  7. package/dist/biomarkers.js.map +1 -0
  8. package/dist/chunk-2EVQ2ESB.cjs +2692 -0
  9. package/dist/chunk-2EVQ2ESB.cjs.map +1 -0
  10. package/dist/chunk-2X6MT5KE.cjs +1464 -0
  11. package/dist/chunk-2X6MT5KE.cjs.map +1 -0
  12. package/dist/chunk-3ILBFLVQ.cjs +63 -0
  13. package/dist/chunk-3ILBFLVQ.cjs.map +1 -0
  14. package/dist/chunk-FDOBUUGY.js +1464 -0
  15. package/dist/chunk-FDOBUUGY.js.map +1 -0
  16. package/dist/chunk-GFXKYXHW.cjs +436 -0
  17. package/dist/chunk-GFXKYXHW.cjs.map +1 -0
  18. package/dist/chunk-I6H35QXI.js +2692 -0
  19. package/dist/chunk-I6H35QXI.js.map +1 -0
  20. package/dist/chunk-N3ZCOLG2.js +63 -0
  21. package/dist/chunk-N3ZCOLG2.js.map +1 -0
  22. package/dist/chunk-O25F6G3K.cjs +153 -0
  23. package/dist/chunk-O25F6G3K.cjs.map +1 -0
  24. package/dist/chunk-S6VJHXJF.js +153 -0
  25. package/dist/chunk-S6VJHXJF.js.map +1 -0
  26. package/dist/chunk-UIDSSWBJ.js +251 -0
  27. package/dist/chunk-UIDSSWBJ.js.map +1 -0
  28. package/dist/chunk-VPMT4MRS.js +436 -0
  29. package/dist/chunk-VPMT4MRS.js.map +1 -0
  30. package/dist/chunk-Z6YE6FJ4.cjs +251 -0
  31. package/dist/chunk-Z6YE6FJ4.cjs.map +1 -0
  32. package/dist/converter-C-QpCcTL.d.ts +99 -0
  33. package/dist/converter-Dee-qjBV.d.cts +99 -0
  34. package/dist/converter.cjs +15 -0
  35. package/dist/converter.cjs.map +1 -0
  36. package/dist/converter.d.cts +2 -0
  37. package/dist/converter.d.ts +2 -0
  38. package/dist/converter.js +15 -0
  39. package/dist/converter.js.map +1 -0
  40. package/dist/fhir-types-D9hUzGrc.d.cts +129 -0
  41. package/dist/fhir-types-D9hUzGrc.d.ts +129 -0
  42. package/dist/importer.cjs +17 -0
  43. package/dist/importer.cjs.map +1 -0
  44. package/dist/importer.d.cts +60 -0
  45. package/dist/importer.d.ts +60 -0
  46. package/dist/importer.js +17 -0
  47. package/dist/importer.js.map +1 -0
  48. package/dist/index.cjs +540 -0
  49. package/dist/index.cjs.map +1 -0
  50. package/dist/index.d.cts +163 -0
  51. package/dist/index.d.ts +163 -0
  52. package/dist/index.js +540 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/reference-ranges.cjs +18 -0
  55. package/dist/reference-ranges.cjs.map +1 -0
  56. package/dist/reference-ranges.d.cts +106 -0
  57. package/dist/reference-ranges.d.ts +106 -0
  58. package/dist/reference-ranges.js +18 -0
  59. package/dist/reference-ranges.js.map +1 -0
  60. package/dist/units.cjs +19 -0
  61. package/dist/units.cjs.map +1 -0
  62. package/dist/units.d.cts +46 -0
  63. package/dist/units.d.ts +46 -0
  64. package/dist/units.js +19 -0
  65. package/dist/units.js.map +1 -0
  66. package/dist/validators.cjs +11 -0
  67. package/dist/validators.cjs.map +1 -0
  68. package/dist/validators.d.cts +23 -0
  69. package/dist/validators.d.ts +23 -0
  70. package/dist/validators.js +11 -0
  71. package/dist/validators.js.map +1 -0
  72. package/package.json +105 -0
@@ -0,0 +1,129 @@
1
+ /**
2
+ * FHIR R4 Resource Types
3
+ *
4
+ * Type definitions for FHIR R4 resources used in lab result conversion.
5
+ * See: https://hl7.org/fhir/R4/
6
+ */
7
+ interface FHIRCodeableConcept {
8
+ coding?: FHIRCoding[];
9
+ text?: string;
10
+ }
11
+ interface FHIRCoding {
12
+ code?: string;
13
+ display?: string;
14
+ system?: string;
15
+ }
16
+ interface FHIRReference {
17
+ display?: string;
18
+ reference?: string;
19
+ }
20
+ interface FHIRQuantity {
21
+ code?: string;
22
+ system?: string;
23
+ unit?: string;
24
+ value?: number;
25
+ }
26
+ interface FHIRReferenceRange {
27
+ high?: FHIRQuantity;
28
+ low?: FHIRQuantity;
29
+ text?: string;
30
+ }
31
+ interface FHIRPeriod {
32
+ end?: string;
33
+ start?: string;
34
+ }
35
+ interface FHIRObservation {
36
+ category?: FHIRCodeableConcept[];
37
+ code: FHIRCodeableConcept;
38
+ effectiveDateTime?: string;
39
+ effectivePeriod?: FHIRPeriod;
40
+ id?: string;
41
+ interpretation?: FHIRCodeableConcept[];
42
+ issued?: string;
43
+ note?: FHIRAnnotation[];
44
+ performer?: FHIRReference[];
45
+ referenceRange?: FHIRReferenceRange[];
46
+ resourceType: 'Observation';
47
+ status: 'registered' | 'preliminary' | 'final' | 'amended' | 'corrected' | 'cancelled';
48
+ subject?: FHIRReference;
49
+ valueQuantity?: FHIRQuantity;
50
+ valueString?: string;
51
+ }
52
+ interface FHIRAnnotation {
53
+ authorString?: string;
54
+ text: string;
55
+ time?: string;
56
+ }
57
+ interface FHIRDiagnosticReport {
58
+ category?: FHIRCodeableConcept[];
59
+ code: FHIRCodeableConcept;
60
+ conclusion?: string;
61
+ conclusionCode?: FHIRCodeableConcept[];
62
+ effectiveDateTime?: string;
63
+ id?: string;
64
+ issued?: string;
65
+ performer?: FHIRReference[];
66
+ presentedForm?: FHIRAttachment[];
67
+ resourceType: 'DiagnosticReport';
68
+ result?: FHIRReference[];
69
+ resultsInterpreter?: FHIRReference[];
70
+ status: 'registered' | 'partial' | 'preliminary' | 'final' | 'amended' | 'corrected' | 'cancelled';
71
+ subject?: FHIRReference;
72
+ }
73
+ interface FHIRAttachment {
74
+ contentType?: string;
75
+ creation?: string;
76
+ data?: string;
77
+ title?: string;
78
+ url?: string;
79
+ }
80
+ interface FHIRPatient {
81
+ address?: FHIRAddress[];
82
+ birthDate?: string;
83
+ gender?: 'male' | 'female' | 'other' | 'unknown';
84
+ id?: string;
85
+ name?: FHIRHumanName[];
86
+ resourceType: 'Patient';
87
+ telecom?: FHIRContactPoint[];
88
+ }
89
+ interface FHIRHumanName {
90
+ family?: string;
91
+ given?: string[];
92
+ text?: string;
93
+ }
94
+ interface FHIRContactPoint {
95
+ system?: 'phone' | 'email' | 'fax' | 'pager' | 'url' | 'sms' | 'other';
96
+ value?: string;
97
+ }
98
+ interface FHIRAddress {
99
+ city?: string;
100
+ country?: string;
101
+ line?: string[];
102
+ postalCode?: string;
103
+ state?: string;
104
+ }
105
+ interface FHIRMedicationStatement {
106
+ category?: FHIRCodeableConcept;
107
+ dateAsserted?: string;
108
+ effectivePeriod?: FHIRPeriod;
109
+ id?: string;
110
+ medicationCodeableConcept?: FHIRCodeableConcept;
111
+ note?: FHIRAnnotation[];
112
+ resourceType: 'MedicationStatement';
113
+ status: 'active' | 'completed' | 'entered-in-error' | 'intended' | 'not-taken' | 'on-hold' | 'stopped' | 'unknown';
114
+ subject?: FHIRReference;
115
+ }
116
+ /**
117
+ * FHIR Bundle containing all resources
118
+ */
119
+ interface FHIRBundle {
120
+ entry: FHIRBundleEntry[];
121
+ resourceType: 'Bundle';
122
+ type: 'collection' | 'document' | 'message' | 'transaction' | 'batch';
123
+ }
124
+ interface FHIRBundleEntry {
125
+ fullUrl?: string;
126
+ resource: FHIRPatient | FHIRDiagnosticReport | FHIRObservation | FHIRMedicationStatement;
127
+ }
128
+
129
+ export type { FHIRMedicationStatement as F, FHIRObservation as a, FHIRBundle as b, FHIRAddress as c, FHIRAnnotation as d, FHIRAttachment as e, FHIRBundleEntry as f, FHIRCodeableConcept as g, FHIRCoding as h, FHIRContactPoint as i, FHIRDiagnosticReport as j, FHIRHumanName as k, FHIRPatient as l, FHIRPeriod as m, FHIRQuantity as n, FHIRReference as o, FHIRReferenceRange as p };
@@ -0,0 +1,17 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+ var _chunkO25F6G3Kcjs = require('./chunk-O25F6G3K.cjs');
8
+ require('./chunk-2EVQ2ESB.cjs');
9
+ require('./chunk-3ILBFLVQ.cjs');
10
+
11
+
12
+
13
+
14
+
15
+
16
+ exports.MAX_FILE_SIZE = _chunkO25F6G3Kcjs.MAX_FILE_SIZE; exports.MAX_OBSERVATIONS = _chunkO25F6G3Kcjs.MAX_OBSERVATIONS; exports.extractObservationsFromBundle = _chunkO25F6G3Kcjs.extractObservationsFromBundle; exports.mapFHIRObservationToInternal = _chunkO25F6G3Kcjs.mapFHIRObservationToInternal; exports.processImportBundle = _chunkO25F6G3Kcjs.processImportBundle;
17
+ //# sourceMappingURL=importer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/rafael/Github/precisa-saude/fhir-brasil/packages/core/dist/importer.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,4WAAC","file":"/Users/rafael/Github/precisa-saude/fhir-brasil/packages/core/dist/importer.cjs"}
@@ -0,0 +1,60 @@
1
+ import { b as FHIRBundle, a as FHIRObservation } from './fhir-types-D9hUzGrc.cjs';
2
+
3
+ /**
4
+ * FHIR Importer
5
+ *
6
+ * Parses FHIR R4 Bundles and extracts Observation resources with known LOINC codes,
7
+ * mapping them to internal biomarker codes for storage as lab results.
8
+ */
9
+
10
+ interface ImportedObservation {
11
+ biomarkerCode: string;
12
+ biomarkerName: string;
13
+ collectionDate: string;
14
+ flag: 'H' | 'L' | '';
15
+ isQualitative: boolean;
16
+ loincCode: string;
17
+ referenceMax?: number;
18
+ referenceMin?: number;
19
+ unit: string;
20
+ value: number | string;
21
+ }
22
+ interface SkippedEntry {
23
+ index: number;
24
+ loincCode?: string;
25
+ reason: string;
26
+ resourceType?: string;
27
+ }
28
+ interface ImportError {
29
+ details: string;
30
+ field: string;
31
+ }
32
+ interface FHIRImportResult {
33
+ errors: ImportError[];
34
+ imported: ImportedObservation[];
35
+ skipped: SkippedEntry[];
36
+ totalProcessed: number;
37
+ }
38
+ declare const MAX_OBSERVATIONS = 1000;
39
+ declare const MAX_FILE_SIZE: number;
40
+ /**
41
+ * Extract Observation resources from a FHIR Bundle
42
+ */
43
+ declare function extractObservationsFromBundle(bundle: FHIRBundle): {
44
+ observations: FHIRObservation[];
45
+ skipped: SkippedEntry[];
46
+ };
47
+ /**
48
+ * Map a FHIR Observation to internal format using LOINC→biomarker code lookup
49
+ */
50
+ declare function mapFHIRObservationToInternal(observation: FHIRObservation, index: number): {
51
+ observation: ImportedObservation;
52
+ } | {
53
+ skipped: SkippedEntry;
54
+ };
55
+ /**
56
+ * Process a complete FHIR Bundle for import
57
+ */
58
+ declare function processImportBundle(data: unknown): FHIRImportResult;
59
+
60
+ export { type FHIRImportResult, type ImportError, type ImportedObservation, MAX_FILE_SIZE, MAX_OBSERVATIONS, type SkippedEntry, extractObservationsFromBundle, mapFHIRObservationToInternal, processImportBundle };
@@ -0,0 +1,60 @@
1
+ import { b as FHIRBundle, a as FHIRObservation } from './fhir-types-D9hUzGrc.js';
2
+
3
+ /**
4
+ * FHIR Importer
5
+ *
6
+ * Parses FHIR R4 Bundles and extracts Observation resources with known LOINC codes,
7
+ * mapping them to internal biomarker codes for storage as lab results.
8
+ */
9
+
10
+ interface ImportedObservation {
11
+ biomarkerCode: string;
12
+ biomarkerName: string;
13
+ collectionDate: string;
14
+ flag: 'H' | 'L' | '';
15
+ isQualitative: boolean;
16
+ loincCode: string;
17
+ referenceMax?: number;
18
+ referenceMin?: number;
19
+ unit: string;
20
+ value: number | string;
21
+ }
22
+ interface SkippedEntry {
23
+ index: number;
24
+ loincCode?: string;
25
+ reason: string;
26
+ resourceType?: string;
27
+ }
28
+ interface ImportError {
29
+ details: string;
30
+ field: string;
31
+ }
32
+ interface FHIRImportResult {
33
+ errors: ImportError[];
34
+ imported: ImportedObservation[];
35
+ skipped: SkippedEntry[];
36
+ totalProcessed: number;
37
+ }
38
+ declare const MAX_OBSERVATIONS = 1000;
39
+ declare const MAX_FILE_SIZE: number;
40
+ /**
41
+ * Extract Observation resources from a FHIR Bundle
42
+ */
43
+ declare function extractObservationsFromBundle(bundle: FHIRBundle): {
44
+ observations: FHIRObservation[];
45
+ skipped: SkippedEntry[];
46
+ };
47
+ /**
48
+ * Map a FHIR Observation to internal format using LOINC→biomarker code lookup
49
+ */
50
+ declare function mapFHIRObservationToInternal(observation: FHIRObservation, index: number): {
51
+ observation: ImportedObservation;
52
+ } | {
53
+ skipped: SkippedEntry;
54
+ };
55
+ /**
56
+ * Process a complete FHIR Bundle for import
57
+ */
58
+ declare function processImportBundle(data: unknown): FHIRImportResult;
59
+
60
+ export { type FHIRImportResult, type ImportError, type ImportedObservation, MAX_FILE_SIZE, MAX_OBSERVATIONS, type SkippedEntry, extractObservationsFromBundle, mapFHIRObservationToInternal, processImportBundle };
@@ -0,0 +1,17 @@
1
+ import {
2
+ MAX_FILE_SIZE,
3
+ MAX_OBSERVATIONS,
4
+ extractObservationsFromBundle,
5
+ mapFHIRObservationToInternal,
6
+ processImportBundle
7
+ } from "./chunk-S6VJHXJF.js";
8
+ import "./chunk-I6H35QXI.js";
9
+ import "./chunk-N3ZCOLG2.js";
10
+ export {
11
+ MAX_FILE_SIZE,
12
+ MAX_OBSERVATIONS,
13
+ extractObservationsFromBundle,
14
+ mapFHIRObservationToInternal,
15
+ processImportBundle
16
+ };
17
+ //# sourceMappingURL=importer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}