@claudebernard/patient-profile-element 0.6.2 → 0.6.3

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.
@@ -149,7 +149,7 @@
149
149
  "type": {
150
150
  "text": "PatientProfilePreferences | undefined"
151
151
  },
152
- "default": "{ forms: { age: { display: true, readOnly: true }, sexe: { display: true, readOnly: true }, }, }",
152
+ "default": "{ forms: { age: { display: true, readOnly: false }, sexe: { display: true, readOnly: false }, }, }",
153
153
  "attribute": "preferences"
154
154
  },
155
155
  {
@@ -315,7 +315,7 @@
315
315
  "type": {
316
316
  "text": "PatientProfilePreferences | undefined"
317
317
  },
318
- "default": "{ forms: { age: { display: true, readOnly: true }, sexe: { display: true, readOnly: true }, }, }",
318
+ "default": "{ forms: { age: { display: true, readOnly: false }, sexe: { display: true, readOnly: false }, }, }",
319
319
  "fieldName": "preferences"
320
320
  }
321
321
  ],
@@ -464,20 +464,37 @@
464
464
  },
465
465
  {
466
466
  "kind": "field",
467
- "name": "patientAge",
467
+ "name": "patientBirthDate",
468
468
  "type": {
469
- "text": "number"
469
+ "text": "string"
470
470
  },
471
- "default": "0"
471
+ "default": "\"\""
472
+ },
473
+ {
474
+ "kind": "field",
475
+ "name": "patientAgeValue",
476
+ "type": {
477
+ "text": "number | undefined"
478
+ },
479
+ "default": "undefined"
472
480
  },
473
481
  {
474
482
  "kind": "field",
475
483
  "name": "patientUnitAge",
476
484
  "type": {
477
- "text": "string"
485
+ "text": "\"ans\" | \"mois\""
478
486
  },
479
487
  "default": "\"ans\""
480
488
  },
489
+ {
490
+ "kind": "field",
491
+ "name": "patientAge",
492
+ "type": {
493
+ "text": "string"
494
+ },
495
+ "privacy": "private",
496
+ "readonly": true
497
+ },
481
498
  {
482
499
  "kind": "field",
483
500
  "name": "creatinineByMg",
@@ -510,14 +527,6 @@
510
527
  },
511
528
  "default": "0"
512
529
  },
513
- {
514
- "kind": "field",
515
- "name": "defaultPatientUnitAge",
516
- "type": {
517
- "text": "{ value?: string; label?: string }"
518
- },
519
- "default": "{}"
520
- },
521
530
  {
522
531
  "kind": "field",
523
532
  "name": "defaultPatientSex",
@@ -665,7 +674,15 @@
665
674
  },
666
675
  {
667
676
  "kind": "field",
668
- "name": "ageInput",
677
+ "name": "ageInputText",
678
+ "type": {
679
+ "text": "HTMLElement & { value: string }"
680
+ },
681
+ "privacy": "private"
682
+ },
683
+ {
684
+ "kind": "field",
685
+ "name": "birthDateInput",
669
686
  "type": {
670
687
  "text": "HTMLElement & { value: string }"
671
688
  },
@@ -743,14 +760,6 @@
743
760
  },
744
761
  "privacy": "private"
745
762
  },
746
- {
747
- "kind": "field",
748
- "name": "ageUnitSelect",
749
- "type": {
750
- "text": "HTMLElement & { value: string }"
751
- },
752
- "privacy": "private"
753
- },
754
763
  {
755
764
  "kind": "method",
756
765
  "name": "open",
@@ -793,17 +802,34 @@
793
802
  },
794
803
  {
795
804
  "kind": "method",
796
- "name": "verifyAgeInput",
805
+ "name": "getAgeErrorMessage",
797
806
  "privacy": "private",
798
807
  "return": {
799
808
  "type": {
800
- "text": "void"
809
+ "text": "string"
801
810
  }
802
- }
811
+ },
812
+ "parameters": [
813
+ {
814
+ "name": "age",
815
+ "type": {
816
+ "text": "number"
817
+ }
818
+ }
819
+ ]
820
+ },
821
+ {
822
+ "kind": "field",
823
+ "name": "isPregnancyAge",
824
+ "type": {
825
+ "text": "boolean"
826
+ },
827
+ "privacy": "private",
828
+ "readonly": true
803
829
  },
