@ttn-shared/ui 1.2.4 → 1.2.6

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.cjs CHANGED
@@ -314,7 +314,14 @@ var useIncomeGroups = ({
314
314
  }) => {
315
315
  const { token, baseUrl } = useTTNSharedContext();
316
316
  const query = (0, import_react_query.useQuery)({
317
- queryKey: ["income-groups", filters?.corpclientId, filters?.eaccount],
317
+ queryKey: [
318
+ "income-groups",
319
+ filters?.corpclientId,
320
+ filters?.contractId,
321
+ filters?.affiliationTypeId,
322
+ filters?.enabled,
323
+ filters?.eaccount
324
+ ],
318
325
  queryFn: () => getIncomeGroups(token, baseUrl, filters),
319
326
  enabled
320
327
  });
@@ -394,10 +401,13 @@ var PatientVoluntaryInsuranceForm = ({
394
401
  }
395
402
  });
396
403
  const { data: incomeGroups } = useIncomeGroups({
397
- enabled: Boolean(insuranceInfo.companyId),
404
+ enabled: Boolean(insuranceInfo.plan),
398
405
  filters: {
399
406
  eaccount: userInfo.accountId,
400
- corpclientId: Number(insuranceInfo.companyId) || void 0
407
+ corpclientId: Number(insuranceInfo.companyId) || void 0,
408
+ contractId: Number(insuranceInfo.plan) || void 0,
409
+ affiliationTypeId: Number(form.values.affiliationTypeId) || void 0,
410
+ enabled: 1
401
411
  }
402
412
  });
