@claudebernard/node-fhir-mapper 2.1.2
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.md +1 -0
- package/README.md +512 -0
- package/dist/index.d.ts +327 -0
- package/dist/index.js +1751 -0
- package/package.json +48 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { Dosage, Bundle } from 'fhir/r5';
|
|
2
|
+
import { CBPatient } from '@claudebernard/types';
|
|
3
|
+
|
|
4
|
+
interface BCBPosologieStructuree2 {
|
|
5
|
+
adequationUP?: number | null;
|
|
6
|
+
codeDuree1?: number | null;
|
|
7
|
+
codeDuree2?: number | null;
|
|
8
|
+
codeDuree3?: number | null;
|
|
9
|
+
codeIndication?: string | null;
|
|
10
|
+
codeMoment?: number | null;
|
|
11
|
+
codeNature?: number | null;
|
|
12
|
+
codePar?: string | null;
|
|
13
|
+
codeProfil?: number | null;
|
|
14
|
+
codeSpecifPrise1?: number | null;
|
|
15
|
+
codeSpecifPrise2?: number | null;
|
|
16
|
+
codeTerrain?: number | null;
|
|
17
|
+
codeUnitePrise?: number | null;
|
|
18
|
+
codeVoie?: number | null;
|
|
19
|
+
coeffMoment?: number | null;
|
|
20
|
+
combien1?: number | null;
|
|
21
|
+
combien2?: number | null;
|
|
22
|
+
idProduit?: number | null;
|
|
23
|
+
implicite?: number | null;
|
|
24
|
+
libDuree1?: string | null;
|
|
25
|
+
libDuree2?: string | null;
|
|
26
|
+
libDuree3?: string | null;
|
|
27
|
+
libIndication?: string | null;
|
|
28
|
+
libSpecifPrise1?: string | null;
|
|
29
|
+
libUnitePrise?: string | null;
|
|
30
|
+
libVoie?: string | null;
|
|
31
|
+
libellePosologie?: string | null;
|
|
32
|
+
maximum?: number | null;
|
|
33
|
+
maximumPoids?: number | null;
|
|
34
|
+
nbUnites?: number | null;
|
|
35
|
+
noPosologie?: number | null;
|
|
36
|
+
parKilo?: number | null;
|
|
37
|
+
pendant1?: number | null;
|
|
38
|
+
pendant2?: number | null;
|
|
39
|
+
quantite1?: number | null;
|
|
40
|
+
quantite2?: number | null;
|
|
41
|
+
tousLes?: number | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* CB Posology Bean interface representing posology information
|
|
46
|
+
* Converted from Java PosologyBean class to TypeScript interface
|
|
47
|
+
*/
|
|
48
|
+
interface CBPosologyBean {
|
|
49
|
+
adequacy?: number;
|
|
50
|
+
biologicalCriterion?: string;
|
|
51
|
+
biologicalValue?: string;
|
|
52
|
+
byCode?: string;
|
|
53
|
+
code?: number;
|
|
54
|
+
comment?: string;
|
|
55
|
+
decodedPosology?: string;
|
|
56
|
+
duration1Code?: number;
|
|
57
|
+
duration1Label?: string;
|
|
58
|
+
duration1PluralLabel?: string;
|
|
59
|
+
duration2Code?: number;
|
|
60
|
+
duration2Label?: string;
|
|
61
|
+
duration2PluralLabel?: string;
|
|
62
|
+
duration3Code?: number;
|
|
63
|
+
duration3Label?: string;
|
|
64
|
+
duration3PluralLabel?: string;
|
|
65
|
+
during1?: number;
|
|
66
|
+
during2?: number;
|
|
67
|
+
every?: number;
|
|
68
|
+
howMuch1?: number;
|
|
69
|
+
howMuch2?: number;
|
|
70
|
+
implicit?: number;
|
|
71
|
+
indicationCode?: string;
|
|
72
|
+
indicationLabel?: string;
|
|
73
|
+
intakeHours?: string;
|
|
74
|
+
intakeSpecification1Code?: number;
|
|
75
|
+
intakeSpecification1Label?: string;
|
|
76
|
+
intakeSpecification2Code?: number;
|
|
77
|
+
intakeSpecification2Label?: string;
|
|
78
|
+
intakeUnitCode?: number;
|
|
79
|
+
intakeUnitLabel?: string;
|
|
80
|
+
maximum?: number;
|
|
81
|
+
momentCode?: number;
|
|
82
|
+
momentCoeff?: number;
|
|
83
|
+
momentLabel?: string;
|
|
84
|
+
numberOfUnits?: number;
|
|
85
|
+
patientGround?: string;
|
|
86
|
+
patientGroundAge1?: string;
|
|
87
|
+
patientGroundAge2?: string;
|
|
88
|
+
patientGroundCode?: number;
|
|
89
|
+
patientGroundLabel?: string;
|
|
90
|
+
patientGroundWeight1?: number;
|
|
91
|
+
patientGroundWeight2?: number;
|
|
92
|
+
patientPosology?: number;
|
|
93
|
+
perKilo?: number;
|
|
94
|
+
posologyLabel?: string;
|
|
95
|
+
productId?: number;
|
|
96
|
+
profilCode?: number;
|
|
97
|
+
profilLabel?: string;
|
|
98
|
+
quantity1?: number;
|
|
99
|
+
quantity2?: number;
|
|
100
|
+
routeCode?: number;
|
|
101
|
+
routeLabel?: string;
|
|
102
|
+
typeCode?: number;
|
|
103
|
+
typeLabel?: string;
|
|
104
|
+
weightMaximum?: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type MappingError = {
|
|
108
|
+
field: string;
|
|
109
|
+
message: string;
|
|
110
|
+
};
|
|
111
|
+
interface MappingResponse<T = unknown> {
|
|
112
|
+
result: T | undefined;
|
|
113
|
+
errors?: MappingError[];
|
|
114
|
+
}
|
|
115
|
+
type SimpleCodification = {
|
|
116
|
+
type?: string;
|
|
117
|
+
code: string;
|
|
118
|
+
label: string;
|
|
119
|
+
};
|
|
120
|
+
type Coding = {
|
|
121
|
+
system?: string;
|
|
122
|
+
code?: string;
|
|
123
|
+
display?: string;
|
|
124
|
+
};
|
|
125
|
+
type CodificationFunction = ((coding: Coding | undefined) => SimpleCodification[] | Promise<SimpleCodification[]>) | undefined;
|
|
126
|
+
|
|
127
|
+
declare function fhirToBcb$2(dosageInstructions: Dosage[], indicationMapper?: CodificationFunction, routeMapper?: CodificationFunction, intakeMapper?: CodificationFunction): Promise<MappingResponse<BCBPosologieStructuree2>[]>;
|
|
128
|
+
declare function mapToBcb(dosageInstructions: Dosage[], indicationMapper?: CodificationFunction, routeMapper?: CodificationFunction, intakeMapper?: CodificationFunction): Promise<MappingResponse<BCBPosologieStructuree2>[]>;
|
|
129
|
+
declare function bcbToFhir$2(bcbDosages: BCBPosologieStructuree2[]): MappingResponse<Dosage>[];
|
|
130
|
+
declare function mapToFhir(bcbDosages: BCBPosologieStructuree2[]): MappingResponse<Dosage>[];
|
|
131
|
+
/**
|
|
132
|
+
* Converts FHIR Dosage instructions to CB Posology Bean format.
|
|
133
|
+
* Uses the existing fhirToBcb function and then converts BCB to CB format.
|
|
134
|
+
* @param dosageInstructions Array of FHIR Dosage resources
|
|
135
|
+
* @param indicationMapper Optional mapper function for indication codes
|
|
136
|
+
* @param routeMapper Optional mapper function for route codes
|
|
137
|
+
* @param intakeMapper Optional mapper function for intake codes
|
|
138
|
+
* @returns Promise of array of CB Posology Beans with mapping responses
|
|
139
|
+
*/
|
|
140
|
+
declare function fhirToCb$1(dosageInstructions: Dosage[], indicationMapper?: CodificationFunction, routeMapper?: CodificationFunction, intakeMapper?: CodificationFunction): Promise<MappingResponse<CBPosologyBean>[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Converts CB Posology Bean format to FHIR Dosage instructions.
|
|
143
|
+
* Converts CB to BCB format first, then uses existing bcbToFhir function.
|
|
144
|
+
* @param cbPosologies Array of CB Posology Beans
|
|
145
|
+
* @returns Array of FHIR Dosage resources with mapping responses
|
|
146
|
+
*/
|
|
147
|
+
declare function cbToFhir$1(cbPosologies: CBPosologyBean[]): MappingResponse<Dosage>[];
|
|
148
|
+
|
|
149
|
+
declare const dosageMapper_d_mapToBcb: typeof mapToBcb;
|
|
150
|
+
declare const dosageMapper_d_mapToFhir: typeof mapToFhir;
|
|
151
|
+
declare namespace dosageMapper_d {
|
|
152
|
+
export {
|
|
153
|
+
bcbToFhir$2 as bcbToFhir,
|
|
154
|
+
cbToFhir$1 as cbToFhir,
|
|
155
|
+
fhirToBcb$2 as fhirToBcb,
|
|
156
|
+
fhirToCb$1 as fhirToCb,
|
|
157
|
+
dosageMapper_d_mapToBcb as mapToBcb,
|
|
158
|
+
dosageMapper_d_mapToFhir as mapToFhir,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface BCBPatient {
|
|
163
|
+
lstIdComposantAllergie: number[];
|
|
164
|
+
lstPathologiesCIM10: string[];
|
|
165
|
+
lstPathologiesAMM: string[];
|
|
166
|
+
age: number;
|
|
167
|
+
poids: number;
|
|
168
|
+
taille: number;
|
|
169
|
+
grossesse: number;
|
|
170
|
+
allaitement: number;
|
|
171
|
+
sexe: string;
|
|
172
|
+
clairanceCreatinine: number;
|
|
173
|
+
creatininemieMol: number;
|
|
174
|
+
creatininemieMg: number;
|
|
175
|
+
insuffisanceHepatique: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare function bcbToFhir$1(bcbPatient: BCBPatient): MappingResponse<Bundle>;
|
|
179
|
+
declare function fhirToBcb$1(fhirBundle: Bundle, allergiesMapper?: CodificationFunction, snomedPathologiesMapper?: CodificationFunction): Promise<MappingResponse<BCBPatient>>;
|
|
180
|
+
declare function cbToFhir(cbPatient: CBPatient): MappingResponse<Bundle>;
|
|
181
|
+
declare function fhirToCb(fhirBundle: Bundle, allergiesMapper?: CodificationFunction, snomedPathologiesMapper?: CodificationFunction): Promise<MappingResponse<CBPatient>>;
|
|
182
|
+
|
|
183
|
+
declare const patientMapper_d_cbToFhir: typeof cbToFhir;
|
|
184
|
+
declare const patientMapper_d_fhirToCb: typeof fhirToCb;
|
|
185
|
+
declare namespace patientMapper_d {
|
|
186
|
+
export {
|
|
187
|
+
bcbToFhir$1 as bcbToFhir,
|
|
188
|
+
patientMapper_d_cbToFhir as cbToFhir,
|
|
189
|
+
fhirToBcb$1 as fhirToBcb,
|
|
190
|
+
patientMapper_d_fhirToCb as fhirToCb,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Generate a hash-based ID for a medication based on its codes
|
|
196
|
+
*/
|
|
197
|
+
declare const generateMedicationId: (codes: string[], system: string) => string;
|
|
198
|
+
/**
|
|
199
|
+
* Extracts a list of codes from a Bundle containing Medication resources based on the specified system.
|
|
200
|
+
* @param bundle Bundle containing Medication resources to extract codes from
|
|
201
|
+
* @param system The coding system to filter by
|
|
202
|
+
* @returns List of codes that match the specified system
|
|
203
|
+
*/
|
|
204
|
+
declare function extractCodesFromMedications(bundle: Bundle, system: string): string[];
|
|
205
|
+
/**
|
|
206
|
+
* Extracts a list of bcb-code strings from a Bundle containing Medication resources.
|
|
207
|
+
* Only codes with system "https://platform.claudebernard.fr/fhir/CodeSystem/bcb-code" are included.
|
|
208
|
+
* @param bundle Bundle containing Medication resources
|
|
209
|
+
* @returns List of BCB codes
|
|
210
|
+
*/
|
|
211
|
+
declare function extractBcbCodesFromMedications(bundle: Bundle): string[];
|
|
212
|
+
/**
|
|
213
|
+
* Extracts a list of cip13-code strings from a Bundle containing Medication resources.
|
|
214
|
+
* Only codes with system "http://terminology.hl7.org/CodeSystem/cip13-code" are included.
|
|
215
|
+
* @param bundle Bundle containing Medication resources
|
|
216
|
+
* @returns List of CIP13 codes
|
|
217
|
+
*/
|
|
218
|
+
declare function extractCIP13CodesFromMedications(bundle: Bundle): string[];
|
|
219
|
+
/**
|
|
220
|
+
* Extracts a list of cis-code strings from a Bundle containing Medication resources.
|
|
221
|
+
* Only codes with system "http://terminology.hl7.org/CodeSystem/cis-code" are included.
|
|
222
|
+
* @param bundle Bundle containing Medication resources
|
|
223
|
+
* @returns List of CIS codes
|
|
224
|
+
*/
|
|
225
|
+
declare function extractCISCodesFromMedications(bundle: Bundle): string[];
|
|
226
|
+
/**
|
|
227
|
+
* Creates a Bundle containing Medication resources from a list of bcb-code strings.
|
|
228
|
+
* Each Medication will have a CodeableConcept with a Coding for the bcb-code system.
|
|
229
|
+
* @param bcbCodes List of BCB codes to convert to Medication resources
|
|
230
|
+
* @returns MappingResponse containing a Bundle with Medication resources
|
|
231
|
+
*/
|
|
232
|
+
declare function createMedicationsFromBcbCodes(bcbCodes: string[]): MappingResponse<Bundle>;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a Bundle containing Medication resources from a list of CIP13 codes.
|
|
235
|
+
* Each Medication will have a CodeableConcept with a Coding for the CIP13 system.
|
|
236
|
+
* @param cip13Codes List of CIP13 codes to convert to Medication resources
|
|
237
|
+
* @returns MappingResponse containing a Bundle with Medication resources
|
|
238
|
+
*/
|
|
239
|
+
declare function createMedicationsFromCIP13Codes(cip13Codes: string[]): MappingResponse<Bundle>;
|
|
240
|
+
/**
|
|
241
|
+
* Creates a Bundle containing Medication resources from a list of CIS codes.
|
|
242
|
+
* Each Medication will have a CodeableConcept with a Coding for the CIS system.
|
|
243
|
+
* @param cisCodes List of CIS codes to convert to Medication resources
|
|
244
|
+
* @returns MappingResponse containing a Bundle with Medication resources
|
|
245
|
+
*/
|
|
246
|
+
declare function createMedicationsFromCISCodes(cisCodes: string[]): MappingResponse<Bundle>;
|
|
247
|
+
|
|
248
|
+
declare const medicationMapper_d_createMedicationsFromBcbCodes: typeof createMedicationsFromBcbCodes;
|
|
249
|
+
declare const medicationMapper_d_createMedicationsFromCIP13Codes: typeof createMedicationsFromCIP13Codes;
|
|
250
|
+
declare const medicationMapper_d_createMedicationsFromCISCodes: typeof createMedicationsFromCISCodes;
|
|
251
|
+
declare const medicationMapper_d_extractBcbCodesFromMedications: typeof extractBcbCodesFromMedications;
|
|
252
|
+
declare const medicationMapper_d_extractCIP13CodesFromMedications: typeof extractCIP13CodesFromMedications;
|
|
253
|
+
declare const medicationMapper_d_extractCISCodesFromMedications: typeof extractCISCodesFromMedications;
|
|
254
|
+
declare const medicationMapper_d_extractCodesFromMedications: typeof extractCodesFromMedications;
|
|
255
|
+
declare const medicationMapper_d_generateMedicationId: typeof generateMedicationId;
|
|
256
|
+
declare namespace medicationMapper_d {
|
|
257
|
+
export {
|
|
258
|
+
medicationMapper_d_createMedicationsFromBcbCodes as createMedicationsFromBcbCodes,
|
|
259
|
+
medicationMapper_d_createMedicationsFromCIP13Codes as createMedicationsFromCIP13Codes,
|
|
260
|
+
medicationMapper_d_createMedicationsFromCISCodes as createMedicationsFromCISCodes,
|
|
261
|
+
medicationMapper_d_extractBcbCodesFromMedications as extractBcbCodesFromMedications,
|
|
262
|
+
medicationMapper_d_extractCIP13CodesFromMedications as extractCIP13CodesFromMedications,
|
|
263
|
+
medicationMapper_d_extractCISCodesFromMedications as extractCISCodesFromMedications,
|
|
264
|
+
medicationMapper_d_extractCodesFromMedications as extractCodesFromMedications,
|
|
265
|
+
medicationMapper_d_generateMedicationId as generateMedicationId,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Generate a hash-based ID for a medication request based on its key properties
|
|
271
|
+
*/
|
|
272
|
+
declare const generateMedicationRequestId: (medicationCode?: string, patientId?: string) => string;
|
|
273
|
+
/**
|
|
274
|
+
* Converts dosage instructions from MedicationRequest resources in a Bundle to BCB format.
|
|
275
|
+
* Uses the dosage-mapper for dosageInstruction field conversion.
|
|
276
|
+
* @param bundle Bundle containing MedicationRequest resources
|
|
277
|
+
* @returns Array of BCB dosage instructions from all MedicationRequest resources
|
|
278
|
+
*/
|
|
279
|
+
declare function fhirToBcb(bundle: Bundle): Promise<MappingResponse<BCBPosologieStructuree2>[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Creates a Bundle containing MedicationRequest resources from BCB dosage data.
|
|
282
|
+
* Uses the dosage-mapper for converting BCB dosage to FHIR dosage instructions.
|
|
283
|
+
* @param bcbDosages Array of BCB dosage data
|
|
284
|
+
* @returns MappingResponse containing a Bundle with MedicationRequest resources
|
|
285
|
+
*/
|
|
286
|
+
declare function bcbToFhir(bcbDosages: BCBPosologieStructuree2[]): MappingResponse<Bundle>;
|
|
287
|
+
/**
|
|
288
|
+
* Extracts medication codes from MedicationRequest resources in a Bundle.
|
|
289
|
+
* @param bundle Bundle containing MedicationRequest resources
|
|
290
|
+
* @returns Array of medication codes
|
|
291
|
+
*/
|
|
292
|
+
declare function extractMedicationCodes(bundle: Bundle): string[];
|
|
293
|
+
/**
|
|
294
|
+
* Extracts patient references from MedicationRequest resources in a Bundle.
|
|
295
|
+
* @param bundle Bundle containing MedicationRequest resources
|
|
296
|
+
* @returns Array of patient references
|
|
297
|
+
*/
|
|
298
|
+
declare function extractPatientReferences(bundle: Bundle): string[];
|
|
299
|
+
|
|
300
|
+
declare const medicationRequestMapper_d_bcbToFhir: typeof bcbToFhir;
|
|
301
|
+
declare const medicationRequestMapper_d_extractMedicationCodes: typeof extractMedicationCodes;
|
|
302
|
+
declare const medicationRequestMapper_d_extractPatientReferences: typeof extractPatientReferences;
|
|
303
|
+
declare const medicationRequestMapper_d_fhirToBcb: typeof fhirToBcb;
|
|
304
|
+
declare const medicationRequestMapper_d_generateMedicationRequestId: typeof generateMedicationRequestId;
|
|
305
|
+
declare namespace medicationRequestMapper_d {
|
|
306
|
+
export {
|
|
307
|
+
medicationRequestMapper_d_bcbToFhir as bcbToFhir,
|
|
308
|
+
medicationRequestMapper_d_extractMedicationCodes as extractMedicationCodes,
|
|
309
|
+
medicationRequestMapper_d_extractPatientReferences as extractPatientReferences,
|
|
310
|
+
medicationRequestMapper_d_fhirToBcb as fhirToBcb,
|
|
311
|
+
medicationRequestMapper_d_generateMedicationRequestId as generateMedicationRequestId,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Simple hash function compatible with both Node.js and browser environments
|
|
317
|
+
* This replaces the Node.js crypto module to avoid browser compatibility issues
|
|
318
|
+
*/
|
|
319
|
+
declare const simpleHash: (str: string) => string;
|
|
320
|
+
/**
|
|
321
|
+
* Generate a deterministic 8-character hash from input data
|
|
322
|
+
* Compatible with browser and Node.js environments
|
|
323
|
+
*/
|
|
324
|
+
declare const generateHash: (data: any) => string;
|
|
325
|
+
|
|
326
|
+
export { dosageMapper_d as dosageMapper, generateHash, medicationMapper_d as medicationMapper, medicationRequestMapper_d as medicationRequestMapper, patientMapper_d as patientMapper, simpleHash };
|
|
327
|
+
export type { CodificationFunction, Coding, MappingError, MappingResponse, SimpleCodification };
|