804
830
  {
805
831
  "kind": "method",
806
- "name": "handleAgeUnit",
832
+ "name": "verifyAgeInput",
807
833
  "privacy": "private",
808
834
  "return": {
809
835
  "type": {
@@ -1097,14 +1123,6 @@
1097
1123
  "text": "{ value: string, label: string }[]"
1098
1124
  },
1099
1125
  "default": "[ { value: \"A\", label: \"Stade A\" }, { value: \"B\", label: \"Stade B\" }, { value: \"C\", label: \"Stade C\" }, ]"
1100
- },
1101
- {
1102
- "kind": "variable",
1103
- "name": "ageOptions",
1104
- "type": {
1105
- "text": "{ value: string, label: string }[]"
1106
- },
1107
- "default": "[ { value: \"ans\", label: \"Ans\" }, { value: \"mois\", label: \"Mois\" }, ]"
1108
1126
  }
1109
1127
  ],
1110
1128
  "exports": [
@@ -1123,14 +1141,6 @@
1123
1141
  "name": "hepaticStadeOptions",
1124
1142
  "module": "src/shared/constants/edition-options.ts"
1125
1143
  }
1126
- },
1127
- {
1128
- "kind": "js",
1129
- "name": "ageOptions",
1130
- "declaration": {
1131
- "name": "ageOptions",
1132
- "module": "src/shared/constants/edition-options.ts"
1133
- }
1134
1144
  }
1135
1145
  ]
1136
1146
  },
@@ -1448,6 +1458,33 @@
1448
1458
  "kind": "javascript-module",
1449
1459
  "path": "src/shared/utils/formula-utils.ts",
1450
1460
  "declarations": [
1461
+ {
1462
+ "kind": "function",
1463
+ "name": "calculateAgeFromBirthDate",
1464
+ "return": {
1465
+ "type": {
1466
+ "text": ""
1467
+ }
1468
+ },
1469
+ "parameters": [
1470
+ {
1471
+ "name": "birthDate",
1472
+ "type": {
1473
+ "text": "Date"
1474
+ },
1475
+ "description": "Date de naissance du patient"
1476
+ },
1477
+ {
1478
+ "name": "referenceDate",
1479
+ "default": "new Date()",
1480
+ "type": {
1481
+ "text": "Date"
1482
+ },
1483
+ "description": "Date de référence pour le calcul (aujourd'hui par défaut)"
1484
+ }
1485
+ ],
1486
+ "description": "Calcule l'âge d'un patient et son unité (années ou mois) à partir de sa date de naissance.\nEn dessous de 24 mois, l'âge est exprimé en mois."
1487
+ },
1451
1488
  {
1452
1489
  "kind": "function",
1453
1490
  "name": "calculateBMI",
@@ -1592,6 +1629,14 @@
1592
1629
  }
1593
1630
  ],
1594
1631
  "exports": [
1632
+ {
1633
+ "kind": "js",
1634
+ "name": "calculateAgeFromBirthDate",
1635
+ "declaration": {
1636
+ "name": "calculateAgeFromBirthDate",
1637
+ "module": "src/shared/utils/formula-utils.ts"
1638
+ }
1639
+ },
1595
1640
  {
1596
1641
  "kind": "js",
1597
1642
  "name": "calculateBMI",
@@ -1799,21 +1844,14 @@
1799
1844
  "description": "Bundle Patient FHIR"
1800
1845
  },
1801
1846
  {
1802
- "name": "age",
1803
- "type": {
1804
- "text": "number"
1805
- },
1806
- "description": "Nouvel âge du patient"
1807
- },
1808
- {
1809
- "name": "ageUnit",
1847
+ "name": "birthdate",
1810
1848
  "type": {
1811
1849
  "text": "string"
1812
1850
  },
1813
- "description": "Unité de l'âge (ex: \"ans\", \"mois\")"
1851
+ "description": "Nouvelle date de naissance du patient"
1814
1852
  }
1815
1853
  ],
1816
- "description": "Modifie l'âge du patient dans la ressource Patient du Bundle FHIR"
1854
+ "description": "Modifie la date de naissance du patient dans la ressource Patient du Bundle FHIR"
1817
1855
  },
1818
1856
  {
1819
1857
  "kind": "function",
@@ -2569,25 +2607,6 @@
2569
2607
  }
2570
2608
  ],
2571
2609
  "description": "Extrait les informations médicales complètes du patient"