403
413
  const companyTypeOptions = (0, import_react2.useMemo)(() => {
@@ -1466,6 +1476,7 @@ var import_jsx_runtime9 = require("react/jsx-runtime");
1466
1476
  var PatientForm = ({
1467
1477
  defaultMode,
1468
1478
  patientId,
1479
+ initialDocumentNumber,
1469
1480
  policyContent,
1470
1481
  disabledFields,
1471
1482
  onSavePatient,
@@ -1486,7 +1497,7 @@ var PatientForm = ({
1486
1497
  mode: "controlled",
1487
1498
  initialValues: {
1488
1499
  documentTypeId: null,
1489
- documentNumber: "",
1500
+ documentNumber: initialDocumentNumber ?? "",
1490
1501
  firstName: "",
1491
1502
  middleName: "",
1492
1503
  surname: "",
@@ -1576,10 +1587,13 @@ var PatientForm = ({
1576
1587
  }
1577
1588
  });
1578
1589
  const { data: incomeGroups } = useIncomeGroups({
1579
- enabled: Boolean(form.values.mandatoryInsurance.companyId),
1590
+ enabled: Boolean(form.values.mandatoryInsurance.plan),
1580
1591
  filters: {
1581
1592
  eaccount: userInfo.accountId,
1582
- corpclientId: Number(form.values.mandatoryInsurance.companyId) || void 0
1593
+ corpclientId: Number(form.values.mandatoryInsurance.companyId) || void 0,
1594
+ contractId: Number(form.values.mandatoryInsurance.plan) || void 0,
1595
+ affiliationTypeId: Number(form.values.affiliationTypeId) || void 0,
1596
+ enabled: 1
1583
1597
  }
1584
1598
  });
1585
1599
  const handleSubmit = (values) => {
@@ -1730,6 +1744,10 @@ var PatientForm = ({
1730
1744
  const patientForm = createPatientForm(patientInfo);
1731
1745
  form.setValues(patientForm);
1732
1746
  }, [patientInfo, mode]);
1747
+ (0, import_react7.useEffect)(() => {
1748
+ if (mode !== "create") return;
1749
+ form.setFieldValue("documentNumber", initialDocumentNumber ?? "");
1750
+ }, [initialDocumentNumber, mode]);
1733
1751
  const documentTypeOptions = (0, import_react7.useMemo)(() => {
1734
1752
  return documentTypes?.map((dt) => ({
1735
1753
  value: String(dt.id),
@@ -1961,6 +1979,15 @@ var PatientForm = ({
1961
1979
  label: "Tipo de afiliaci\xF3n",
1962
1980
  data: affiliationTypeOptions,
1963
1981
  ...form.getInputProps("affiliationTypeId"),
1982
+ onChange: (value) => {
1983
+ form.setFieldValue("affiliationTypeId", value);
1984
+ form.setFieldValue("mandatoryInsurance.companyId", null);
1985
+ form.setFieldValue("mandatoryInsurance.plan", null);
1986
+ form.setFieldValue("mandatoryInsurance.population", null);
1987
+ form.setFieldValue("mandatoryInsurance.groupId", null);
1988
+ form.setFieldValue("mandatoryInsurance.policyNumber", "");
1989
+ form.setFieldValue("voluntaryInsurance", []);
1990
+ },
1964
1991
  "data-testid": "patient-form-affiliation-type-select"
1965
1992
  }
1966
1993
  ) }),
package/dist/index.d.cts CHANGED
@@ -186,13 +186,14 @@ interface PatientDetail {
186
186
  interface PatientFormProps {
187
187
  defaultMode: PatientFormMode;
188
188
  patientId?: number;
189
+ initialDocumentNumber?: string;
189
190
  policyContent?: string;
190
191
  disabledFields?: (keyof PatientFormValues)[];
191
192
  onSavePatient?: (payload: PatientPayload, mode: PatientFormMode) => void;
192
193
  onSaveError?: (error: string) => void;
193
194
  onBack?: () => void;
194
195
  }
195
- declare const PatientForm: ({ defaultMode, patientId, policyContent, disabledFields, onSavePatient, onSaveError, onBack, }: PatientFormProps) => react_jsx_runtime.JSX.Element;
196
+ declare const PatientForm: ({ defaultMode, patientId, initialDocumentNumber, policyContent, disabledFields, onSavePatient, onSaveError, onBack, }: PatientFormProps) => react_jsx_runtime.JSX.Element;
196
197
 
197
198
  interface Comment {
198
199
  id: number;
package/dist/index.d.ts CHANGED
@@ -186,13 +186,14 @@ interface PatientDetail {
186
186
  interface PatientFormProps {
187
187
  defaultMode: PatientFormMode;
188
188
  patientId?: number;
189
+ initialDocumentNumber?: string;
189
190
  policyContent?: string;
190
191
  disabledFields?: (keyof PatientFormValues)[];
191
192
  onSavePatient?: (payload: PatientPayload, mode: PatientFormMode) => void;
192
193
  onSaveError?: (error: string) => void;
193
194
  onBack?: () => void;
194
195
  }
195
- declare const PatientForm: ({ defaultMode, patientId, policyContent, disabledFields, onSavePatient, onSaveError, onBack, }: PatientFormProps) => react_jsx_runtime.JSX.Element;
196
+ declare const PatientForm: ({ defaultMode, patientId, initialDocumentNumber, policyContent, disabledFields, onSavePatient, onSaveError, onBack, }: PatientFormProps) => react_jsx_runtime.JSX.Element;
196
197
 
197
198
  interface Comment {
198
199
  id: number;
package/dist/index.js CHANGED
@@ -282,7 +282,14 @@ var useIncomeGroups = ({
282
282
  }) => {
283
283
  const { token, baseUrl } = useTTNSharedContext();
284
284
  const query = useQuery({
285
- queryKey: ["income-groups", filters?.corpclientId, filters?.eaccount],
285
+ queryKey: [
286
+ "income-groups",
287
+ filters?.corpclientId,
288
+ filters?.contractId,
289
+ filters?.affiliationTypeId,
290
+ filters?.enabled,
291
+ filters?.eaccount
292
+ ],
286
293
  queryFn: () => getIncomeGroups(token, baseUrl, filters),
287
294
  enabled
288
295
  });
@@ -362,10 +369,13 @@ var PatientVoluntaryInsuranceForm = ({
362
369
  }
363
370
  });
364
371
  const { data: incomeGroups } = useIncomeGroups({
365
- enabled: Boolean(insuranceInfo.companyId),
372
+ enabled: Boolean(insuranceInfo.plan),
366
373
  filters: {
367
374
  eaccount: userInfo.accountId,
368
- corpclientId: Number(insuranceInfo.companyId) || void 0
375
+ corpclientId: Number(insuranceInfo.companyId) || void 0,
376
+ contractId: Number(insuranceInfo.plan) || void 0,
377
+ affiliationTypeId: Number(form.values.affiliationTypeId) || void 0,
378
+ enabled: 1
369
379
  }
370
380
  });
371
381
  const companyTypeOptions = useMemo(() => {
@@ -1478,6 +1488,7 @@ import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-run
1478
1488
  var PatientForm = ({
1479
1489
  defaultMode,
1480
1490
  patientId,
1491
+ initialDocumentNumber,
1481
1492
  policyContent,
1482
1493
  disabledFields,
1483
1494
  onSavePatient,
@@ -1498,7 +1509,7 @@ var PatientForm = ({
1498
1509
  mode: "controlled",
1499
1510
  initialValues: {
1500
1511
  documentTypeId: null,
1501
- documentNumber: "",
1512
+ documentNumber: initialDocumentNumber ?? "",
1502
1513
  firstName: "",
1503
1514
  middleName: "",
1504
1515
  surname: "",
@@ -1588,10 +1599,13 @@ var PatientForm = ({
1588
1599
  }
1589
1600
  });
1590
1601
  const { data: incomeGroups } = useIncomeGroups({
1591
- enabled: Boolean(form.values.mandatoryInsurance.companyId),
1602
+ enabled: Boolean(form.values.mandatoryInsurance.plan),
1592
1603
  filters: {
1593
1604
  eaccount: userInfo.accountId,
1594
- corpclientId: Number(form.values.mandatoryInsurance.companyId) || void 0
1605
+ corpclientId: Number(form.values.mandatoryInsurance.companyId) || void 0,
1606
+ contractId: Number(form.values.mandatoryInsurance.plan) || void 0,
1607
+ affiliationTypeId: Number(form.values.affiliationTypeId) || void 0,
1608
+ enabled: 1
1595
1609
  }
1596
1610
  });
1597
1611
  const handleSubmit = (values) => {
@@ -1742,6 +1756,10 @@ var PatientForm = ({
1742
1756
  const patientForm = createPatientForm(patientInfo);
1743
1757
  form.setValues(patientForm);
1744
1758
  }, [patientInfo, mode]);
1759
+ useEffect3(() => {
1760
+ if (mode !== "create") return;
1761
+ form.setFieldValue("documentNumber", initialDocumentNumber ?? "");
1762
+ }, [initialDocumentNumber, mode]);
1745
1763
  const documentTypeOptions = useMemo4(() => {
1746
1764
  return documentTypes?.map((dt) => ({
1747
1765
  value: String(dt.id),
@@ -1973,6 +1991,15 @@ var PatientForm = ({
1973
1991
  label: "Tipo de afiliaci\xF3n",
1974
1992
  data: affiliationTypeOptions,
1975
1993
  ...form.getInputProps("affiliationTypeId"),
1994
+ onChange: (value) => {
1995
+ form.setFieldValue("affiliationTypeId", value);
1996
+ form.setFieldValue("mandatoryInsurance.companyId", null);
1997
+ form.setFieldValue("mandatoryInsurance.plan", null);
1998
+ form.setFieldValue("mandatoryInsurance.population", null);
1999
+ form.setFieldValue("mandatoryInsurance.groupId", null);
2000
+ form.setFieldValue("mandatoryInsurance.policyNumber", "");
2001
+ form.setFieldValue("voluntaryInsurance", []);
2002
+ },
1976
2003
  "data-testid": "patient-form-affiliation-type-select"
1977
2004
  }
1978
2005
  ) }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttn-shared/ui",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [