@claudebernard/patient-profile-element 0.6.2 → 0.6.4

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.
@@ -1,6 +1,15 @@
1
- import { SearchRequestBody } from "@claudebernard/types";
2
1
  import "@claudebernard/design-system";
2
+ import { SearchRequestBody } from "@claudebernard/types";
3
3
  const PREFIX = "claudebernard";
4
+ function calculateAgeFromBirthDate(birthDate, referenceDate = /* @__PURE__ */ new Date()) {
5
+ const yearsDiff = referenceDate.getFullYear() - birthDate.getFullYear();
6
+ const monthsDiff = referenceDate.getMonth() - birthDate.getMonth();
7
+ const monthsDifference = yearsDiff * 12 + monthsDiff;
8
+ if (monthsDifference < 24) {
9
+ return { age: monthsDifference, unit: "mois" };
10
+ }
11
+ return { age: Math.floor(monthsDifference / 12), unit: "ans" };
12
+ }
4
13
  function calculateBMI(weight, height) {
5
14
  if (height === 0 || weight === 0) {
6
15
  return 0;
@@ -97,6 +106,66 @@ function getPatientFullUrl(bundle) {
97
106
  );
98
107
  return patientEntry?.fullUrl ?? `Patient/${patientEntry?.resource?.id ?? bundle.id}`;
99
108
  }
109
+ function findObservationByCode(bundle, codes) {
110
+ return bundle?.entry?.find(
111
+ (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some((coding) => codes.includes(coding.code ?? ""))
112
+ )?.resource;
113
+ }
114
+ function findObservationByCodeAndValue(bundle, code, valueCode) {
115
+ return bundle?.entry?.find(
116
+ (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some((coding) => coding.code === code) && entry.resource.valueCodeableConcept?.coding?.some((coding) => coding.code === valueCode)
117
+ )?.resource;
118
+ }
119
+ function findConditionByCode(bundle, code) {
120
+ return bundle?.entry?.find(
121
+ (entry) => entry.resource?.resourceType === "Condition" && entry.resource.code?.coding?.some((coding) => coding.code === code)
122
+ )?.resource;
123
+ }
124
+ function removeEntryById(bundle, resourceId) {
125
+ bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== resourceId);
126
+ }
127
+ function removeObservationByCode(bundle, code) {
128
+ bundle.entry = bundle.entry?.filter((entry) => !(entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some((coding) => coding.code === code)));
129
+ }
130
+ function removeConditionByCode(bundle, code) {
131
+ bundle.entry = bundle.entry?.filter((entry) => !(entry.resource?.resourceType === "Condition" && entry.resource.code?.coding?.some((coding) => coding.code === code)));
132
+ }
133
+ function upsertQuantityObservation(bundle, codes, meta, quantity, removeIfZero) {
134
+ const obs = findObservationByCode(bundle, codes);
135
+ if (!obs) {
136
+ if (removeIfZero && quantity.value === 0) {
137
+ return;
138
+ }
139
+ const obsId = generateUUID();
140
+ const newObs = {
141
+ resourceType: "Observation",
142
+ id: obsId,
143
+ status: "final",
144
+ code: {
145
+ coding: [
146
+ {
147
+ system: meta.system ?? "http://loinc.org",
148
+ code: meta.code,
149
+ display: meta.display
150
+ }
151
+ ],
152
+ text: meta.text
153
+ },
154
+ subject: {
155
+ reference: getPatientFullUrl(bundle)
156
+ },
157
+ valueQuantity: quantity
158
+ };
159
+ bundle.entry = bundle.entry || [];
160
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: newObs });
161
+ return;
162
+ }
163
+ if (removeIfZero && quantity.value === 0) {
164
+ removeEntryById(bundle, obs.id);
165
+ return;
166
+ }
167
+ obs.valueQuantity = quantity;
168
+ }
100
169
  function setInitialPatientProfile() {
101
170
  const compositionId = generateUUID();
102
171
  return {
@@ -181,7 +250,7 @@ function getPatientBirthDate(bundle) {
181
250
  }
182
251
  return new Date(patient.birthDate);
183
252
  }
184
- function setPatientAge(bundle, age, ageUnit) {
253
+ function setPatientAge(bundle, birthdate) {
185
254
  const patientEntry = bundle.entry?.find(
186
255
  (entry) => entry.resource?.resourceType === "Patient"
187
256
  );
@@ -202,158 +271,54 @@ function setPatientAge(bundle, age, ageUnit) {
202
271
  composition.subject = [{ reference: patientFullUrl }];
203
272
  }
204
273
  }
205
- const today = /* @__PURE__ */ new Date();
206
- let birthDate;
207
- if (ageUnit === "mois") {
208
- birthDate = new Date(Date.UTC(today.getUTCFullYear(), today.getUTCMonth() - age, today.getUTCDate()));
209
- } else {
210
- const birthYear = today.getFullYear() - age;
211
- birthDate = new Date(Date.UTC(birthYear, 0, 1));
212
- }
213
- patient.birthDate = birthDate.toISOString().split("T")[0];
274
+ patient.birthDate = birthdate;
214
275
  }
276
+ const WEIGHT_LOINC_CODE = "29463-7";
215
277
  function getPatientWeight(bundle) {
216
- const obs = bundle?.entry?.find(
217
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
218
- (coding) => coding.code === "29463-7"
219
- )
220
- )?.resource;
221
- return obs?.valueQuantity?.value;
278
+ return findObservationByCode(bundle, [WEIGHT_LOINC_CODE])?.valueQuantity?.value;
222
279
  }
223
280
  function getPatientWeightWithUnit(bundle) {
224
- const obs = bundle?.entry?.find(
225
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
226
- (coding) => coding.code === "29463-7"
227
- )
228
- )?.resource;
281
+ const obs = findObservationByCode(bundle, [WEIGHT_LOINC_CODE]);
229
282
  return (obs?.valueQuantity?.value ? obs.valueQuantity.value.toString() : "") + (obs?.valueQuantity?.unit ? ` ${obs.valueQuantity.unit}` : "");
230
283
  }
231
284
  function setPatientWeight(bundle, weight) {
232
- const newObsWeight = {
233
- value: weight,
234
- unit: "kg",
235
- system: "http://unitsofmeasure.org",
236
- code: "kg"
237
- };
238
- let obs = bundle.entry?.find(
239
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
240
- (coding) => coding.code === "29463-7"
241
- )
242
- )?.resource;
243
- if (!obs) {
244
- if (weight === 0) {
245
- return;
246
- }
247
- const obsId = generateUUID();
248
- obs = {
249
- resourceType: "Observation",
250
- id: obsId,
251
- status: "final",
252
- code: {
253
- coding: [
254
- {
255
- system: "http://loinc.org",
256
- code: "29463-7",
257
- display: "Body weight"
258
- }
259
- ],
260
- text: "Poids corporel"
261
- },
262
- subject: {
263
- reference: getPatientFullUrl(bundle)
264
- },
265
- valueQuantity: newObsWeight
266
- };
267
- bundle.entry = bundle.entry || [];
268
- bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
269
- } else {
270
- if (weight === 0) {
271
- bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
272
- return;
273
- }
274
- obs.valueQuantity = newObsWeight;
275
- }
285
+ upsertQuantityObservation(
286
+ bundle,
287
+ [WEIGHT_LOINC_CODE],
288
+ { code: WEIGHT_LOINC_CODE, display: "Body weight", text: "Poids corporel" },
289
+ { value: weight, unit: "kg", system: "http://unitsofmeasure.org", code: "kg" },
290
+ true
291
+ );
276
292
  }
293
+ const HEIGHT_LOINC_CODE = "8302-2";
277
294
  function getPatientHeight(bundle) {
278
- const obs = bundle?.entry?.find(
279
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
280
- (coding) => coding.code === "8302-2"
281
- )
282
- )?.resource;
283
- return obs?.valueQuantity?.value;
295
+ return findObservationByCode(bundle, [HEIGHT_LOINC_CODE])?.valueQuantity?.value;
284
296
  }
285
297
  function getPatientHeightWithUnit(bundle) {
286
- const obs = bundle?.entry?.find(
287
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
288
- (coding) => coding.code === "8302-2"
289
- )
290
- )?.resource;
298
+ const obs = findObservationByCode(bundle, [HEIGHT_LOINC_CODE]);
291
299
  return (obs?.valueQuantity?.value ? obs.valueQuantity.value.toString() : "") + (obs?.valueQuantity?.unit ? ` ${obs.valueQuantity.unit}` : "");
292
300
  }
293
301
  function setPatientHeight(bundle, height) {
294
- const newObsHeight = {
295
- value: height,
296
- unit: "cm",
297
- system: "http://unitsofmeasure.org",
298
- code: "cm"
299
- };
300
- let obs = bundle.entry?.find(
301
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
302
- (coding) => coding.code === "8302-2"
303
- )
304
- )?.resource;
305
- if (!obs) {
306
- if (height === 0) {
307
- return;
308
- }
309
- const obsId = generateUUID();
310
- obs = {
311
- resourceType: "Observation",
312
- id: obsId,
313
- status: "final",
314
- code: {
315
- coding: [
316
- {
317
- system: "http://loinc.org",
318
- code: "8302-2",
319
- display: "Body height"
320
- }
321
- ],
322
- text: "Taille corporelle"
323
- },
324
- subject: {
325
- reference: getPatientFullUrl(bundle)
326
- },
327
- valueQuantity: {
328
- value: height,
329
- unit: "cm",
330
- system: "http://unitsofmeasure.org",
331
- code: "cm"
332
- }
333
- };
334
- bundle.entry = bundle.entry || [];
335
- bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
336
- } else {
337
- if (height === 0) {
338
- bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
339
- return;
340
- }
341
- obs.valueQuantity = newObsHeight;
342
- }
302
+ upsertQuantityObservation(
303
+ bundle,
304
+ [HEIGHT_LOINC_CODE],
305
+ { code: HEIGHT_LOINC_CODE, display: "Body height", text: "Taille corporelle" },
306
+ { value: height, unit: "cm", system: "http://unitsofmeasure.org", code: "cm" },
307
+ true
308
+ );
343
309
  }
310
+ const PREGNANCY_STATUS_LOINC_CODE = "82810-3";
311
+ const PREGNANT_SNOMED_CODE = "77386006";
344
312
  function getPatientPregnancyStatus(bundle) {
345
- const obsPreg = bundle?.entry?.find(
346
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some((coding) => coding.code === "82810-3") && entry.resource.valueCodeableConcept?.coding?.some((coding) => coding.code === "77386006")
347
- );
348
- const condPreg = bundle?.entry?.find(
349
- (entry) => entry.resource?.resourceType === "Condition" && entry.resource.code?.coding?.some((coding) => coding.code === "77386006")
350
- );
313
+ const obsPreg = findObservationByCodeAndValue(bundle, PREGNANCY_STATUS_LOINC_CODE, PREGNANT_SNOMED_CODE);
314
+ const condPreg = findConditionByCode(bundle, PREGNANT_SNOMED_CODE);
351
315
  return !!(obsPreg || condPreg);
352
316
  }
353
317
  function setPatientPregnancyStatus(bundle, isPregnant) {
354
318
  if (getPatientPregnancyStatus(bundle)) {
355
319
  if (!isPregnant) {
356
- bundle.entry = bundle.entry?.filter((entry) => !(entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some((coding) => coding.code === "82810-3")) && !(entry.resource?.resourceType === "Condition" && entry.resource.code?.coding?.some((coding) => coding.code === "77386006")));
320
+ removeObservationByCode(bundle, PREGNANCY_STATUS_LOINC_CODE);
321
+ removeConditionByCode(bundle, PREGNANT_SNOMED_CODE);
357
322
  }
358
323
  } else if (isPregnant) {
359
324
  const obsId = generateUUID();
@@ -365,7 +330,7 @@ function setPatientPregnancyStatus(bundle, isPregnant) {
365
330
  coding: [
366
331
  {
367
332
  system: "http://loinc.org",
368
- code: "82810-3",
333
+ code: PREGNANCY_STATUS_LOINC_CODE,
369
334
  display: "Pregnancy status"
370
335
  }
371
336
  ],
@@ -378,7 +343,7 @@ function setPatientPregnancyStatus(bundle, isPregnant) {
378
343
  coding: [
379
344
  {
380
345
  system: "http://snomed.info/sct",
381
- code: "77386006",
346
+ code: PREGNANT_SNOMED_CODE,
382
347
  display: "Pregnant"
383
348
  }
384
349
  ],
@@ -389,73 +354,29 @@ function setPatientPregnancyStatus(bundle, isPregnant) {
389
354
  bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: newObsPreg });
390
355
  }
391
356
  }
357
+ const AMENORRHEA_LOINC_CODE = "18185-9";
392
358
  function getPatientAmenorrheaStatus(bundle) {
393
- const obs = bundle?.entry?.find(
394
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
395
- (coding) => coding.code === "18185-9"
396
- )
397
- )?.resource;
398
- return obs?.valueQuantity?.value;
359
+ return findObservationByCode(bundle, [AMENORRHEA_LOINC_CODE])?.valueQuantity?.value;
399
360
  }
400
361
  function setPatientAmenorrheaStatus(bundle, weeks) {
401
- const newObsAmenorrhea = {
402
- value: weeks,
403
- unit: "weeks",
404
- system: "http://unitsofmeasure.org",
405
- code: "wk"
406
- };
407
- let obs = bundle.entry?.find(
408
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
409
- (coding) => coding.code === "18185-9"
410
- )
411
- )?.resource;
412
- if (!obs) {
413
- const obsId = generateUUID();
414
- obs = {
415
- resourceType: "Observation",
416
- id: obsId,
417
- status: "final",
418
- code: {
419
- coding: [
420
- {
421
- system: "http://loinc.org",
422
- code: "18185-9",
423
- display: "Gestational age"
424
- }
425
- ],
426
- text: "Âge gestationnel"
427
- },
428
- subject: {
429
- reference: getPatientFullUrl(bundle)
430
- },
431
- valueQuantity: newObsAmenorrhea
432
- };
433
- bundle.entry = bundle.entry || [];
434
- bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
435
- } else {
436
- obs.valueQuantity = newObsAmenorrhea;
437
- }
362
+ upsertQuantityObservation(
363
+ bundle,
364
+ [AMENORRHEA_LOINC_CODE],
365
+ { code: AMENORRHEA_LOINC_CODE, display: "Gestational age", text: "Âge gestationnel" },
366
+ { value: weeks, unit: "weeks", system: "http://unitsofmeasure.org", code: "wk" },
367
+ false
368
+ );
438
369
  }
370
+ const BREASTFEEDING_LOINC_CODE = "63895-7";
371
+ const BREASTFEEDING_SNOMED_CODE = "69840006";
439
372
  function getPatientBreastfeedingStatus(bundle) {
440
- const obsBf = bundle?.entry?.find(
441
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some((coding) => coding.code === "63895-7") && entry.resource.valueCodeableConcept?.coding?.some((coding) => coding.code === "69840006")
442
- );
443
- const condBf = bundle?.entry?.find(
444
- (entry) => entry.resource?.resourceType === "Condition" && entry.resource.code?.coding?.some((coding) => coding.code === "69840006")
445
- );
373
+ const obsBf = findObservationByCodeAndValue(bundle, BREASTFEEDING_LOINC_CODE, BREASTFEEDING_SNOMED_CODE);
374
+ const condBf = findConditionByCode(bundle, BREASTFEEDING_SNOMED_CODE);
446
375
  return !!(obsBf || condBf);
447
376
  }