2572
- },
2573
- {
2574
- "kind": "function",
2575
- "name": "getPatientInfo",
2576
- "return": {
2577
- "type": {
2578
- "text": ""
2579
- }
2580
- },
2581
- "parameters": [
2582
- {
2583
- "name": "bundle",
2584
- "type": {
2585
- "text": "Bundle | undefined"
2586
- },
2587
- "description": "Bundle FHIR"
2588
- }
2589
- ],
2590
- "description": "Extrait toutes les informations du patient (démographiques + médicales)"
2591
2610
  }
2592
2611
  ],
2593
2612
  "exports": [
@@ -2942,14 +2961,6 @@
2942
2961
  "name": "getPatientMedicalInfo",
2943
2962
  "module": "src/shared/utils/patient-fhir-utils.ts"
2944
2963
  }
2945
- },
2946
- {
2947
- "kind": "js",
2948
- "name": "getPatientInfo",
2949
- "declaration": {
2950
- "name": "getPatientInfo",
2951
- "module": "src/shared/utils/patient-fhir-utils.ts"
2952
- }
2953
2964
  }
2954
2965
  ]
2955
2966
  }
@@ -1,63 +1,2 @@
1
- import { Bundle } from 'fhir/r5';
2
- import { CSSResult } from 'lit';
3
- import { LitElement } from 'lit';
4
- import { nothing } from 'lit';
5
- import { TemplateResult } from 'lit';
6
-
7
- declare interface FormPreferences {
8
- age?: SectionPreferences;
9
- sexe?: SectionPreferences;
10
- }
11
-
12
- export declare class PatientProfile extends LitElement {
13
- patientProfile?: Bundle;
14
- editButtonVisible: boolean | undefined;
15
- apiUrl: string;
16
- apiKey: string | undefined;
17
- preferences: PatientProfilePreferences | undefined;
18
- moreInformationVisible: boolean;
19
- patientAgeUnit: "ans" | "mois";
20
- private editionModalElement;
21
- handleMoreInformation(): void;
22
- displayRenalInsufficiencyStatus(): symbol | TemplateResult<1>;
23
- displayCreatininemieSection(): TemplateResult<1> | typeof nothing;
24
- private displayHepaticInsufficiencySection;
25
- private truncateLabel;
26
- private displayPregnancy;
27
- private displayBreastfeeding;
28
- displayPathologies(): TemplateResult<1> | typeof nothing;
29
- displayAllergies(): TemplateResult<1> | typeof nothing;
30
- openEditionModal(): void;
31
- private editProfilePatient;
32
- private getPatientAge;
33
- render(): TemplateResult<1>;
34
- static styles: CSSResult;
35
- }
36
-
37
- declare interface PatientProfilePreferences {
38
- /**
39
- * Filtre le type de pathologie utilisé lors de l'appel fetchPathologiesByTerm.
40
- * - "AMM" : pathologies avec Autorisation de Mise sur le Marché
41
- * - "CIM10" : pathologies selon la classification CIM-10
42
- * - "" : aucun filtre (toutes les pathologies)
43
- */
44
- typePathology?: "AMM" | "CIM10" | "";
45
- forms?: FormPreferences;
46
- }
47
-
48
- export declare interface PatientProfileProps {
49
- patientProfile?: Bundle;
50
- editButtonVisible?: boolean;
51
- apiUrl: string;
52
- apiKey?: string;
53
- preferences?: PatientProfilePreferences;
54
- }
55
-
56
- declare interface SectionPreferences {
57
- /** @default true */
58
- display?: boolean;
59
- /** @default true */
60
- readOnly?: boolean;
61
- }
62
-
63
- export { }
1
+ export * from './src/patient-profile/patient-profile.js'
2
+ export {}
@@ -1,6 +1,15 @@
1
1
  import { SearchRequestBody } from "@claudebernard/types";
2
2
  import "@claudebernard/design-system";
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;
@@ -181,7 +190,7 @@ function getPatientBirthDate(bundle) {
181
190
  }
182
191
  return new Date(patient.birthDate);
183
192
  }
184
- function setPatientAge(bundle, age, ageUnit) {
193
+ function setPatientAge(bundle, birthdate) {
185
194
  const patientEntry = bundle.entry?.find(
186
195
  (entry) => entry.resource?.resourceType === "Patient"
187
196
  );
@@ -202,15 +211,7 @@ function setPatientAge(bundle, age, ageUnit) {
202
211
  composition.subject = [{ reference: patientFullUrl }];
203
212
  }
204
213
  }
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];
214
+ patient.birthDate = birthdate;
214
215
  }
