@claudebernard/patient-profile-element 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,6 +104,47 @@ const childPughStadeToSnomedMap = {
104
104
  "B": "710066005",
105
105
  "C": "710067001"
106
106
  };
107
+ function generateUUID() {
108
+ return crypto.randomUUID();
109
+ }
110
+ function getPatientFullUrl(bundle) {
111
+ const patientEntry = bundle.entry?.find(
112
+ (entry) => entry.resource?.resourceType === "Patient"
113
+ );
114
+ return patientEntry?.fullUrl ?? `Patient/${patientEntry?.resource?.id ?? bundle.id}`;
115
+ }
116
+ function setInitialPatientProfile() {
117
+ const compositionId = generateUUID();
118
+ return {
119
+ resourceType: "Bundle",
120
+ id: generateUUID(),
121
+ type: "document",
122
+ entry: [
123
+ {
124
+ fullUrl: `Composition/${compositionId}`,
125
+ resource: {
126
+ resourceType: "Composition",
127
+ // On a Bundle of type document, the first entry must be a Composition
128
+ id: compositionId,
129
+ status: "final",
130
+ type: {
131
+ coding: [
132
+ {
133
+ system: "http://loinc.org",
134
+ code: "34133-9",
135
+ display: "Summary of episode note"
136
+ }
137
+ ]
138
+ },
139
+ subject: [{ reference: "Patient/patient-complete" }],
140
+ date: "2025-09-02",
141
+ title: "Patient complete composition",
142
+ author: [{ reference: "Practitioner/dr-martin" }]
143
+ }
144
+ }
145
+ ]
146
+ };
147
+ }
107
148
  function getPatientGender(bundle) {
108
149
  const patient = bundle?.entry?.find(
109
150
  (entry) => entry.resource?.resourceType === "Patient"
@@ -157,11 +198,25 @@ function getPatientBirthDate(bundle) {
157
198
  return new Date(patient.birthDate);
158
199
  }
159
200
  function setPatientAge(bundle, age, ageUnit) {
160
- const patient = bundle.entry?.find(
201
+ const patientEntry = bundle.entry?.find(
161
202
  (entry) => entry.resource?.resourceType === "Patient"
162
- )?.resource;
203
+ );
204
+ let patient = patientEntry?.resource;
163
205
  if (!patient) {
164
- return;
206
+ const patientId = generateUUID();
207
+ patient = {
208
+ resourceType: "Patient",
209
+ id: patientId
210
+ };
211
+ const patientFullUrl = `Patient/${patientId}`;
212
+ bundle.entry = bundle.entry || [];
213
+ bundle.entry.push({ fullUrl: patientFullUrl, resource: patient });
214
+ const composition = bundle.entry.find(
215
+ (e2) => e2.resource?.resourceType === "Composition"
216
+ )?.resource;
217
+ if (composition && "subject" in composition) {
218
+ composition.subject = [{ reference: patientFullUrl }];
219
+ }
165
220
  }
166
221
  const today = /* @__PURE__ */ new Date();
167
222
  let birthDate;
@@ -202,9 +257,13 @@ function setPatientWeight(bundle, weight) {
202
257
  )
203
258
  )?.resource;
204
259
  if (!obs) {
260
+ if (weight === 0) {
261
+ return;
262
+ }
263
+ const obsId = generateUUID();
205
264
  obs = {
206
265
  resourceType: "Observation",
207
- id: "obs-body-weight",
266
+ id: obsId,
208
267
  status: "final",
209
268
  code: {
210
269
  coding: [
@@ -217,13 +276,17 @@ function setPatientWeight(bundle, weight) {
217
276
  text: "Poids corporel"
218
277
  },
219
278
  subject: {
220
- reference: `Patient/${bundle.id}`
279
+ reference: getPatientFullUrl(bundle)
221
280
  },
222
281
  valueQuantity: newObsWeight
223
282
  };
224
283
  bundle.entry = bundle.entry || [];
225
- bundle.entry.push({ resource: obs });
284
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
226
285
  } else {
286
+ if (weight === 0) {
287
+ bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
288
+ return;
289
+ }
227
290
  obs.valueQuantity = newObsWeight;
228
291
  }
229
292
  }
@@ -256,9 +319,13 @@ function setPatientHeight(bundle, height) {
256
319
  )
257
320
  )?.resource;
258
321
  if (!obs) {
322
+ if (height === 0) {
323
+ return;
324
+ }
325
+ const obsId = generateUUID();
259
326
  obs = {
260
327
  resourceType: "Observation",
261
- id: "obs-body-height",
328
+ id: obsId,
262
329
  status: "final",
263
330
  code: {
264
331
  coding: [
@@ -271,7 +338,7 @@ function setPatientHeight(bundle, height) {
271
338
  text: "Taille corporelle"
272
339
  },
273
340
  subject: {
274
- reference: `Patient/${bundle.id}`
341
+ reference: getPatientFullUrl(bundle)
275
342
  },
276
343
  valueQuantity: {
277
344
  value: height,
@@ -281,8 +348,12 @@ function setPatientHeight(bundle, height) {
281
348
  }
282
349
  };
283
350
  bundle.entry = bundle.entry || [];
284
- bundle.entry.push({ resource: obs });
351
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
285
352
  } else {
353
+ if (height === 0) {
354
+ bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
355
+ return;
356
+ }
286
357
  obs.valueQuantity = newObsHeight;
287
358
  }
288
359
  }
@@ -301,9 +372,10 @@ function setPatientPregnancyStatus(bundle, isPregnant) {
301
372
  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")));
302
373
  }
303
374
  } else if (isPregnant) {
375
+ const obsId = generateUUID();
304
376
  const newObsPreg = {
305
377
  resourceType: "Observation",
306
- id: "obs-pregnancy-status",
378
+ id: obsId,
307
379
  status: "final",
308
380
  code: {
309
381
  coding: [
@@ -316,7 +388,7 @@ function setPatientPregnancyStatus(bundle, isPregnant) {
316
388
  text: "Statut de grossesse"
317
389
  },
318
390
  subject: {
319
- reference: `Patient/${bundle.id}`
391
+ reference: getPatientFullUrl(bundle)
320
392
  },
321
393
  valueCodeableConcept: {
322
394
  coding: [
@@ -330,7 +402,7 @@ function setPatientPregnancyStatus(bundle, isPregnant) {
330
402
  }
331
403
  };
332
404
  bundle.entry = bundle.entry || [];
333
- bundle.entry.push({ resource: newObsPreg });
405
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: newObsPreg });
334
406
  }
335
407
  }
336
408
  function getPatientAmenorrheaStatus(bundle) {
@@ -354,9 +426,10 @@ function setPatientAmenorrheaStatus(bundle, weeks) {
354
426
  )
355
427
  )?.resource;
356
428
  if (!obs) {
429
+ const obsId = generateUUID();
357
430
  obs = {
358
431
  resourceType: "Observation",
359
- id: "obs-gestational-age",
432
+ id: obsId,
360
433
  status: "final",
361
434
  code: {
362
435
  coding: [
@@ -369,12 +442,12 @@ function setPatientAmenorrheaStatus(bundle, weeks) {
369
442
  text: "Âge gestationnel"
370
443
  },
371
444
  subject: {
372
- reference: `Patient/${bundle.id}`
445
+ reference: getPatientFullUrl(bundle)
373
446
  },
374
447
  valueQuantity: newObsAmenorrhea
375
448
  };
376
449
  bundle.entry = bundle.entry || [];
377
- bundle.entry.push({ resource: obs });
450
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
378
451
  } else {
379
452
  obs.valueQuantity = newObsAmenorrhea;
380
453
  }
@@ -401,9 +474,10 @@ function setPatientBreastfeedingStatus(bundle, isBreastfeeding) {
401
474
  )?.resource;
402
475
  if (isBreastfeeding) {
403
476
  if (!obsBf && !condBf) {
477
+ const obsId = generateUUID();
404
478
  const newObsBf = {
405
479
  resourceType: "Observation",
406
- id: "obs-breastfeeding-status",
480
+ id: obsId,
407
481
  status: "final",
408
482
  code: {
409
483
  coding: [
@@ -416,7 +490,7 @@ function setPatientBreastfeedingStatus(bundle, isBreastfeeding) {
416
490
  text: "Statut d'allaitement"
417
491
  },
418
492
  subject: {
419
- reference: `Patient/${bundle.id}`
493
+ reference: getPatientFullUrl(bundle)
420
494
  },
421
495
  valueCodeableConcept: {
422
496
  coding: [
@@ -430,7 +504,7 @@ function setPatientBreastfeedingStatus(bundle, isBreastfeeding) {
430
504
  }
431
505
  };
432
506
  bundle.entry = bundle.entry || [];
433
- bundle.entry.push({ resource: newObsBf });
507
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: newObsBf });
434
508
  }
435
509
  } else {
436
510
  if (obsBf) {
@@ -479,9 +553,13 @@ function setPatientClearance(bundle, clearance) {
479
553
  )
480
554
  )?.resource;
481
555
  if (!obs) {
556
+ if (clearance === 0) {
557
+ return;
558
+ }
559
+ const obsId = generateUUID();
482
560
  obs = {
483
561
  resourceType: "Observation",
484
- id: "obs-creatinine-clearance",
562
+ id: obsId,
485
563
  status: "final",
486
564
  code: {
487
565
  coding: [
@@ -494,13 +572,17 @@ function setPatientClearance(bundle, clearance) {
494
572
  text: "Clairance de la créatinine"
495
573
  },
496
574
  subject: {
497
- reference: `Patient/${bundle.id}`
575
+ reference: getPatientFullUrl(bundle)
498
576
  },
499
577
  valueQuantity: newObsClearance
500
578
  };
501
579
  bundle.entry = bundle.entry || [];
502
- bundle.entry.push({ resource: obs });
580
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
503
581
  } else {
582
+ if (clearance === 0) {
583
+ bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
584
+ return;
585
+ }
504
586
  obs.valueQuantity = newObsClearance;
505
587
  }
506
588
  }
@@ -517,9 +599,13 @@ function setPatientGFRByBSA(bundle, gfr) {
517
599
  )
518
600
  )?.resource;
519
601
  if (!obs) {
602
+ if (gfr === 0) {
603
+ return;
604
+ }
605
+ const obsId = generateUUID();
520
606
  obs = {
521
607
  resourceType: "Observation",
522
- id: "obs-gfr-bsa",
608
+ id: obsId,
523
609
  status: "final",
524
610
  code: {
525
611
  coding: [
@@ -532,13 +618,17 @@ function setPatientGFRByBSA(bundle, gfr) {
532
618
  text: "DFG"
533
619
  },
534
620
  subject: {
535
- reference: `Patient/${bundle.id}`
621
+ reference: getPatientFullUrl(bundle)
536
622
  },
537
623
  valueQuantity: newObsGFR
538
624
  };
539
625
  bundle.entry = bundle.entry || [];
540
- bundle.entry.push({ resource: obs });
626
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
541
627
  } else {
628
+ if (gfr === 0) {
629
+ bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
630
+ return;
631
+ }
542
632
  obs.valueQuantity = newObsGFR;
543
633
  }
544
634
  }
@@ -640,9 +730,13 @@ function setCreatinineBymgL(bundle, mgL) {
640
730
  )
641
731
  )?.resource;
642
732
  if (!obs) {
733
+ if (mgL === 0) {
734
+ return;
735
+ }
736
+ const obsId = generateUUID();
643
737
  obs = {
644
738
  resourceType: "Observation",
645
- id: "obs-creatinine",
739
+ id: obsId,
646
740
  status: "final",
647
741
  code: {
648
742
  coding: [
@@ -655,13 +749,17 @@ function setCreatinineBymgL(bundle, mgL) {
655
749
  text: "Créatininémie"
656
750
  },
657
751
  subject: {
658
- reference: `Patient/${bundle.id}`
752
+ reference: getPatientFullUrl(bundle)
659
753
  },
660
754
  valueQuantity: newObsCreatinine
661
755
  };
662
756
  bundle.entry = bundle.entry || [];
663
- bundle.entry.push({ resource: obs });
757
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
664
758
  } else {
759
+ if (mgL === 0) {
760
+ bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
761
+ return;
762
+ }
665
763
  obs.valueQuantity = newObsCreatinine;
666
764
  }
667
765
  }
@@ -678,9 +776,13 @@ function setCreatinineByUmolL(bundle, umolL) {
678
776
  )
679
777
  )?.resource;
680
778
  if (!obs) {
779
+ if (umolL === 0) {
780
+ return;
781
+ }
782
+ const obsId = generateUUID();
681
783
  obs = {
682
784
  resourceType: "Observation",
683
- id: "obs-creatinine",
785
+ id: obsId,
684
786
  status: "final",
685
787
  code: {
686
788
  coding: [
@@ -693,13 +795,17 @@ function setCreatinineByUmolL(bundle, umolL) {
693
795
  text: "Créatininémie"
694
796
  },
695
797
  subject: {
696
- reference: `Patient/${bundle.id}`
798
+ reference: getPatientFullUrl(bundle)
697
799
  },
698
800
  valueQuantity: newObsCreatinine
699
801
  };
700
802
  bundle.entry = bundle.entry || [];
701
- bundle.entry.push({ resource: obs });
803
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
702
804
  } else {
805
+ if (umolL === 0) {
806
+ bundle.entry = bundle.entry?.filter((entry) => entry.resource?.id !== obs?.id);
807
+ return;
808
+ }
703
809
  obs.valueQuantity = newObsCreatinine;
704
810
  }
705
811
  }
@@ -768,9 +874,10 @@ function setPatientHepaticInsufficiencyStatus(bundle, stade, score) {
768
874
  text: `Stade ${stade}`
769
875
  };
770
876
  if (!obs) {
877
+ const obsId = generateUUID();
771
878
  obs = {
772
879
  resourceType: "Observation",
773
- id: "obs-child-pugh",
880
+ id: obsId,
774
881
  status: "final",
775
882
  code: {
776
883
  coding: [
@@ -783,12 +890,12 @@ function setPatientHepaticInsufficiencyStatus(bundle, stade, score) {
783
890
  text: "Score de Child-Pugh"
784
891
  },
785
892
  subject: {
786
- reference: `Patient/${bundle.id}`
893
+ reference: getPatientFullUrl(bundle)
787
894
  },
788
895
  valueCodeableConcept: stadeConcept
789
896
  };
790
897
  bundle.entry = bundle.entry || [];
791
- bundle.entry.push({ resource: obs });
898
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
792
899
  } else {
793
900
  obs.valueCodeableConcept = stadeConcept;
794
901
  if (!score) {
@@ -830,9 +937,10 @@ function setPatientHepaticInsufficiencyStatus(bundle, stade, score) {
830
937
  text: `Stade ${stadeLetter}`
831
938
  } : void 0;
832
939
  if (!obs) {
940
+ const obsId = generateUUID();
833
941
  obs = {
834
942
  resourceType: "Observation",
835
- id: "obs-child-pugh",
943
+ id: obsId,
836
944
  status: "final",
837
945
  code: {
838
946
  coding: [
@@ -845,13 +953,13 @@ function setPatientHepaticInsufficiencyStatus(bundle, stade, score) {
845
953
  text: "Score de Child-Pugh"
846
954
  },
847
955
  subject: {
848
- reference: `Patient/${bundle.id}`
956
+ reference: getPatientFullUrl(bundle)
849
957
  },
850
958
  valueQuantity: newObsValueQuantity,
851
959
  ...stadeConcept ? { valueCodeableConcept: stadeConcept } : {}
852
960
  };
853
961
  bundle.entry = bundle.entry || [];
854
- bundle.entry.push({ resource: obs });
962
+ bundle.entry.push({ fullUrl: `Observation/${obsId}`, resource: obs });
855
963
  } else {
856
964
  obs.valueQuantity = newObsValueQuantity;
857
965
  if (stadeConcept) {
@@ -914,9 +1022,10 @@ function getPatientConditionsWithCode(patient) {
914
1022
  function setPatientConditions(patient, conditions) {
915
1023
  patient.entry = patient.entry?.filter((entry) => entry.resource?.resourceType !== "Condition");
916
1024
  for (const condition of conditions) {
1025
+ const condId = generateUUID();
917
1026
  const newCondition = {
918
1027
  resourceType: "Condition",
919
- id: `cond-${condition.value}-patient-${patient.id}`,
1028
+ id: condId,
920
1029
  clinicalStatus: {
921
1030
  coding: [
922
1031
  {
@@ -936,11 +1045,11 @@ function setPatientConditions(patient, conditions) {
936
1045
  text: condition.label
937
1046
  },
938
1047
  subject: {
939
- reference: `Patient/${patient.id}`
1048
+ reference: getPatientFullUrl(patient)
940
1049
  }
941
1050
  };
942
1051
  patient.entry = patient.entry || [];
943
- patient.entry.push({ resource: newCondition });
1052
+ patient.entry.push({ fullUrl: `Condition/${condId}`, resource: newCondition });
944
1053
  }
945
1054
  }
946
1055
  function getPatientAllergies(patient) {
@@ -980,9 +1089,10 @@ function getPatientAllergiesWithCode(patient) {
980
1089
  function setPatientAllergies(patient, allergies) {
981
1090
  patient.entry = patient.entry?.filter((entry) => entry.resource?.resourceType !== "AllergyIntolerance");
982
1091
  for (const allergy of allergies) {
1092
+ const allergyId = generateUUID();
983
1093
  const newAllergy = {
984
1094
  resourceType: "AllergyIntolerance",
985
- id: `allergy-${allergy.value}-patient-${patient.id}`,
1095
+ id: allergyId,
986
1096
  clinicalStatus: {
987
1097
  coding: [
988
1098
  {
@@ -1002,11 +1112,11 @@ function setPatientAllergies(patient, allergies) {
1002
1112
  text: allergy.label
1003
1113
  },
1004
1114
  patient: {
1005
- reference: `Patient/${patient.id}`
1115
+ reference: getPatientFullUrl(patient)
1006
1116
  }
1007
1117
  };
1008
1118
  patient.entry = patient.entry || [];
1009
- patient.entry.push({ resource: newAllergy });
1119
+ patient.entry.push({ fullUrl: `AllergyIntolerance/${allergyId}`, resource: newAllergy });
1010
1120
  }
1011
1121
  }
1012
1122
  function childPughScore(score) {
@@ -1571,7 +1681,7 @@ function e(e2, r2) {
1571
1681
  } });
1572
1682
  };
1573
1683
  }
1574
- 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}\n@container (max-width: 600px) {\n .claudebernard-patient-profile {\n font-size: 0.8rem;\n }\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-direction: column;\n gap: 1rem;\n align-items: 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.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}\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.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}\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.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}';
1684
+ 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}\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-direction: column;\n gap: 1rem;\n align-items: 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.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}\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.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}\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.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}';
1575
1685
  const sexOptions = [
1576
1686
  { value: "male", label: "Masculin" },
1577
1687
  { value: "female", label: "Féminin" },
@@ -1606,7 +1716,7 @@ const fetchMoleculesByTerm = async (term, params, apiUrl) => {
1606
1716
  });
1607
1717
  return response.json();
1608
1718
  };
1609
- 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 padding-top: 10px;\n padding-bottom: 30px;\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);\n}\n.claudebernard-edition-modal-error-message {\n color: var(--bcbd-danger-color);\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);\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}";
1719
+ 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 padding-top: 10px;\n padding-bottom: 30px;\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}";
1610
1720
  var __defProp$1 = Object.defineProperty;
1611
1721
  var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
1612
1722
  var __decorateClass$1 = (decorators, target, key, kind) => {
@@ -1639,6 +1749,8 @@ let PatientProfileEdition = class extends i {
1639
1749
  this.weightErrorMessageInput = "";
1640
1750
  this.pathologiesApiErrorMessage = "";
1641
1751
  this.allergiesApiErrorMessage = "";
1752
+ this.renalLackInformationErrorMessage = "";
1753
+ this.childPughErrorMessage = "";
1642
1754
  this.pathologyOptions = [];
1643
1755
  this.allergyOptions = [];
1644
1756
  this.selectedPathologyOptions = [];
@@ -1655,8 +1767,12 @@ let PatientProfileEdition = class extends i {
1655
1767
  const age = Number(this.ageInput?.value ?? 0);
1656
1768
  this.isPregnancyDivVisible = this.patientUnitAge === "ans" && (age >= 12 && age <= 55);
1657
1769
  }
1770
+ this.recalculateRenalValues();
1658
1771
  }
1659
- firstUpdated() {
1772
+ updated(changedProperties) {
1773
+ if (!changedProperties.has("patientProfile")) {
1774
+ return;
1775
+ }
1660
1776
  this.imc = calculateBMI(getPatientWeight(this.patientProfile) ?? 0, getPatientHeight(this.patientProfile) ?? 0);
1661
1777
  this.defaultPatientSex = this.getPatientSexFromProfile();
1662
1778
  this.defaultHepaticStade = this.getPatientHepaticStadeFromProfile();
@@ -1683,6 +1799,13 @@ let PatientProfileEdition = class extends i {
1683
1799
  value: this.patientUnitAge,
1684
1800
  label: ageOptions.find((option) => option.value === this.patientUnitAge)?.label
1685
1801
  };
1802
+ } else {
1803
+ this.ageErrorMessageInput = "L'âge est requis";
1804
+ this.ageInput.setAttribute("warning-msg", this.ageErrorMessageInput);
1805
+ this.defaultPatientUnitAge = {
1806
+ value: "ans",
1807
+ label: ageOptions.find((option) => option.value === "ans")?.label
1808
+ };
1686
1809
  }
1687
1810
  const creatinine = getCreatinine(this.patientProfile);
1688
1811
  const renalStatus = getPatientRenalInsufficiencyStatus(this.patientProfile);
@@ -1708,12 +1831,13 @@ let PatientProfileEdition = class extends i {
1708
1831
  }
1709
1832
  this.ageInput.setAttribute("warning-msg", this.ageErrorMessageInput);
1710
1833
  if (this.patientUnitAge === "ans" && (age >= 12 && age <= 55)) {
1711
- if (this.genderSelect?.value !== "male") {
1834
+ if (this.genderSelect?.value && this.genderSelect?.value !== "male") {
1712
1835
  this.isPregnancyDivVisible = true;
1713
1836
  }
1714
1837
  } else {
1715
1838
  this.isPregnancyDivVisible = false;
1716
1839
  }
1840
+ this.recalculateRenalValues();
1717
1841
  }
1718
1842
  handleAgeUnit() {
1719
1843
  this.patientUnitAge = this.ageUnitSelect?.value ?? "ans";
@@ -1722,7 +1846,7 @@ let PatientProfileEdition = class extends i {
1722
1846
  verifySizeInput() {
1723
1847
  const size = Number(this.sizeInput?.value ?? 0);
1724
1848
  if (size < 1 || size > 399) {
1725
- this.sizeErrorMessageInput = "La taille n'est pas valide";
1849
+ this.sizeErrorMessageInput = "La taille n'est pas valide (entre 1 et 399)";
1726
1850
  } else {
1727
1851
  this.sizeErrorMessageInput = "";
1728
1852
  }
@@ -1731,13 +1855,14 @@ let PatientProfileEdition = class extends i {
1731
1855
  }
1732
1856
  verifyWeightInput() {
1733
1857
  const weight = Number(this.weightInput?.value ?? 0);
1734
- if (weight > 300) {
1735
- this.weightErrorMessageInput = "Le poids ne doit pas dépasser 300kg";
1858
+ if (weight < 1 || weight > 300) {
1859
+ this.weightErrorMessageInput = "Le poids n'est pas valide (entre 1 et 300)";
1736
1860
  } else {
1737
1861
  this.weightErrorMessageInput = "";
1738
1862
  }
1739
1863
  this.weightInput.setAttribute("warning-msg", this.weightErrorMessageInput);
1740
1864
  this.imc = calculateBMI(weight, Number(this.sizeInput?.value ?? 0));
1865
+ this.recalculateRenalValues();
1741
1866
  }
1742
1867
  getPatientSexFromProfile() {
1743
1868
  let gender = getPatientGender(this.patientProfile);
@@ -1749,7 +1874,7 @@ let PatientProfileEdition = class extends i {
1749
1874
  gender = "female";
1750
1875
  break;
1751
1876
  }
1752
- this.isPregnancyDivVisible = gender !== "Homme";
1877
+ this.isPregnancyDivVisible = !!(gender && gender !== "Homme");
1753
1878
  const selectedOption = sexOptions.find((option) => option.value === gender);
1754
1879
  return selectedOption ? { value: selectedOption.value, label: selectedOption.label } : {};
1755
1880
  }
@@ -1764,9 +1889,25 @@ let PatientProfileEdition = class extends i {
1764
1889
  handleBreastfeeding(event) {
1765
1890
  this.breastfeeding = event.detail;
1766
1891
  }
1892
+ recalculateRenalValues() {
1893
+ const creatinineUmol = Number(this.creatinineUmolInput?.value ?? "");
1894
+ const creatinineMg = Number(this.creatinineMgLInput?.value ?? "");
1895
+ const clairance = Number(this.clairanceCreatinineInput?.value ?? "");
1896
+ const dfg = Number(this.dfgInput?.value ?? "");
1897
+ if (!isNaN(creatinineUmol) && creatinineUmol > 0) {
1898
+ this.setFormWithCreatinineUmol();
1899
+ } else if (!isNaN(creatinineMg) && creatinineMg > 0) {
1900
+ this.setFormWithCreatinineMgL();
1901
+ } else if (!isNaN(clairance) && clairance > 0) {
1902
+ this.setFormWithClairance();
1903
+ } else if (!isNaN(dfg) && dfg > 0) {
1904
+ this.setFormWithDFG();
1905
+ }
1906
+ }
1767
1907
  setFormWithCreatinineUmol() {
1768
1908
  const inputValue = Number(this.creatinineUmolInput?.value ?? "");
1769
1909
  if (isNaN(inputValue) || inputValue <= 0) {
1910
+ this.renalLackInformationErrorMessage = "";
1770
1911
  return;
1771
1912
  }
1772
1913
  this.creatinineByUmol = inputValue;
@@ -1774,24 +1915,27 @@ let PatientProfileEdition = class extends i {
1774
1915
  if (scrMgdl <= 0) {
1775
1916
  return;
1776
1917
  }
1777
- const age = getPatientAge(this.patientProfile);
1778
- const weight = getPatientWeight(this.patientProfile);
1779
- const gender = getPatientGender(this.patientProfile);
1780
- const isFemale = gender === "Femme";
1918
+ const age = Number(this.ageInput?.value);
1919
+ const weight = Number(this.weightInput?.value);
1920
+ const gender = this.genderSelect?.value;
1781
1921
  if (!age || !weight || !gender) {
1782
1922
  this.clairanceCreatinine = 0;
1783
1923
  this.creatinineByMg = 0;
1924
+ this.renalLackInformationErrorMessage = "Pour faire les calculs à partir des données de l'insuffisance rénale, il faut que l'âge, le poids et le sexe soient renseignés. Les informations contenues dans cette partie ne seront pas pris en compte.";
1784
1925
  return;
1785
1926
  }
1927
+ const isFemale = gender === "Femme";
1786
1928
  const clearance = calculateCreatinineClearance(age, weight, scrMgdl, isFemale);
1787
1929
  this.clairanceCreatinine = Math.round(clearance);
1788
1930
  const scrMgl = convertCreatinineMgdLToMgL(scrMgdl);
1789
1931
  this.creatinineByMg = Math.round(scrMgl);
1790
1932
  this.dfg = Math.round(calculateGFRFromCreatinine(age, isFemale, inputValue));
1933
+ this.renalLackInformationErrorMessage = "";
1791
1934
  }
1792
1935
  setFormWithCreatinineMgL() {
1793
1936
  const inputValue = Number(this.creatinineMgLInput?.value ?? "");
1794
1937
  if (isNaN(inputValue) || inputValue <= 0) {
1938
+ this.renalLackInformationErrorMessage = "";
1795
1939
  return;
1796
1940
  }
1797
1941
  this.creatinineByMg = inputValue;
@@ -1799,13 +1943,14 @@ let PatientProfileEdition = class extends i {
1799
1943
  if (scrMgdl <= 0) {
1800
1944
  return;
1801
1945
  }
1802
- const age = getPatientAge(this.patientProfile);
1803
- const weight = getPatientWeight(this.patientProfile);
1804
- const gender = getPatientGender(this.patientProfile);
1946
+ const age = Number(this.ageInput?.value);
1947
+ const weight = Number(this.weightInput?.value);
1948
+ const gender = this.genderSelect?.value;
1805
1949
  const isFemale = gender === "Femme";
1806
1950
  if (!age || !weight || !gender) {
1807
1951
  this.clairanceCreatinine = 0;
1808
1952
  this.creatinineByUmol = 0;
1953
+ this.renalLackInformationErrorMessage = "Pour faire les calculs à partir des données de l'insuffisance rénale, il faut que l'âge, le poids et le sexe soient renseignés. Les informations contenues dans cette partie ne seront pas pris en compte.";
1809
1954
  return;
1810
1955
  }
1811
1956
  const clearance = calculateCreatinineClearance(age, weight, scrMgdl, isFemale);
@@ -1813,19 +1958,22 @@ let PatientProfileEdition = class extends i {
1813
1958
  const scrUmolL = convertCreatinineMgdLToUmol(scrMgdl);
1814
1959
  this.creatinineByUmol = Math.round(scrUmolL);
1815
1960
  this.dfg = Math.round(calculateGFRFromCreatinine(age, isFemale, scrUmolL));
1961
+ this.renalLackInformationErrorMessage = "";
1816
1962
  }
1817
1963
  setFormWithClairance() {
1818
1964
  const inputValue = Number(this.clairanceCreatinineInput?.value ?? "");
1819
1965
  if (isNaN(inputValue) || inputValue <= 0) {
1966
+ this.renalLackInformationErrorMessage = "";
1820
1967
  return;
1821
1968
  }
1822
1969
  this.clairanceCreatinine = inputValue;
1823
- const age = getPatientAge(this.patientProfile);
1824
- const weight = getPatientWeight(this.patientProfile);
1825
- const gender = getPatientGender(this.patientProfile);
1970
+ const age = Number(this.ageInput?.value);
1971
+ const weight = Number(this.weightInput?.value);
1972
+ const gender = this.genderSelect?.value;
1826
1973
  if (!age || !weight || !gender) {
1827
1974
  this.creatinineByMg = 0;
1828
1975
  this.creatinineByUmol = 0;
1976
+ this.renalLackInformationErrorMessage = "Pour faire les calculs à partir des données de l'insuffisance rénale, il faut que l'âge, le poids et le sexe soient renseignés. Les informations contenues dans cette partie ne seront pas pris en compte.";
1829
1977
  return;
1830
1978
  }
1831
1979
  const isFemale = gender === "Femme";
@@ -1837,16 +1985,24 @@ let PatientProfileEdition = class extends i {
1837
1985
  this.creatinineByUmol = creatinineByUmol?.value ?? 0;
1838
1986
  this.creatinineByUmol = Math.round(this.creatinineByUmol);
1839
1987
  this.dfg = Math.round(calculateGFRFromCreatinine(age, isFemale, creatinineByUmol?.value ?? 0));
1988
+ this.renalLackInformationErrorMessage = "";
1840
1989
  }
1841
1990
  setFormWithDFG() {
1842
1991
  const inputValue = Number(this.dfgInput?.value ?? "");
1843
1992
  if (isNaN(inputValue) || inputValue <= 0) {
1993
+ this.renalLackInformationErrorMessage = "";
1844
1994
  return;
1845
1995
  }
1846
1996
  this.dfg = inputValue;
1847
- const age = getPatientAge(this.patientProfile) ?? 0;
1848
- const weight = getPatientWeight(this.patientProfile) ?? 0;
1849
- const gender = getPatientGender(this.patientProfile);
1997
+ const age = Number(this.ageInput?.value);
1998
+ const weight = Number(this.weightInput?.value);
1999
+ const gender = this.genderSelect?.value;
2000
+ if (!age || !weight || !gender) {
2001
+ this.creatinineByMg = 0;
2002
+ this.creatinineByUmol = 0;
2003
+ this.renalLackInformationErrorMessage = "Pour faire les calculs à partir des données de l'insuffisance rénale, il faut que l'âge, le poids et le sexe soient renseignés. Les informations contenues dans cette partie ne seront pas pris en compte.";
2004
+ return;
2005
+ }
1850
2006
  const isFemale = gender === "Femme";
1851
2007
  const creatinine = calculateCreatinineFromGFR(age, isFemale, this.dfg);
1852
2008
  this.creatinineByUmol = Math.round(creatinine);
@@ -1854,6 +2010,7 @@ let PatientProfileEdition = class extends i {
1854
2010
  this.creatinineByMg = Math.round(convertCreatinineMgdLToMgL(scrMgdl));
1855
2011
  const clearance = calculateCreatinineClearance(age, weight, scrMgdl, isFemale);
1856
2012
  this.clairanceCreatinine = Math.round(clearance);
2013
+ this.renalLackInformationErrorMessage = "";
1857
2014
  }
1858
2015
  apiReturntoSelectOption(pathology) {
1859
2016
  return {
@@ -1920,7 +2077,13 @@ let PatientProfileEdition = class extends i {
1920
2077
  const childPughInputScore = Number(this.childPughInput?.value ?? "");
1921
2078
  if (isNaN(childPughInputScore) || childPughInputScore <= 0) {
1922
2079
  this.defaultHepaticStade = {};
2080
+ this.childPughErrorMessage = "";
1923
2081
  } else {
2082
+ if (childPughInputScore < 5 || childPughInputScore > 15) {
2083
+ this.childPughErrorMessage = "Le score Child-Pugh doit être compris entre 5 et 15";
2084
+ } else {
2085
+ this.childPughErrorMessage = "";
2086
+ }
1924
2087
  const stade = childPughScore(childPughInputScore);
1925
2088
  const selectedOption = hepaticStadeOptions.find((option) => option.label === stade);
1926
2089
  if (selectedOption) {
@@ -1930,8 +2093,8 @@ let PatientProfileEdition = class extends i {
1930
2093
  }
1931
2094
  // eslint-disable-next-line complexity
1932
2095
  validateForm() {
1933
- if (!this.patientProfile) {
1934
- return;
2096
+ if (!this.patientProfile || Object.keys(this.patientProfile).length === 0) {
2097
+ this.patientProfile = setInitialPatientProfile();
1935
2098
  }
1936
2099
  const size = Number(this.sizeInput?.value ?? "");
1937
2100
  const age = Number(this.ageInput?.value ?? "");
@@ -1945,7 +2108,7 @@ let PatientProfileEdition = class extends i {
1945
2108
  const gestationalWeeks = Number(this.gestationalWeeksInput?.value ?? "");
1946
2109
  const hepaticStade = this.hepaticStadeSelect?.value ?? "";
1947
2110
  const childPughScore2 = Number(this.childPughInput?.value ?? "");
1948
- if (!isNaN(age) || age > 0) {
2111
+ if (age > 0) {
1949
2112
  setPatientAge(this.patientProfile, age, ageUnit);
1950
2113
  }
1951
2114
  if (!isNaN(weight) || weight > 0) {
@@ -1978,10 +2141,12 @@ let PatientProfileEdition = class extends i {
1978
2141
  this.isPregnant = false;
1979
2142
  this.breastfeeding = false;
1980
2143
  }
1981
- if (!this.isPregnant) {
1982
- setPatientAmenorrheaStatus(this.patientProfile, 0);
1983
- } else if (!isNaN(gestationalWeeks)) {
1984
- setPatientAmenorrheaStatus(this.patientProfile, gestationalWeeks);
2144
+ if (this.isPregnant) {
2145
+ if (!isNaN(gestationalWeeks)) {
2146
+ setPatientAmenorrheaStatus(this.patientProfile, gestationalWeeks);
2147
+ } else {
2148
+ setPatientAmenorrheaStatus(this.patientProfile, 0);
2149
+ }
1985
2150
  }
1986
2151
  setPatientBreastfeedingStatus(this.patientProfile, this.breastfeeding);
1987
2152
  setPatientPregnancyStatus(this.patientProfile, this.isPregnant);
@@ -2013,41 +2178,41 @@ let PatientProfileEdition = class extends i {
2013
2178
  <div class="${PREFIX}-edition-modal-little-section">
2014
2179
  <span>Age</span>
2015
2180
  <div class="${PREFIX}-edition-modal-age-input-group">
2016
- <bcbd-input data-test-id="age-input" id="ageInput" type="number" .value=${this.patientAge} warning-msg="" @input=${this.verifyAgeInput}></bcbd-input>
2181
+ <bcbd-input data-test-id="age-input" id="ageInput" required type="number" aria-label="Age" .value=${this.patientAge} warning-msg="" @change=${this.verifyAgeInput}></bcbd-input>
2017
2182
  <bcbd-select data-test-id="age-unit-select" id="ageUnitSelect" .options=${ageOptions} .selectedOptions=${this.defaultPatientUnitAge} @change=${this.handleAgeUnit}></bcbd-select>
2018
2183
  </div>
2019
2184
  </div>
2020
2185
  <div class="${PREFIX}-edition-modal-little-section">
2021
2186
  <span>Taille (cm)</span>
2022
- <bcbd-input data-test-id="size-input" id="sizeInput" type="number" .value=${getPatientHeight(this.patientProfile) ?? ""} warning-msg="" @input=${this.verifySizeInput}></bcbd-input>
2187
+ <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>
2023
2188
  </div>
2024
2189
  <div class="${PREFIX}-edition-modal-little-section">
2025
2190
  <span>Poids (kg)</span>
2026
- <bcbd-input data-test-id="weight-input" id="weightInput" type="number" .value=${getPatientWeight(this.patientProfile) ?? ""} warning-msg="" @input=${this.verifyWeightInput}></bcbd-input>
2191
+ <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>
2027
2192
  </div>
2028
2193
  <div class="${PREFIX}-edition-modal-little-section">
2029
2194
  <span>IMC</span>
2030
- <bcbd-input data-test-id="weight-input" id="weightInput" type="number" disabled .value=${this.imc} warning-msg=""></bcbd-input>
2195
+ <bcbd-input data-test-id="imc-input" id="imcInput" type="number" aria-label="IMC" disabled .value=${this.imc} warning-msg=""></bcbd-input>
2031
2196
  </div>
2032
2197
  </div>
2033
2198
  ${this.isPregnancyDivVisible ? b`
2034
2199
  <div class="${PREFIX}-edition-modal-pregnant-div">
2035
2200
  <bcbd-checkbox data-test-id="pregnancy-checkbox" id="pregnancyCheckbox" .checked=${this.isPregnant} label="Grossesse" color="primary" @change=${this.handlePregnancy}></bcbd-checkbox>
2036
- <bcbd-input data-test-id="gestational-input" id="gestationalWeeksInput" .value=${getPatientAmenorrheaStatus(this.patientProfile)} type="number" warning-msg="" label="Nombre de semaines" placeholder=""></bcbd-input>
2201
+ <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>
2037
2202
  <bcbd-checkbox data-test-id="breastfeeding-checkbox" id="breastfeedingCheckbox" .checked=${this.breastfeeding} label="Allaitement" color="primary" @change=${this.handleBreastfeeding}></bcbd-checkbox>
2038
2203
  </div>` : b` `}
2039
2204
 
2040
2205
  <div class="${PREFIX}-edition-modal-large-section">
2041
2206
  <span>Pathologies suivies</span>
2042
2207
  ${this.pathologiesApiErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.pathologiesApiErrorMessage}</span>` : b` `}
2043
- <bcbd-select data-test-id="pathologies-select" id="pathologiesSelect" use-input multiple
2208
+ <bcbd-select data-test-id="pathologies-select" id="pathologiesSelect" use-input multiple aria-label="Pathologies suivies"
2044
2209
  .selectedOptions=${this.selectedPathologyOptions} .options=${this.pathologyOptions}
2045
2210
  @filter=${this.searchPathologies} @change=${this.updatePathologies}></bcbd-select>
2046
2211
  </div>
2047
2212
  <div class="${PREFIX}-edition-modal-large-section">
2048
2213
  <span>Allergies</span>
2049
2214
  ${this.allergiesApiErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.allergiesApiErrorMessage}</span>` : b` `}
2050
- <bcbd-select data-test-id="allergies-select" id="allergiesSelect" use-input multiple
2215
+ <bcbd-select data-test-id="allergies-select" id="allergiesSelect" use-input multiple aria-label="Allergies"
2051
2216
  .selectedOptions=${this.selectedAllergyOptions} .options=${this.allergyOptions}
2052
2217
  @filter=${this.searchAllergies} @change=${this.updateAllergies}
2053
2218
  ></bcbd-select>
@@ -2056,24 +2221,25 @@ let PatientProfileEdition = class extends i {
2056
2221
  <legend class="${PREFIX}-edition-modal-subtitle">
2057
2222
  <span>Insuffisance rénale</span>
2058
2223
  </legend>
2224
+ ${this.renalLackInformationErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.renalLackInformationErrorMessage}</span>` : b` `}
2059
2225
  <div class="${PREFIX}-edition-modal-information-section">
2060
2226
  <div class="${PREFIX}-edition-modal-little-section">
2061
2227
  <span>Créatininémie (μmol/L)</span>
2062
- <bcbd-input data-test-id="creatinine-umol-input" id="creatinineUmolInput" type="number" .value=${this.creatinineByUmol <= 0 ? "" : this.creatinineByUmol} warning-msg="" @input=${this.setFormWithCreatinineUmol}></bcbd-input>
2228
+ <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.setFormWithCreatinineUmol}></bcbd-input>
2063
2229
  </div>
2064
2230
  <div class="${PREFIX}-edition-modal-little-section">
2065
2231
  <span>Créatininémie (mg/L)</span>
2066
- <bcbd-input data-test-id="creatinine-mgl-input" id="creatininemgLInput" type="number" .value=${this.creatinineByMg <= 0 ? "" : this.creatinineByMg} warning-msg="" @input=${this.setFormWithCreatinineMgL}></bcbd-input>
2232
+ <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.setFormWithCreatinineMgL}></bcbd-input>
2067
2233
  </div>
2068
2234
  </div>
2069
2235
  <div class="${PREFIX}-edition-modal-information-section">
2070
2236
  <div class="${PREFIX}-edition-modal-little-section">
2071
2237
  <span>Clairance créatinine (ml/min)</span>
2072
- <bcbd-input data-test-id="clearance-input" id="clairanceCreatinineInput" type="number" .value=${this.clairanceCreatinine <= 0 ? "" : this.clairanceCreatinine} warning-msg="" @input=${this.setFormWithClairance}></bcbd-input>
2238
+ <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.setFormWithClairance}></bcbd-input>
2073
2239
  </div>
2074
2240
  <div class="${PREFIX}-edition-modal-little-section">
2075
2241
  <span>DFG (mL/min/1.73.m2)</span>
2076
- <bcbd-input data-test-id="dfg-input" id="dfgInput" type="number" .value=${this.dfg <= 0 ? "" : this.dfg} warning-msg="" @input=${this.setFormWithDFG}></bcbd-input>
2242
+ <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.setFormWithDFG}></bcbd-input>
2077
2243
  </div>
2078
2244
  </div>
2079
2245
  </fieldset>
@@ -2092,8 +2258,9 @@ let PatientProfileEdition = class extends i {
2092
2258
  </div>
2093
2259
  <div class="${PREFIX}-edition-modal-little-section">
2094
2260
  <span>Score de Child-Pugh</span>
2095
- <bcbd-input data-test-id="hepatic-score-input" id="childPughInput" type="number" warning-msg=""
2096
- .value=${getPatientHepaticInsufficiencyScore(this.patientProfile)} @input=${this.handleHepaticScore}></bcbd-input>
2261
+ <bcbd-input data-test-id="hepatic-score-input" id="childPughInput" type="number" aria-label="Score de Child-Pugh" warning-msg=""
2262
+ .value=${getPatientHepaticInsufficiencyScore(this.patientProfile)} @change=${this.handleHepaticScore}></bcbd-input>
2263
+ ${this.childPughErrorMessage !== "" ? b`<span class="${PREFIX}-edition-modal-error-message">${this.childPughErrorMessage}</span>` : b` `}
2097
2264
  </div>
2098
2265
  </div>
2099
2266
  </fieldset>
@@ -2103,7 +2270,7 @@ let PatientProfileEdition = class extends i {
2103
2270
  </div>
2104
2271
 
2105
2272
  <div class="${PREFIX}-edition-modal-action-buttons" data-test-id="action-buttons">
2106
- <bcbd-button ?disabled=${this.ageErrorMessageInput !== "" || this.sizeErrorMessageInput !== "" || this.weightErrorMessageInput !== ""}
2273
+ <bcbd-button ?disabled=${this.ageErrorMessageInput !== "" || this.sizeErrorMessageInput !== "" || this.weightErrorMessageInput !== "" || this.childPughErrorMessage !== ""}
2107
2274
  data-test-id="save-button" background-color="primary" @click=${this.validateForm}>Valider</bcbd-button>
2108
2275
  <bcbd-button data-test-id="cancel-button" outlined background-color="black" @click=${() => this.editionModalElement.close()}>Annuler</bcbd-button>
2109
2276
  </div>
@@ -2181,6 +2348,12 @@ __decorateClass$1([
2181
2348
  __decorateClass$1([
2182
2349
  r()
2183
2350
  ], PatientProfileEdition.prototype, "allergiesApiErrorMessage", 2);
2351
+ __decorateClass$1([
2352
+ r()
2353
+ ], PatientProfileEdition.prototype, "renalLackInformationErrorMessage", 2);
2354
+ __decorateClass$1([
2355
+ r()
2356
+ ], PatientProfileEdition.prototype, "childPughErrorMessage", 2);
2184
2357
  __decorateClass$1([
2185
2358
  r()
2186
2359
  ], PatientProfileEdition.prototype, "pathologyOptions", 2);
@@ -2285,6 +2458,9 @@ let PatientProfile = class extends i {
2285
2458
  const creatinine = getCreatinine(this.patientProfile);
2286
2459
  const creatinineByMg = creatinine.find((c2) => c2.unit?.toLowerCase() === "mg/l");
2287
2460
  const creatinineByUmol = creatinine.find((c2) => c2.unit === "μmol/L");
2461
+ if (!creatinineByMg && !creatinineByUmol) {
2462
+ return A;
2463
+ }
2288
2464
  return b`
2289
2465
  <div class="${PREFIX}-patient-profile__second-info" id="creatinine-section" data-test-id="creatinine-section">
2290
2466
  <span class="${PREFIX}-patient-profile__second-info-label">Créatininémie </span>
@@ -2349,6 +2525,9 @@ let PatientProfile = class extends i {
2349
2525
  }
2350
2526
  displayPathologies() {
2351
2527
  const conditions = getPatientConditions(this.patientProfile);
2528
+ if (conditions.length === 0) {
2529
+ return A;
2530
+ }
2352
2531
  const items = conditions.map((condition, index) => {
2353
2532
  const truncated = this.truncateLabel(condition);
2354
2533
  const separator = index < conditions.length - 1 ? ", " : "";
@@ -2366,10 +2545,16 @@ let PatientProfile = class extends i {
2366
2545
  </bcbd-tooltip>
2367
2546
  `;
2368
2547
  });
2369
- return b`${items}`;
2548
+ return b`<div class="${PREFIX}-patient-profile__second-info" data-test-id="pathology-section">
2549
+ <span class="${PREFIX}-patient-profile__second-info-label">Pathologies suivies </span>
2550
+ <span class="${PREFIX}-patient-profile__second-info-result">${items} </span>
2551
+ </div>`;
2370
2552
  }
2371
2553
  displayAllergies() {
2372
2554
  const allergies = getPatientAllergies(this.patientProfile);
2555
+ if (allergies.length === 0) {
2556
+ return A;
2557
+ }
2373
2558
  const items = allergies.map((allergy, index) => {
2374
2559
  const truncated = this.truncateLabel(allergy);
2375
2560
  const separator = index < allergies.length - 1 ? ", " : "";
@@ -2387,7 +2572,10 @@ let PatientProfile = class extends i {
2387
2572
  </bcbd-tooltip>
2388
2573
  `;
2389
2574
  });
2390
- return b`${items}`;
2575
+ return b`<div class="${PREFIX}-patient-profile__second-info" data-test-id="allergy-section">
2576
+ <span class="${PREFIX}-patient-profile__second-info-label">Allergies </span>
2577
+ <span class="${PREFIX}-patient-profile__second-info-result">${items}</span>
2578
+ </div>`;
2391
2579
  }
2392
2580
  openEditionModal() {
2393
2581
  this.editionModalElement.open();
@@ -2412,80 +2600,92 @@ let PatientProfile = class extends i {
2412
2600
  }
2413
2601
  return null;
2414
2602
  }
2603
+ // eslint-disable-next-line complexity
2415
2604
  render() {
2605
+ const pregnancy = this.displayPregnancy();
2606
+ const breastfeeding = this.displayBreastfeeding();
2607
+ const pathologies = this.displayPathologies();
2608
+ const allergies = this.displayAllergies();
2609
+ const renalStatus = this.displayRenalInsufficiencyStatus();
2610
+ const creatinine = this.displayCreatininemieSection();
2611
+ const hepatic = this.displayHepaticInsufficiencySection();
2612
+ const hasSecondaryInfo = [pregnancy, breastfeeding, pathologies, allergies, renalStatus, creatinine, hepatic].some((section) => section !== A);
2416
2613
  return b`
2417
2614
  <div class="${PREFIX}-patient-profile">
2418
- <div class="${PREFIX}-patient-profile__first-info-container">
2419
- <div class="${PREFIX}-patient-profile__id-info-container">
2420
- <div class="${PREFIX}-patient-profile__name-info" data-test-id="patient-name">
2421
- ${getPatientName(this.patientProfile)}
2422
- </div>
2423
- <div class="${PREFIX}-patient-profile__id-info">
2424
- <div class="${PREFIX}-patient-profile__id-info-info" data-test-id="patient-gender">
2425
- ${getPatientGender(this.patientProfile)}
2426
- </div>
2427
- <div class="${PREFIX}-patient-profile__separator">
2428
- </div>
2429
- <div class="${PREFIX}-patient-profile__id-info-info" data-test-id="patient-age">
2430
- ${this.getPatientAge()} ${this.patientAgeUnit}
2431
- </div>
2432
- </div>
2433
- </div>
2434
-
2435
- <div class="${PREFIX}-patient-profile__physical-info-container">
2436
- <div class="${PREFIX}-patient-profile__physical-info" data-test-id="patient-height">
2437
- <div class="${PREFIX}-patient-profile__physical-info-label">
2438
- Taille
2439
- </div>
2440
- <div class="${PREFIX}-patient-profile__physical-info-result">
2441
- ${getPatientHeightWithUnit(this.patientProfile) === "" ? "-" : getPatientHeightWithUnit(this.patientProfile)}
2442
- </div>
2615
+ <div class="${PREFIX}-patient-profile__first-info-container" data-test-id="first-info-container">
2616
+ ${!this.patientProfile?.entry || this.patientProfile?.entry?.length <= 1 ? b`
2617
+ <div class="${PREFIX}-patient-profile__no-profile" data-test-id="no-data">
2618
+ <div class="${PREFIX}-patient-profile__no-profile__first">Aucun profil patient renseigné</div>
2619
+ <div class="${PREFIX}-patient-profile__no-profile__second">Veuillez remplir le formulaire</div>
2443
2620
  </div>
2444
- <div class="${PREFIX}-patient-profile__separator">
2445
- </div>
2446
- <div class="${PREFIX}-patient-profile__physical-info" data-test-id="patient-weight">
2447
- <div class="${PREFIX}-patient-profile__physical-info-label">
2448
- Poids
2449
- </div>
2450
- <div class="${PREFIX}-patient-profile__physical-info-result">
2451
- ${getPatientWeightWithUnit(this.patientProfile) === "" ? "-" : getPatientWeightWithUnit(this.patientProfile)}
2452
- </div>
2453
- </div>
2454
- <div class="${PREFIX}-patient-profile__separator">
2455
- </div>
2456
- <div class="${PREFIX}-patient-profile__physical-info" data-test-id="patient-IMC">
2457
- <div class="${PREFIX}-patient-profile__physical-info-label">
2458
- IMC
2459
- </div>
2460
- <div class="${PREFIX}-patient-profile__physical-info-result">
2461
- ${calculateBMI(getPatientWeight(this.patientProfile) ?? 0, getPatientHeight(this.patientProfile) ?? 0) === 0 ? "-" : calculateBMI(getPatientWeight(this.patientProfile) ?? 0, getPatientHeight(this.patientProfile) ?? 0)}
2621
+ ${this.editButtonVisible || this.editButtonVisible === void 0 ? b`<bcbd-button icon="pencil" size="medium" background-color="black" outlined aria-label="Modifier le profil patient" data-test-id="modify-button" @click=${this.openEditionModal}></bcbd-button>` : A}
2622
+ ` : b`
2623
+ <div class="${PREFIX}-patient-profile__id-info-container">
2624
+ <div class="${PREFIX}-patient-profile__name-info" data-test-id="patient-name">
2625
+ ${getPatientName(this.patientProfile)}
2626
+ </div>
2627
+ ${getPatientGender(this.patientProfile) === void 0 && this.getPatientAge() === null ? A : b`
2628
+ <div class="${PREFIX}-patient-profile__id-info">
2629
+ ${getPatientGender(this.patientProfile) === void 0 ? A : b`
2630
+ <div class="${PREFIX}-patient-profile__id-info-info" data-test-id="patient-gender">
2631
+ ${getPatientGender(this.patientProfile)}
2632
+ </div>
2633
+ <div class="${PREFIX}-patient-profile__separator">
2634
+ </div>
2635
+ `}
2636
+
2637
+ <div class="${PREFIX}-patient-profile__id-info-info" data-test-id="patient-age">
2638
+ ${this.getPatientAge() === null ? A : b`${this.getPatientAge()} ${this.patientAgeUnit}`}
2639
+ </div>
2462
2640
  </div>
2463
- </div>
2464
- </div>
2465
-
2466
- <div class="${PREFIX}-patient-profile__action-buttons-container" data-test-id="action-buttons">
2467
- ${this.editButtonVisible || this.editButtonVisible === void 0 ? b`<bcbd-button icon="pencil" size="medium" background-color="black" outlined data-test-id="modify-button" @click=${this.openEditionModal}></bcbd-button>` : A}
2468
- <bcbd-button icon=${this.moreInformationVisible ? "chevron-up" : "chevron-down"} size="medium" background-color="primary" @click=${this.handleMoreInformation} data-test-id="visible-button"></bcbd-button>
2469
- </div>
2641
+ `}
2642
+ </div>
2643
+
2644
+ <div class="${PREFIX}-patient-profile__physical-info-container">
2645
+ <div class="${PREFIX}-patient-profile__physical-info" data-test-id="patient-height">
2646
+ <div class="${PREFIX}-patient-profile__physical-info-label">
2647
+ Taille
2648
+ </div>
2649
+ <div class="${PREFIX}-patient-profile__physical-info-result">
2650
+ ${getPatientHeightWithUnit(this.patientProfile) === "" ? "-" : getPatientHeightWithUnit(this.patientProfile)}
2651
+ </div>
2652
+ </div>
2653
+ <div class="${PREFIX}-patient-profile__separator">
2654
+ </div>
2655
+ <div class="${PREFIX}-patient-profile__physical-info" data-test-id="patient-weight">
2656
+ <div class="${PREFIX}-patient-profile__physical-info-label">
2657
+ Poids
2658
+ </div>
2659
+ <div class="${PREFIX}-patient-profile__physical-info-result">
2660
+ ${getPatientWeightWithUnit(this.patientProfile) === "" ? "-" : getPatientWeightWithUnit(this.patientProfile)}
2661
+ </div>
2662
+ </div>
2663
+ <div class="${PREFIX}-patient-profile__separator">
2664
+ </div>
2665
+ <div class="${PREFIX}-patient-profile__physical-info" data-test-id="patient-IMC">
2666
+ <div class="${PREFIX}-patient-profile__physical-info-label">
2667
+ IMC
2668
+ </div>
2669
+ <div class="${PREFIX}-patient-profile__physical-info-result">
2670
+ ${calculateBMI(getPatientWeight(this.patientProfile) ?? 0, getPatientHeight(this.patientProfile) ?? 0) === 0 ? "-" : calculateBMI(getPatientWeight(this.patientProfile) ?? 0, getPatientHeight(this.patientProfile) ?? 0)}
2671
+ </div>
2672
+ </div>
2673
+ </div>
2674
+
2675
+ <div class="${PREFIX}-patient-profile__action-buttons-container" data-test-id="action-buttons">
2676
+ ${this.editButtonVisible || this.editButtonVisible === void 0 ? b`<bcbd-button icon="pencil" size="medium" background-color="black" outlined aria-label="Modifier le profil patient" data-test-id="modify-button" @click=${this.openEditionModal}></bcbd-button>` : A}
2677
+ <bcbd-button icon=${this.moreInformationVisible ? "chevron-up" : "chevron-down"} size="medium" background-color="primary" aria-label=${this.moreInformationVisible ? "Masquer les informations supplémentaires" : "Afficher les informations supplémentaires"} @click=${this.handleMoreInformation} data-test-id="visible-button"></bcbd-button>
2678
+ </div>`}
2470
2679
  </div>
2471
2680
  <div class="${PREFIX}-patient-profile__second-info-container ${this.moreInformationVisible ? "active" : ""}" data-test-id="more-information-section">
2472
- ${this.displayPregnancy()}
2473
- ${this.displayBreastfeeding()}
2474
-
2475
- <div class="${PREFIX}-patient-profile__second-info" data-test-id="pathology-section">
2476
- <span class="${PREFIX}-patient-profile__second-info-label">Pathologies suivies </span>
2477
- <span class="${PREFIX}-patient-profile__second-info-result">${this.displayPathologies()} </span>
2478
- </div>
2479
- <div class="${PREFIX}-patient-profile__second-info" data-test-id="allergy-section">
2480
- <span class="${PREFIX}-patient-profile__second-info-label">Allergies </span>
2481
- <span class="${PREFIX}-patient-profile__second-info-result">${this.displayAllergies()} </span>
2482
- </div>
2483
-
2484
- ${this.displayRenalInsufficiencyStatus()}
2485
-
2486
- ${this.displayCreatininemieSection()}
2487
-
2488
- ${this.displayHepaticInsufficiencySection()}
2681
+ ${pregnancy}
2682
+ ${breastfeeding}
2683
+ ${pathologies}
2684
+ ${allergies}
2685
+ ${renalStatus}
2686
+ ${creatinine}
2687
+ ${hepatic}
2688
+ ${!hasSecondaryInfo ? b`Aucune information renseignée` : A}
2489
2689
  </div>
2490
2690
  <bcb-patient-profile-edition .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl} .apiKey=${this.apiKey}
2491
2691
  .preferences=${this.preferences}