448
377
  function setPatientBreastfeedingStatus(bundle, isBreastfeeding) {
449
- const obsBf = bundle.entry?.find(
450
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
451
- (coding) => coding.code === "63895-7"
452
- )
453
- )?.resource;
454
- const condBf = bundle.entry?.find(
455
- (entry) => entry.resource?.resourceType === "Condition" && entry.resource.code?.coding?.some(
456
- (coding) => coding.code === "69840006"
457
- )
458
- )?.resource;
378
+ const obsBf = findObservationByCode(bundle, [BREASTFEEDING_LOINC_CODE]);
379
+ const condBf = findConditionByCode(bundle, BREASTFEEDING_SNOMED_CODE);
459
380
  if (isBreastfeeding) {
460
381
  if (!obsBf && !condBf) {
461
382
  const obsId = generateUUID();
@@ -467,7 +388,7 @@ function setPatientBreastfeedingStatus(bundle, isBreastfeeding) {
467
388
  coding: [
468
389
  {
469
390
  system: "http://loinc.org",
470
- code: "63895-7",
391
+ code: BREASTFEEDING_LOINC_CODE,
471
392
  display: "Breastfeeding status"
472
393
  }
473
394
  ],
@@ -480,7 +401,7 @@ function setPatientBreastfeedingStatus(bundle, isBreastfeeding) {
480
401
  coding: [
481
402
  {
482
403
  system: "http://snomed.info/sct",
483
- code: "69840006",
404
+ code: BREASTFEEDING_SNOMED_CODE,
484
405
  display: "Breastfeeding"
485
406
  }
486
407
  ],
@@ -492,25 +413,17 @@ function setPatientBreastfeedingStatus(bundle, isBreastfeeding) {
492
413
  }
493
414
  } else {
494
415
  if (obsBf) {
495
- bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obsBf.id);
416
+ removeEntryById(bundle, obsBf.id);
496
417
  }
497
418
  if (condBf) {
498
- bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== condBf.id);
419
+ removeEntryById(bundle, condBf.id);
499
420
  }
500
421
  }
501
422
  }
502
423
  function getPatientRenalInsufficiencyStatus(bundle) {
503
- const clearance = bundle?.entry?.find(
504
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
505
- (coding) => acceptedLoincCodesForRenalClearance.includes(coding.code ?? "")
506
- )
507
- )?.resource;
424
+ const clearance = findObservationByCode(bundle, acceptedLoincCodesForRenalClearance);
508
425
  let gfrValue;
509
- const gfrByBsa = bundle?.entry?.find(
510
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
511
- (coding) => acceptedLoincCodesForRenalGFRPerBSA.includes(coding.code ?? "")
512
- )
513
- )?.resource;
426
+ const gfrByBsa = findObservationByCode(bundle, acceptedLoincCodesForRenalGFRPerBSA);
514
427
  if (gfrByBsa?.valueQuantity?.value) {
515
428
  gfrValue = {
516
429
  value: gfrByBsa.valueQuantity.value,
@@ -525,96 +438,26 @@ function getPatientRenalInsufficiencyStatus(bundle) {
525
438
  };
526
439
  }
527
440
  function setPatientClearance(bundle, clearance) {
528
- const newObsClearance = {
529
- value: clearance,
530
- unit: "mL/min",
531
- system: "http://unitsofmeasure.org",
532
- code: "mL/min"
533
- };
534
- let obs = bundle?.entry?.find(
535
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
536
- (coding) => acceptedLoincCodesForRenalClearance.includes(coding.code ?? "")
537
- )
538
- )?.resource;
539
- if (!obs) {
540
- if (clearance === 0) {
541
- return;
542
- }
543
- const obsId = generateUUID();
544
- obs = {
545
- resourceType: "Observation",
546
- id: obsId,
547
- status: "final",
548
- code: {
549
- coding: [
550
- {
551
- system: "http://loinc.org",
552
- code: acceptedLoincCodesForRenalClearance[0],
553
- display: "Creatinine Clearance"
554
- }
555
- ],
556
- text: "Clairance de la créatinine"
557
- },
558
- subject: {
559
- reference: getPatientFullUrl(bundle)
560
- },
561
- valueQuantity: newObsClearance
562
- };
563
- bundle.entry = bundle.entry || [];
564
- bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
565
- } else {
566
- if (clearance === 0) {
567
- bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
568
- return;
569
- }
570
- obs.valueQuantity = newObsClearance;
571
- }
441
+ upsertQuantityObservation(
442
+ bundle,
443
+ acceptedLoincCodesForRenalClearance,
444
+ { code: acceptedLoincCodesForRenalClearance[0], display: "Creatinine Clearance", text: "Clairance de la créatinine" },
445
+ { value: clearance, unit: "mL/min", system: "http://unitsofmeasure.org", code: "mL/min" },
446
+ true
447
+ );
572
448
  }
573
449
  function setPatientGFRByBSA(bundle, gfr) {
574
- const newObsGFR = {
575
- value: gfr,
576
- unit: "mL/min/1.73.m2",
577
- system: "http://unitsofmeasure.org",
578
- code: "mL/min/1.73.m2"
579
- };
580
- let obs = bundle?.entry?.find(
581
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
582
- (coding) => acceptedLoincCodesForRenalGFRPerBSA.includes(coding.code ?? "")
583
- )
584
- )?.resource;
585
- if (!obs) {
586
- if (gfr === 0) {
587
- return;
588
- }
589
- const obsId = generateUUID();
590
- obs = {
591
- resourceType: "Observation",
592
- id: obsId,
593
- status: "final",
594
- code: {
595
- coding: [
596
- {
597
- system: "http://loinc.org",
598
- code: "48642-3",
599
- display: "Glomerular filtration rate [Volume Rate/Area] in Serum, Plasma or Blood by Creatinine-based formula (MDRD)/1.73 sq M"
600
- }
601
- ],
602
- text: "DFG"
603
- },
604
- subject: {
605
- reference: getPatientFullUrl(bundle)
606
- },
607
- valueQuantity: newObsGFR
608
- };
609
- bundle.entry = bundle.entry || [];
610
- bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
611
- } else {
612
- if (gfr === 0) {
613
- bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
614
- return;
615
- }
616
- obs.valueQuantity = newObsGFR;
617
- }
450
+ upsertQuantityObservation(
451
+ bundle,
452
+ acceptedLoincCodesForRenalGFRPerBSA,
453
+ {
454
+ code: "48642-3",
455
+ display: "Glomerular filtration rate [Volume Rate/Area] in Serum, Plasma or Blood by Creatinine-based formula (MDRD)/1.73 sq M",
456
+ text: "DFG"
457
+ },
458
+ { value: gfr, unit: "mL/min/1.73.m2", system: "http://unitsofmeasure.org", code: "mL/min/1.73.m2" },
459
+ true
460
+ );
618
461
  }
619
462
  function computeCreatinineFromClearance(clearance, age, weight, isFemale) {
620
463
  const results = [];
@@ -676,9 +519,11 @@ function convertAndAddMissingUnits(results) {
676
519
  });
677
520
  }
678
521
  }
