@ttn-shared/ui 1.0.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -331,24 +331,24 @@ var PatientVoluntaryInsuranceForm = ({
331
331
  mode,
332
332
  form
333
333
  }) => {
334
- const { userAccountId } = useTTNSharedContext();
334
+ const { userInfo } = useTTNSharedContext();
335
335
  const insuranceInfo = form.values.voluntaryInsurance[index];
336
336
  const { data: companyTypes } = useCompanyTypes({
337
337
  filters: {
338
- eaccount: userAccountId,
338
+ eaccount: userInfo.accountId,
339
339
  status: "enabled"
340
340
  }
341
341
  });
342
342
  const { data: companyClients } = useCompanyClients({
343
343
  filters: {
344
- eaccount: userAccountId,
344
+ eaccount: userInfo.accountId,
345
345
  status: "enabled"
346
346
  }
347
347
  });
348
348
  const { data: contracts } = useContracts({
349
349
  enabled: Boolean(insuranceInfo.companyId),
350
350
  filters: {
351
- eaccount: userAccountId,
351
+ eaccount: userInfo.accountId,
352
352
  cType: "particular",
353
353
  client: Number(insuranceInfo.companyId) || void 0,
354
354
  status: "enabled"
@@ -357,7 +357,7 @@ var PatientVoluntaryInsuranceForm = ({
357
357
  const { data: contractPopulations } = useContractPopulations({
358
358
  enabled: Boolean(insuranceInfo.plan),
359
359
  filters: {
360
- eaccount: userAccountId,
360
+ eaccount: userInfo.accountId,
361
361
  contract: Number(insuranceInfo.plan) || void 0,
362
362
  status: "enabled"
363
363
  }
@@ -365,7 +365,7 @@ var PatientVoluntaryInsuranceForm = ({
365
365
  const { data: incomeGroups } = useIncomeGroups({
366
366
  enabled: Boolean(insuranceInfo.companyId),
367
367
  filters: {
368
- eaccount: userAccountId,
368
+ eaccount: userInfo.accountId,
369
369
  corpclientId: Number(insuranceInfo.companyId) || void 0
370
370
  }
371
371
  });
@@ -613,7 +613,7 @@ var PatientNotes = ({
613
613
  closeOnSave = true,
614
614
  onAttemptRemoveNote
615
615
  }) => {
616
- const { userId, userName } = useTTNSharedContext();
616
+ const { userInfo } = useTTNSharedContext();
617
617
  const [comment, setComment] = useState("");
618
618
  const { data: notes } = useComments({
619
619
  enabled: isOpen && Boolean(patientId),
@@ -624,7 +624,7 @@ var PatientNotes = ({
624
624
  const handleAddNote = async () => {
625
625
  await createComment2({
626
626
  entity: "userClient",
627
- userId: userId ?? 0,
627
+ userId: userInfo.id ?? 0,
628
628
  comment,
629
629
  id: patientId ?? 0
630
630
  });
@@ -673,7 +673,7 @@ var PatientNotes = ({
673
673
  !notes?.length && /* @__PURE__ */ jsx3(Text, { c: "dimmed", ta: "center", children: "No hay notas disponibles." })
674
674
  ] }),
675
675
  /* @__PURE__ */ jsx3(Box, { p: "lg", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsxs2(Paper2, { withBorder: true, p: "md", bg: "brand-color.0", shadow: "none", children: [
676
- /* @__PURE__ */ jsx3(Text, { c: "brand-color", children: userName }),
676
+ /* @__PURE__ */ jsx3(Text, { c: "brand-color", children: userInfo.name }),
677
677
  /* @__PURE__ */ jsx3(
678
678
  Textarea,
679
679
  {
@@ -779,13 +779,13 @@ var PatientAdministrativeRisks = ({
779
779
  isOpen,
780
780
  onClose
781
781
  }) => {
782
- const { userAccountId } = useTTNSharedContext();
782
+ const { userInfo } = useTTNSharedContext();
783
783
  const [riskValue, setRiskValue] = useState2(null);
784
784
  const [selectedRisks, setSelectedRisks] = useState2([]);
785
785
  const { data: patientInfo } = usePatientDetail({
786
786
  enabled: Boolean(patientId) && isOpen,
787
787
  filters: {
788
- eaccount: userAccountId,
788
+ eaccount: userInfo.accountId,
789
789
  id: patientId
790
790
  }
791
791
  });
@@ -798,7 +798,7 @@ var PatientAdministrativeRisks = ({
798
798
  const { mutateAsync: updateRisks2 } = useUpdateRisks();
799
799
  const handleSaveRisks = async () => {
800
800
  await updateRisks2({
801
- eaccount: userAccountId ?? 0,
801
+ eaccount: userInfo.accountId ?? 0,
802
802
  idPatient: patientId ?? 0,
803
803
  riskList: {
804
804
  administrative: selectedRisks
@@ -932,13 +932,13 @@ var PatientAssistanceRisks = ({
932
932
  isOpen,
933
933
  onClose
934
934
  }) => {
935
- const { userAccountId } = useTTNSharedContext();
935
+ const { userInfo } = useTTNSharedContext();
936
936
  const [riskValue, setRiskValue] = useState3(null);
937
937
  const [selectedRisks, setSelectedRisks] = useState3([]);
938
938
  const { data: patientInfo } = usePatientDetail({
939
939
  enabled: Boolean(patientId) && isOpen,
940
940
  filters: {
941
- eaccount: userAccountId,
941
+ eaccount: userInfo.accountId,
942
942
  id: patientId
943
943
  }
944
944
  });
@@ -962,7 +962,7 @@ var PatientAssistanceRisks = ({
962
962
  };
963
963
  const handleSaveRisks = async () => {
964
964
  await updateRisks2({
965
- eaccount: userAccountId ?? 0,
965
+ eaccount: userInfo.accountId ?? 0,
966
966
  idPatient: patientId ?? 0,
967
967
  riskList: {
968
968
  assistance: selectedRisks.map((risk) => ({ id: risk.clinicalDiseaseId }))
@@ -1204,7 +1204,7 @@ function AppPagination(props) {
1204
1204
  // src/components/PatientAppointmentHistory.tsx
1205
1205
  import { Fragment, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1206
1206
  var PatientAppointmentHistory = ({ patientId }) => {
1207
- const { userAccountId } = useTTNSharedContext();
1207
+ const { userInfo } = useTTNSharedContext();
1208
1208
  const [currentPage, setCurrentPage] = useState4(1);
1209
1209
  const [selectedAppointment, setSelectedAppointment] = useState4();
1210
1210
  const { data: appointments, rowTotal } = useAppointments({
@@ -1213,7 +1213,7 @@ var PatientAppointmentHistory = ({ patientId }) => {
1213
1213
  idPatient: patientId,
1214
1214
  page: currentPage,
1215
1215
  perpage: 10,
1216
- idAccount: userAccountId ?? 0
1216
+ idAccount: userInfo.accountId ?? 0
1217
1217
  }
1218
1218
  });
1219
1219
  return /* @__PURE__ */ jsxs6(Fragment, { children: [
@@ -1460,11 +1460,16 @@ var PatientForm = ({
1460
1460
  defaultMode,
1461
1461
  patientId,
1462
1462
  policyContent,
1463
+ disabledFields,
1463
1464
  onSavePatient,
1464
1465
  onSaveError,
1465
1466
  onBack
1466
1467
  }) => {
1467
- const { userAccountId } = useTTNSharedContext();
1468
+ const { userInfo } = useTTNSharedContext();
1469
+ const disabledFieldSet = useMemo4(() => new Set(disabledFields ?? []), [disabledFields]);
1470
+ const isFieldDisabled = (field) => disabledFieldSet.has(field);
1471
+ const isMandatoryInsuranceDisabled = isFieldDisabled("mandatoryInsurance");
1472
+ const isVoluntaryInsuranceDisabled = isFieldDisabled("voluntaryInsurance");
1468
1473
  const [mode, setMode] = useState5(defaultMode);
1469
1474
  const [openPatientNotes, setOpenPatientNotes] = useState5(false);
1470
1475
  const [openPatientAssistanceRisks, setOpenPatientAssistanceRisks] = useState5(false);
@@ -1524,16 +1529,16 @@ var PatientForm = ({
1524
1529
  const { data: patientInfo, refetch: refetchPatientInfo } = usePatientDetail({
1525
1530
  enabled: Boolean(patientId) && mode !== "create",
1526
1531
  filters: {
1527
- eaccount: userAccountId,
1532
+ eaccount: userInfo.accountId,
1528
1533
  id: patientId
1529
1534
  }
1530
1535
  });
1531
1536
  const { data: documentTypes } = useDocumentTypes({});
1532
1537
  const { data: affiliationTypes } = useAffiliationTypes({
1533
- filters: { eaccount: userAccountId }
1538
+ filters: { eaccount: userInfo.accountId }
1534
1539
  });
1535
1540
  const { data: provinces } = useProvinces({
1536
- filters: { eaccount: userAccountId }
1541
+ filters: { eaccount: userInfo.accountId }
1537
1542
  });
1538
1543
  const { data: cities } = useCities({
1539
1544
  enabled: Boolean(form.values.provinceId),
@@ -1541,32 +1546,32 @@ var PatientForm = ({
1541
1546
  });
1542
1547
  const { data: stratums } = useStratums({});
1543
1548
  const { data: ethnicGroups } = useEthnicGroups({
1544
- filters: { eaccount: userAccountId }
1549
+ filters: { eaccount: userInfo.accountId }
1545
1550
  });
1546
1551
  const { data: educationLevels } = useEducationLevels({
1547
- filters: { eaccount: userAccountId }
1552
+ filters: { eaccount: userInfo.accountId }
1548
1553
  });
1549
1554
  const { data: companyClients } = useCompanyClients({
1550
- filters: { eaccount: userAccountId }
1555
+ filters: { eaccount: userInfo.accountId }
1551
1556
  });
1552
1557
  const { data: contracts } = useContracts({
1553
1558
  enabled: Boolean(form.values.mandatoryInsurance.companyId),
1554
1559
  filters: {
1555
- eaccount: userAccountId,
1560
+ eaccount: userInfo.accountId,
1556
1561
  client: Number(form.values.mandatoryInsurance.companyId) || void 0
1557
1562
  }
1558
1563
  });
1559
1564
  const { data: contractPopulations } = useContractPopulations({
1560
1565
  enabled: Boolean(form.values.mandatoryInsurance.plan),
1561
1566
  filters: {
1562
- eaccount: userAccountId,
1567
+ eaccount: userInfo.accountId,
1563
1568
  contract: Number(form.values.mandatoryInsurance.plan) || void 0
1564
1569
  }
1565
1570
  });
1566
1571
  const { data: incomeGroups } = useIncomeGroups({
1567
1572
  enabled: Boolean(form.values.mandatoryInsurance.companyId),
1568
1573
  filters: {
1569
- eaccount: userAccountId,
1574
+ eaccount: userInfo.accountId,
1570
1575
  corpclientId: Number(form.values.mandatoryInsurance.companyId) || void 0
1571
1576
  }
1572
1577
  });
@@ -1604,10 +1609,6 @@ var PatientForm = ({
1604
1609
  value: values.affiliationTypeId,
1605
1610
  message: "El campo Tipo de afiliado es obligatorio."
1606
1611
  },
1607
- {
1608
- value: values.maritalStatus,
1609
- message: "El campo Estado civil es obligatorio."
1610
- },
1611
1612
  {
1612
1613
  value: values.provinceId,
1613
1614
  message: "El campo Departamento es obligatorio."
@@ -1848,7 +1849,7 @@ var PatientForm = ({
1848
1849
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1849
1850
  Select4,
1850
1851
  {
1851
- readOnly: mode === "view",
1852
+ readOnly: mode === "view" || isFieldDisabled("documentTypeId"),
1852
1853
  withAsterisk: mode !== "view",
1853
1854
  label: "Tipo de Documento",
1854
1855
  data: documentTypeOptions,
@@ -1859,7 +1860,7 @@ var PatientForm = ({
1859
1860
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1860
1861
  TextInput3,
1861
1862
  {
1862
- readOnly: mode === "view",
1863
+ readOnly: mode === "view" || isFieldDisabled("documentNumber"),
1863
1864
  withAsterisk: mode !== "view",
1864
1865
  label: "N\xFAmero de Documento",
1865
1866
  ...form.getInputProps("documentNumber"),
@@ -1869,7 +1870,7 @@ var PatientForm = ({
1869
1870
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1870
1871
  TextInput3,
1871
1872
  {
1872
- readOnly: mode === "view",
1873
+ readOnly: mode === "view" || isFieldDisabled("firstName"),
1873
1874
  withAsterisk: mode !== "view",
1874
1875
  label: "Primer Nombre",
1875
1876
  ...form.getInputProps("firstName"),
@@ -1879,7 +1880,7 @@ var PatientForm = ({
1879
1880
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1880
1881
  TextInput3,
1881
1882
  {
1882
- readOnly: mode === "view",
1883
+ readOnly: mode === "view" || isFieldDisabled("middleName"),
1883
1884
  label: "Segundo Nombre",
1884
1885
  ...form.getInputProps("middleName"),
1885
1886
  "data-testid": "patient-form-middle-name-input"
@@ -1888,7 +1889,7 @@ var PatientForm = ({
1888
1889
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1889
1890
  TextInput3,
1890
1891
  {
1891
- readOnly: mode === "view",
1892
+ readOnly: mode === "view" || isFieldDisabled("surname"),
1892
1893
  withAsterisk: mode !== "view",
1893
1894
  label: "Primer Apellido",
1894
1895
  ...form.getInputProps("surname"),
@@ -1898,7 +1899,7 @@ var PatientForm = ({
1898
1899
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1899
1900
  TextInput3,
1900
1901
  {
1901
- readOnly: mode === "view",
1902
+ readOnly: mode === "view" || isFieldDisabled("secondSurname"),
1902
1903
  label: "Segundo Apellido",
1903
1904
  ...form.getInputProps("secondSurname"),
1904
1905
  "data-testid": "patient-form-second-surname-input"
@@ -1907,7 +1908,7 @@ var PatientForm = ({
1907
1908
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1908
1909
  TextInput3,
1909
1910
  {
1910
- readOnly: mode === "view",
1911
+ readOnly: mode === "view" || isFieldDisabled("birthDate"),
1911
1912
  withAsterisk: mode !== "view",
1912
1913
  label: "Fecha de Nacimiento",
1913
1914
  type: "date",
@@ -1918,7 +1919,8 @@ var PatientForm = ({
1918
1919
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1919
1920
  NumberInput,
1920
1921
  {
1921
- readOnly: true,
1922
+ readOnly: isFieldDisabled("age"),
1923
+ disabled: true,
1922
1924
  label: "Edad",
1923
1925
  suffix: !form.values.age ? "" : " a\xF1os",
1924
1926
  ...form.getInputProps("age"),
@@ -1928,7 +1930,7 @@ var PatientForm = ({
1928
1930
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1929
1931
  NumberInput,
1930
1932
  {
1931
- readOnly: mode === "view",
1933
+ readOnly: mode === "view" || isFieldDisabled("whatsapp"),
1932
1934
  withAsterisk: mode !== "view",
1933
1935
  label: "WhatsApp",
1934
1936
  allowNegative: false,
@@ -1940,7 +1942,7 @@ var PatientForm = ({
1940
1942
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1941
1943
  Select4,
1942
1944
  {
1943
- readOnly: mode === "view",
1945
+ readOnly: mode === "view" || isFieldDisabled("gender"),
1944
1946
  withAsterisk: mode !== "view",
1945
1947
  label: "G\xE9nero",
1946
1948
  data: genderOptions,
@@ -1951,7 +1953,7 @@ var PatientForm = ({
1951
1953
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1952
1954
  Select4,
1953
1955
  {
1954
- readOnly: mode === "view",
1956
+ readOnly: mode === "view" || isFieldDisabled("affiliationTypeId"),
1955
1957
  withAsterisk: mode !== "view",
1956
1958
  label: "Tipo de afiliaci\xF3n",
1957
1959
  data: affiliationTypeOptions,
@@ -1962,7 +1964,7 @@ var PatientForm = ({
1962
1964
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1963
1965
  TextInput3,
1964
1966
  {
1965
- readOnly: mode === "view",
1967
+ readOnly: mode === "view" || isFieldDisabled("email"),
1966
1968
  label: "Correo electr\xF3nico",
1967
1969
  ...form.getInputProps("email"),
1968
1970
  "data-testid": "patient-form-email-input"
@@ -1971,8 +1973,7 @@ var PatientForm = ({
1971
1973
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
1972
1974
  Select4,
1973
1975
  {
1974
- readOnly: mode === "view",
1975
- withAsterisk: mode !== "view",
1976
+ readOnly: mode === "view" || isFieldDisabled("maritalStatus"),
1976
1977
  label: "Estado civil",
1977
1978
  data: maritalStatusOptions,
1978
1979
  ...form.getInputProps("maritalStatus"),
@@ -1982,7 +1983,7 @@ var PatientForm = ({
1982
1983
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 12, mt: "sm", children: /* @__PURE__ */ jsx9(
1983
1984
  Checkbox,
1984
1985
  {
1985
- disabled: mode === "view",
1986
+ readOnly: mode === "view" || isFieldDisabled("isDataPolicyAccepted"),
1986
1987
  label: /* @__PURE__ */ jsxs8(Text6, { fz: "sm", children: [
1987
1988
  "Autorizo el tratamiento de mis datos personales conforme a la",
1988
1989
  " ",
@@ -2011,7 +2012,7 @@ var PatientForm = ({
2011
2012
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2012
2013
  Select4,
2013
2014
  {
2014
- readOnly: mode === "view",
2015
+ readOnly: mode === "view" || isFieldDisabled("provinceId"),
2015
2016
  withAsterisk: mode !== "view",
2016
2017
  label: "Departamento",
2017
2018
  data: provinceOptions,
@@ -2026,7 +2027,7 @@ var PatientForm = ({
2026
2027
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2027
2028
  Select4,
2028
2029
  {
2029
- readOnly: mode === "view",
2030
+ readOnly: mode === "view" || isFieldDisabled("cityId"),
2030
2031
  withAsterisk: mode !== "view",
2031
2032
  label: "Municipio",
2032
2033
  data: cityOptions,
@@ -2037,7 +2038,7 @@ var PatientForm = ({
2037
2038
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2038
2039
  TextInput3,
2039
2040
  {
2040
- readOnly: mode === "view",
2041
+ readOnly: mode === "view" || isFieldDisabled("homeAddress"),
2041
2042
  label: "Direcci\xF3n",
2042
2043
  ...form.getInputProps("homeAddress"),
2043
2044
  "data-testid": "patient-form-home-address-input"
@@ -2046,7 +2047,7 @@ var PatientForm = ({
2046
2047
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2047
2048
  Select4,
2048
2049
  {
2049
- readOnly: mode === "view",
2050
+ readOnly: mode === "view" || isFieldDisabled("bloodType"),
2050
2051
  label: "Grupo sangu\xEDneo",
2051
2052
  data: bloodTypeOptions,
2052
2053
  ...form.getInputProps("bloodType"),
@@ -2056,7 +2057,7 @@ var PatientForm = ({
2056
2057
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2057
2058
  NumberInput,
2058
2059
  {
2059
- readOnly: mode === "view",
2060
+ readOnly: mode === "view" || isFieldDisabled("cellphone"),
2060
2061
  withAsterisk: mode !== "view",
2061
2062
  label: "Celular",
2062
2063
  allowNegative: false,
@@ -2069,7 +2070,7 @@ var PatientForm = ({
2069
2070
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2070
2071
  NumberInput,
2071
2072
  {
2072
- readOnly: mode === "view",
2073
+ readOnly: mode === "view" || isFieldDisabled("homephone"),
2073
2074
  label: "Tel\xE9fono fijo",
2074
2075
  allowNegative: false,
2075
2076
  allowDecimal: false,
@@ -2081,7 +2082,7 @@ var PatientForm = ({
2081
2082
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2082
2083
  Select4,
2083
2084
  {
2084
- readOnly: mode === "view",
2085
+ readOnly: mode === "view" || isFieldDisabled("stratumId"),
2085
2086
  withAsterisk: mode !== "view",
2086
2087
  label: "Estrato",
2087
2088
  data: stratumOptions,
@@ -2092,7 +2093,7 @@ var PatientForm = ({
2092
2093
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2093
2094
  Select4,
2094
2095
  {
2095
- readOnly: mode === "view",
2096
+ readOnly: mode === "view" || isFieldDisabled("ethnicGroupId"),
2096
2097
  withAsterisk: mode !== "view",
2097
2098
  label: "Pertenencia \xE9tnica",
2098
2099
  data: ethnicGroupOptions,
@@ -2103,7 +2104,7 @@ var PatientForm = ({
2103
2104
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2104
2105
  Select4,
2105
2106
  {
2106
- readOnly: mode === "view",
2107
+ readOnly: mode === "view" || isFieldDisabled("educationLevelId"),
2107
2108
  withAsterisk: mode !== "view",
2108
2109
  label: "Nivel educativo",
2109
2110
  data: educationLevelOptions,
@@ -2118,6 +2119,7 @@ var PatientForm = ({
2118
2119
  Select4,
2119
2120
  {
2120
2121
  readOnly: mode === "view",
2122
+ disabled: isMandatoryInsuranceDisabled,
2121
2123
  withAsterisk: mode !== "view",
2122
2124
  label: "Seguro",
2123
2125
  data: companyClientOptions,
@@ -2136,6 +2138,7 @@ var PatientForm = ({
2136
2138
  Select4,
2137
2139
  {
2138
2140
  readOnly: mode === "view",
2141
+ disabled: isMandatoryInsuranceDisabled,
2139
2142
  withAsterisk: mode !== "view",
2140
2143
  label: "Plan",
2141
2144
  data: contractOptions,
@@ -2153,6 +2156,7 @@ var PatientForm = ({
2153
2156
  Select4,
2154
2157
  {
2155
2158
  readOnly: mode === "view",
2159
+ disabled: isMandatoryInsuranceDisabled,
2156
2160
  withAsterisk: mode !== "view",
2157
2161
  label: "Poblaci\xF3n",
2158
2162
  data: contractPopulationOptions,
@@ -2164,6 +2168,7 @@ var PatientForm = ({
2164
2168
  Select4,
2165
2169
  {
2166
2170
  readOnly: mode === "view",
2171
+ disabled: isMandatoryInsuranceDisabled,
2167
2172
  withAsterisk: mode !== "view",
2168
2173
  label: "Grupo de ingreso",
2169
2174
  data: incomeGroupOptions,
@@ -2174,7 +2179,8 @@ var PatientForm = ({
2174
2179
  /* @__PURE__ */ jsx9(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx9(
2175
2180
  TextInput3,
2176
2181
  {
2177
- readOnly: mode === "view",
2182
+ readOnly: mode === "view" || isMandatoryInsuranceDisabled,
2183
+ disabled: isMandatoryInsuranceDisabled,
2178
2184
  label: "N\xFAmero de p\xF3liza",
2179
2185
  ...form.getInputProps("mandatoryInsurance.policyNumber"),
2180
2186
  "data-testid": "patient-form-mandatory-insurance-policy-number-input"
@@ -2187,7 +2193,7 @@ var PatientForm = ({
2187
2193
  PatientVoluntaryInsuranceForm,
2188
2194
  {
2189
2195
  index,
2190
- mode,
2196
+ mode: isVoluntaryInsuranceDisabled ? "view" : mode,
2191
2197
  form
2192
2198
  },
2193
2199
  insurance.id ?? index
@@ -2198,6 +2204,7 @@ var PatientForm = ({
2198
2204
  variant: "outline",
2199
2205
  color: "secondary",
2200
2206
  size: "xs",
2207
+ disabled: isVoluntaryInsuranceDisabled,
2201
2208
  onClick: handleAddVoluntaryInsurance,
2202
2209
  leftSection: /* @__PURE__ */ jsx9(IconPlus, { style: { width: 16, height: 16 } }),
2203
2210
  "data-testid": "patient-form-add-voluntary-insurance-button",
@@ -2354,12 +2361,354 @@ var createPatientForm = (info) => {
2354
2361
  }))
2355
2362
  };
2356
2363
  };
2364
+
2365
+ // src/components/header/Header.tsx
2366
+ import * as MC3 from "@mantine/core";
2367
+ import * as TI4 from "@tabler/icons-react";
2368
+ import { useMemo as useMemo5, useState as useState6 } from "react";
2369
+
2370
+ // src/components/header/HelpModal.tsx
2371
+ import * as MC from "@mantine/core";
2372
+ import * as TI2 from "@tabler/icons-react";
2373
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
2374
+ var HelpModal = ({ opened, onClose, enterpriseLogo }) => {
2375
+ return /* @__PURE__ */ jsxs9(MC.Modal, { title: "Ayuda", opened, onClose, "data-testid": "header-help-modal", children: [
2376
+ /* @__PURE__ */ jsxs9(MC.Stack, { mb: "lg", align: "center", children: [
2377
+ enterpriseLogo,
2378
+ /* @__PURE__ */ jsx10(MC.Text, { fz: "lg", fw: "bold", children: "Informaci\xF3n de contacto" }),
2379
+ /* @__PURE__ */ jsxs9(MC.Stack, { children: [
2380
+ /* @__PURE__ */ jsxs9(MC.Group, { children: [
2381
+ /* @__PURE__ */ jsx10(MC.ThemeIcon, { variant: "transparent", c: "primary-color", children: /* @__PURE__ */ jsx10(TI2.IconPhone, { style: { width: 24, height: 24 } }) }),
2382
+ /* @__PURE__ */ jsx10(MC.Text, { fz: "xs", children: "+57 300 658 32 65" })
2383
+ ] }),
2384
+ /* @__PURE__ */ jsxs9(MC.Group, { children: [
2385
+ /* @__PURE__ */ jsx10(MC.ThemeIcon, { variant: "transparent", c: "primary-color", children: /* @__PURE__ */ jsx10(TI2.IconMail, { style: { width: 24, height: 24 } }) }),
2386
+ /* @__PURE__ */ jsx10(MC.Text, { fz: "xs", children: "analistadesoporte@ttncompany.com" })
2387
+ ] }),
2388
+ /* @__PURE__ */ jsxs9(MC.Group, { children: [
2389
+ /* @__PURE__ */ jsx10(MC.ThemeIcon, { variant: "transparent", c: "primary-color", children: /* @__PURE__ */ jsx10(TI2.IconMapPin, { style: { width: 24, height: 24 } }) }),
2390
+ /* @__PURE__ */ jsx10(MC.Text, { fz: "xs", children: "Carrera 51b # 87 - 50 Piso 3 Local 337" })
2391
+ ] })
2392
+ ] })
2393
+ ] }),
2394
+ /* @__PURE__ */ jsx10(MC.Group, { justify: "end", mt: "xl", children: /* @__PURE__ */ jsx10(
2395
+ MC.Button,
2396
+ {
2397
+ onClick: onClose,
2398
+ size: "sm",
2399
+ px: "xl",
2400
+ color: "brand-color",
2401
+ "data-testid": "header-help-accept-button",
2402
+ children: "Aceptar"
2403
+ }
2404
+ ) })
2405
+ ] });
2406
+ };
2407
+
2408
+ // src/components/header/ChangeAccountModal.tsx
2409
+ import * as MC2 from "@mantine/core";
2410
+ import * as TI3 from "@tabler/icons-react";
2411
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
2412
+ var ChangeAccountModal = ({
2413
+ opened,
2414
+ onClose,
2415
+ accounts,
2416
+ onChangeAccount
2417
+ }) => {
2418
+ return /* @__PURE__ */ jsx11(MC2.Modal, { opened, onClose, size: 1200, title: "Cambiar cuenta", children: /* @__PURE__ */ jsx11(MC2.Grid, { px: "lg", children: accounts.map((account, accountIndex) => /* @__PURE__ */ jsx11(MC2.Grid.Col, { span: 6, children: /* @__PURE__ */ jsxs10(MC2.Menu, { position: "right", width: 210, children: [
2419
+ /* @__PURE__ */ jsx11(MC2.Menu.Target, { "data-testid": `change-account-account-option-${accountIndex}`, children: /* @__PURE__ */ jsxs10(
2420
+ MC2.Group,
2421
+ {
2422
+ w: 216,
2423
+ h: 100,
2424
+ justify: "space-between",
2425
+ align: "center",
2426
+ style: (theme) => ({
2427
+ border: `1px solid ${theme.colors.gray[3]}`,
2428
+ borderRadius: theme.radius.md,
2429
+ padding: "8px",
2430
+ cursor: "pointer"
2431
+ }),
2432
+ children: [
2433
+ /* @__PURE__ */ jsx11("div", {}),
2434
+ /* @__PURE__ */ jsx11(MC2.Text, { fw: "bold", tt: "uppercase", children: account.name }),
2435
+ /* @__PURE__ */ jsx11(MC2.ThemeIcon, { variant: "transparent", c: "dimmed", children: /* @__PURE__ */ jsx11(TI3.IconChevronRight, { style: { width: 32, height: 32 } }) })
2436
+ ]
2437
+ }
2438
+ ) }),
2439
+ /* @__PURE__ */ jsx11(MC2.Menu.Dropdown, { p: 0, children: account.profiles.map((profile, profileIndex) => /* @__PURE__ */ jsx11(
2440
+ MC2.Menu.Item,
2441
+ {
2442
+ ta: "center",
2443
+ tt: "uppercase",
2444
+ py: "xs",
2445
+ onClick: () => {
2446
+ onChangeAccount(account, profile);
2447
+ onClose();
2448
+ },
2449
+ style: (theme) => ({
2450
+ borderRadius: 0,
2451
+ borderBottom: profileIndex !== account.profiles.length - 1 ? `1px solid ${theme.colors.gray[3]}` : void 0
2452
+ }),
2453
+ "data-testid": `change-account-profile-option-${accountIndex}-${profileIndex}`,
2454
+ children: profile.name
2455
+ },
2456
+ profile.id
2457
+ )) })
2458
+ ] }) }, account.id)) }) });
2459
+ };
2460
+
2461
+ // src/components/header/Header.tsx
2462
+ import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
2463
+ var Header = ({
2464
+ moduleName,
2465
+ logo,
2466
+ enterpriseLogo,
2467
+ accounts,
2468
+ currentSite,
2469
+ onBackHome,
2470
+ onChangeAccount,
2471
+ onClickMyPayroll,
2472
+ onClickSettings,
2473
+ onLogout
2474
+ }) => {
2475
+ const { userInfo } = useTTNSharedContext();
2476
+ const [changeAccountModalOpened, setChangeAccountModalOpened] = useState6(false);
2477
+ const [helpModalOpened, setHelpModalOpened] = useState6(false);
2478
+ const { currentAccount, currentProfile } = useMemo5(() => {
2479
+ if (!userInfo.accountId || !userInfo.profileId) {
2480
+ return { currentAccount: void 0, currentProfile: void 0 };
2481
+ }
2482
+ const currentAccount2 = accounts.find((account) => account.id === userInfo.accountId);
2483
+ const currentProfile2 = currentAccount2?.profiles.find(
2484
+ (profile) => profile.id === userInfo.profileId
2485
+ );
2486
+ return { currentAccount: currentAccount2, currentProfile: currentProfile2 };
2487
+ }, [accounts, userInfo]);
2488
+ return /* @__PURE__ */ jsxs11(Fragment3, { children: [
2489
+ /* @__PURE__ */ jsxs11(MC3.Flex, { w: "100%", px: 16, py: 6, justify: "space-between", align: "center", children: [
2490
+ /* @__PURE__ */ jsxs11(MC3.Group, { children: [
2491
+ /* @__PURE__ */ jsx12(MC3.UnstyledButton, { onClick: onBackHome, "data-testid": "header-logo-button", children: logo }),
2492
+ /* @__PURE__ */ jsxs11(MC3.Title, { order: 3, c: "gray.4", fw: "inherit", children: [
2493
+ "\u2022 ",
2494
+ moduleName
2495
+ ] })
2496
+ ] }),
2497
+ /* @__PURE__ */ jsxs11(MC3.Flex, { gap: "sm", children: [
2498
+ Boolean(currentSite) && /* @__PURE__ */ jsxs11(MC3.Flex, { align: "center", children: [
2499
+ /* @__PURE__ */ jsx12(MC3.ThemeIcon, { variant: "transparent", c: "dimmed", children: /* @__PURE__ */ jsx12(TI4.IconMapPinFilled, { style: { width: 24, height: 24 } }) }),
2500
+ /* @__PURE__ */ jsx12(MC3.Text, { c: "gray.6", fz: "sm", children: currentSite?.name })
2501
+ ] }),
2502
+ /* @__PURE__ */ jsxs11(MC3.Menu, { width: 216, position: "bottom-end", children: [
2503
+ /* @__PURE__ */ jsx12(MC3.Menu.Target, { "data-testid": "header-account-menu-button", children: /* @__PURE__ */ jsxs11(
2504
+ MC3.Box,
2505
+ {
2506
+ w: 216,
2507
+ style: (theme) => ({
2508
+ display: "flex",
2509
+ alignItems: "center",
2510
+ border: `1px solid ${theme.colors.gray[3]}`,
2511
+ borderRadius: theme.radius.sm,
2512
+ padding: "4px 8px",
2513
+ cursor: "pointer"
2514
+ }),
2515
+ children: [
2516
+ Boolean(currentAccount) && /* @__PURE__ */ jsx12(MC3.ThemeIcon, { variant: "transparent", c: "primary-color", size: "lg", children: /* @__PURE__ */ jsx12(TI4.IconBuilding, { style: { width: 24, height: 24 } }) }),
2517
+ /* @__PURE__ */ jsx12(MC3.Text, { ml: 6, flex: 1, children: currentAccount?.name }),
2518
+ /* @__PURE__ */ jsx12(MC3.Avatar, { src: userInfo?.imageUrl })
2519
+ ]
2520
+ }
2521
+ ) }),
2522
+ /* @__PURE__ */ jsxs11(MC3.Menu.Dropdown, { children: [
2523
+ /* @__PURE__ */ jsxs11(MC3.Stack, { px: "md", py: "sm", gap: "xs", align: "center", children: [
2524
+ /* @__PURE__ */ jsx12(MC3.Avatar, { src: userInfo?.imageUrl, size: "lg" }),
2525
+ /* @__PURE__ */ jsx12(MC3.Text, { fw: "bold", children: userInfo?.name }),
2526
+ /* @__PURE__ */ jsxs11(MC3.Text, { fw: "bold", ta: "center", c: "gray.4", children: [
2527
+ currentAccount?.name,
2528
+ " - ",
2529
+ currentProfile?.name
2530
+ ] })
2531
+ ] }),
2532
+ Boolean(currentAccount) && /* @__PURE__ */ jsxs11(Fragment3, { children: [
2533
+ /* @__PURE__ */ jsx12(
2534
+ MC3.Menu.Item,
2535
+ {
2536
+ onClick: () => setChangeAccountModalOpened(true),
2537
+ "data-testid": "header-change-account-menu-item",
2538
+ children: "Cambiar rol y cuenta"
2539
+ }
2540
+ ),
2541
+ /* @__PURE__ */ jsx12(
2542
+ MC3.Menu.Item,
2543
+ {
2544
+ onClick: onClickMyPayroll,
2545
+ "data-testid": "header-my-payroll-menu-item",
2546
+ children: "Mi n\xF3mina"
2547
+ }
2548
+ ),
2549
+ /* @__PURE__ */ jsx12(MC3.Menu.Item, { onClick: onClickSettings, "data-testid": "header-settings-menu-item", children: "Configuraci\xF3n" })
2550
+ ] }),
2551
+ /* @__PURE__ */ jsx12(
2552
+ MC3.Menu.Item,
2553
+ {
2554
+ onClick: () => setHelpModalOpened(true),
2555
+ "data-testid": "header-help-menu-item",
2556
+ children: "Ayuda"
2557
+ }
2558
+ ),
2559
+ /* @__PURE__ */ jsx12(MC3.Menu.Divider, {}),
2560
+ /* @__PURE__ */ jsx12(MC3.Menu.Item, { onClick: onLogout, "data-testid": "header-logout-menu-item", children: "Cerrar sesi\xF3n" })
2561
+ ] })
2562
+ ] })
2563
+ ] })
2564
+ ] }),
2565
+ /* @__PURE__ */ jsx12(
2566
+ ChangeAccountModal,
2567
+ {
2568
+ opened: changeAccountModalOpened,
2569
+ onClose: () => setChangeAccountModalOpened(false),
2570
+ accounts,
2571
+ onChangeAccount
2572
+ }
2573
+ ),
2574
+ /* @__PURE__ */ jsx12(
2575
+ HelpModal,
2576
+ {
2577
+ opened: helpModalOpened,
2578
+ onClose: () => setHelpModalOpened(false),
2579
+ enterpriseLogo
2580
+ }
2581
+ )
2582
+ ] });
2583
+ };
2584
+
2585
+ // src/components/sidebar/Sidebar.tsx
2586
+ import { useState as useState7 } from "react";
2587
+ import * as MC5 from "@mantine/core";
2588
+ import * as TI5 from "@tabler/icons-react";
2589
+
2590
+ // src/components/sidebar/SidebarMenu.tsx
2591
+ import * as MC4 from "@mantine/core";
2592
+ import { Fragment as Fragment4 } from "react/jsx-runtime";
2593
+ import { NavLink } from "react-router";
2594
+ import { Fragment as Fragment5, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
2595
+ var SidebarMenu = ({
2596
+ id,
2597
+ label,
2598
+ icon,
2599
+ active,
2600
+ screens,
2601
+ onClickMenu,
2602
+ onCloseSidebar,
2603
+ onClickExternalScreen
2604
+ }) => {
2605
+ return /* @__PURE__ */ jsxs12(Fragment5, { children: [
2606
+ /* @__PURE__ */ jsx13(
2607
+ MC4.UnstyledButton,
2608
+ {
2609
+ onClick: () => onClickMenu(id),
2610
+ className: "ttn-sidebar-menu",
2611
+ "data-testid": `sidebar-menu-${label}`,
2612
+ children: /* @__PURE__ */ jsxs12(MC4.Flex, { align: "center", children: [
2613
+ /* @__PURE__ */ jsx13(MC4.Center, { w: 40, h: 40, me: 10, children: /* @__PURE__ */ jsx13(
2614
+ MC4.Box,
2615
+ {
2616
+ className: "ttn-sidebar-menu-icon",
2617
+ style: { maskImage: `url(${icon})`, WebkitMaskImage: `url(${icon})` }
2618
+ }
2619
+ ) }),
2620
+ /* @__PURE__ */ jsx13(MC4.Text, { size: "sm", c: "gray.7", lineClamp: 1, children: label })
2621
+ ] })
2622
+ }
2623
+ ),
2624
+ Boolean(screens?.length) && /* @__PURE__ */ jsx13(MC4.Collapse, { in: active ?? false, children: screens?.map((screen) => /* @__PURE__ */ jsxs12(Fragment4, { children: [
2625
+ screen.external && /* @__PURE__ */ jsx13(MC4.Box, { onClick: () => onClickExternalScreen(screen), children: /* @__PURE__ */ jsx13(MC4.Text, { size: "sm", c: "gray.7", lineClamp: 1, children: screen.label }) }),
2626
+ !screen.external && /* @__PURE__ */ jsx13(
2627
+ NavLink,
2628
+ {
2629
+ to: screen.url || "#",
2630
+ onClick: onCloseSidebar,
2631
+ className: ({ isActive }) => isActive ? "ttn-sidebar-menu-item active" : "ttn-sidebar-menu-item",
2632
+ children: /* @__PURE__ */ jsx13(MC4.Text, { size: "sm", c: "gray.7", lineClamp: 1, children: screen.label })
2633
+ }
2634
+ )
2635
+ ] }, screen.id)) })
2636
+ ] });
2637
+ };
2638
+
2639
+ // src/components/sidebar/Sidebar.tsx
2640
+ import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
2641
+ var Sidebar = ({ modules, onClickExternalScreen }) => {
2642
+ const [opened, setOpened] = useState7(false);
2643
+ const [activeModuleId, setActiveModuleId] = useState7(null);
2644
+ const handleClickMenu = (id) => {
2645
+ setActiveModuleId(id === activeModuleId ? null : id);
2646
+ if (!opened) {
2647
+ setOpened(true);
2648
+ }
2649
+ };
2650
+ const handleCloseSidebar = () => {
2651
+ setActiveModuleId(null);
2652
+ setOpened(false);
2653
+ };
2654
+ const handleClickExternalScreen = (item) => {
2655
+ setActiveModuleId(null);
2656
+ setOpened(false);
2657
+ onClickExternalScreen(item);
2658
+ };
2659
+ return /* @__PURE__ */ jsxs13("aside", { className: opened ? "ttn-sidebar" : "ttn-sidebar closed", children: [
2660
+ /* @__PURE__ */ jsxs13(MC5.Flex, { direction: "column", justify: "center", h: 56, children: [
2661
+ opened && /* @__PURE__ */ jsx14(
2662
+ MC5.ActionIcon,
2663
+ {
2664
+ variant: "white",
2665
+ c: "gray.6",
2666
+ onClick: handleCloseSidebar,
2667
+ style: { alignSelf: "flex-end" },
2668
+ "data-testid": "sidebar-close-button",
2669
+ children: /* @__PURE__ */ jsx14(TI5.IconX, { style: { width: 20, height: 20 } })
2670
+ }
2671
+ ),
2672
+ !opened && /* @__PURE__ */ jsx14(MC5.Center, { w: 80, children: /* @__PURE__ */ jsx14(
2673
+ MC5.ActionIcon,
2674
+ {
2675
+ w: 32,
2676
+ h: 32,
2677
+ variant: "outline",
2678
+ radius: "xs",
2679
+ onClick: () => setOpened(true),
2680
+ style: { alignSelf: "flex-end", borderWidth: 2 },
2681
+ "data-testid": "sidebar-open-button",
2682
+ children: /* @__PURE__ */ jsx14(TI5.IconMenu2, { style: { width: 20, height: 20, strokeWidth: 2 } })
2683
+ }
2684
+ ) })
2685
+ ] }),
2686
+ modules.map((module) => /* @__PURE__ */ jsx14(
2687
+ SidebarMenu,
2688
+ {
2689
+ id: module.id,
2690
+ label: module.label,
2691
+ icon: module.icon,
2692
+ active: activeModuleId === module.id,
2693
+ screens: module.screens,
2694
+ onClickMenu: handleClickMenu,
2695
+ onCloseSidebar: handleCloseSidebar,
2696
+ onClickExternalScreen: handleClickExternalScreen
2697
+ },
2698
+ module.id
2699
+ ))
2700
+ ] });
2701
+ };
2357
2702
  export {
2703
+ ChangeAccountModal,
2704
+ Header,
2705
+ HelpModal,
2358
2706
  PatientAdministrativeRisks,
2359
2707
  PatientAppointmentHistory,
2360
2708
  PatientAssistanceRisks,
2361
2709
  PatientForm,
2362
2710
  PatientNotes,
2711
+ Sidebar,
2363
2712
  TTNSharedProvider,
2364
2713
  useTTNSharedContext
2365
2714
  };