215
216
  function getPatientWeight(bundle) {
216
217
  const obs = bundle?.entry?.find(
@@ -1590,10 +1591,6 @@ const hepaticStadeOptions = [
1590
1591
  { value: "B", label: "Stade B" },
1591
1592
  { value: "C", label: "Stade C" }
1592
1593
  ];
1593
- const ageOptions = [
1594
- { value: "ans", label: "Ans" },
1595
- { value: "mois", label: "Mois" }
1596
- ];
1597
1594
  const convertRenalInsufficiency = async (type, value, patient, apiUrl) => {
1598
1595
  const response = await fetch(`${apiUrl}/prescription/patient/fhir/renal-insufficiency-conversion`, {
1599
1596
  method: "POST",
@@ -1657,7 +1654,7 @@ const i3 = e(class extends i$1 {
1657
1654
  return t2 !== this.key && (p(r2), this.key = t2), e2;
1658
1655
  }
1659
1656
  });
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}";
1657
+ 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 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-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 padding-bottom: 10px;\n}\n\nbcbd-checkbox {\n --bcbd-checkbox-font-size: .9rem;\n}";
1661
1658
  var __defProp$1 = Object.defineProperty;
1662
1659
  var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
1663
1660
  var __decorateClass$1 = (decorators, target, key, kind) => {
@@ -1672,13 +1669,13 @@ let PatientProfileEdition = class extends i$2 {
1672
1669
  constructor() {
1673
1670
  super(...arguments);
1674
1671
  this.apiUrl = "https://api-dev.claudebernard.fr";
1675
- this.patientAge = 0;
1672
+ this.patientBirthDate = "";
1673
+ this.patientAgeValue = void 0;
1676
1674
  this.patientUnitAge = "ans";
1677
1675
  this.creatinineByMg = 0;
1678
1676
  this.creatinineByUmol = 0;
1679
1677
  this.clairanceCreatinine = 0;
1680
1678
  this.dfg = 0;
1681
- this.defaultPatientUnitAge = {};
1682
1679
  this.defaultPatientSex = {};
1683
1680
  this.defaultHepaticStade = {};
1684
1681
  this.isPregnancyDivVisible = false;
@@ -1701,24 +1698,22 @@ let PatientProfileEdition = class extends i$2 {
1701
1698
  return this.preferences?.forms?.age?.display ?? true;
1702
1699
  }
1703
1700
  get isAgeReadOnly() {
1704
- return this.preferences?.forms?.age?.readOnly ?? true;
1701
+ return this.preferences?.forms?.age?.readOnly ?? false;
1705
1702
  }
1706
1703
  get isSexeDisplay() {
1707
1704
  return this.preferences?.forms?.sexe?.display ?? true;
1708
1705
  }
1709
1706
  get isSexeReadOnly() {
1710
- return this.preferences?.forms?.sexe?.readOnly ?? true;
1707
+ return this.preferences?.forms?.sexe?.readOnly ?? false;
1708
+ }
1709
+ get patientAge() {
1710
+ return this.patientAgeValue === void 0 ? "" : `${this.patientAgeValue} ${this.patientUnitAge}`;
1711
1711
  }
1712
1712
  open() {
1713
1713
  this.editionModalElement.open();
1714
1714
  }
1715
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);
1721
- }
1716
+ this.isPregnancyDivVisible = this.isPregnancyAge;
1722
1717
  this.recalculateRenalValues();
1723
1718
  }
1724
1719
  resetToProfileValues() {
@@ -1736,35 +1731,18 @@ let PatientProfileEdition = class extends i$2 {
1736
1731
  this.breastfeeding = getPatientBreastfeedingStatus(this.patientProfile);
1737
1732
  this.isPregnant = getPatientPregnancyStatus(this.patientProfile);
1738
1733
  const birthDate = getPatientBirthDate(this.patientProfile);
1734
+ this.patientBirthDate = birthDate?.toISOString().split("T")[0] ?? "";
1739
1735
  this.isPregnancyDivVisible = false;
1740
1736
  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
- };
1737
+ this.ageInputText.setAttribute("warning-msg", "");
1738
+ const { age, unit } = calculateAgeFromBirthDate(birthDate);
1739
+ this.patientAgeValue = age;
1740
+ this.patientUnitAge = unit;
1741
+ this.isPregnancyDivVisible = unit === "ans" && this.defaultPatientSex.value !== "male";
1761
1742
  } else {
1743
+ this.patientAgeValue = void 0;
1762
1744
  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
- };
1745
+ this.ageInputText.setAttribute("warning-msg", this.ageErrorMessageInput);
1768
1746
  }
1769
1747
  const creatinine = getCreatinine(this.patientProfile);
1770
1748
  const renalStatus = getPatientRenalInsufficiencyStatus(this.patientProfile);
@@ -1786,33 +1764,39 @@ let PatientProfileEdition = class extends i$2 {
1786
1764
  this.resetKey++;
1787
1765
  this.editionModalElement.close();
1788
1766
  }
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 = "";
1767
+ getAgeErrorMessage(age) {
1768
+ if (age > 150) {
1769
+ return "L'âge ne doit pas dépasser 150 ans";
1801
1770
  }
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 {
1771
+ if (age < 1) {
1772
+ return "L'âge est invalide";
1773
+ }
1774
+ return "";
1775
+ }
1776
+ get isPregnancyAge() {
1777
+ const age = this.patientAgeValue ?? 0;
1778
+ return this.patientUnitAge === "ans" && age >= 12 && age <= 55 && !!this.genderSelect?.value && this.genderSelect.value !== "male";
1779
+ }
1780
+ verifyAgeInput() {
1781
+ const birthDateValue = String(this.birthDateInput?.value ?? "");
1782
+ const birthDate = new Date(birthDateValue);
1783
+ const today = /* @__PURE__ */ new Date();
1784
+ if (!birthDateValue || isNaN(birthDate.getTime()) || birthDate > today) {
1785
+ this.ageErrorMessageInput = "La date de naissance n'est pas valide";
1786
+ this.ageInputText.setAttribute("warning-msg", this.ageErrorMessageInput);
1787
+ this.patientAgeValue = void 0;
1808
1788
  this.isPregnancyDivVisible = false;
1789
+ return;
1809
1790
  }
1791
+ this.patientBirthDate = birthDateValue;
1792
+ const { age, unit } = calculateAgeFromBirthDate(birthDate, today);
1793
+ this.patientAgeValue = age;
1794
+ this.patientUnitAge = unit;
1795
+ this.ageErrorMessageInput = this.getAgeErrorMessage(age);
1796
+ this.ageInputText.setAttribute("warning-msg", this.ageErrorMessageInput);
1797
+ this.isPregnancyDivVisible = this.isPregnancyAge;
1810
1798
  this.recalculateRenalValues();
1811
1799
  }
1812
- handleAgeUnit() {
1813
- this.patientUnitAge = this.ageUnitSelect?.value ?? "ans";
1814
- this.verifyAgeInput();
1815
- }
1816
1800
  verifySizeInput() {
1817
1801
  const size = Number(this.sizeInput?.value ?? 0);
1818
1802
  if (size < 1 || size > 399) {
@@ -1970,8 +1954,7 @@ let PatientProfileEdition = class extends i$2 {
1970
1954
  this.patientProfile = setInitialPatientProfile();
1971
1955
  }
1972
1956
  const size = Number(this.sizeInput?.value ?? "");
1973
- const age = Number(this.ageInput?.value ?? "");
1974
- const ageUnit = this.ageUnitSelect?.value ?? "ans";
1957
+ const birthDate = this.birthDateInput?.value ?? "";
1975
1958
  const weight = Number(this.weightInput?.value ?? "");
1976
1959
  const gender = this.genderSelect?.value ?? "";
1977
1960
  const creatinineUmol = Number(this.creatinineUmolInput?.value ?? "");
@@ -1980,8 +1963,8 @@ let PatientProfileEdition = class extends i$2 {
1980
1963
  const dfg = Number(this.dfgInput?.value ?? "");
1981
1964
  const gestationalWeeks = Number(this.gestationalWeeksInput?.value ?? "");
1982
1965
  const hepaticStade = this.hepaticStadeSelect?.value ?? "";
1983
- if (age > 0) {
1984
- setPatientAge(this.patientProfile, age, ageUnit);
1966
+ if (birthDate !== "") {
1967
+ setPatientAge(this.patientProfile, birthDate);
1985
1968
  }
1986
1969
  if (!isNaN(weight) || weight > 0) {
1987
1970
  setPatientWeight(this.patientProfile, weight);
@@ -2050,23 +2033,26 @@ let PatientProfileEdition = class extends i$2 {
2050
2033
  </div>` : A}
2051
2034
  ${this.isAgeDisplay ? b`
2052
2035
  <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>
2036
+ <span>Date de naissance</span>
2037
+ <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>
2066
2038
  </div>
2067
2039
  <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>
2040
+ <span>Age</span>
2041
+ <bcbd-input data-test-id="age-input-text" id="ageInputText" disabled type="text" aria-label="Age" .value=${this.patientAge} warning-msg="" readonly></bcbd-input>
2042
+ </div>` : A}
2043
+ <div class="${PREFIX}-edition-modal-information-section-secondary-group">
2044
+ <div class="${PREFIX}-edition-modal-little-section">
2045
+ <span>Taille (cm)</span>
2046
+ <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>
2047
+ </div>
2048
+ <div class="${PREFIX}-edition-modal-little-section">
2049
+ <span>Poids (kg)</span>
2050
+ <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>
2051
+ </div>
2052
+ <div class="${PREFIX}-edition-modal-little-section">
2053
+ <span>IMC</span>
2054
+ <bcbd-input data-test-id="imc-input" id="imcInput" type="number" aria-label="IMC" disabled .value=${this.imc} warning-msg=""></bcbd-input>
2055
+ </div>
2070
2056
  </div>
2071
2057
  </div>
2072
2058
  ${this.isPregnancyDivVisible ? b`
@@ -2131,9 +2117,9 @@ let PatientProfileEdition = class extends i$2 {
2131
2117
  </div>
2132
2118
  </div>
2133
2119
  </fieldset>
2134
-
2135
2120
  <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.
2121
+ <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">
2122
+ </bcbd-alert>
2137
2123
  </div>
2138
2124
  </div>
2139
2125
  <div slot="actions" class="${PREFIX}-edition-modal-action-buttons" data-test-id="action-buttons">
@@ -2160,7 +2146,10 @@ __decorateClass$1([
2160
2146
  ], PatientProfileEdition.prototype, "preferences", 2);
2161
2147
  __decorateClass$1([
2162
2148
  r()
2163
- ], PatientProfileEdition.prototype, "patientAge", 2);
2149
+ ], PatientProfileEdition.prototype, "patientBirthDate", 2);
2150
+ __decorateClass$1([
2151
+ r()
2152
+ ], PatientProfileEdition.prototype, "patientAgeValue", 2);
2164
2153
  __decorateClass$1([
2165
2154
  r()
2166
2155
  ], PatientProfileEdition.prototype, "patientUnitAge", 2);
@@ -2176,9 +2165,6 @@ __decorateClass$1([
2176
2165
  __decorateClass$1([
2177
2166
  r()
2178
2167
  ], PatientProfileEdition.prototype, "dfg", 2);
2179
- __decorateClass$1([
2180
- r()
2181
- ], PatientProfileEdition.prototype, "defaultPatientUnitAge", 2);
2182
2168
  __decorateClass$1([
2183
2169
  r()
2184
2170
  ], PatientProfileEdition.prototype, "defaultPatientSex", 2);
@@ -2234,8 +2220,11 @@ __decorateClass$1([
2234
2220
  e$1("#sizeInput")
2235
2221
  ], PatientProfileEdition.prototype, "sizeInput", 2);
2236
2222
  __decorateClass$1([
2237
- e$1("#ageInput")
2238
- ], PatientProfileEdition.prototype, "ageInput", 2);
2223
+ e$1("#ageInputText")
2224
+ ], PatientProfileEdition.prototype, "ageInputText", 2);
2225
+ __decorateClass$1([
2226
+ e$1("#birthDateInput")
2227
+ ], PatientProfileEdition.prototype, "birthDateInput", 2);
2239
2228
  __decorateClass$1([
2240
2229
  e$1("#weightInput")
2241
2230
  ], PatientProfileEdition.prototype, "weightInput", 2);
@@ -2263,9 +2252,6 @@ __decorateClass$1([
2263
2252
  __decorateClass$1([
2264
2253
  e$1("#hepaticStadeSelect")
2265
2254
  ], PatientProfileEdition.prototype, "hepaticStadeSelect", 2);
2266
- __decorateClass$1([
2267
- e$1("#ageUnitSelect")
2268
- ], PatientProfileEdition.prototype, "ageUnitSelect", 2);
2269
2255
  PatientProfileEdition = __decorateClass$1([
2270
2256
  t("bcb-patient-profile-edition")
2271
2257
  ], PatientProfileEdition);
@@ -2286,8 +2272,8 @@ let PatientProfile = class extends i$2 {
2286
2272
  this.apiUrl = "https://api-dev.claudebernard.fr";
2287
2273
  this.preferences = {
2288
2274
  forms: {
2289
- age: { display: true, readOnly: true },
2290
- sexe: { display: true, readOnly: true }
2275
+ age: { display: true, readOnly: false },
2276
+ sexe: { display: true, readOnly: false }
2291
2277
  }
2292
2278
  };
2293
2279
  this.moreInformationVisible = false;
@@ -0,0 +1,4 @@
1
+ import { UserConfig } from 'vite';
2
+ declare const _default: UserConfig;
3
+ export default _default;
4
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";;AAWA,wBA8CG"}
@@ -0,0 +1 @@
1
+ /// <reference types="@vitest/browser-playwright" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claudebernard/patient-profile-element",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "main": "dist/patient-profile.es.js",
5
5
  "module": "dist/patient-profile.es.js",
6
6
  "types": "dist/patient-profile.d.ts",
@@ -50,9 +50,9 @@
50
50
  "@custom-elements-manifest/analyzer": "^0.11.0",
51
51
  "@hey-api/openapi-ts": "^0.99.0",
52
52
  "@lit/localize-tools": "^0.8.0",
53
- "@playwright/test": "^1.58.1",
53
+ "@playwright/test": "1.61.1",
54
54
  "@storybook/addon-a11y": "^10.2.11",
55
- "@storybook/addon-coverage": "^3.0.0",
55
+ "@storybook/addon-coverage": "^3.0.2",
56
56
  "@storybook/addon-docs": "^10.2.11",
57
57
  "@storybook/addon-links": "^10.2.11",
58
58
  "@storybook/addon-vitest": "^10.2.11",
@@ -62,17 +62,17 @@
62
62
  "@types/fhir": "^0.0.41",
63
63
  "@types/he": "^1.2.3",
64
64
  "@types/node": "^24.9.2",
65
- "@typescript-eslint/eslint-plugin": "8.64.0",
66
- "@typescript-eslint/parser": "8.64.0",
65
+ "@typescript-eslint/eslint-plugin": "8.65.0",
66
+ "@typescript-eslint/parser": "8.65.0",
67
67
  "@vitest/browser-playwright": "^4.0.5",
68
68
  "@vitest/coverage-v8": "^4.0.5",
69
69
  "@webcomponents/webcomponentsjs": "^2.8.0",
70
- "eslint": "^9.38.0",
71
- "eslint-plugin-import": "2.32.0",
70
+ "eslint": "^10.0.0",
71
+ "eslint-plugin-import-x": "^4.17.1",
72
72
  "eslint-plugin-lit": "^2.1.1",
73
73
  "eslint-plugin-storybook": "^10.2.11",
74
74
  "lit-analyzer": "^2.0.3",
75
- "playwright": "^1.58.1",
75
+ "playwright": "1.61.1",
76
76
  "sass": "^1.79.4",
77
77
  "storybook": "^10.2.11",
78
78
  "ts-lit-plugin": "^2.0.2",
@@ -80,8 +80,7 @@
80
80
  "tslib": "^2.6.2",
81
81
  "typescript": "~5.9.0",
82
82
  "vite": "^7.1.12",
83
- "vite-plugin-dts": "^4.5.4",
84
- "vite-svg-sprite-wrapper": "1.5.0",
83
+ "vite-plugin-dts": "^5.0.3",
85
84
  "vitest": "^4.0.7"
86
85
  },
87
86
  "peerDependencies": {
@@ -149,8 +148,11 @@
149
148
  ]
150
149
  },
151
150
  "overrides": {
152
- "@microsoft/api-extractor": {
153
- "minimatch": "^10.2.2"
151
+ "esbuild": "0.28.1",
152
+ "js-yaml@4.2.0": "^4.3.0",
153
+ "@storybook/addon-coverage": {
154
+ "test-exclude": "^8.0.0",
155
+ "vite-plugin-istanbul": "^9.0.1"
154
156
  }
155
157
  }
156
158
  }