522
+ const CREATININE_MASS_LOINC_CODE = "2160-0";
523
+ const CREATININE_MOLAR_LOINC_CODE = "15051-6";
679
524
  function getCreatinine(bundle) {
680
525
  const results = [];
681
- const creatinineMassObs = bundle?.entry?.find((e2) => e2.resource?.resourceType === "Observation" && e2.resource.code?.coding?.some((c2) => c2.code === "2160-0"))?.resource;
526
+ const creatinineMassObs = findObservationByCode(bundle, [CREATININE_MASS_LOINC_CODE]);
682
527
  if (creatinineMassObs?.valueQuantity?.value !== null && creatinineMassObs?.valueQuantity?.value !== void 0) {
683
528
  const mgdl = creatinineMassObs.valueQuantity.value;
684
529
  results.push({
@@ -688,7 +533,7 @@ function getCreatinine(bundle) {
688
533
  code: "mg/L"
689
534
  });
690
535
  }
691
- const creatinineMolObs = bundle?.entry?.find((e2) => e2.resource?.resourceType === "Observation" && e2.resource.code?.coding?.some((c2) => c2.code === "15051-6"))?.resource;
536
+ const creatinineMolObs = findObservationByCode(bundle, [CREATININE_MOLAR_LOINC_CODE]);
692
537
  if (creatinineMolObs?.valueQuantity?.value !== null && creatinineMolObs?.valueQuantity?.value !== void 0) {
693
538
  results.push({
694
539
  value: creatinineMolObs.valueQuantity.value,
@@ -702,96 +547,22 @@ function getCreatinine(bundle) {
702
547
  return results;
703
548
  }
704
549
  function setCreatinineBymgL(bundle, mgL) {
705
- const newObsCreatinine = {
706
- value: mgL / 10,
707
- unit: "mg/dL",
708
- system: "http://unitsofmeasure.org",
709
- code: "mg/dL"
710
- };
711
- let obs = bundle?.entry?.find(
712
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
713
- (coding) => coding.code === "2160-0"
714
- )
715
- )?.resource;
716
- if (!obs) {
717
- if (mgL === 0) {
718
- return;
719
- }
720
- const obsId = generateUUID();
721
- obs = {
722
- resourceType: "Observation",
723
- id: obsId,
724
- status: "final",
725
- code: {
726
- coding: [
727
- {
728
- system: "http://loinc.org",
729
- code: "2160-0",
730
- display: "Creatinine [Mass/volume] in Serum or Plasma"
731
- }
732
- ],
733
- text: "Créatininémie"
734
- },
735
- subject: {
736
- reference: getPatientFullUrl(bundle)
737
- },
738
- valueQuantity: newObsCreatinine
739
- };
740
- bundle.entry = bundle.entry || [];
741
- bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
742
- } else {
743
- if (mgL === 0) {
744
- bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
745
- return;
746
- }
747
- obs.valueQuantity = newObsCreatinine;
748
- }
550
+ upsertQuantityObservation(
551
+ bundle,
552
+ [CREATININE_MASS_LOINC_CODE],
553
+ { code: CREATININE_MASS_LOINC_CODE, display: "Creatinine [Mass/volume] in Serum or Plasma", text: "Créatininémie" },
554
+ { value: mgL / 10, unit: "mg/dL", system: "http://unitsofmeasure.org", code: "mg/dL" },
555
+ true
556
+ );
749
557
  }
750
558
  function setCreatinineByUmolL(bundle, umolL) {
751
- const newObsCreatinine = {
752
- value: umolL,
753
- unit: "μmol/L",
754
- system: "http://unitsofmeasure.org",
755
- code: "umol/L"
756
- };
757
- let obs = bundle?.entry?.find(
758
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
759
- (coding) => coding.code === "15051-6"
760
- )
761
- )?.resource;
762
- if (!obs) {
763
- if (umolL === 0) {
764
- return;
765
- }
766
- const obsId = generateUUID();
767
- obs = {
768
- resourceType: "Observation",
769
- id: obsId,
770
- status: "final",
771
- code: {
772
- coding: [
773
- {
774
- system: "http://loinc.org",
775
- code: "15051-6",
776
- display: "Creatinine [Moles/volume] in Serum or Plasma"
777
- }
778
- ],
779
- text: "Créatininémie"
780
- },
781
- subject: {
782
- reference: getPatientFullUrl(bundle)
783
- },
784
- valueQuantity: newObsCreatinine
785
- };
786
- bundle.entry = bundle.entry || [];
787
- bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
788
- } else {
789
- if (umolL === 0) {
790
- bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
791
- return;
792
- }
793
- obs.valueQuantity = newObsCreatinine;
794
- }
559
+ upsertQuantityObservation(
560
+ bundle,
561
+ [CREATININE_MOLAR_LOINC_CODE],
562
+ { code: CREATININE_MOLAR_LOINC_CODE, display: "Creatinine [Moles/volume] in Serum or Plasma", text: "Créatininémie" },
563
+ { value: umolL, unit: "μmol/L", system: "http://unitsofmeasure.org", code: "umol/L" },
564
+ true
565
+ );
795
566
  }
796
567
  function mgdlToMgl(mgdl) {
797
568
  return mgdl * 10;
@@ -808,12 +579,9 @@ function umolLToMgl(umolL) {
808
579
  function round2(n3) {
809
580
  return Math.round(n3 * 100) / 100;
810
581
  }
582
+ const HEPATIC_INSUFFICIENCY_LOINC_CODE = "98152-2";
811
583
  function getPatientHepaticInsufficiencyStade(bundle) {
812
- const obs = bundle?.entry?.find(
813
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
814
- (coding) => coding.code === "98152-2"
815
- )
816
- )?.resource;
584
+ const obs = findObservationByCode(bundle, [HEPATIC_INSUFFICIENCY_LOINC_CODE]);
817
585
  if (obs?.valueQuantity?.value) {
818
586
  return childPughScore(obs.valueQuantity.value);
819
587
  } else if (obs?.valueCodeableConcept?.coding?.[0]?.code) {
@@ -826,11 +594,7 @@ function getPatientHepaticInsufficiencyStade(bundle) {
826
594
  return "";
827
595
  }
828
596
  function setPatientHepaticInsufficiencyStatus(bundle, stade, score) {
829
- let obs = bundle.entry?.find(
830
- (entry) => entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
831
- (coding) => coding.code === "98152-2"
832
- )
833
- )?.resource;
597
+ let obs = findObservationByCode(bundle, [HEPATIC_INSUFFICIENCY_LOINC_CODE]);
834
598
  if (stade) {
835
599
  const snomedCode = childPughStadeToSnomedMap[stade];
836
600
  if (!snomedCode) {
@@ -856,7 +620,7 @@ function setPatientHepaticInsufficiencyStatus(bundle, stade, score) {
856
620
  coding: [
857
621
  {
858
622
  system: "http://loinc.org",
859
- code: "98152-2",
623
+ code: HEPATIC_INSUFFICIENCY_LOINC_CODE,
860
624
  display: "Child-Pugh score"
861
625
  }
862
626
  ],
@@ -879,9 +643,7 @@ function setPatientHepaticInsufficiencyStatus(bundle, stade, score) {
879
643
  }
880
644
  }
881
645
  function deletePatientHepaticInsufficiencyStatus(bundle) {
882
- bundle.entry = bundle.entry?.filter((entry) => !(entry.resource?.resourceType === "Observation" && entry.resource.code?.coding?.some(
883
- (coding) => coding.code === "98152-2"
884
- )));
646
+ removeObservationByCode(bundle, HEPATIC_INSUFFICIENCY_LOINC_CODE);
885
647
  }
886
648
  function getPatientConditions(patient) {
887
649
  if (!patient?.entry) {
@@ -945,7 +707,7 @@ function setPatientConditions(patient, conditions) {
945
707
  code: {
946
708
  coding: [
947
709
  {
948
- system: condition.category === "snomed" ? "http://snomed.info/sct" : condition.category === "CIM10" ? "http://hl7.org/fhir/sid/icd-10" : condition.category === "AMM" ? "http://example.org/fhir/amm-codes" : "",
710
+ system: condition.category === "snomed" ? "http://snomed.info/sct" : condition.category === "CIM10" ? "http://hl7.org/fhir/sid/icd-10" : condition.category === "AMM" ? "https://platform.claudebernard.fr/fhir/CodeSystem/amm-pathologies" : "",
949
711
  code: condition.value,
950
712
  display: condition.label
951
713
  }
@@ -1580,54 +1342,6 @@ function e$1(e2, r2) {
1580
1342
  };
1581
1343
  }
1582
1344
  const patientProfileCSS = '@charset "UTF-8";\n.claudebernard-patient-profile {\n font-family: var(--custom-font-family, "Ubuntu"), sans-serif;\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n padding: 1rem;\n border-radius: 0.5rem;\n background-color: var(--bcbd-white-color, #FFFFFF);\n container-type: inline-size;\n}\n@container (max-width: 600px) {\n .claudebernard-patient-profile {\n font-size: 0.8rem;\n }\n}\n.claudebernard-patient-profile__no-profile {\n display: flex;\n flex-direction: column;\n gap: 0.3rem;\n}\n.claudebernard-patient-profile__no-profile__first {\n font-weight: bold;\n}\n.claudebernard-patient-profile__no-profile__second {\n color: var(--bcbd-gray-500-color, #64748B);\n font-size: 0.8rem;\n}\n.claudebernard-patient-profile__separator {\n border-right: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n}\n.claudebernard-patient-profile__first-info-container {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n gap: 0.5rem;\n}\n@container (max-width: 450px) {\n .claudebernard-patient-profile__first-info-container {\n flex-wrap: wrap;\n gap: 1rem;\n align-items: center;\n }\n}\n@container (max-width: 320px) {\n .claudebernard-patient-profile__first-info-container {\n justify-content: center;\n }\n}\n.claudebernard-patient-profile__id-info-container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 0.5rem;\n}\n@container (max-width: 450px) {\n .claudebernard-patient-profile__id-info-container {\n flex: 1;\n }\n}\n@container (max-width: 320px) {\n .claudebernard-patient-profile__id-info-container {\n flex: 0 0 auto;\n align-items: center;\n }\n}\n.claudebernard-patient-profile__name-info {\n font-size: 1rem;\n}\n.claudebernard-patient-profile__id-info {\n width: fit-content;\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n border-radius: 1rem;\n display: flex;\n flex-direction: row;\n padding: 0 0.8rem;\n gap: 0.5rem;\n}\n.claudebernard-patient-profile__id-info-info {\n padding: 0.2rem 0;\n white-space: nowrap;\n font-size: 1rem;\n}\n.claudebernard-patient-profile__physical-info-container {\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 1rem;\n}\n@container (max-width: 600px) {\n .claudebernard-patient-profile__physical-info-container {\n gap: 0.5rem;\n }\n}\n@container (max-width: 450px) {\n .claudebernard-patient-profile__physical-info-container {\n order: 3;\n width: 100%;\n }\n}\n@container (max-width: 320px) {\n .claudebernard-patient-profile__physical-info-container {\n order: 2;\n }\n}\n.claudebernard-patient-profile__physical-info {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: space-between;\n padding: 1rem 0;\n font-size: 1rem;\n}\n.claudebernard-patient-profile__physical-info-result {\n white-space: nowrap;\n}\n.claudebernard-patient-profile__physical-info-label {\n color: var(--bcbd-gray-600-color, #475569);\n}\n.claudebernard-patient-profile__action-buttons-container {\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n align-content: center;\n flex-wrap: wrap;\n gap: 1rem;\n}\n@container (max-width: 600px) {\n .claudebernard-patient-profile__action-buttons-container {\n gap: 0.5rem;\n }\n}\n@container (max-width: 450px) {\n .claudebernard-patient-profile__action-buttons-container {\n order: 2;\n margin: 0 auto;\n }\n}\n@container (max-width: 320px) {\n .claudebernard-patient-profile__action-buttons-container {\n order: 3;\n }\n}\n.claudebernard-patient-profile__second-info-container {\n margin-top: 1rem;\n display: none;\n}\n.claudebernard-patient-profile__second-info-container.active {\n display: flex;\n flex-direction: column;\n}\n.claudebernard-patient-profile__second-info {\n margin-top: 1rem;\n}\n.claudebernard-patient-profile__second-info bcbd-tooltip {\n display: inline-block;\n}\n.claudebernard-patient-profile__second-info bcbd-tooltip > span {\n font-size: 1rem;\n}\n.claudebernard-patient-profile__second-info-label {\n padding-right: 0.5rem;\n color: var(--bcbd-primary-color, #0C75AD);\n}\n@container (max-width: 600px) {\n .claudebernard-patient-profile__second-info-label {\n font-size: 0.8rem;\n }\n}\n.claudebernard-patient-profile__second-info-result.sep-dots > * + *::before {\n content: "•";\n margin: 0 0.5rem;\n}';
1583
- const sexOptions = [
1584
- { value: "male", label: "Masculin" },
1585
- { value: "female", label: "Féminin" },
1586
- { value: "unknown", label: "Inconnu" }
1587
- ];
1588
- const hepaticStadeOptions = [
1589
- { value: "A", label: "Stade A" },
1590
- { value: "B", label: "Stade B" },
1591
- { value: "C", label: "Stade C" }
1592
- ];
1593
- const ageOptions = [
1594
- { value: "ans", label: "Ans" },
1595
- { value: "mois", label: "Mois" }
1596
- ];
1597
- const convertRenalInsufficiency = async (type, value, patient, apiUrl) => {
1598
- const response = await fetch(`${apiUrl}/prescription/patient/fhir/renal-insufficiency-conversion`, {
1599
- method: "POST",
1600
- headers: {
1601
- "Content-Type": "application/json"
1602
- },
1603
- body: JSON.stringify({
1604
- typeEntree: type,
1605
- valeur: value,
1606
- patient
1607
- })
1608
- });
1609
- return response.json();
1610
- };
1611
- const fetchPathologiesByTerm = async (term, typePathology, params, apiUrl) => {
1612
- const response = await fetch(`${apiUrl}/search/pathologies/?term=${term}&typePathology=${typePathology}`, {
1613
- method: "POST",
1614
- headers: {
1615
- "Content-Type": "application/json"
1616
- },
1617
- body: JSON.stringify(params)
1618
- });
1619
- return response.json();
1620
- };
1621
- const fetchMoleculesByTerm = async (term, params, apiUrl) => {
1622
- const response = await fetch(`${apiUrl}/search/molecules/?term=${term}`, {
1623
- method: "POST",
1624
- headers: {
1625
- "Content-Type": "application/json"
1626
- },
1627
- body: JSON.stringify(params)
1628
- });
1629
- return response.json();
1630
- };
1631
1345
  const e = (t2) => (...e2) => ({ _$litDirective$: t2, values: e2 });
1632
1346
  let i$1 = class i2 {
1633
1347
  constructor(t2) {
@@ -1657,161 +1371,140 @@ const i3 = e(class extends i$1 {
1657
1371
  return t2 !== this.key && (p(r2), this.key = t2), e2;
1658
1372
  }
1659
1373
  });
1660
- const patientProfileEditionCSS = ".claudebernard-edition-modal {\n font-size: 0.9rem;\n}\n.claudebernard-edition-modal-content {\n display: flex;\n flex-direction: column;\n width: 100%;\n min-width: 60vw;\n height: 100%;\n max-height: 60vh;\n gap: 16px;\n}\n.claudebernard-edition-modal-large-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n width: 100%;\n}\n.claudebernard-edition-modal-information-section {\n display: flex;\n flex-direction: row;\n gap: 16px;\n}\n.claudebernard-edition-modal-little-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n flex: 1;\n min-width: 0;\n}\n.claudebernard-edition-modal-little-section bcbd-input {\n height: 100%;\n}\n.claudebernard-edition-modal-pregnant-div {\n display: flex;\n align-items: center;\n gap: 16px;\n}\n.claudebernard-edition-modal-pregnant-div bcbd-input {\n width: 40% !important;\n}\n.claudebernard-edition-modal-action-buttons {\n display: flex;\n justify-content: flex-end;\n height: 100%;\n gap: 16px;\n align-items: flex-end;\n}\n.claudebernard-edition-modal-subtitle {\n font-weight: 600;\n font-size: 1.1rem;\n color: var(--bcbd-primary-color, #0C75AD);\n}\n.claudebernard-edition-modal-error-message {\n color: var(--bcbd-danger-color, #CF406E);\n font-size: 0.8rem;\n}\n.claudebernard-edition-modal-age-input-group {\n display: flex;\n gap: 8px;\n}\n.claudebernard-edition-modal-age-input-group bcbd-input {\n width: 50% !important;\n}\n.claudebernard-edition-modal-age-input-group bcbd-select {\n width: 50% !important;\n}\n.claudebernard-edition-modal-fieldset {\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n margin-inline: 0;\n border-radius: 4px;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n.claudebernard-edition-modal-disclaimer-section {\n font-size: 0.8rem;\n}\n\nbcbd-checkbox {\n --bcbd-checkbox-font-size: .9rem;\n}";
1661
- var __defProp$1 = Object.defineProperty;
1662
- var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
1663
- var __decorateClass$1 = (decorators, target, key, kind) => {
1664
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
1374
+ const sexOptions = [
1375
+ { value: "male", label: "Masculin" },
1376
+ { value: "female", label: "Féminin" },
1377
+ { value: "unknown", label: "Inconnu" }
1378
+ ];
1379
+ const hepaticStadeOptions = [
1380
+ { value: "A", label: "Stade A" },
1381
+ { value: "B", label: "Stade B" },
1382
+ { value: "C", label: "Stade C" }
1383
+ ];
1384
+ const patientDemographicsFormCSS = ".claudebernard-edition-modal {\n font-size: 0.9rem;\n}\n.claudebernard-edition-modal-large-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n width: 100%;\n}\n.claudebernard-edition-modal-information-section {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex-wrap: wrap;\n}\n.claudebernard-edition-modal-information-section span {\n white-space: nowrap;\n}\n.claudebernard-edition-modal-information-section-secondary-group {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex: 3;\n flex-wrap: wrap;\n}\n@media (max-width: 950px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n flex-basis: 100%;\n }\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n display: contents;\n }\n}\n.claudebernard-edition-modal-little-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n flex: 1;\n min-width: 0;\n}\n.claudebernard-edition-modal-little-section bcbd-input {\n height: 100%;\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-little-section {\n flex: 1 1 calc(50% - 8px);\n }\n .claudebernard-edition-modal-little-section span {\n white-space: nowrap;\n }\n}\n.claudebernard-edition-modal-subtitle {\n font-weight: 600;\n font-size: 1.1rem;\n color: var(--bcbd-primary-color, #0C75AD);\n}\n.claudebernard-edition-modal-error-message {\n color: var(--bcbd-danger-color, #CF406E);\n font-size: 0.8rem;\n}\n.claudebernard-edition-modal-fieldset {\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n margin-inline: 0;\n border-radius: 4px;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\nbcbd-checkbox {\n --bcbd-checkbox-font-size: .9rem;\n}\n\n.claudebernard-edition-modal-demographic-div {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}";
1385
+ var __defProp$7 = Object.defineProperty;
1386
+ var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
1387
+ var __decorateClass$8 = (decorators, target, key, kind) => {
1388
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
1665
1389
  for (var i4 = decorators.length - 1, decorator; i4 >= 0; i4--)
1666
1390
  if (decorator = decorators[i4])
1667
1391
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1668
- if (kind && result) __defProp$1(target, key, result);
1392
+ if (kind && result) __defProp$7(target, key, result);
1669
1393
  return result;
1670
1394
  };
1671
- let PatientProfileEdition = class extends i$2 {
1395
+ let PatientDemographicsForm = class extends i$2 {
1672
1396
  constructor() {
1673
1397
  super(...arguments);
1674
- this.apiUrl = "https://api-dev.claudebernard.fr";
1675
- this.patientAge = 0;
1398
+ this.patientBirthDate = "";
1399
+ this.patientAgeValue = void 0;
1676
1400
  this.patientUnitAge = "ans";
1677
- this.creatinineByMg = 0;
1678
- this.creatinineByUmol = 0;
1679
- this.clairanceCreatinine = 0;
1680
- this.dfg = 0;
1681
- this.defaultPatientUnitAge = {};
1682
1401
  this.defaultPatientSex = {};
1683
- this.defaultHepaticStade = {};
1684
- this.isPregnancyDivVisible = false;
1685
- this.isPregnant = false;
1686
- this.breastfeeding = false;
1687
1402
  this.ageErrorMessageInput = "";
1688
1403
  this.sizeErrorMessageInput = "";
1689
1404
  this.weightErrorMessageInput = "";
1690
- this.pathologiesApiErrorMessage = "";
1691
- this.allergiesApiErrorMessage = "";
1692
- this.renalLackInformationErrorMessage = "";
1693
- this.pathologyOptions = [];
1694
- this.allergyOptions = [];
1695
- this.selectedPathologyOptions = [];
1696
- this.selectedAllergyOptions = [];
1697
1405
  this.imc = 0;
1698
- this.resetKey = 0;
1699
1406
  }
1700
1407
  get isAgeDisplay() {
1701
1408
  return this.preferences?.forms?.age?.display ?? true;
1702
1409
  }
1703
1410
  get isAgeReadOnly() {
1704
- return this.preferences?.forms?.age?.readOnly ?? true;
1411
+ return this.preferences?.forms?.age?.readOnly ?? false;
1705
1412
  }
1706
1413
  get isSexeDisplay() {
1707
1414
  return this.preferences?.forms?.sexe?.display ?? true;
1708
1415
  }
1709
1416
  get isSexeReadOnly() {
1710
- return this.preferences?.forms?.sexe?.readOnly ?? true;
1417
+ return this.preferences?.forms?.sexe?.readOnly ?? false;
1711
1418
  }
1712
- open() {
1713
- this.editionModalElement.open();
1419
+ get patientAge() {
1420
+ return this.patientAgeValue === void 0 ? "" : `${this.patientAgeValue} ${this.patientUnitAge}`;
1714
1421
  }
1715
- modifyGender() {
1716
- if (this.genderSelect?.value === "male") {
1717
- this.isPregnancyDivVisible = false;
1718
- } else {
1719
- const age = Number(this.ageInput?.value ?? 0);
1720
- this.isPregnancyDivVisible = this.patientUnitAge === "ans" && (age >= 12 && age <= 55);
1422
+ get isPregnancyAge() {
1423
+ const age = this.patientAgeValue ?? 0;
1424
+ return this.patientUnitAge === "ans" && age >= 12 && age <= 55 && !!this.genderSelect?.value && this.genderSelect.value !== "male";
1425
+ }
1426
+ emitChange(isPregnancyEligible, triggerRenalRecalculation) {
1427
+ this.dispatchEvent(new CustomEvent("demographics-change", {
1428
+ detail: {
1429
+ hasError: this.ageErrorMessageInput !== "" || this.sizeErrorMessageInput !== "" || this.weightErrorMessageInput !== "",
1430
+ isPregnancyEligible,
1431
+ triggerRenalRecalculation
1432
+ },
1433
+ bubbles: true,
1434
+ composed: true
1435
+ }));
1436
+ }
1437
+ getPatientSexFromProfile() {
1438
+ let gender = getPatientGender(this.patientProfile);
1439
+ switch (gender) {
1440
+ case "Homme":
1441
+ gender = "male";
1442
+ break;
1443
+ case "Femme":
1444
+ gender = "female";
1445
+ break;
1721
1446
  }
1722
- this.recalculateRenalValues();
1447
+ const selectedOption = sexOptions.find((option) => option.value === gender);
1448
+ return selectedOption ? { value: selectedOption.value, label: selectedOption.label } : {};
1723
1449
  }
1724
- resetToProfileValues() {
1450
+ resetFromProfile() {
1725
1451
  this.imc = calculateBMI(getPatientWeight(this.patientProfile) ?? 0, getPatientHeight(this.patientProfile) ?? 0);
1726
1452
  this.defaultPatientSex = this.getPatientSexFromProfile();
1727
- this.defaultHepaticStade = this.getPatientHepaticStadeFromProfile();
1728
- this.selectedPathologyOptions = getPatientConditionsWithCode(this.patientProfile);
1729
- this.selectedAllergyOptions = getPatientAllergiesWithCode(this.patientProfile);
1730
1453
  this.ageErrorMessageInput = "";
1731
1454
  this.sizeErrorMessageInput = "";
1732
1455
  this.weightErrorMessageInput = "";
1733
- this.renalLackInformationErrorMessage = "";
1734
- this.pathologyOptions = [];
1735
- this.allergyOptions = [];
1736
- this.breastfeeding = getPatientBreastfeedingStatus(this.patientProfile);
1737
- this.isPregnant = getPatientPregnancyStatus(this.patientProfile);
1738
1456
  const birthDate = getPatientBirthDate(this.patientProfile);
1739
- this.isPregnancyDivVisible = false;
1457
+ this.patientBirthDate = birthDate?.toISOString().split("T")[0] ?? "";
1458
+ let isPregnancyEligible = false;
1740
1459
  if (birthDate) {
1741
- this.ageInput.setAttribute("warning-msg", "");
1742
- const today = /* @__PURE__ */ new Date();
1743
- const yearsDiff = today.getFullYear() - birthDate.getFullYear();
1744
- const monthsDiff = today.getMonth() - birthDate.getMonth();
1745
- const monthsDifference = yearsDiff * 12 + monthsDiff;
1746
- if (monthsDifference < 24) {
1747
- this.patientAge = monthsDifference;
1748
- this.patientUnitAge = "mois";
1749
- this.isPregnancyDivVisible = false;
1750
- } else {
1751
- this.patientAge = Math.floor(monthsDifference / 12);
1752
- this.patientUnitAge = "ans";
1753
- if (this.defaultPatientSex.value !== "male") {
1754
- this.isPregnancyDivVisible = true;
1755
- }
1756
- }
1757
- this.defaultPatientUnitAge = {
1758
- value: this.patientUnitAge,
1759
- label: ageOptions.find((option) => option.value === this.patientUnitAge)?.label
1760
- };
1460
+ this.ageInputText.setAttribute("warning-msg", "");
1461
+ const { age, unit } = calculateAgeFromBirthDate(birthDate);
1462
+ this.patientAgeValue = age;
1463
+ this.patientUnitAge = unit;
1464
+ isPregnancyEligible = unit === "ans" && this.defaultPatientSex.value !== "male";
1761
1465
  } else {
1466
+ this.patientAgeValue = void 0;
1762
1467
  this.ageErrorMessageInput = "L'âge est requis";
1763
- this.ageInput.setAttribute("warning-msg", this.ageErrorMessageInput);
1764
- this.defaultPatientUnitAge = {
1765
- value: "ans",
1766
- label: ageOptions.find((option) => option.value === "ans")?.label
1767
- };
1468
+ this.ageInputText.setAttribute("warning-msg", this.ageErrorMessageInput);
1768
1469
  }
1769
- const creatinine = getCreatinine(this.patientProfile);
1770
- const renalStatus = getPatientRenalInsufficiencyStatus(this.patientProfile);
1771
- const creatinineByMg = creatinine.find((c2) => c2.unit?.toLowerCase() === "mg/l");
1772
- const creatinineByUmol = creatinine.find((c2) => c2.unit === "μmol/L");
1773
- this.clairanceCreatinine = renalStatus?.clearance?.value ?? 0;
1774
- this.dfg = renalStatus?.gfr?.value ?? 0;
1775
- this.creatinineByMg = creatinineByMg?.value ?? 0;
1776
- this.creatinineByUmol = creatinineByUmol?.value ?? 0;
1470
+ this.emitChange(isPregnancyEligible, false);
1777
1471
  }
1778
1472
  updated(changedProperties) {
1779
1473
  if (!changedProperties.has("patientProfile")) {
1780
1474
  return;
1781
1475
  }
1782
- this.resetToProfileValues();
1783
- }
1784
- handleCancel() {
1785
- this.resetToProfileValues();
1786
- this.resetKey++;
1787
- this.editionModalElement.close();
1476
+ this.resetFromProfile();
1788
1477
  }
1789
- verifyAgeInput() {
1790
- const age = Number(this.ageInput?.value ?? 0);
1791
- if (age < 2 && this.patientUnitAge === "ans") {
1792
- this.ageErrorMessageInput = "L'âge doit être exprimé en mois si inférieur à 2 ans";
1793
- } else if (age > 150 && this.patientUnitAge === "ans") {
1794
- this.ageErrorMessageInput = "L'âge ne doit pas dépasser 150 ans";
1795
- } else if (age > 23 && this.patientUnitAge === "mois") {
1796
- this.ageErrorMessageInput = "L'âge en mois ne doit pas dépasser 23 mois, veuillez compter en années";
1797
- } else if (age < 1 && this.patientUnitAge === "mois") {
1798
- this.ageErrorMessageInput = "L'âge est invalide";
1799
- } else {
1800
- this.ageErrorMessageInput = "";
1478
+ getAgeErrorMessage(age) {
1479
+ if (age > 150) {
1480
+ return "L'âge ne doit pas dépasser 150 ans";
1801
1481
  }
1802
- this.ageInput.setAttribute("warning-msg", this.ageErrorMessageInput);
1803
- if (this.patientUnitAge === "ans" && (age >= 12 && age <= 55)) {
1804
- if (this.genderSelect?.value && this.genderSelect?.value !== "male") {
1805
- this.isPregnancyDivVisible = true;
1806
- }
1807
- } else {
1808
- this.isPregnancyDivVisible = false;
1482
+ if (age < 1) {
1483
+ return "L'âge est invalide";
1809
1484
  }
1810
- this.recalculateRenalValues();
1485
+ return "";
1811
1486
  }
1812
- handleAgeUnit() {
1813
- this.patientUnitAge = this.ageUnitSelect?.value ?? "ans";
1814
- this.verifyAgeInput();
1487
+ modifyGender() {
1488
+ this.emitChange(this.isPregnancyAge, true);
1489
+ }
1490
+ verifyAgeInput() {
1491
+ const birthDateValue = String(this.birthDateInput?.value ?? "");
1492
+ const birthDate = new Date(birthDateValue);
1493
+ const today = /* @__PURE__ */ new Date();
1494
+ if (!birthDateValue || isNaN(birthDate.getTime()) || birthDate > today) {
1495
+ this.ageErrorMessageInput = "La date de naissance n'est pas valide";
1496
+ this.ageInputText.setAttribute("warning-msg", this.ageErrorMessageInput);
1497
+ this.patientAgeValue = void 0;
1498
+ this.emitChange(false, true);
1499
+ return;
1500
+ }
1501
+ this.patientBirthDate = birthDateValue;
1502
+ const { age, unit } = calculateAgeFromBirthDate(birthDate, today);
1503
+ this.patientAgeValue = age;
1504
+ this.patientUnitAge = unit;
1505
+ this.ageErrorMessageInput = this.getAgeErrorMessage(age);
1506
+ this.ageInputText.setAttribute("warning-msg", this.ageErrorMessageInput);
1507
+ this.emitChange(this.isPregnancyAge, true);
1815
1508
  }
1816
1509
  verifySizeInput() {
1817
1510
  const size = Number(this.sizeInput?.value ?? 0);
@@ -1822,6 +1515,7 @@ let PatientProfileEdition = class extends i$2 {
1822
1515
  }
1823
1516
  this.sizeInput.setAttribute("warning-msg", this.sizeErrorMessageInput);
1824
1517
  this.imc = calculateBMI(Number(this.weightInput?.value ?? 0), size);
1518
+ this.emitChange(this.isPregnancyAge, false);
1825
1519
  }
1826
1520
  verifyWeightInput() {
1827
1521
  const weight = Number(this.weightInput?.value ?? 0);
@@ -1832,26 +1526,129 @@ let PatientProfileEdition = class extends i$2 {
1832
1526
  }
1833
1527
  this.weightInput.setAttribute("warning-msg", this.weightErrorMessageInput);
1834
1528
  this.imc = calculateBMI(weight, Number(this.sizeInput?.value ?? 0));
1835
- this.recalculateRenalValues();
1529
+ this.emitChange(this.isPregnancyAge, true);
1836
1530
  }
1837
- getPatientSexFromProfile() {
1838
- let gender = getPatientGender(this.patientProfile);
1839
- switch (gender) {
1840
- case "Homme":
1841
- gender = "male";
1842
- break;
1843
- case "Femme":
1844
- gender = "female";
1845
- break;
1846
- }
1847
- this.isPregnancyDivVisible = !!(gender && gender !== "Homme");
1848
- const selectedOption = sexOptions.find((option) => option.value === gender);
1849
- return selectedOption ? { value: selectedOption.value, label: selectedOption.label } : {};
1531
+ getValue() {
1532
+ return {
1533
+ gender: this.genderSelect?.value ?? "",
1534
+ birthDate: this.birthDateInput?.value ?? "",
1535
+ height: Number(this.sizeInput?.value ?? ""),
1536
+ weight: Number(this.weightInput?.value ?? "")
1537
+ };
1850
1538
  }
1851
- getPatientHepaticStadeFromProfile() {
1852
- const renalStade = getPatientHepaticInsufficiencyStade(this.patientProfile);
1853
- const selectedOption = hepaticStadeOptions.find((option) => option.label === renalStade);
1854
- return selectedOption ? { value: selectedOption.value, label: selectedOption.label } : {};
1539
+ render() {
1540
+ return b`
1541
+ <div class="${PREFIX}-edition-modal-demographic-div">
1542
+ <div class="${PREFIX}-edition-modal-large-section">
1543
+ <bcbd-select data-test-id="name-select" .selectedOptions=${{ value: "1", label: getPatientName(this.patientProfile) }} readonly></bcbd-select>
1544
+ </div>
1545
+ <div class="${PREFIX}-edition-modal-information-section">
1546
+ ${this.isSexeDisplay ? b`
1547
+ <div class="${PREFIX}-edition-modal-little-section">
1548
+ <span>Sexe</span>
1549
+ <bcbd-select data-test-id="sex-select" id="genderSelect" ?disabled=${this.isSexeReadOnly} placeholder="Choisir" .options=${sexOptions} .selectedOptions=${this.defaultPatientSex} ?readonly=${this.isSexeReadOnly} @change=${this.modifyGender}></bcbd-select>
1550
+ </div>` : A}
1551
+ ${this.isAgeDisplay ? b`
1552
+ <div class="${PREFIX}-edition-modal-little-section">
1553
+ <span>Date de naissance</span>
1554
+ <bcbd-input data-test-id="birth-date-input" id="birthDateInput" ?disabled=${this.isAgeReadOnly} .value=${this.patientBirthDate} type="date" aria-label="Date de naissance" warning-msg="" ?readonly=${this.isAgeReadOnly} @change=${this.verifyAgeInput}></bcbd-input>
1555
+ </div>
1556
+ <div class="${PREFIX}-edition-modal-little-section">
1557
+ <span>Age</span>
1558
+ <bcbd-input data-test-id="age-input-text" id="ageInputText" disabled type="text" aria-label="Age" .value=${this.patientAge} warning-msg="" readonly></bcbd-input>
1559
+ </div>` : A}
1560
+ <div class="${PREFIX}-edition-modal-information-section-secondary-group">
1561
+ <div class="${PREFIX}-edition-modal-little-section">
1562
+ <span>Taille (cm)</span>
1563
+ <bcbd-input data-test-id="size-input" id="sizeInput" type="number" aria-label="Taille (cm)" .value=${getPatientHeight(this.patientProfile) ?? ""} warning-msg="" @change=${this.verifySizeInput}></bcbd-input>
1564
+ </div>
1565
+ <div class="${PREFIX}-edition-modal-little-section">
1566
+ <span>Poids (kg)</span>
1567
+ <bcbd-input data-test-id="weight-input" id="weightInput" type="number" aria-label="Poids (kg)" .value=${getPatientWeight(this.patientProfile) ?? ""} warning-msg="" @change=${this.verifyWeightInput}></bcbd-input>
1568
+ </div>
1569
+ <div class="${PREFIX}-edition-modal-little-section">
1570
+ <span>IMC</span>
1571
+ <bcbd-input data-test-id="imc-input" id="imcInput" type="number" aria-label="IMC" disabled .value=${this.imc} warning-msg=""></bcbd-input>
1572
+ </div>
1573
+ </div>
1574
+ </div>
1575
+ </div>
1576
+ `;
1577
+ }
1578
+ };
1579
+ PatientDemographicsForm.styles = i$5`${r$4(patientDemographicsFormCSS)}`;
1580
+ __decorateClass$8([
1581
+ n2({ type: Object, attribute: "patient-profile" })
1582
+ ], PatientDemographicsForm.prototype, "patientProfile", 2);
1583
+ __decorateClass$8([
1584
+ n2({ type: Object })
1585
+ ], PatientDemographicsForm.prototype, "preferences", 2);
1586
+ __decorateClass$8([
1587
+ r()
1588
+ ], PatientDemographicsForm.prototype, "patientBirthDate", 2);
1589
+ __decorateClass$8([
1590
+ r()
1591
+ ], PatientDemographicsForm.prototype, "patientAgeValue", 2);
1592
+ __decorateClass$8([
1593
+ r()
1594
+ ], PatientDemographicsForm.prototype, "patientUnitAge", 2);
1595
+ __decorateClass$8([
1596
+ r()
1597
+ ], PatientDemographicsForm.prototype, "defaultPatientSex", 2);
1598
+ __decorateClass$8([
1599
+ r()
1600
+ ], PatientDemographicsForm.prototype, "ageErrorMessageInput", 2);
1601
+ __decorateClass$8([
1602
+ r()
1603
+ ], PatientDemographicsForm.prototype, "sizeErrorMessageInput", 2);
1604
+ __decorateClass$8([
1605
+ r()
1606
+ ], PatientDemographicsForm.prototype, "weightErrorMessageInput", 2);
1607
+ __decorateClass$8([
1608
+ r()
1609
+ ], PatientDemographicsForm.prototype, "imc", 2);
1610
+ __decorateClass$8([
1611
+ e$1("#sizeInput")
1612
+ ], PatientDemographicsForm.prototype, "sizeInput", 2);
1613
+ __decorateClass$8([
1614
+ e$1("#ageInputText")
1615
+ ], PatientDemographicsForm.prototype, "ageInputText", 2);
1616
+ __decorateClass$8([
1617
+ e$1("#birthDateInput")
1618
+ ], PatientDemographicsForm.prototype, "birthDateInput", 2);
1619
+ __decorateClass$8([
1620
+ e$1("#weightInput")
1621
+ ], PatientDemographicsForm.prototype, "weightInput", 2);
1622
+ __decorateClass$8([
1623
+ e$1("#genderSelect")
1624
+ ], PatientDemographicsForm.prototype, "genderSelect", 2);
1625
+ PatientDemographicsForm = __decorateClass$8([
1626
+ t("bcb-patient-demographics-form")
1627
+ ], PatientDemographicsForm);
1628
+ const patientReproductiveFormCSS = ".claudebernard-edition-modal {\n font-size: 0.9rem;\n}\n.claudebernard-edition-modal-large-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n width: 100%;\n}\n.claudebernard-edition-modal-information-section {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex-wrap: wrap;\n}\n.claudebernard-edition-modal-information-section span {\n white-space: nowrap;\n}\n.claudebernard-edition-modal-information-section-secondary-group {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex: 3;\n flex-wrap: wrap;\n}\n@media (max-width: 950px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n flex-basis: 100%;\n }\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n display: contents;\n }\n}\n.claudebernard-edition-modal-little-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n flex: 1;\n min-width: 0;\n}\n.claudebernard-edition-modal-little-section bcbd-input {\n height: 100%;\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-little-section {\n flex: 1 1 calc(50% - 8px);\n }\n .claudebernard-edition-modal-little-section span {\n white-space: nowrap;\n }\n}\n.claudebernard-edition-modal-subtitle {\n font-weight: 600;\n font-size: 1.1rem;\n color: var(--bcbd-primary-color, #0C75AD);\n}\n.claudebernard-edition-modal-error-message {\n color: var(--bcbd-danger-color, #CF406E);\n font-size: 0.8rem;\n}\n.claudebernard-edition-modal-fieldset {\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n margin-inline: 0;\n border-radius: 4px;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\nbcbd-checkbox {\n --bcbd-checkbox-font-size: .9rem;\n}\n\n.claudebernard-edition-modal-pregnant-div {\n display: flex;\n align-items: center;\n gap: 16px;\n}\n.claudebernard-edition-modal-pregnant-div bcbd-input {\n width: 40% !important;\n}";
1629
+ var __defProp$6 = Object.defineProperty;
1630
+ var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
1631
+ var __decorateClass$7 = (decorators, target, key, kind) => {
1632
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
1633
+ for (var i4 = decorators.length - 1, decorator; i4 >= 0; i4--)
1634
+ if (decorator = decorators[i4])
1635
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1636
+ if (kind && result) __defProp$6(target, key, result);
1637
+ return result;
1638
+ };
1639
+ let PatientReproductiveForm = class extends i$2 {
1640
+ constructor() {
1641
+ super(...arguments);
1642
+ this.visible = false;
1643
+ this.isPregnant = false;
1644
+ this.breastfeeding = false;
1645
+ }
1646
+ updated(changedProperties) {
1647
+ if (!changedProperties.has("patientProfile")) {
1648
+ return;
1649
+ }
1650
+ this.breastfeeding = getPatientBreastfeedingStatus(this.patientProfile);
1651
+ this.isPregnant = getPatientPregnancyStatus(this.patientProfile);
1855
1652
  }
1856
1653
  handlePregnancy(event) {
1857
1654
  this.isPregnant = event.detail;
@@ -1859,6 +1656,288 @@ let PatientProfileEdition = class extends i$2 {
1859
1656
  handleBreastfeeding(event) {
1860
1657
  this.breastfeeding = event.detail;
1861
1658
  }
1659
+ getValue() {
1660
+ if (!this.visible) {
1661
+ return { isPregnant: false, breastfeeding: false, gestationalWeeks: 0 };
1662
+ }
1663
+ return {
1664
+ isPregnant: this.isPregnant,
1665
+ breastfeeding: this.breastfeeding,
1666
+ gestationalWeeks: Number(this.gestationalWeeksInput?.value ?? "")
1667
+ };
1668
+ }
1669
+ render() {
1670
+ if (!this.visible) {
1671
+ return A;
1672
+ }
1673
+ return b`
1674
+ <div class="${PREFIX}-edition-modal-pregnant-div">
1675
+ <bcbd-checkbox data-test-id="pregnancy-checkbox" id="pregnancyCheckbox" .checked=${this.isPregnant} label="Grossesse" color="primary" @change=${this.handlePregnancy}></bcbd-checkbox>
1676
+ <bcbd-input data-test-id="gestational-input" id="gestationalWeeksInput" .value=${getPatientAmenorrheaStatus(this.patientProfile) ?? 0} type="number" warning-msg="" label="Nombre de semaines" placeholder=""></bcbd-input>
1677
+ <bcbd-checkbox data-test-id="breastfeeding-checkbox" id="breastfeedingCheckbox" .checked=${this.breastfeeding} label="Allaitement" color="primary" @change=${this.handleBreastfeeding}></bcbd-checkbox>
1678
+ </div>`;
1679
+ }
1680
+ };
1681
+ PatientReproductiveForm.styles = i$5`${r$4(patientReproductiveFormCSS)}`;
1682
+ __decorateClass$7([
1683
+ n2({ type: Object, attribute: "patient-profile" })
1684
+ ], PatientReproductiveForm.prototype, "patientProfile", 2);
1685
+ __decorateClass$7([
1686
+ n2({ type: Boolean })
1687
+ ], PatientReproductiveForm.prototype, "visible", 2);
1688
+ __decorateClass$7([
1689
+ r()
1690
+ ], PatientReproductiveForm.prototype, "isPregnant", 2);
1691
+ __decorateClass$7([
1692
+ r()
1693
+ ], PatientReproductiveForm.prototype, "breastfeeding", 2);
1694
+ __decorateClass$7([
1695
+ e$1("#gestationalWeeksInput")
1696
+ ], PatientReproductiveForm.prototype, "gestationalWeeksInput", 2);
1697
+ PatientReproductiveForm = __decorateClass$7([
1698
+ t("bcb-patient-reproductive-form")
1699
+ ], PatientReproductiveForm);
1700
+ const fetchPathologiesByTerm = async (term, typePathology, params, apiUrl) => {
1701
+ const response = await fetch(`${apiUrl}/search/pathologies/?term=${term}&typePathology=${typePathology}`, {
1702
+ method: "POST",
1703
+ headers: {
1704
+ "Content-Type": "application/json"
1705
+ },
1706
+ body: JSON.stringify(params)
1707
+ });
1708
+ return response.json();
1709
+ };
1710
+ const fetchMoleculesByTerm = async (term, params, apiUrl) => {
1711
+ const response = await fetch(`${apiUrl}/search/molecules/?term=${term}`, {
1712
+ method: "POST",
1713
+ headers: {
1714
+ "Content-Type": "application/json"
1715
+ },
1716
+ body: JSON.stringify(params)
1717
+ });
1718
+ return response.json();
1719
+ };
1720
+ var __defProp$5 = Object.defineProperty;
1721
+ var __decorateClass$6 = (decorators, target, key, kind) => {
1722
+ var result = void 0;
1723
+ for (var i4 = decorators.length - 1, decorator; i4 >= 0; i4--)
1724
+ if (decorator = decorators[i4])
1725
+ result = decorator(target, key, result) || result;
1726
+ if (result) __defProp$5(target, key, result);
1727
+ return result;
1728
+ };
1729
+ class PatientCodeSearchFormBase extends i$2 {
1730
+ constructor() {
1731
+ super(...arguments);
1732
+ this.apiUrl = "https://api-dev.claudebernard.fr";
1733
+ this.options = [];
1734
+ this.selected = [];
1735
+ this.apiErrorMessage = "";
1736
+ }
1737
+ updated(changedProperties) {
1738
+ if (!changedProperties.has("patientProfile")) {
1739
+ return;
1740
+ }
1741
+ this.selected = this.extractInitialSelection(this.patientProfile);
1742
+ this.apiErrorMessage = "";
1743
+ this.options = [];
1744
+ }
1745
+ apiReturnToSelectOption(item) {
1746
+ return { value: item.code, label: item.label, category: item.subType };
1747
+ }
1748
+ handleSearch(event) {
1749
+ if (!this.apiUrl) {
1750
+ return;
1751
+ }
1752
+ const valueSearch = event.detail.value;
1753
+ if (valueSearch.length > 2) {
1754
+ this.search(valueSearch).then((options) => {
1755
+ this.options = options;
1756
+ this.apiErrorMessage = "";
1757
+ }).catch(() => {
1758
+ this.apiErrorMessage = this.searchErrorMessage;
1759
+ this.options = [];
1760
+ });
1761
+ } else {
1762
+ this.options = [];
1763
+ }
1764
+ }
1765
+ handleUpdateSelection(event) {
1766
+ const newValues = event.detail;
1767
+ const newSelections = newValues.filter((value) => !this.selected.some((option) => option.value === value)).map((value) => this.options.find((option) => option.value === value)).filter((option) => option !== void 0);
1768
+ const updatedSelections = this.selected.filter((option) => newValues.includes(option.value));
1769
+ this.selected = [...updatedSelections, ...newSelections];
1770
+ this.options = [];
1771
+ }
1772
+ getValue() {
1773
+ return this.selected;
1774
+ }
1775
+ }
1776
+ __decorateClass$6([
1777
+ n2({ type: Object, attribute: "patient-profile" })
1778
+ ], PatientCodeSearchFormBase.prototype, "patientProfile");
1779
+ __decorateClass$6([
1780
+ n2({ type: String, attribute: "api-url" })
1781
+ ], PatientCodeSearchFormBase.prototype, "apiUrl");
1782
+ __decorateClass$6([
1783
+ r()
1784
+ ], PatientCodeSearchFormBase.prototype, "options");
1785
+ __decorateClass$6([
1786
+ r()
1787
+ ], PatientCodeSearchFormBase.prototype, "selected");
1788
+ __decorateClass$6([
1789
+ r()
1790
+ ], PatientCodeSearchFormBase.prototype, "apiErrorMessage");
1791
+ const patientCodeSearchFormCSS = ".claudebernard-edition-modal {\n font-size: 0.9rem;\n}\n.claudebernard-edition-modal-large-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n width: 100%;\n}\n.claudebernard-edition-modal-information-section {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex-wrap: wrap;\n}\n.claudebernard-edition-modal-information-section span {\n white-space: nowrap;\n}\n.claudebernard-edition-modal-information-section-secondary-group {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex: 3;\n flex-wrap: wrap;\n}\n@media (max-width: 950px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n flex-basis: 100%;\n }\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n display: contents;\n }\n}\n.claudebernard-edition-modal-little-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n flex: 1;\n min-width: 0;\n}\n.claudebernard-edition-modal-little-section bcbd-input {\n height: 100%;\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-little-section {\n flex: 1 1 calc(50% - 8px);\n }\n .claudebernard-edition-modal-little-section span {\n white-space: nowrap;\n }\n}\n.claudebernard-edition-modal-subtitle {\n font-weight: 600;\n font-size: 1.1rem;\n color: var(--bcbd-primary-color, #0C75AD);\n}\n.claudebernard-edition-modal-error-message {\n color: var(--bcbd-danger-color, #CF406E);\n font-size: 0.8rem;\n}\n.claudebernard-edition-modal-fieldset {\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n margin-inline: 0;\n border-radius: 4px;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\nbcbd-checkbox {\n --bcbd-checkbox-font-size: .9rem;\n}";
1792
+ var __defProp$4 = Object.defineProperty;
1793
+ var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
1794
+ var __decorateClass$5 = (decorators, target, key, kind) => {
1795
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target;
1796
+ for (var i4 = decorators.length - 1, decorator; i4 >= 0; i4--)
1797
+ if (decorator = decorators[i4])
1798
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1799
+ if (kind && result) __defProp$4(target, key, result);
1800
+ return result;
1801
+ };
1802
+ let PatientPathologiesForm = class extends PatientCodeSearchFormBase {
1803
+ get searchErrorMessage() {
1804
+ return "Erreur lors de la récupération des pathologies";
1805
+ }
1806
+ extractInitialSelection(patientProfile) {
1807
+ return getPatientConditionsWithCode(patientProfile);
1808
+ }
1809
+ async search(term) {
1810
+ const typePathology = this.preferences?.typePathology ?? "";
1811
+ const response = await fetchPathologiesByTerm(term, typePathology, new SearchRequestBody({}), this.apiUrl);
1812
+ return response.content.map((pathology) => this.apiReturnToSelectOption(pathology));
1813
+ }
1814
+ render() {
1815
+ return b`
1816
+ <div class="${PREFIX}-edition-modal-large-section">
1817
+ <span>Pathologies suivies</span>
1818
+ ${this.apiErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.apiErrorMessage}</span>` : A}
1819
+ <bcbd-select data-test-id="pathologies-select" id="pathologiesSelect" use-input multiple aria-label="Pathologies suivies"
1820
+ .selectedOptions=${this.selected} .options=${this.options}
1821
+ @filter=${this.handleSearch} @change=${this.handleUpdateSelection}></bcbd-select>
1822
+ </div>
1823
+ `;
1824
+ }
1825
+ };
1826
+ PatientPathologiesForm.styles = i$5`${r$4(patientCodeSearchFormCSS)}`;
1827
+ __decorateClass$5([
1828
+ n2({ type: Object })
1829
+ ], PatientPathologiesForm.prototype, "preferences", 2);
1830
+ PatientPathologiesForm = __decorateClass$5([
1831
+ t("bcb-patient-pathologies-form")
1832
+ ], PatientPathologiesForm);
1833
+ var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
1834
+ var __decorateClass$4 = (decorators, target, key, kind) => {
1835
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target;
1836
+ for (var i4 = decorators.length - 1, decorator; i4 >= 0; i4--)
1837
+ if (decorator = decorators[i4])
1838
+ result = decorator(result) || result;
1839
+ return result;
1840
+ };
1841
+ let PatientAllergiesForm = class extends PatientCodeSearchFormBase {
1842
+ get searchErrorMessage() {
1843
+ return "Erreur lors de la récupération des allergies";
1844
+ }
1845
+ extractInitialSelection(patientProfile) {
1846
+ return getPatientAllergiesWithCode(patientProfile);
1847
+ }
1848
+ async search(term) {
1849
+ const response = await fetchMoleculesByTerm(term, new SearchRequestBody({}), this.apiUrl);
1850
+ return response.content.map((allergy) => this.apiReturnToSelectOption(allergy));
1851
+ }
1852
+ render() {
1853
+ return b`
1854
+ <div class="${PREFIX}-edition-modal-large-section">
1855
+ <span>Allergies</span>
1856
+ ${this.apiErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.apiErrorMessage}</span>` : A}
1857
+ <bcbd-select data-test-id="allergies-select" id="allergiesSelect" use-input multiple aria-label="Allergies"
1858
+ .selectedOptions=${this.selected} .options=${this.options}
1859
+ @filter=${this.handleSearch} @change=${this.handleUpdateSelection}
1860
+ ></bcbd-select>
1861
+ </div>
1862
+ `;
1863
+ }
1864
+ };
1865
+ PatientAllergiesForm.styles = i$5`${r$4(patientCodeSearchFormCSS)}`;
1866
+ PatientAllergiesForm = __decorateClass$4([
1867
+ t("bcb-patient-allergies-form")
1868
+ ], PatientAllergiesForm);
1869
+ const convertRenalInsufficiency = async (type, value, patient, apiUrl) => {
1870
+ const response = await fetch(`${apiUrl}/prescription/patient/fhir/renal-insufficiency-conversion`, {
1871
+ method: "POST",
1872
+ headers: {
1873
+ "Content-Type": "application/json"
1874
+ },
1875
+ body: JSON.stringify({
1876
+ typeEntree: type,
1877
+ valeur: value,
1878
+ patient
1879
+ })
1880
+ });
1881
+ return response.json();
1882
+ };
1883
+ const patientRenalFormCSS = ".claudebernard-edition-modal {\n font-size: 0.9rem;\n}\n.claudebernard-edition-modal-large-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n width: 100%;\n}\n.claudebernard-edition-modal-information-section {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex-wrap: wrap;\n}\n.claudebernard-edition-modal-information-section span {\n white-space: nowrap;\n}\n.claudebernard-edition-modal-information-section-secondary-group {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex: 3;\n flex-wrap: wrap;\n}\n@media (max-width: 950px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n flex-basis: 100%;\n }\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n display: contents;\n }\n}\n.claudebernard-edition-modal-little-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n flex: 1;\n min-width: 0;\n}\n.claudebernard-edition-modal-little-section bcbd-input {\n height: 100%;\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-little-section {\n flex: 1 1 calc(50% - 8px);\n }\n .claudebernard-edition-modal-little-section span {\n white-space: nowrap;\n }\n}\n.claudebernard-edition-modal-subtitle {\n font-weight: 600;\n font-size: 1.1rem;\n color: var(--bcbd-primary-color, #0C75AD);\n}\n.claudebernard-edition-modal-error-message {\n color: var(--bcbd-danger-color, #CF406E);\n font-size: 0.8rem;\n}\n.claudebernard-edition-modal-fieldset {\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n margin-inline: 0;\n border-radius: 4px;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\nbcbd-checkbox {\n --bcbd-checkbox-font-size: .9rem;\n}";
1884
+ var __defProp$3 = Object.defineProperty;
1885
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
1886
+ var __decorateClass$3 = (decorators, target, key, kind) => {
1887
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
1888
+ for (var i4 = decorators.length - 1, decorator; i4 >= 0; i4--)
1889
+ if (decorator = decorators[i4])
1890
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1891
+ if (kind && result) __defProp$3(target, key, result);
1892
+ return result;
1893
+ };
1894
+ let PatientRenalForm = class extends i$2 {
1895
+ constructor() {
1896
+ super(...arguments);
1897
+ this.apiUrl = "https://api-dev.claudebernard.fr";
1898
+ this.creatinineByMg = 0;
1899
+ this.creatinineByUmol = 0;
1900
+ this.clairanceCreatinine = 0;
1901
+ this.dfg = 0;
1902
+ this.renalLackInformationErrorMessage = "";
1903
+ }
1904
+ updated(changedProperties) {
1905
+ if (!changedProperties.has("patientProfile")) {
1906
+ return;
1907
+ }
1908
+ this.resetFromProfile();
1909
+ }
1910
+ resetFromProfile() {
1911
+ const creatinine = getCreatinine(this.patientProfile);
1912
+ const renalStatus = getPatientRenalInsufficiencyStatus(this.patientProfile);
1913
+ const creatinineByMg = creatinine.find((c2) => c2.unit?.toLowerCase() === "mg/l");
1914
+ const creatinineByUmol = creatinine.find((c2) => c2.unit === "μmol/L");
1915
+ this.renalLackInformationErrorMessage = "";
1916
+ this.clairanceCreatinine = renalStatus?.clearance?.value ?? 0;
1917
+ this.dfg = renalStatus?.gfr?.value ?? 0;
1918
+ this.creatinineByMg = creatinineByMg?.value ?? 0;
1919
+ this.creatinineByUmol = creatinineByUmol?.value ?? 0;
1920
+ }
1921
+ // Patch un clone du profil avec les valeurs démographiques en cours de saisie
1922
+ // (non encore validées, donc absentes de `this.patientProfile`) : l'API de
1923
+ // conversion rénale a besoin de l'âge/sexe/poids à jour pour calculer correctement.
1924
+ buildConversionPatient() {
1925
+ if (!this.patientProfile) {
1926
+ return this.patientProfile;
1927
+ }
1928
+ const patched = structuredClone(this.patientProfile);
1929
+ const demographics = this.demographics;
1930
+ if (demographics?.birthDate) {
1931
+ setPatientAge(patched, demographics.birthDate);
1932
+ }
1933
+ if (demographics?.gender === "male" || demographics?.gender === "female" || demographics?.gender === "unknown") {
1934
+ setPatientGender(patched, demographics.gender);
1935
+ }
1936
+ if (demographics && !isNaN(demographics.weight) && demographics.weight > 0) {
1937
+ setPatientWeight(patched, demographics.weight);
1938
+ }
1939
+ return patched;
1940
+ }
1862
1941
  async handleRenalConversion(type, value) {
1863
1942
  if (isNaN(value) || value <= 0) {
1864
1943
  return;
@@ -1867,7 +1946,7 @@ let PatientProfileEdition = class extends i$2 {
1867
1946
  const result = await convertRenalInsufficiency(
1868
1947
  type,
1869
1948
  value,
1870
- this.patientProfile,
1949
+ this.buildConversionPatient(),
1871
1950
  this.apiUrl
1872
1951
  );
1873
1952
  if (result.error) {
@@ -1891,7 +1970,7 @@ let PatientProfileEdition = class extends i$2 {
1891
1970
  this.renalLackInformationErrorMessage = "Erreur lors de la conversion de l'insuffisance rénale";
1892
1971
  }
1893
1972
  }
1894
- recalculateRenalValues() {
1973
+ recalculate() {
1895
1974
  const creatinineUmol = Number(this.creatinineUmolInput?.value ?? "");
1896
1975
  const creatinineMg = Number(this.creatinineMgLInput?.value ?? "");
1897
1976
  const clairance = Number(this.clairanceCreatinineInput?.value ?? "");
@@ -1906,124 +1985,231 @@ let PatientProfileEdition = class extends i$2 {
1906
1985
  this.handleRenalConversion(4, dfg);
1907
1986
  }
1908
1987
  }
1909
- apiReturntoSelectOption(pathology) {
1988
+ getValue() {
1910
1989
  return {
1911
- value: pathology.code,
1912
- label: pathology.label,
1913
- category: pathology.subType
1990
+ creatinineByMg: Number(this.creatinineMgLInput?.value ?? ""),
1991
+ creatinineByUmol: Number(this.creatinineUmolInput?.value ?? ""),
1992
+ clairanceCreatinine: Number(this.clairanceCreatinineInput?.value ?? ""),
1993
+ dfg: Number(this.dfgInput?.value ?? "")
1914
1994
  };
1915
1995
  }
1916
- searchPathologies(event) {
1917
- if (!this.apiUrl) {
1996
+ render() {
1997
+ return b`
1998
+ <fieldset class="${PREFIX}-edition-modal-fieldset" data-test-id="renal-insufficiency-fieldset">
1999
+ <legend class="${PREFIX}-edition-modal-subtitle">
2000
+ <span>Insuffisance rénale</span>
2001
+ </legend>
2002
+ ${this.renalLackInformationErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.renalLackInformationErrorMessage}</span>` : A}
2003
+ <div class="${PREFIX}-edition-modal-information-section">
2004
+ <div class="${PREFIX}-edition-modal-little-section">
2005
+ <span>Créatininémie (μmol/L)</span>
2006
+ <bcbd-input data-test-id="creatinine-umol-input" id="creatinineUmolInput" type="number" aria-label="Créatininémie (μmol/L)" .value=${this.creatinineByUmol <= 0 ? "" : this.creatinineByUmol} warning-msg="" @change=${() => this.handleRenalConversion(1, Number(this.creatinineUmolInput?.value ?? 0))}></bcbd-input>
2007
+ </div>
2008
+ <div class="${PREFIX}-edition-modal-little-section">
2009
+ <span>Créatininémie (mg/L)</span>
2010
+ <bcbd-input data-test-id="creatinine-mgl-input" id="creatininemgLInput" type="number" aria-label="Créatininémie (mg/L)" .value=${this.creatinineByMg <= 0 ? "" : this.creatinineByMg} warning-msg="" @change=${() => this.handleRenalConversion(2, Number(this.creatinineMgLInput?.value ?? 0))}></bcbd-input>
2011
+ </div>
2012
+ </div>
2013
+ <div class="${PREFIX}-edition-modal-information-section">
2014
+ <div class="${PREFIX}-edition-modal-little-section">
2015
+ <span>Clairance créatinine (ml/min)</span>
2016
+ <bcbd-input data-test-id="clearance-input" id="clairanceCreatinineInput" type="number" aria-label="Clairance créatinine (ml/min)" .value=${this.clairanceCreatinine <= 0 ? "" : this.clairanceCreatinine} warning-msg="" @change=${() => this.handleRenalConversion(3, Number(this.clairanceCreatinineInput?.value ?? 0))}></bcbd-input>
2017
+ </div>
2018
+ <div class="${PREFIX}-edition-modal-little-section">
2019
+ <span>DFG (mL/min/1.73.m2)</span>
2020
+ <bcbd-input data-test-id="dfg-input" id="dfgInput" type="number" aria-label="DFG (mL/min/1.73.m2)" .value=${this.dfg <= 0 ? "" : this.dfg} warning-msg="" @change=${() => this.handleRenalConversion(4, Number(this.dfgInput?.value ?? 0))}></bcbd-input>
2021
+ </div>
2022
+ </div>
2023
+ </fieldset>`;
2024
+ }
2025
+ };
2026
+ PatientRenalForm.styles = i$5`${r$4(patientRenalFormCSS)}`;
2027
+ __decorateClass$3([
2028
+ n2({ type: Object, attribute: "patient-profile" })
2029
+ ], PatientRenalForm.prototype, "patientProfile", 2);
2030
+ __decorateClass$3([
2031
+ n2({ type: String, attribute: "api-url" })
2032
+ ], PatientRenalForm.prototype, "apiUrl", 2);
2033
+ __decorateClass$3([
2034
+ n2({ type: Object })
2035
+ ], PatientRenalForm.prototype, "demographics", 2);
2036
+ __decorateClass$3([
2037
+ r()
2038
+ ], PatientRenalForm.prototype, "creatinineByMg", 2);
2039
+ __decorateClass$3([
2040
+ r()
2041
+ ], PatientRenalForm.prototype, "creatinineByUmol", 2);
2042
+ __decorateClass$3([
2043
+ r()
2044
+ ], PatientRenalForm.prototype, "clairanceCreatinine", 2);
2045
+ __decorateClass$3([
2046
+ r()
2047
+ ], PatientRenalForm.prototype, "dfg", 2);
2048
+ __decorateClass$3([
2049
+ r()
2050
+ ], PatientRenalForm.prototype, "renalLackInformationErrorMessage", 2);
2051
+ __decorateClass$3([
2052
+ e$1("#creatinineUmolInput")
2053
+ ], PatientRenalForm.prototype, "creatinineUmolInput", 2);
2054
+ __decorateClass$3([
2055
+ e$1("#creatininemgLInput")
2056
+ ], PatientRenalForm.prototype, "creatinineMgLInput", 2);
2057
+ __decorateClass$3([
2058
+ e$1("#clairanceCreatinineInput")
2059
+ ], PatientRenalForm.prototype, "clairanceCreatinineInput", 2);
2060
+ __decorateClass$3([
2061
+ e$1("#dfgInput")
2062
+ ], PatientRenalForm.prototype, "dfgInput", 2);
2063
+ PatientRenalForm = __decorateClass$3([
2064
+ t("bcb-patient-renal-form")
2065
+ ], PatientRenalForm);
2066
+ const patientHepaticFormCSS = ".claudebernard-edition-modal {\n font-size: 0.9rem;\n}\n.claudebernard-edition-modal-large-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n width: 100%;\n}\n.claudebernard-edition-modal-information-section {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex-wrap: wrap;\n}\n.claudebernard-edition-modal-information-section span {\n white-space: nowrap;\n}\n.claudebernard-edition-modal-information-section-secondary-group {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex: 3;\n flex-wrap: wrap;\n}\n@media (max-width: 950px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n flex-basis: 100%;\n }\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n display: contents;\n }\n}\n.claudebernard-edition-modal-little-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n flex: 1;\n min-width: 0;\n}\n.claudebernard-edition-modal-little-section bcbd-input {\n height: 100%;\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-little-section {\n flex: 1 1 calc(50% - 8px);\n }\n .claudebernard-edition-modal-little-section span {\n white-space: nowrap;\n }\n}\n.claudebernard-edition-modal-subtitle {\n font-weight: 600;\n font-size: 1.1rem;\n color: var(--bcbd-primary-color, #0C75AD);\n}\n.claudebernard-edition-modal-error-message {\n color: var(--bcbd-danger-color, #CF406E);\n font-size: 0.8rem;\n}\n.claudebernard-edition-modal-fieldset {\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n margin-inline: 0;\n border-radius: 4px;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\nbcbd-checkbox {\n --bcbd-checkbox-font-size: .9rem;\n}";
2067
+ var __defProp$2 = Object.defineProperty;
2068
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
2069
+ var __decorateClass$2 = (decorators, target, key, kind) => {
2070
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
2071
+ for (var i4 = decorators.length - 1, decorator; i4 >= 0; i4--)
2072
+ if (decorator = decorators[i4])
2073
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2074
+ if (kind && result) __defProp$2(target, key, result);
2075
+ return result;
2076
+ };
2077
+ let PatientHepaticForm = class extends i$2 {
2078
+ constructor() {
2079
+ super(...arguments);
2080
+ this.defaultHepaticStade = {};
2081
+ }
2082
+ updated(changedProperties) {
2083
+ if (!changedProperties.has("patientProfile")) {
1918
2084
  return;
1919
2085
  }
1920
- const valueSearch = event.detail.value;
1921
- if (valueSearch.length > 2) {
1922
- const typePathology = this.preferences?.typePathology ?? "";
1923
- fetchPathologiesByTerm(valueSearch, typePathology, new SearchRequestBody({}), this.apiUrl).then((response) => {
1924
- this.pathologyOptions = [];
1925
- this.pathologyOptions = response.content.map((pathology) => this.apiReturntoSelectOption(pathology));
1926
- this.pathologiesApiErrorMessage = "";
1927
- }).catch(() => {
1928
- this.pathologiesApiErrorMessage = "Erreur lors de la récupération des pathologies";
1929
- this.pathologyOptions = [];
1930
- });
1931
- } else {
1932
- this.pathologyOptions = [];
2086
+ this.defaultHepaticStade = this.getPatientHepaticStadeFromProfile();
2087
+ }
2088
+ getPatientHepaticStadeFromProfile() {
2089
+ const renalStade = getPatientHepaticInsufficiencyStade(this.patientProfile);
2090
+ const selectedOption = hepaticStadeOptions.find((option) => option.label === renalStade);
2091
+ return selectedOption ? { value: selectedOption.value, label: selectedOption.label } : {};
2092
+ }
2093
+ getValue() {
2094
+ return { stade: this.hepaticStadeSelect?.value ?? "" };
2095
+ }
2096
+ render() {
2097
+ return b`
2098
+ <fieldset class="${PREFIX}-edition-modal-fieldset" data-test-id="hepatic-insufficiency-fieldset">
2099
+ <legend class="${PREFIX}-edition-modal-subtitle">
2100
+ <span>Insuffisance hépatique</span>
2101
+ </legend>
2102
+ <div class="${PREFIX}-edition-modal-information-section">
2103
+ <div class="${PREFIX}-edition-modal-little-section">
2104
+ <span>Stade de l'insuffisance hépatique</span>
2105
+ <bcbd-select data-test-id="hepatic-stade-select" id="hepaticStadeSelect"
2106
+ .options=${hepaticStadeOptions} .selectedOptions=${this.defaultHepaticStade} clearable>
2107
+ </bcbd-select>
2108
+ </div>
2109
+ </div>
2110
+ </fieldset>
2111
+ `;
2112
+ }
2113
+ };
2114
+ PatientHepaticForm.styles = i$5`${r$4(patientHepaticFormCSS)}`;
2115
+ __decorateClass$2([
2116
+ n2({ type: Object, attribute: "patient-profile" })
2117
+ ], PatientHepaticForm.prototype, "patientProfile", 2);
2118
+ __decorateClass$2([
2119
+ r()
2120
+ ], PatientHepaticForm.prototype, "defaultHepaticStade", 2);
2121
+ __decorateClass$2([
2122
+ e$1("#hepaticStadeSelect")
2123
+ ], PatientHepaticForm.prototype, "hepaticStadeSelect", 2);
2124
+ PatientHepaticForm = __decorateClass$2([
2125
+ t("bcb-patient-hepatic-form")
2126
+ ], PatientHepaticForm);
2127
+ const patientProfileEditionCSS = ".claudebernard-edition-modal {\n font-size: 0.9rem;\n}\n.claudebernard-edition-modal-content {\n display: flex;\n flex-direction: column;\n width: 100%;\n min-width: 60vw;\n height: 100%;\n max-height: 60vh;\n gap: 16px;\n}\n.claudebernard-edition-modal-action-buttons {\n display: flex;\n justify-content: flex-end;\n height: 100%;\n gap: 16px;\n align-items: flex-end;\n}\n.claudebernard-edition-modal-disclaimer-section {\n padding-bottom: 10px;\n}";
2128
+ var __defProp$1 = Object.defineProperty;
2129
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
2130
+ var __decorateClass$1 = (decorators, target, key, kind) => {
2131
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
2132
+ for (var i4 = decorators.length - 1, decorator; i4 >= 0; i4--)
2133
+ if (decorator = decorators[i4])
2134
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
2135
+ if (kind && result) __defProp$1(target, key, result);
2136
+ return result;
2137
+ };
2138
+ let PatientProfileEdition = class extends i$2 {
2139
+ constructor() {
2140
+ super(...arguments);
2141
+ this.apiUrl = "https://api-dev.claudebernard.fr";
2142
+ this.isPregnancyDivVisible = false;
2143
+ this.demographicsHasError = false;
2144
+ this.resetKey = 0;
2145
+ }
2146
+ open() {
2147
+ if (!this.patientProfile || Object.keys(this.patientProfile).length === 0) {
2148
+ this.patientProfile = setInitialPatientProfile();
1933
2149
  }
2150
+ this.editionModalElement.open();
1934
2151
  }
1935
- updatePathologies(event) {
1936
- const newValues = event.detail;
1937
- const newSelections = newValues.filter((value) => !this.selectedPathologyOptions.some((option) => option.value === value)).map((value) => this.pathologyOptions.find((option) => option.value === value)).filter((option) => option !== void 0);
1938
- const updatedSelections = this.selectedPathologyOptions.filter((option) => newValues.includes(option.value));
1939
- this.selectedPathologyOptions = [...updatedSelections, ...newSelections];
1940
- this.pathologyOptions = [];
2152
+ handleCancel() {
2153
+ this.resetKey++;
2154
+ this.editionModalElement.close();
1941
2155
  }
1942
- searchAllergies(event) {
1943
- if (!this.apiUrl) {
1944
- return;
2156
+ handleDemographicsChange(event) {
2157
+ this.demographicsHasError = event.detail.hasError;
2158
+ this.isPregnancyDivVisible = event.detail.isPregnancyEligible;
2159
+ if (this.renalForm) {
2160
+ this.renalForm.demographics = this.demographicsForm.getValue();
1945
2161
  }
1946
- const valueSearch = event.detail.value;
1947
- if (valueSearch.length > 2) {
1948
- fetchMoleculesByTerm(valueSearch, new SearchRequestBody({}), this.apiUrl).then((response) => {
1949
- this.allergyOptions = [];
1950
- this.allergyOptions = response.content.map((allergy) => this.apiReturntoSelectOption(allergy));
1951
- this.allergiesApiErrorMessage = "";
1952
- }).catch(() => {
1953
- this.allergiesApiErrorMessage = "Erreur lors de la récupération des allergies";
1954
- this.allergyOptions = [];
1955
- });
1956
- } else {
1957
- this.allergyOptions = [];
2162
+ if (event.detail.triggerRenalRecalculation) {
2163
+ this.renalForm?.recalculate();
1958
2164
  }
1959
2165
  }
1960
- updateAllergies(event) {
1961
- const newValues = event.detail;
1962
- const newSelections = newValues.filter((value) => !this.selectedAllergyOptions.some((option) => option.value === value)).map((value) => this.allergyOptions.find((option) => option.value === value)).filter((option) => option !== void 0);
1963
- const updatedSelections = this.selectedAllergyOptions.filter((option) => newValues.includes(option.value));
1964
- this.selectedAllergyOptions = [...updatedSelections, ...newSelections];
1965
- this.allergyOptions = [];
1966
- }
1967
2166
  // eslint-disable-next-line complexity
1968
2167
  validateForm() {
1969
2168
  if (!this.patientProfile || Object.keys(this.patientProfile).length === 0) {
1970
2169
  this.patientProfile = setInitialPatientProfile();
1971
2170
  }
1972
- const size = Number(this.sizeInput?.value ?? "");
1973
- const age = Number(this.ageInput?.value ?? "");
1974
- const ageUnit = this.ageUnitSelect?.value ?? "ans";
1975
- const weight = Number(this.weightInput?.value ?? "");
1976
- const gender = this.genderSelect?.value ?? "";
1977
- const creatinineUmol = Number(this.creatinineUmolInput?.value ?? "");
1978
- const creatinineMg = Number(this.creatinineMgLInput?.value ?? "");
1979
- const clairanceCreatinine = Number(this.clairanceCreatinineInput?.value ?? "");
1980
- const dfg = Number(this.dfgInput?.value ?? "");
1981
- const gestationalWeeks = Number(this.gestationalWeeksInput?.value ?? "");
1982
- const hepaticStade = this.hepaticStadeSelect?.value ?? "";
1983
- if (age > 0) {
1984
- setPatientAge(this.patientProfile, age, ageUnit);
2171
+ const demographics = this.demographicsForm.getValue();
2172
+ const reproductive = this.reproductiveForm.getValue();
2173
+ const pathologies = this.pathologiesForm.getValue();
2174
+ const allergies = this.allergiesForm.getValue();
2175
+ const renal = this.renalForm.getValue();
2176
+ const hepatic = this.hepaticForm.getValue();
2177
+ if (demographics.birthDate !== "") {
2178
+ setPatientAge(this.patientProfile, demographics.birthDate);
1985
2179
  }
1986
- if (!isNaN(weight) || weight > 0) {
1987
- setPatientWeight(this.patientProfile, weight);
2180
+ if (!isNaN(demographics.weight) || demographics.weight > 0) {
2181
+ setPatientWeight(this.patientProfile, demographics.weight);
1988
2182
  }
1989
- if (!isNaN(size) || size > 0) {
1990
- setPatientHeight(this.patientProfile, size);
2183
+ if (!isNaN(demographics.height) || demographics.height > 0) {
2184
+ setPatientHeight(this.patientProfile, demographics.height);
1991
2185
  }
1992
- if (gender === "male" || gender === "female" || gender === "unknown") {
1993
- setPatientGender(this.patientProfile, gender);
2186
+ if (demographics.gender === "male" || demographics.gender === "female" || demographics.gender === "unknown") {
2187
+ setPatientGender(this.patientProfile, demographics.gender);
1994
2188
  }
1995
- if (!isNaN(creatinineUmol) || creatinineUmol > 0) {
1996
- setCreatinineByUmolL(this.patientProfile, creatinineUmol);
2189
+ if (!isNaN(renal.creatinineByUmol) || renal.creatinineByUmol > 0) {
2190
+ setCreatinineByUmolL(this.patientProfile, renal.creatinineByUmol);
1997
2191
  }
1998
- if (!isNaN(creatinineMg) || creatinineMg > 0) {
1999
- setCreatinineBymgL(this.patientProfile, creatinineMg);
2192
+ if (!isNaN(renal.creatinineByMg) || renal.creatinineByMg > 0) {
2193
+ setCreatinineBymgL(this.patientProfile, renal.creatinineByMg);
2000
2194
  }
2001
- if (!isNaN(clairanceCreatinine) || clairanceCreatinine > 0) {
2002
- setPatientClearance(this.patientProfile, clairanceCreatinine);
2195
+ if (!isNaN(renal.clairanceCreatinine) || renal.clairanceCreatinine > 0) {
2196
+ setPatientClearance(this.patientProfile, renal.clairanceCreatinine);
2003
2197
  }
2004
- if (!isNaN(dfg) || dfg > 0) {
2005
- setPatientGFRByBSA(this.patientProfile, dfg);
2198
+ if (!isNaN(renal.dfg) || renal.dfg > 0) {
2199
+ setPatientGFRByBSA(this.patientProfile, renal.dfg);
2006
2200
  }
2007
- if (hepaticStade === "A" || hepaticStade === "B" || hepaticStade === "C") {
2008
- setPatientHepaticInsufficiencyStatus(this.patientProfile, hepaticStade);
2201
+ if (hepatic.stade === "A" || hepatic.stade === "B" || hepatic.stade === "C") {
2202
+ setPatientHepaticInsufficiencyStatus(this.patientProfile, hepatic.stade);
2009
2203
  } else {
2010
2204
  deletePatientHepaticInsufficiencyStatus(this.patientProfile);
2011
2205
  }
2012
- if (!this.isPregnancyDivVisible) {
2013
- this.isPregnant = false;
2014
- this.breastfeeding = false;
2015
- }
2016
- if (this.isPregnant) {
2017
- if (!isNaN(gestationalWeeks)) {
2018
- setPatientAmenorrheaStatus(this.patientProfile, gestationalWeeks);
2019
- } else {
2020
- setPatientAmenorrheaStatus(this.patientProfile, 0);
2021
- }
2206
+ if (reproductive.isPregnant) {
2207
+ setPatientAmenorrheaStatus(this.patientProfile, isNaN(reproductive.gestationalWeeks) ? 0 : reproductive.gestationalWeeks);
2022
2208
  }
2023
- setPatientBreastfeedingStatus(this.patientProfile, this.breastfeeding);
2024
- setPatientPregnancyStatus(this.patientProfile, this.isPregnant);
2025
- setPatientConditions(this.patientProfile, this.selectedPathologyOptions);
2026
- setPatientAllergies(this.patientProfile, this.selectedAllergyOptions);
2209
+ setPatientBreastfeedingStatus(this.patientProfile, reproductive.breastfeeding);
2210
+ setPatientPregnancyStatus(this.patientProfile, reproductive.isPregnant);
2211
+ setPatientConditions(this.patientProfile, pathologies);
2212
+ setPatientAllergies(this.patientProfile, allergies);
2027
2213
  const updatedProfile = {
2028
2214
  ...this.patientProfile,
2029
2215
  entry: this.patientProfile?.entry ? [...this.patientProfile.entry] : void 0
@@ -2039,105 +2225,26 @@ let PatientProfileEdition = class extends i$2 {
2039
2225
  return b`
2040
2226
  <bcbd-modal title="Édition du profil patient" persistent id="patient-profile-edition-modal" class="${PREFIX}-edition-modal" data-test-id="patient-profile-edition-modal" >
2041
2227
  ${i3(this.resetKey, b`<div class="${PREFIX}-edition-modal-content">
2042
- <div class="${PREFIX}-edition-modal-large-section">
2043
- <bcbd-select data-test-id="name-select" .selectedOptions=${{ value: "1", label: getPatientName(this.patientProfile) }} readonly></bcbd-select>
2044
- </div>
2045
- <div class="${PREFIX}-edition-modal-information-section">
2046
- ${this.isSexeDisplay ? b`
2047
- <div class="${PREFIX}-edition-modal-little-section">
2048
- <span>Sexe</span>
2049
- <bcbd-select data-test-id="sex-select" id="genderSelect" ?disabled=${this.isSexeReadOnly} placeholder="Choisir" .options=${sexOptions} .selectedOptions=${this.defaultPatientSex} ?readonly=${this.isSexeReadOnly} @change=${this.modifyGender}></bcbd-select>
2050
- </div>` : A}
2051
- ${this.isAgeDisplay ? b`
2052
- <div class="${PREFIX}-edition-modal-little-section">
2053
- <span>Age</span>
2054
- <div class="${PREFIX}-edition-modal-age-input-group">
2055
- <bcbd-input data-test-id="age-input" id="ageInput" ?disabled=${this.isAgeReadOnly} required type="number" aria-label="Age" .value=${this.patientAge} warning-msg="" ?readonly=${this.isAgeReadOnly} @change=${this.verifyAgeInput}></bcbd-input>
2056
- <bcbd-select data-test-id="age-unit-select" id="ageUnitSelect" ?disabled=${this.isAgeReadOnly} .options=${ageOptions} .selectedOptions=${this.defaultPatientUnitAge} ?readonly=${this.isAgeReadOnly} @change=${this.handleAgeUnit}></bcbd-select>
2057
- </div>
2058
- </div>` : A}
2059
- <div class="${PREFIX}-edition-modal-little-section">
2060
- <span>Taille (cm)</span>
2061
- <bcbd-input data-test-id="size-input" id="sizeInput" type="number" aria-label="Taille (cm)" .value=${getPatientHeight(this.patientProfile) ?? ""} warning-msg="" @change=${this.verifySizeInput}></bcbd-input>
2062
- </div>
2063
- <div class="${PREFIX}-edition-modal-little-section">
2064
- <span>Poids (kg)</span>
2065
- <bcbd-input data-test-id="weight-input" id="weightInput" type="number" aria-label="Poids (kg)" .value=${getPatientWeight(this.patientProfile) ?? ""} warning-msg="" @change=${this.verifyWeightInput}></bcbd-input>
2066
- </div>
2067
- <div class="${PREFIX}-edition-modal-little-section">
2068
- <span>IMC</span>
2069
- <bcbd-input data-test-id="imc-input" id="imcInput" type="number" aria-label="IMC" disabled .value=${this.imc} warning-msg=""></bcbd-input>
2070
- </div>
2071
- </div>
2072
- ${this.isPregnancyDivVisible ? b`
2073
- <div class="${PREFIX}-edition-modal-pregnant-div">
2074
- <bcbd-checkbox data-test-id="pregnancy-checkbox" id="pregnancyCheckbox" .checked=${this.isPregnant} label="Grossesse" color="primary" @change=${this.handlePregnancy}></bcbd-checkbox>
2075
- <bcbd-input data-test-id="gestational-input" id="gestationalWeeksInput" .value=${getPatientAmenorrheaStatus(this.patientProfile) ?? 0} type="number" warning-msg="" label="Nombre de semaines" placeholder=""></bcbd-input>
2076
- <bcbd-checkbox data-test-id="breastfeeding-checkbox" id="breastfeedingCheckbox" .checked=${this.breastfeeding} label="Allaitement" color="primary" @change=${this.handleBreastfeeding}></bcbd-checkbox>
2077
- </div>` : b` `}
2078
-
2079
- <div class="${PREFIX}-edition-modal-large-section">
2080
- <span>Pathologies suivies</span>
2081
- ${this.pathologiesApiErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.pathologiesApiErrorMessage}</span>` : b` `}
2082
- <bcbd-select data-test-id="pathologies-select" id="pathologiesSelect" use-input multiple aria-label="Pathologies suivies"
2083
- .selectedOptions=${this.selectedPathologyOptions} .options=${this.pathologyOptions}
2084
- @filter=${this.searchPathologies} @change=${this.updatePathologies}></bcbd-select>
2085
- </div>
2086
- <div class="${PREFIX}-edition-modal-large-section">
2087
- <span>Allergies</span>
2088
- ${this.allergiesApiErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.allergiesApiErrorMessage}</span>` : b` `}
2089
- <bcbd-select data-test-id="allergies-select" id="allergiesSelect" use-input multiple aria-label="Allergies"
2090
- .selectedOptions=${this.selectedAllergyOptions} .options=${this.allergyOptions}
2091
- @filter=${this.searchAllergies} @change=${this.updateAllergies}
2092
- ></bcbd-select>
2093
- </div>
2094
- <fieldset class="${PREFIX}-edition-modal-fieldset" data-test-id="renal-insufficiency-fieldset">
2095
- <legend class="${PREFIX}-edition-modal-subtitle">
2096
- <span>Insuffisance rénale</span>
2097
- </legend>
2098
- ${this.renalLackInformationErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.renalLackInformationErrorMessage}</span>` : b` `}
2099
- <div class="${PREFIX}-edition-modal-information-section">
2100
- <div class="${PREFIX}-edition-modal-little-section">
2101
- <span>Créatininémie (μmol/L)</span>
2102
- <bcbd-input data-test-id="creatinine-umol-input" id="creatinineUmolInput" type="number" aria-label="Créatininémie (μmol/L)" .value=${this.creatinineByUmol <= 0 ? "" : this.creatinineByUmol} warning-msg="" @change=${() => this.handleRenalConversion(1, Number(this.creatinineUmolInput?.value ?? 0))}></bcbd-input>
2103
- </div>
2104
- <div class="${PREFIX}-edition-modal-little-section">
2105
- <span>Créatininémie (mg/L)</span>
2106
- <bcbd-input data-test-id="creatinine-mgl-input" id="creatininemgLInput" type="number" aria-label="Créatininémie (mg/L)" .value=${this.creatinineByMg <= 0 ? "" : this.creatinineByMg} warning-msg="" @change=${() => this.handleRenalConversion(2, Number(this.creatinineMgLInput?.value ?? 0))}></bcbd-input>
2107
- </div>
2108
- </div>
2109
- <div class="${PREFIX}-edition-modal-information-section">
2110
- <div class="${PREFIX}-edition-modal-little-section">
2111
- <span>Clairance créatinine (ml/min)</span>
2112
- <bcbd-input data-test-id="clearance-input" id="clairanceCreatinineInput" type="number" aria-label="Clairance créatinine (ml/min)" .value=${this.clairanceCreatinine <= 0 ? "" : this.clairanceCreatinine} warning-msg="" @change=${() => this.handleRenalConversion(3, Number(this.clairanceCreatinineInput?.value ?? 0))}></bcbd-input>
2113
- </div>
2114
- <div class="${PREFIX}-edition-modal-little-section">
2115
- <span>DFG (mL/min/1.73.m2)</span>
2116
- <bcbd-input data-test-id="dfg-input" id="dfgInput" type="number" aria-label="DFG (mL/min/1.73.m2)" .value=${this.dfg <= 0 ? "" : this.dfg} warning-msg="" @change=${() => this.handleRenalConversion(4, Number(this.dfgInput?.value ?? 0))}></bcbd-input>
2117
- </div>
2118
- </div>
2119
- </fieldset>
2228
+ <bcb-patient-demographics-form .patientProfile=${this.patientProfile} .preferences=${this.preferences}
2229
+ @demographics-change=${this.handleDemographicsChange}></bcb-patient-demographics-form>
2230
+
2231
+ <bcb-patient-reproductive-form .patientProfile=${this.patientProfile} .visible=${this.isPregnancyDivVisible}></bcb-patient-reproductive-form>
2232
+
2233
+ <bcb-patient-pathologies-form .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl} .preferences=${this.preferences}></bcb-patient-pathologies-form>
2234
+
2235
+ <bcb-patient-allergies-form .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl}></bcb-patient-allergies-form>
2236
+
2237
+ <bcb-patient-renal-form .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl}></bcb-patient-renal-form>
2238
+
2239
+ <bcb-patient-hepatic-form .patientProfile=${this.patientProfile}></bcb-patient-hepatic-form>
2120
2240
 
2121
- <fieldset class="${PREFIX}-edition-modal-fieldset" data-test-id="hepatic-insufficiency-fieldset">
2122
- <legend class="${PREFIX}-edition-modal-subtitle">
2123
- <span>Insuffisance hépatique</span>
2124
- </legend>
2125
- <div class="${PREFIX}-edition-modal-information-section">
2126
- <div class="${PREFIX}-edition-modal-little-section">
2127
- <span>Stade de l'insuffisance hépatique</span>
2128
- <bcbd-select data-test-id="hepatic-stade-select" id="hepaticStadeSelect"
2129
- .options=${hepaticStadeOptions} .selectedOptions=${this.defaultHepaticStade} clearable>
2130
- </bcbd-select>
2131
- </div>
2132
- </div>
2133
- </fieldset>
2134
-
2135
2241
  <div class="${PREFIX}-edition-modal-disclaimer-section">
2136
- <b>Important :</b> La qualité des alertes générées est directement liée à l'exhaustivité des données patient renseignées. Des informations incomplètes peuvent entraîner des alertes manquantes ou peu pertinentes. Nous vous recommandons de compléter l'ensemble des champs disponibles pour une analyse pharmaceutique fiable.
2242
+ <bcbd-alert description-message="La qualité des alertes générées dépend de l'exhaustivité des données patient renseignées. Des données incomplètes peuvent entraîner des alertes manquantes ou peu pertinentes. Il est recommandé de compléter l'ensemble des champs disponibles pour garantir une analyse pharmaceutique fiable." type="info">
2243
+ </bcbd-alert>
2137
2244
  </div>
2138
2245
  </div>
2139
2246
  <div slot="actions" class="${PREFIX}-edition-modal-action-buttons" data-test-id="action-buttons">
2140
- <bcbd-button ?disabled=${this.ageErrorMessageInput !== "" || this.sizeErrorMessageInput !== "" || this.weightErrorMessageInput !== ""}
2247
+ <bcbd-button ?disabled=${this.demographicsHasError}
2141
2248
  data-test-id="save-button" background-color="primary" @click=${this.validateForm}>Valider</bcbd-button>
2142
2249
  <bcbd-button data-test-id="cancel-button" outlined background-color="primary" @click=${this.handleCancel}>Annuler</bcbd-button>
2143
2250
  </div>
@@ -2158,114 +2265,36 @@ __decorateClass$1([
2158
2265
  __decorateClass$1([
2159
2266
  n2({ type: Object })
2160
2267
  ], PatientProfileEdition.prototype, "preferences", 2);
2161
- __decorateClass$1([
2162
- r()
2163
- ], PatientProfileEdition.prototype, "patientAge", 2);
2164
- __decorateClass$1([
2165
- r()
2166
- ], PatientProfileEdition.prototype, "patientUnitAge", 2);
2167
- __decorateClass$1([
2168
- r()
2169
- ], PatientProfileEdition.prototype, "creatinineByMg", 2);
2170
- __decorateClass$1([
2171
- r()
2172
- ], PatientProfileEdition.prototype, "creatinineByUmol", 2);
2173
- __decorateClass$1([
2174
- r()
2175
- ], PatientProfileEdition.prototype, "clairanceCreatinine", 2);
2176
- __decorateClass$1([
2177
- r()
2178
- ], PatientProfileEdition.prototype, "dfg", 2);
2179
- __decorateClass$1([
2180
- r()
2181
- ], PatientProfileEdition.prototype, "defaultPatientUnitAge", 2);
2182
- __decorateClass$1([
2183
- r()
2184
- ], PatientProfileEdition.prototype, "defaultPatientSex", 2);
2185
- __decorateClass$1([
2186
- r()
2187
- ], PatientProfileEdition.prototype, "defaultHepaticStade", 2);
2188
2268
  __decorateClass$1([
2189
2269
  r()
2190
2270
  ], PatientProfileEdition.prototype, "isPregnancyDivVisible", 2);
2191
2271
  __decorateClass$1([
2192
2272
  r()
2193
- ], PatientProfileEdition.prototype, "isPregnant", 2);
2194
- __decorateClass$1([
2195
- r()
2196
- ], PatientProfileEdition.prototype, "breastfeeding", 2);
2197
- __decorateClass$1([
2198
- r()
2199
- ], PatientProfileEdition.prototype, "ageErrorMessageInput", 2);
2200
- __decorateClass$1([
2201
- r()
2202
- ], PatientProfileEdition.prototype, "sizeErrorMessageInput", 2);
2203
- __decorateClass$1([
2204
- r()
2205
- ], PatientProfileEdition.prototype, "weightErrorMessageInput", 2);
2206
- __decorateClass$1([
2207
- r()
2208
- ], PatientProfileEdition.prototype, "pathologiesApiErrorMessage", 2);
2209
- __decorateClass$1([
2210
- r()
2211
- ], PatientProfileEdition.prototype, "allergiesApiErrorMessage", 2);
2212
- __decorateClass$1([
2213
- r()
2214
- ], PatientProfileEdition.prototype, "renalLackInformationErrorMessage", 2);
2215
- __decorateClass$1([
2216
- r()
2217
- ], PatientProfileEdition.prototype, "pathologyOptions", 2);
2218
- __decorateClass$1([
2219
- r()
2220
- ], PatientProfileEdition.prototype, "allergyOptions", 2);
2221
- __decorateClass$1([
2222
- r()
2223
- ], PatientProfileEdition.prototype, "selectedPathologyOptions", 2);
2224
- __decorateClass$1([
2225
- r()
2226
- ], PatientProfileEdition.prototype, "selectedAllergyOptions", 2);
2227
- __decorateClass$1([
2228
- r()
2229
- ], PatientProfileEdition.prototype, "imc", 2);
2273
+ ], PatientProfileEdition.prototype, "demographicsHasError", 2);
2230
2274
  __decorateClass$1([
2231
2275
  r()
2232
2276
  ], PatientProfileEdition.prototype, "resetKey", 2);
2233
- __decorateClass$1([
2234
- e$1("#sizeInput")
2235
- ], PatientProfileEdition.prototype, "sizeInput", 2);
2236
- __decorateClass$1([
2237
- e$1("#ageInput")
2238
- ], PatientProfileEdition.prototype, "ageInput", 2);
2239
- __decorateClass$1([
2240
- e$1("#weightInput")
2241
- ], PatientProfileEdition.prototype, "weightInput", 2);
2242
- __decorateClass$1([
2243
- e$1("#creatinineUmolInput")
2244
- ], PatientProfileEdition.prototype, "creatinineUmolInput", 2);
2245
- __decorateClass$1([
2246
- e$1("#creatininemgLInput")
2247
- ], PatientProfileEdition.prototype, "creatinineMgLInput", 2);
2248
- __decorateClass$1([
2249
- e$1("#clairanceCreatinineInput")
2250
- ], PatientProfileEdition.prototype, "clairanceCreatinineInput", 2);
2251
2277
  __decorateClass$1([
2252
2278
  e$1("#patient-profile-edition-modal")
2253
2279
  ], PatientProfileEdition.prototype, "editionModalElement", 2);
2254
2280
  __decorateClass$1([
2255
- e$1("#dfgInput")
2256
- ], PatientProfileEdition.prototype, "dfgInput", 2);
2281
+ e$1("bcb-patient-demographics-form")
2282
+ ], PatientProfileEdition.prototype, "demographicsForm", 2);
2257
2283
  __decorateClass$1([
2258
- e$1("#genderSelect")
2259
- ], PatientProfileEdition.prototype, "genderSelect", 2);
2284
+ e$1("bcb-patient-reproductive-form")
2285
+ ], PatientProfileEdition.prototype, "reproductiveForm", 2);
2260
2286
  __decorateClass$1([
2261
- e$1("#gestationalWeeksInput")
2262
- ], PatientProfileEdition.prototype, "gestationalWeeksInput", 2);
2287
+ e$1("bcb-patient-pathologies-form")
2288
+ ], PatientProfileEdition.prototype, "pathologiesForm", 2);
2263
2289
  __decorateClass$1([
2264
- e$1("#hepaticStadeSelect")
2265
- ], PatientProfileEdition.prototype, "hepaticStadeSelect", 2);
2290
+ e$1("bcb-patient-allergies-form")
2291
+ ], PatientProfileEdition.prototype, "allergiesForm", 2);
2292
+ __decorateClass$1([
2293
+ e$1("bcb-patient-renal-form")
2294
+ ], PatientProfileEdition.prototype, "renalForm", 2);
2266
2295
  __decorateClass$1([
2267
- e$1("#ageUnitSelect")
2268
- ], PatientProfileEdition.prototype, "ageUnitSelect", 2);
2296
+ e$1("bcb-patient-hepatic-form")
2297
+ ], PatientProfileEdition.prototype, "hepaticForm", 2);
2269
2298
  PatientProfileEdition = __decorateClass$1([
2270
2299
  t("bcb-patient-profile-edition")
2271
2300
  ], PatientProfileEdition);
@@ -2286,8 +2315,8 @@ let PatientProfile = class extends i$2 {
2286
2315
  this.apiUrl = "https://api-dev.claudebernard.fr";
2287
2316
  this.preferences = {
2288
2317
  forms: {
2289
- age: { display: true, readOnly: true },
2290
- sexe: { display: true, readOnly: true }
2318
+ age: { display: true, readOnly: false },
2319
+ sexe: { display: true, readOnly: false }
2291
2320
  }
2292
2321
  };
2293
2322
  this.moreInformationVisible = false;