@ttn-shared/ui 0.0.1
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 +2292 -0
- package/dist/index.d.cts +101 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +2313 -0
- package/package.json +54 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2313 @@
|
|
|
1
|
+
// src/components/PatientForm.tsx
|
|
2
|
+
import { useEffect as useEffect3, useMemo as useMemo4, useState as useState5 } from "react";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import {
|
|
5
|
+
ActionIcon as ActionIcon6,
|
|
6
|
+
Button as Button3,
|
|
7
|
+
Checkbox,
|
|
8
|
+
Flex as Flex6,
|
|
9
|
+
Grid as Grid3,
|
|
10
|
+
NumberInput,
|
|
11
|
+
Paper as Paper5,
|
|
12
|
+
Select as Select4,
|
|
13
|
+
Text as Text6,
|
|
14
|
+
TextInput as TextInput3,
|
|
15
|
+
Title as Title4,
|
|
16
|
+
Tooltip
|
|
17
|
+
} from "@mantine/core";
|
|
18
|
+
import { useForm } from "@mantine/form";
|
|
19
|
+
import {
|
|
20
|
+
IconExclamationCircleFilled as IconExclamationCircleFilled2,
|
|
21
|
+
IconMessage,
|
|
22
|
+
IconPencil,
|
|
23
|
+
IconPlus,
|
|
24
|
+
IconX as IconX5
|
|
25
|
+
} from "@tabler/icons-react";
|
|
26
|
+
|
|
27
|
+
// src/hooks/select.ts
|
|
28
|
+
import { useQuery } from "@tanstack/react-query";
|
|
29
|
+
|
|
30
|
+
// src/config/axios.ts
|
|
31
|
+
import axios from "axios";
|
|
32
|
+
var getBaseURL = (url, token) => {
|
|
33
|
+
return {
|
|
34
|
+
baseURL: url,
|
|
35
|
+
headers: {
|
|
36
|
+
Accept: "application/json",
|
|
37
|
+
Authorization: token
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
var HTTP_MEDICAL = (token, baseURL) => {
|
|
42
|
+
const url = `${baseURL}/medical`;
|
|
43
|
+
return axios.create(getBaseURL(url, token));
|
|
44
|
+
};
|
|
45
|
+
var HTTP_PAYROLL = (token, baseURL) => {
|
|
46
|
+
const url = `${baseURL}/payroll`;
|
|
47
|
+
return axios.create(getBaseURL(url, token));
|
|
48
|
+
};
|
|
49
|
+
var HTTP_ADMIN = (token, baseURL) => {
|
|
50
|
+
const url = `${baseURL}/admin`;
|
|
51
|
+
return axios.create(getBaseURL(url, token));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/services/select.ts
|
|
55
|
+
var getDocumentTypes = async (token, baseURL) => {
|
|
56
|
+
const response = await HTTP_PAYROLL(token, baseURL).get(
|
|
57
|
+
"/document_types/"
|
|
58
|
+
);
|
|
59
|
+
return response.data;
|
|
60
|
+
};
|
|
61
|
+
var getAffiliationTypes = async (token, baseURL, filters) => {
|
|
62
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
63
|
+
"/generals/affiliation-types/",
|
|
64
|
+
{ params: filters }
|
|
65
|
+
);
|
|
66
|
+
return response.data;
|
|
67
|
+
};
|
|
68
|
+
var getProvinces = async (token, baseURL, filters) => {
|
|
69
|
+
const response = await HTTP_ADMIN(token, baseURL).get("/provinces/", {
|
|
70
|
+
params: { entity_account: filters?.eaccount }
|
|
71
|
+
});
|
|
72
|
+
return response.data;
|
|
73
|
+
};
|
|
74
|
+
var getCities = async (token, baseURL, provinceId) => {
|
|
75
|
+
const response = await HTTP_ADMIN(token, baseURL).get("/cities/", {
|
|
76
|
+
params: { provinceId }
|
|
77
|
+
});
|
|
78
|
+
return response.data;
|
|
79
|
+
};
|
|
80
|
+
var getStratums = async (token, baseURL) => {
|
|
81
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
82
|
+
"/patient/stratums"
|
|
83
|
+
);
|
|
84
|
+
return response.data;
|
|
85
|
+
};
|
|
86
|
+
var getEthnicGroups = async (token, baseURL, filters) => {
|
|
87
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
88
|
+
"/generals/ethnic-groups/",
|
|
89
|
+
{ params: filters }
|
|
90
|
+
);
|
|
91
|
+
return response.data;
|
|
92
|
+
};
|
|
93
|
+
var getEducationLevels = async (token, baseURL, filters) => {
|
|
94
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
95
|
+
"/generals/education-levels/",
|
|
96
|
+
{ params: filters }
|
|
97
|
+
);
|
|
98
|
+
return response.data;
|
|
99
|
+
};
|
|
100
|
+
var getCompanyTypes = async (token, baseURL, filters) => {
|
|
101
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
102
|
+
"/client/companytype/",
|
|
103
|
+
{ params: filters }
|
|
104
|
+
);
|
|
105
|
+
return response.data;
|
|
106
|
+
};
|
|
107
|
+
var getCompanyClients = async (token, baseURL, filters) => {
|
|
108
|
+
const response = await HTTP_MEDICAL(token, baseURL).get("/client/", {
|
|
109
|
+
params: filters
|
|
110
|
+
});
|
|
111
|
+
return response.data;
|
|
112
|
+
};
|
|
113
|
+
var getContracts = async (token, baseURL, filters) => {
|
|
114
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
115
|
+
"/client/contract/",
|
|
116
|
+
{ params: filters }
|
|
117
|
+
);
|
|
118
|
+
return response.data;
|
|
119
|
+
};
|
|
120
|
+
var getContractPopulations = async (token, baseURL, filters) => {
|
|
121
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
122
|
+
"/client/contractpopulation/",
|
|
123
|
+
{ params: filters }
|
|
124
|
+
);
|
|
125
|
+
return response.data;
|
|
126
|
+
};
|
|
127
|
+
var getIncomeGroups = async (token, baseURL, filters) => {
|
|
128
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
129
|
+
"/client/copaymentRate/",
|
|
130
|
+
{ params: filters }
|
|
131
|
+
);
|
|
132
|
+
return response.data;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/providers/TTNSharedProvider.tsx
|
|
136
|
+
import { createContext, useContext } from "react";
|
|
137
|
+
import { jsx } from "react/jsx-runtime";
|
|
138
|
+
var TTNSharedContext = createContext(null);
|
|
139
|
+
var TTNSharedProvider = ({
|
|
140
|
+
children,
|
|
141
|
+
...props
|
|
142
|
+
}) => {
|
|
143
|
+
return /* @__PURE__ */ jsx(TTNSharedContext.Provider, { value: props, children });
|
|
144
|
+
};
|
|
145
|
+
var useTTNSharedContext = () => {
|
|
146
|
+
const context = useContext(TTNSharedContext);
|
|
147
|
+
if (!context) {
|
|
148
|
+
throw new Error("useTTNSharedContext must be used within a TTNSharedProvider");
|
|
149
|
+
}
|
|
150
|
+
return context;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/hooks/select.ts
|
|
154
|
+
var useDocumentTypes = ({ enabled = true }) => {
|
|
155
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
156
|
+
const query = useQuery({
|
|
157
|
+
queryKey: ["document-types"],
|
|
158
|
+
queryFn: () => getDocumentTypes(token, baseUrl),
|
|
159
|
+
enabled
|
|
160
|
+
});
|
|
161
|
+
return { data: query.data?.results };
|
|
162
|
+
};
|
|
163
|
+
var useAffiliationTypes = ({
|
|
164
|
+
enabled = true,
|
|
165
|
+
filters
|
|
166
|
+
}) => {
|
|
167
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
168
|
+
const query = useQuery({
|
|
169
|
+
queryKey: ["affiliation-types", filters?.eaccount],
|
|
170
|
+
queryFn: () => getAffiliationTypes(token, baseUrl, filters),
|
|
171
|
+
enabled
|
|
172
|
+
});
|
|
173
|
+
return { data: query.data?.results };
|
|
174
|
+
};
|
|
175
|
+
var useProvinces = ({
|
|
176
|
+
enabled = true,
|
|
177
|
+
filters
|
|
178
|
+
}) => {
|
|
179
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
180
|
+
const query = useQuery({
|
|
181
|
+
queryKey: ["provinces", filters?.eaccount],
|
|
182
|
+
queryFn: () => getProvinces(token, baseUrl, filters),
|
|
183
|
+
enabled
|
|
184
|
+
});
|
|
185
|
+
return { data: query.data?.data };
|
|
186
|
+
};
|
|
187
|
+
var useCities = ({
|
|
188
|
+
enabled = true,
|
|
189
|
+
provinceId
|
|
190
|
+
}) => {
|
|
191
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
192
|
+
const query = useQuery({
|
|
193
|
+
queryKey: ["cities", provinceId],
|
|
194
|
+
queryFn: () => getCities(token, baseUrl, provinceId),
|
|
195
|
+
enabled
|
|
196
|
+
});
|
|
197
|
+
return { data: query.data?.data };
|
|
198
|
+
};
|
|
199
|
+
var useStratums = ({ enabled = true }) => {
|
|
200
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
201
|
+
const query = useQuery({
|
|
202
|
+
queryKey: ["stratums"],
|
|
203
|
+
queryFn: () => getStratums(token, baseUrl),
|
|
204
|
+
enabled
|
|
205
|
+
});
|
|
206
|
+
return { data: query.data?.results };
|
|
207
|
+
};
|
|
208
|
+
var useEthnicGroups = ({
|
|
209
|
+
enabled = true,
|
|
210
|
+
filters
|
|
211
|
+
}) => {
|
|
212
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
213
|
+
const query = useQuery({
|
|
214
|
+
queryKey: ["ethnic-groups", filters?.eaccount],
|
|
215
|
+
queryFn: () => getEthnicGroups(token, baseUrl, filters),
|
|
216
|
+
enabled
|
|
217
|
+
});
|
|
218
|
+
return { data: query.data?.results };
|
|
219
|
+
};
|
|
220
|
+
var useEducationLevels = ({
|
|
221
|
+
enabled = true,
|
|
222
|
+
filters
|
|
223
|
+
}) => {
|
|
224
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
225
|
+
const query = useQuery({
|
|
226
|
+
queryKey: ["education-levels", filters?.eaccount],
|
|
227
|
+
queryFn: () => getEducationLevels(token, baseUrl, filters),
|
|
228
|
+
enabled
|
|
229
|
+
});
|
|
230
|
+
return { data: query.data?.results };
|
|
231
|
+
};
|
|
232
|
+
var useCompanyTypes = ({
|
|
233
|
+
enabled = true,
|
|
234
|
+
filters
|
|
235
|
+
}) => {
|
|
236
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
237
|
+
const query = useQuery({
|
|
238
|
+
queryKey: ["company-types", filters?.status, filters?.eaccount],
|
|
239
|
+
queryFn: () => getCompanyTypes(token, baseUrl, filters),
|
|
240
|
+
enabled
|
|
241
|
+
});
|
|
242
|
+
return { data: query.data?.results };
|
|
243
|
+
};
|
|
244
|
+
var useCompanyClients = ({
|
|
245
|
+
enabled = true,
|
|
246
|
+
filters
|
|
247
|
+
}) => {
|
|
248
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
249
|
+
const query = useQuery({
|
|
250
|
+
queryKey: ["company-clients", filters?.contractCompanyType, filters?.status, filters?.eaccount],
|
|
251
|
+
queryFn: () => getCompanyClients(token, baseUrl, filters),
|
|
252
|
+
enabled
|
|
253
|
+
});
|
|
254
|
+
return { data: query.data?.results };
|
|
255
|
+
};
|
|
256
|
+
var useContracts = ({
|
|
257
|
+
enabled = true,
|
|
258
|
+
filters
|
|
259
|
+
}) => {
|
|
260
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
261
|
+
const query = useQuery({
|
|
262
|
+
queryKey: ["contracts", filters?.cType, filters?.client, filters?.status, filters?.eaccount],
|
|
263
|
+
queryFn: () => getContracts(token, baseUrl, filters),
|
|
264
|
+
enabled
|
|
265
|
+
});
|
|
266
|
+
return { data: query.data?.results };
|
|
267
|
+
};
|
|
268
|
+
var useContractPopulations = ({
|
|
269
|
+
enabled = true,
|
|
270
|
+
filters
|
|
271
|
+
}) => {
|
|
272
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
273
|
+
const query = useQuery({
|
|
274
|
+
queryKey: ["contract-populations", filters?.contract, filters?.eaccount, filters?.status],
|
|
275
|
+
queryFn: () => getContractPopulations(token, baseUrl, filters),
|
|
276
|
+
enabled
|
|
277
|
+
});
|
|
278
|
+
return { data: query.data?.results };
|
|
279
|
+
};
|
|
280
|
+
var useIncomeGroups = ({
|
|
281
|
+
enabled = true,
|
|
282
|
+
filters
|
|
283
|
+
}) => {
|
|
284
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
285
|
+
const query = useQuery({
|
|
286
|
+
queryKey: ["income-groups", filters?.corpclientId, filters?.eaccount],
|
|
287
|
+
queryFn: () => getIncomeGroups(token, baseUrl, filters),
|
|
288
|
+
enabled
|
|
289
|
+
});
|
|
290
|
+
return { data: query.data?.results };
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// src/constants/select.ts
|
|
294
|
+
var genderOptions = [
|
|
295
|
+
{ value: "male", label: "Masculino" },
|
|
296
|
+
{ value: "female", label: "Femenino" }
|
|
297
|
+
];
|
|
298
|
+
var maritalStatusOptions = [
|
|
299
|
+
{ value: "single", label: "Soltero(a)" },
|
|
300
|
+
{ value: "married", label: "Casado(a)" },
|
|
301
|
+
{ value: "divorced", label: "Divorciado(a)" },
|
|
302
|
+
{ value: "widowed", label: "Viudo(a)" },
|
|
303
|
+
{ value: "freeunion", label: "Uni\xF3n Libre" }
|
|
304
|
+
];
|
|
305
|
+
var bloodTypeOptions = [
|
|
306
|
+
{ value: "A+", label: "A+" },
|
|
307
|
+
{ value: "A-", label: "A-" },
|
|
308
|
+
{ value: "B+", label: "B+" },
|
|
309
|
+
{ value: "B-", label: "B-" },
|
|
310
|
+
{ value: "AB+", label: "AB+" },
|
|
311
|
+
{ value: "AB-", label: "AB-" },
|
|
312
|
+
{ value: "O+", label: "O+" },
|
|
313
|
+
{ value: "O-", label: "O-" }
|
|
314
|
+
];
|
|
315
|
+
|
|
316
|
+
// src/constants/patient.ts
|
|
317
|
+
var patientFormTitles = {
|
|
318
|
+
create: "Crear paciente",
|
|
319
|
+
edit: "Editar paciente",
|
|
320
|
+
view: "Detalle del paciente"
|
|
321
|
+
};
|
|
322
|
+
var VOLUNTARY_INSURANCE_TAGS = ["arl", "particular"];
|
|
323
|
+
|
|
324
|
+
// src/components/PatientVoluntaryInsuranceForm.tsx
|
|
325
|
+
import { useMemo } from "react";
|
|
326
|
+
import { ActionIcon, Flex, Grid, Paper, Select, TextInput, Title } from "@mantine/core";
|
|
327
|
+
import { IconX } from "@tabler/icons-react";
|
|
328
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
329
|
+
var PatientVoluntaryInsuranceForm = ({
|
|
330
|
+
index,
|
|
331
|
+
mode,
|
|
332
|
+
form
|
|
333
|
+
}) => {
|
|
334
|
+
const { userAccountId } = useTTNSharedContext();
|
|
335
|
+
const insuranceInfo = form.values.voluntaryInsurance[index];
|
|
336
|
+
const { data: companyTypes } = useCompanyTypes({
|
|
337
|
+
filters: {
|
|
338
|
+
eaccount: userAccountId,
|
|
339
|
+
status: "enabled"
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
const { data: companyClients } = useCompanyClients({
|
|
343
|
+
filters: {
|
|
344
|
+
eaccount: userAccountId,
|
|
345
|
+
status: "enabled"
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
const { data: contracts } = useContracts({
|
|
349
|
+
enabled: Boolean(insuranceInfo.companyId),
|
|
350
|
+
filters: {
|
|
351
|
+
eaccount: userAccountId,
|
|
352
|
+
cType: "particular",
|
|
353
|
+
client: Number(insuranceInfo.companyId) || void 0,
|
|
354
|
+
status: "enabled"
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
const { data: contractPopulations } = useContractPopulations({
|
|
358
|
+
enabled: Boolean(insuranceInfo.plan),
|
|
359
|
+
filters: {
|
|
360
|
+
eaccount: userAccountId,
|
|
361
|
+
contract: Number(insuranceInfo.plan) || void 0,
|
|
362
|
+
status: "enabled"
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
const { data: incomeGroups } = useIncomeGroups({
|
|
366
|
+
enabled: Boolean(insuranceInfo.companyId),
|
|
367
|
+
filters: {
|
|
368
|
+
eaccount: userAccountId,
|
|
369
|
+
corpclientId: Number(insuranceInfo.companyId) || void 0
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
const companyTypeOptions = useMemo(() => {
|
|
373
|
+
return companyTypes?.map((ct) => ({
|
|
374
|
+
value: String(ct.id),
|
|
375
|
+
label: ct.name
|
|
376
|
+
}));
|
|
377
|
+
}, [companyTypes]);
|
|
378
|
+
const companyClientOptions = useMemo(() => {
|
|
379
|
+
return companyClients?.map((cc) => ({
|
|
380
|
+
value: String(cc.id),
|
|
381
|
+
label: cc.name
|
|
382
|
+
}));
|
|
383
|
+
}, [companyClients]);
|
|
384
|
+
const contractOptions = useMemo(() => {
|
|
385
|
+
return contracts?.map((c) => ({
|
|
386
|
+
value: String(c.id),
|
|
387
|
+
label: c.name
|
|
388
|
+
}));
|
|
389
|
+
}, [contracts]);
|
|
390
|
+
const contractPopulationOptions = useMemo(() => {
|
|
391
|
+
return contractPopulations?.map((cp) => ({
|
|
392
|
+
value: String(cp.idPopulation),
|
|
393
|
+
label: cp.name
|
|
394
|
+
}));
|
|
395
|
+
}, [contractPopulations]);
|
|
396
|
+
const incomeGroupOptions = useMemo(() => {
|
|
397
|
+
return incomeGroups?.map((ig) => ({
|
|
398
|
+
value: String(ig.crtId),
|
|
399
|
+
label: ig.copaymentRateName
|
|
400
|
+
}));
|
|
401
|
+
}, [incomeGroups]);
|
|
402
|
+
const selectedCompanyType = companyTypes?.find((ct) => String(ct.id) === insuranceInfo.companyType);
|
|
403
|
+
return /* @__PURE__ */ jsxs(Paper, { withBorder: true, p: "md", mb: "sm", bg: "#d6e0eb", shadow: "none", children: [
|
|
404
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", mb: "sm", children: [
|
|
405
|
+
/* @__PURE__ */ jsx2(Title, { order: 6, c: "secondary-color", children: "Aseguradora voluntaria" }),
|
|
406
|
+
mode !== "view" && /* @__PURE__ */ jsx2(
|
|
407
|
+
ActionIcon,
|
|
408
|
+
{
|
|
409
|
+
variant: "subtle",
|
|
410
|
+
color: "secondary-color",
|
|
411
|
+
onClick: () => form.removeListItem("voluntaryInsurance", index),
|
|
412
|
+
"data-testid": `patient-form-voluntary-insurance-remove-button-${index}`,
|
|
413
|
+
children: /* @__PURE__ */ jsx2(IconX, { size: 16 })
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
] }),
|
|
417
|
+
/* @__PURE__ */ jsxs(Grid, { children: [
|
|
418
|
+
/* @__PURE__ */ jsx2(Grid.Col, { span: 6, children: /* @__PURE__ */ jsx2(
|
|
419
|
+
Select,
|
|
420
|
+
{
|
|
421
|
+
readOnly: mode === "view",
|
|
422
|
+
withAsterisk: mode !== "view",
|
|
423
|
+
label: "Tipo de seguro",
|
|
424
|
+
data: companyTypeOptions,
|
|
425
|
+
...form.getInputProps(`voluntaryInsurance.${index}.companyType`),
|
|
426
|
+
onChange: (value) => {
|
|
427
|
+
if (value) {
|
|
428
|
+
const companyTypeTag = companyTypes?.find((ct) => String(ct.id) === value)?.tag;
|
|
429
|
+
form.setFieldValue(
|
|
430
|
+
`voluntaryInsurance.${index}.companyTypeTag`,
|
|
431
|
+
companyTypeTag || ""
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
form.setFieldValue(`voluntaryInsurance.${index}.companyType`, value || "");
|
|
435
|
+
form.setFieldValue(`voluntaryInsurance.${index}.companyId`, "");
|
|
436
|
+
form.setFieldValue(`voluntaryInsurance.${index}.plan`, "");
|
|
437
|
+
form.setFieldValue(`voluntaryInsurance.${index}.population`, "");
|
|
438
|
+
form.setFieldValue(`voluntaryInsurance.${index}.groupId`, "");
|
|
439
|
+
form.setFieldValue(`voluntaryInsurance.${index}.policyNumber`, "");
|
|
440
|
+
},
|
|
441
|
+
"data-testid": `patient-form-voluntary-insurance-company-type-select-${index}`
|
|
442
|
+
}
|
|
443
|
+
) }),
|
|
444
|
+
/* @__PURE__ */ jsx2(Grid.Col, { span: 6, children: /* @__PURE__ */ jsx2(
|
|
445
|
+
Select,
|
|
446
|
+
{
|
|
447
|
+
readOnly: mode === "view",
|
|
448
|
+
withAsterisk: mode !== "view",
|
|
449
|
+
label: "Seguro",
|
|
450
|
+
data: companyClientOptions,
|
|
451
|
+
...form.getInputProps(`voluntaryInsurance.${index}.companyId`),
|
|
452
|
+
onChange: (value) => {
|
|
453
|
+
form.setFieldValue(`voluntaryInsurance.${index}.companyId`, value || "");
|
|
454
|
+
form.setFieldValue(`voluntaryInsurance.${index}.plan`, "");
|
|
455
|
+
form.setFieldValue(`voluntaryInsurance.${index}.population`, "");
|
|
456
|
+
form.setFieldValue(`voluntaryInsurance.${index}.groupId`, "");
|
|
457
|
+
form.setFieldValue(`voluntaryInsurance.${index}.policyNumber`, "");
|
|
458
|
+
},
|
|
459
|
+
"data-testid": `patient-form-voluntary-insurance-company-select-${index}`
|
|
460
|
+
}
|
|
461
|
+
) }),
|
|
462
|
+
/* @__PURE__ */ jsx2(Grid.Col, { span: 6, children: /* @__PURE__ */ jsx2(
|
|
463
|
+
Select,
|
|
464
|
+
{
|
|
465
|
+
readOnly: mode === "view",
|
|
466
|
+
withAsterisk: mode !== "view",
|
|
467
|
+
label: "Plan",
|
|
468
|
+
data: contractOptions,
|
|
469
|
+
...form.getInputProps(`voluntaryInsurance.${index}.plan`),
|
|
470
|
+
onChange: (value) => {
|
|
471
|
+
form.setFieldValue(`voluntaryInsurance.${index}.plan`, value || "");
|
|
472
|
+
form.setFieldValue(`voluntaryInsurance.${index}.population`, "");
|
|
473
|
+
form.setFieldValue(`voluntaryInsurance.${index}.groupId`, "");
|
|
474
|
+
form.setFieldValue(`voluntaryInsurance.${index}.policyNumber`, "");
|
|
475
|
+
},
|
|
476
|
+
"data-testid": `patient-form-voluntary-insurance-plan-select-${index}`
|
|
477
|
+
}
|
|
478
|
+
) }),
|
|
479
|
+
/* @__PURE__ */ jsx2(Grid.Col, { span: 6, children: /* @__PURE__ */ jsx2(
|
|
480
|
+
Select,
|
|
481
|
+
{
|
|
482
|
+
readOnly: mode === "view",
|
|
483
|
+
withAsterisk: mode !== "view",
|
|
484
|
+
label: "Poblaci\xF3n",
|
|
485
|
+
data: contractPopulationOptions,
|
|
486
|
+
...form.getInputProps(`voluntaryInsurance.${index}.population`),
|
|
487
|
+
"data-testid": `patient-form-voluntary-insurance-population-select-${index}`
|
|
488
|
+
}
|
|
489
|
+
) }),
|
|
490
|
+
VOLUNTARY_INSURANCE_TAGS.includes(selectedCompanyType?.tag ?? "") && /* @__PURE__ */ jsx2(Grid.Col, { span: 6, children: /* @__PURE__ */ jsx2(
|
|
491
|
+
Select,
|
|
492
|
+
{
|
|
493
|
+
readOnly: mode === "view",
|
|
494
|
+
withAsterisk: mode !== "view",
|
|
495
|
+
label: "Grupo de ingreso",
|
|
496
|
+
data: incomeGroupOptions,
|
|
497
|
+
...form.getInputProps(`voluntaryInsurance.${index}.groupId`),
|
|
498
|
+
"data-testid": `patient-form-voluntary-insurance-group-select-${index}`
|
|
499
|
+
}
|
|
500
|
+
) }),
|
|
501
|
+
[...VOLUNTARY_INSURANCE_TAGS, "prepaid"].includes(selectedCompanyType?.tag ?? "") && /* @__PURE__ */ jsx2(Grid.Col, { span: 6, children: /* @__PURE__ */ jsx2(
|
|
502
|
+
TextInput,
|
|
503
|
+
{
|
|
504
|
+
readOnly: mode === "view",
|
|
505
|
+
label: "No. de p\xF3liza",
|
|
506
|
+
...form.getInputProps(`voluntaryInsurance.${index}.policyNumber`),
|
|
507
|
+
"data-testid": `patient-form-voluntary-insurance-policy-number-select-${index}`
|
|
508
|
+
}
|
|
509
|
+
) })
|
|
510
|
+
] })
|
|
511
|
+
] });
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// src/hooks/patient.ts
|
|
515
|
+
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
516
|
+
|
|
517
|
+
// src/services/patient.ts
|
|
518
|
+
var getPatientDetail = async (token, baseURL, filters) => {
|
|
519
|
+
const response = await HTTP_MEDICAL(token, baseURL).get("/patient/", {
|
|
520
|
+
params: filters
|
|
521
|
+
});
|
|
522
|
+
return response.data;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
// src/hooks/patient.ts
|
|
526
|
+
var usePatientDetail = ({
|
|
527
|
+
enabled = true,
|
|
528
|
+
filters
|
|
529
|
+
}) => {
|
|
530
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
531
|
+
const query = useQuery2({
|
|
532
|
+
queryKey: ["patient-detail", filters?.eaccount, filters?.id],
|
|
533
|
+
queryFn: () => getPatientDetail(token, baseUrl, filters),
|
|
534
|
+
enabled
|
|
535
|
+
});
|
|
536
|
+
return { data: query.data?.results, refetch: query.refetch };
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// src/components/PatientNotes.tsx
|
|
540
|
+
import { useState } from "react";
|
|
541
|
+
import {
|
|
542
|
+
ActionIcon as ActionIcon2,
|
|
543
|
+
Box,
|
|
544
|
+
Divider,
|
|
545
|
+
Drawer,
|
|
546
|
+
Flex as Flex2,
|
|
547
|
+
Paper as Paper2,
|
|
548
|
+
ScrollArea,
|
|
549
|
+
Text,
|
|
550
|
+
Textarea,
|
|
551
|
+
Title as Title2
|
|
552
|
+
} from "@mantine/core";
|
|
553
|
+
import { IconSend2, IconTrash, IconX as IconX2 } from "@tabler/icons-react";
|
|
554
|
+
|
|
555
|
+
// src/hooks/comment.ts
|
|
556
|
+
import { useMutation, useQuery as useQuery3 } from "@tanstack/react-query";
|
|
557
|
+
|
|
558
|
+
// src/services/comment.ts
|
|
559
|
+
var getComments = async (token, baseURL, filters) => {
|
|
560
|
+
const response = await HTTP_MEDICAL(token, baseURL).get("/comments/", {
|
|
561
|
+
params: filters
|
|
562
|
+
});
|
|
563
|
+
return response.data;
|
|
564
|
+
};
|
|
565
|
+
var createComment = async (token, baseURL, payload) => {
|
|
566
|
+
const response = await HTTP_MEDICAL(token, baseURL).post(
|
|
567
|
+
"/comments/",
|
|
568
|
+
payload
|
|
569
|
+
);
|
|
570
|
+
return response.data;
|
|
571
|
+
};
|
|
572
|
+
var deleteComment = async (token, baseURL, id) => {
|
|
573
|
+
const response = await HTTP_MEDICAL(token, baseURL).delete(`/comments/`, {
|
|
574
|
+
data: { id }
|
|
575
|
+
});
|
|
576
|
+
return response.data;
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
// src/hooks/comment.ts
|
|
580
|
+
var useComments = ({
|
|
581
|
+
enabled = true,
|
|
582
|
+
filters
|
|
583
|
+
}) => {
|
|
584
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
585
|
+
const query = useQuery3({
|
|
586
|
+
queryKey: ["comments", filters?.entity, filters?.id],
|
|
587
|
+
queryFn: () => getComments(token, baseUrl, filters),
|
|
588
|
+
enabled
|
|
589
|
+
});
|
|
590
|
+
return { data: query.data?.results };
|
|
591
|
+
};
|
|
592
|
+
var useCreateComment = () => {
|
|
593
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
594
|
+
const mutation = useMutation({
|
|
595
|
+
mutationFn: (payload) => createComment(token, baseUrl, payload)
|
|
596
|
+
});
|
|
597
|
+
return mutation;
|
|
598
|
+
};
|
|
599
|
+
var useDeleteComment = () => {
|
|
600
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
601
|
+
const mutation = useMutation({
|
|
602
|
+
mutationFn: (id) => deleteComment(token, baseUrl, id)
|
|
603
|
+
});
|
|
604
|
+
return mutation;
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
// src/components/PatientNotes.tsx
|
|
608
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
609
|
+
var PatientNotes = ({
|
|
610
|
+
patientId,
|
|
611
|
+
isOpen,
|
|
612
|
+
onClose,
|
|
613
|
+
closeOnSave = true,
|
|
614
|
+
onAttemptRemoveNote
|
|
615
|
+
}) => {
|
|
616
|
+
const { userId, userName } = useTTNSharedContext();
|
|
617
|
+
const [comment, setComment] = useState("");
|
|
618
|
+
const { data: notes } = useComments({
|
|
619
|
+
enabled: isOpen && Boolean(patientId),
|
|
620
|
+
filters: { entity: "userClient", id: patientId }
|
|
621
|
+
});
|
|
622
|
+
const { mutateAsync: createComment2 } = useCreateComment();
|
|
623
|
+
const { mutateAsync: deleteComment2 } = useDeleteComment();
|
|
624
|
+
const handleAddNote = async () => {
|
|
625
|
+
await createComment2({
|
|
626
|
+
entity: "userClient",
|
|
627
|
+
userId: userId ?? 0,
|
|
628
|
+
comment,
|
|
629
|
+
id: patientId ?? 0
|
|
630
|
+
});
|
|
631
|
+
setComment("");
|
|
632
|
+
if (closeOnSave) {
|
|
633
|
+
onClose();
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
const handleRemoveNote = async (comment2) => {
|
|
637
|
+
const canDelete = await onAttemptRemoveNote?.(comment2) ?? true;
|
|
638
|
+
if (!canDelete) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
await deleteComment2(comment2.id);
|
|
642
|
+
setComment("");
|
|
643
|
+
if (closeOnSave) {
|
|
644
|
+
onClose();
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
return /* @__PURE__ */ jsxs2(Drawer.Root, { opened: isOpen, onClose, position: "right", size: "xs", children: [
|
|
648
|
+
/* @__PURE__ */ jsx3(Drawer.Overlay, {}),
|
|
649
|
+
/* @__PURE__ */ jsx3(Drawer.Content, { style: { overflow: "hidden" }, children: /* @__PURE__ */ jsxs2(Flex2, { direction: "column", style: { height: "100%" }, children: [
|
|
650
|
+
/* @__PURE__ */ jsxs2(Box, { p: "lg", style: { flexShrink: 0 }, children: [
|
|
651
|
+
/* @__PURE__ */ jsx3(ActionIcon2, { variant: "subtle", "data-testid": "patient-notes-close-button", onClick: onClose, children: /* @__PURE__ */ jsx3(IconX2, { style: { width: 30, height: 30 } }) }),
|
|
652
|
+
/* @__PURE__ */ jsx3(Title2, { order: 2, fz: "h2", c: "secondary-color", children: "Notas" })
|
|
653
|
+
] }),
|
|
654
|
+
/* @__PURE__ */ jsxs2(ScrollArea, { px: "lg", style: { flexGrow: 1 }, children: [
|
|
655
|
+
notes?.map((note, index) => /* @__PURE__ */ jsxs2(Box, { p: "sm", children: [
|
|
656
|
+
/* @__PURE__ */ jsxs2(Flex2, { justify: "space-between", children: [
|
|
657
|
+
/* @__PURE__ */ jsx3(Text, { c: "secondary-color", children: note.userName }),
|
|
658
|
+
/* @__PURE__ */ jsx3(
|
|
659
|
+
ActionIcon2,
|
|
660
|
+
{
|
|
661
|
+
size: "sm",
|
|
662
|
+
variant: "subtle",
|
|
663
|
+
onClick: () => handleRemoveNote(note),
|
|
664
|
+
"data-testid": `patient-note-delete-button-${index}`,
|
|
665
|
+
children: /* @__PURE__ */ jsx3(IconTrash, {})
|
|
666
|
+
}
|
|
667
|
+
)
|
|
668
|
+
] }),
|
|
669
|
+
/* @__PURE__ */ jsx3(Text, { c: "dimmed", children: note.comment }),
|
|
670
|
+
/* @__PURE__ */ jsx3(Text, { c: "dimmed", ta: "end", children: note.date }),
|
|
671
|
+
/* @__PURE__ */ jsx3(Divider, {})
|
|
672
|
+
] }, note.id)),
|
|
673
|
+
!notes?.length && /* @__PURE__ */ jsx3(Text, { c: "dimmed", ta: "center", children: "No hay notas disponibles." })
|
|
674
|
+
] }),
|
|
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 }),
|
|
677
|
+
/* @__PURE__ */ jsx3(
|
|
678
|
+
Textarea,
|
|
679
|
+
{
|
|
680
|
+
value: comment,
|
|
681
|
+
onChange: (event) => setComment(event.currentTarget.value),
|
|
682
|
+
rows: 4,
|
|
683
|
+
"data-testid": "patient-note-comment-textarea"
|
|
684
|
+
}
|
|
685
|
+
),
|
|
686
|
+
/* @__PURE__ */ jsx3(Flex2, { justify: "flex-end", mt: "xs", children: /* @__PURE__ */ jsx3(
|
|
687
|
+
ActionIcon2,
|
|
688
|
+
{
|
|
689
|
+
disabled: comment.trim().length < 3,
|
|
690
|
+
variant: "subtle",
|
|
691
|
+
c: "brand-color",
|
|
692
|
+
onClick: handleAddNote,
|
|
693
|
+
"data-testid": "patient-note-send-button",
|
|
694
|
+
children: /* @__PURE__ */ jsx3(IconSend2, { style: { width: 16, height: 16 } })
|
|
695
|
+
}
|
|
696
|
+
) })
|
|
697
|
+
] }) })
|
|
698
|
+
] }) })
|
|
699
|
+
] });
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
// src/components/PatientAdministrativeRisks.tsx
|
|
703
|
+
import { useEffect, useMemo as useMemo2, useState as useState2 } from "react";
|
|
704
|
+
import {
|
|
705
|
+
ActionIcon as ActionIcon3,
|
|
706
|
+
Button,
|
|
707
|
+
Flex as Flex3,
|
|
708
|
+
FocusTrap,
|
|
709
|
+
Group,
|
|
710
|
+
Modal,
|
|
711
|
+
Paper as Paper3,
|
|
712
|
+
ScrollArea as ScrollArea2,
|
|
713
|
+
Select as Select2,
|
|
714
|
+
Text as Text2,
|
|
715
|
+
ThemeIcon
|
|
716
|
+
} from "@mantine/core";
|
|
717
|
+
|
|
718
|
+
// src/hooks/risk.ts
|
|
719
|
+
import { useMutation as useMutation2, useQuery as useQuery4 } from "@tanstack/react-query";
|
|
720
|
+
|
|
721
|
+
// src/services/risk.ts
|
|
722
|
+
var getAssistanceRisks = async (token, baseURL, filters) => {
|
|
723
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
724
|
+
"/patient/assistance-risks",
|
|
725
|
+
{ params: filters }
|
|
726
|
+
);
|
|
727
|
+
return response.data;
|
|
728
|
+
};
|
|
729
|
+
var getAdministrativeRisks = async (token, baseURL, filters) => {
|
|
730
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
731
|
+
"/markups/",
|
|
732
|
+
{ params: filters }
|
|
733
|
+
);
|
|
734
|
+
return response.data;
|
|
735
|
+
};
|
|
736
|
+
var updateRisks = async (token, baseURL, payload) => {
|
|
737
|
+
const response = await HTTP_MEDICAL(token, baseURL).put("/patient/risk", payload);
|
|
738
|
+
return response.data;
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
// src/hooks/risk.ts
|
|
742
|
+
var useAssistanceRisks = ({
|
|
743
|
+
enabled = true,
|
|
744
|
+
filters
|
|
745
|
+
}) => {
|
|
746
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
747
|
+
const query = useQuery4({
|
|
748
|
+
queryKey: ["assistance-risks", filters?.status],
|
|
749
|
+
queryFn: () => getAssistanceRisks(token, baseUrl, filters),
|
|
750
|
+
enabled
|
|
751
|
+
});
|
|
752
|
+
return { data: query.data?.results };
|
|
753
|
+
};
|
|
754
|
+
var useAdministrativeRisks = ({
|
|
755
|
+
enabled = true,
|
|
756
|
+
filters
|
|
757
|
+
}) => {
|
|
758
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
759
|
+
const query = useQuery4({
|
|
760
|
+
queryKey: ["administrative-risks", filters?.status],
|
|
761
|
+
queryFn: () => getAdministrativeRisks(token, baseUrl, filters),
|
|
762
|
+
enabled
|
|
763
|
+
});
|
|
764
|
+
return { data: query.data?.results };
|
|
765
|
+
};
|
|
766
|
+
var useUpdateRisks = () => {
|
|
767
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
768
|
+
const mutation = useMutation2({
|
|
769
|
+
mutationFn: (payload) => updateRisks(token, baseUrl, payload)
|
|
770
|
+
});
|
|
771
|
+
return mutation;
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
// src/components/PatientAdministrativeRisks.tsx
|
|
775
|
+
import { IconExclamationCircleFilled, IconX as IconX3 } from "@tabler/icons-react";
|
|
776
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
777
|
+
var PatientAdministrativeRisks = ({
|
|
778
|
+
patientId,
|
|
779
|
+
isOpen,
|
|
780
|
+
onClose
|
|
781
|
+
}) => {
|
|
782
|
+
const { userAccountId } = useTTNSharedContext();
|
|
783
|
+
const [riskValue, setRiskValue] = useState2(null);
|
|
784
|
+
const [selectedRisks, setSelectedRisks] = useState2([]);
|
|
785
|
+
const { data: patientInfo } = usePatientDetail({
|
|
786
|
+
enabled: Boolean(patientId) && isOpen,
|
|
787
|
+
filters: {
|
|
788
|
+
eaccount: userAccountId,
|
|
789
|
+
id: patientId
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
const { data: administrativeRisks } = useAdministrativeRisks({
|
|
793
|
+
enabled: Boolean(patientId) && isOpen,
|
|
794
|
+
filters: {
|
|
795
|
+
status: "enabled"
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
const { mutateAsync: updateRisks2 } = useUpdateRisks();
|
|
799
|
+
const handleSaveRisks = async () => {
|
|
800
|
+
await updateRisks2({
|
|
801
|
+
eaccount: userAccountId ?? 0,
|
|
802
|
+
idPatient: patientId ?? 0,
|
|
803
|
+
riskList: {
|
|
804
|
+
administrative: selectedRisks
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
onClose();
|
|
808
|
+
};
|
|
809
|
+
const handleChangeRisk = (riskId) => {
|
|
810
|
+
if (!riskId) {
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
const selectedRisk = administrativeRisks?.find((risk) => String(risk.id) === riskId);
|
|
814
|
+
if (selectedRisk) {
|
|
815
|
+
const newRisks = [...selectedRisks, selectedRisk];
|
|
816
|
+
setSelectedRisks(newRisks);
|
|
817
|
+
setRiskValue(null);
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
const handleRemoveRisk = (riskId) => {
|
|
821
|
+
const newRisks = selectedRisks.filter((risk) => risk.id !== riskId);
|
|
822
|
+
setSelectedRisks(newRisks);
|
|
823
|
+
};
|
|
824
|
+
useEffect(() => {
|
|
825
|
+
if (!patientInfo || !isOpen) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
setSelectedRisks(patientInfo.risk.administrative ?? []);
|
|
829
|
+
}, [patientInfo, isOpen]);
|
|
830
|
+
const administrativeRiskOptions = useMemo2(() => {
|
|
831
|
+
const options = [];
|
|
832
|
+
for (const risk of administrativeRisks ?? []) {
|
|
833
|
+
if (selectedRisks.some((selected) => selected.id === risk.id)) {
|
|
834
|
+
continue;
|
|
835
|
+
}
|
|
836
|
+
options.push({ value: String(risk.id), label: risk.description });
|
|
837
|
+
}
|
|
838
|
+
return options;
|
|
839
|
+
}, [administrativeRisks, selectedRisks]);
|
|
840
|
+
return /* @__PURE__ */ jsxs3(
|
|
841
|
+
Modal,
|
|
842
|
+
{
|
|
843
|
+
opened: isOpen,
|
|
844
|
+
onClose,
|
|
845
|
+
title: "Importancias administrativas",
|
|
846
|
+
withCloseButton: false,
|
|
847
|
+
children: [
|
|
848
|
+
/* @__PURE__ */ jsx4(FocusTrap.InitialFocus, {}),
|
|
849
|
+
/* @__PURE__ */ jsx4(
|
|
850
|
+
Select2,
|
|
851
|
+
{
|
|
852
|
+
data: administrativeRiskOptions,
|
|
853
|
+
value: riskValue,
|
|
854
|
+
onChange: handleChangeRisk,
|
|
855
|
+
"data-testid": "patient-administrative-risks-select"
|
|
856
|
+
}
|
|
857
|
+
),
|
|
858
|
+
/* @__PURE__ */ jsx4(ScrollArea2.Autosize, { mah: 228, mt: "lg", children: /* @__PURE__ */ jsxs3(Paper3, { withBorder: true, mx: "xs", children: [
|
|
859
|
+
selectedRisks.map((risk, index) => /* @__PURE__ */ jsxs3(Flex3, { align: "center", justify: "space-between", p: "xs", children: [
|
|
860
|
+
/* @__PURE__ */ jsxs3(Group, { gap: "sm", align: "center", children: [
|
|
861
|
+
/* @__PURE__ */ jsx4(
|
|
862
|
+
ThemeIcon,
|
|
863
|
+
{
|
|
864
|
+
color: risk.classification === "high" ? "#f39682" : "#83c036",
|
|
865
|
+
variant: "light",
|
|
866
|
+
children: /* @__PURE__ */ jsx4(
|
|
867
|
+
IconExclamationCircleFilled,
|
|
868
|
+
{
|
|
869
|
+
color: risk.classification === "high" ? "#f39682" : "#83c036",
|
|
870
|
+
style: { width: 20, height: 20 }
|
|
871
|
+
}
|
|
872
|
+
)
|
|
873
|
+
}
|
|
874
|
+
),
|
|
875
|
+
/* @__PURE__ */ jsx4(Text2, { lineClamp: 2, title: risk.description, children: risk.description })
|
|
876
|
+
] }),
|
|
877
|
+
/* @__PURE__ */ jsx4(
|
|
878
|
+
ActionIcon3,
|
|
879
|
+
{
|
|
880
|
+
variant: "subtle",
|
|
881
|
+
onClick: () => handleRemoveRisk(risk.id),
|
|
882
|
+
"data-testid": `patient-administrative-risks-remove-button-${index}`,
|
|
883
|
+
children: /* @__PURE__ */ jsx4(IconX3, { style: { width: 20, height: 20 } })
|
|
884
|
+
}
|
|
885
|
+
)
|
|
886
|
+
] }, risk.id)),
|
|
887
|
+
selectedRisks.length === 0 && /* @__PURE__ */ jsx4(Text2, { c: "dimmed", p: "xs", children: "No hay riesgos administrativos seleccionados." })
|
|
888
|
+
] }) }),
|
|
889
|
+
/* @__PURE__ */ jsxs3(Group, { justify: "flex-end", gap: "md", mt: "xl", children: [
|
|
890
|
+
/* @__PURE__ */ jsx4(
|
|
891
|
+
Button,
|
|
892
|
+
{
|
|
893
|
+
variant: "outline",
|
|
894
|
+
onClick: onClose,
|
|
895
|
+
"data-testid": "patient-administrative-risks-cancel-button",
|
|
896
|
+
children: "Cancelar"
|
|
897
|
+
}
|
|
898
|
+
),
|
|
899
|
+
/* @__PURE__ */ jsx4(
|
|
900
|
+
Button,
|
|
901
|
+
{
|
|
902
|
+
type: "submit",
|
|
903
|
+
onClick: handleSaveRisks,
|
|
904
|
+
"data-testid": "patient-administrative-risks-save-button",
|
|
905
|
+
children: "Guardar"
|
|
906
|
+
}
|
|
907
|
+
)
|
|
908
|
+
] })
|
|
909
|
+
]
|
|
910
|
+
}
|
|
911
|
+
);
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
// src/components/PatientAssistanceRisks.tsx
|
|
915
|
+
import { useEffect as useEffect2, useMemo as useMemo3, useState as useState3 } from "react";
|
|
916
|
+
import {
|
|
917
|
+
ActionIcon as ActionIcon4,
|
|
918
|
+
Button as Button2,
|
|
919
|
+
Flex as Flex4,
|
|
920
|
+
FocusTrap as FocusTrap2,
|
|
921
|
+
Group as Group2,
|
|
922
|
+
Modal as Modal2,
|
|
923
|
+
Paper as Paper4,
|
|
924
|
+
ScrollArea as ScrollArea3,
|
|
925
|
+
Select as Select3,
|
|
926
|
+
Text as Text3
|
|
927
|
+
} from "@mantine/core";
|
|
928
|
+
import { IconX as IconX4 } from "@tabler/icons-react";
|
|
929
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
930
|
+
var PatientAssistanceRisks = ({
|
|
931
|
+
patientId,
|
|
932
|
+
isOpen,
|
|
933
|
+
onClose
|
|
934
|
+
}) => {
|
|
935
|
+
const { userAccountId } = useTTNSharedContext();
|
|
936
|
+
const [riskValue, setRiskValue] = useState3(null);
|
|
937
|
+
const [selectedRisks, setSelectedRisks] = useState3([]);
|
|
938
|
+
const { data: patientInfo } = usePatientDetail({
|
|
939
|
+
enabled: Boolean(patientId) && isOpen,
|
|
940
|
+
filters: {
|
|
941
|
+
eaccount: userAccountId,
|
|
942
|
+
id: patientId
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
const { data: assistanceRisks } = useAssistanceRisks({
|
|
946
|
+
enabled: Boolean(patientId) && isOpen,
|
|
947
|
+
filters: {
|
|
948
|
+
status: "enabled"
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
const { mutateAsync: updateRisks2 } = useUpdateRisks();
|
|
952
|
+
const handleChangeRisk = (riskId) => {
|
|
953
|
+
if (!riskId) {
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
const selectedRisk = assistanceRisks?.find((risk) => String(risk.clinicalDiseaseId) === riskId);
|
|
957
|
+
if (selectedRisk) {
|
|
958
|
+
const newRisks = [...selectedRisks, selectedRisk];
|
|
959
|
+
setSelectedRisks(newRisks);
|
|
960
|
+
setRiskValue(null);
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
const handleSaveRisks = async () => {
|
|
964
|
+
await updateRisks2({
|
|
965
|
+
eaccount: userAccountId ?? 0,
|
|
966
|
+
idPatient: patientId ?? 0,
|
|
967
|
+
riskList: {
|
|
968
|
+
assistance: selectedRisks
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
onClose();
|
|
972
|
+
};
|
|
973
|
+
const handleRemoveRisk = (riskId) => {
|
|
974
|
+
const newRisks = selectedRisks.filter((risk) => risk.clinicalDiseaseId !== riskId);
|
|
975
|
+
setSelectedRisks(newRisks);
|
|
976
|
+
};
|
|
977
|
+
useEffect2(() => {
|
|
978
|
+
if (!patientInfo || !isOpen) {
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
const formattedRisks = (patientInfo.risk.assistance ?? []).map((risk) => ({
|
|
982
|
+
clinicalDiseaseId: risk.id,
|
|
983
|
+
clinicalDiseaseName: risk.name,
|
|
984
|
+
clinicalDiseaseTag: ""
|
|
985
|
+
}));
|
|
986
|
+
setSelectedRisks(formattedRisks);
|
|
987
|
+
}, [patientInfo, isOpen]);
|
|
988
|
+
const assistanceRiskOptions = useMemo3(() => {
|
|
989
|
+
const options = [];
|
|
990
|
+
for (const risk of assistanceRisks ?? []) {
|
|
991
|
+
if (selectedRisks.some((selected) => selected.clinicalDiseaseId === risk.clinicalDiseaseId)) {
|
|
992
|
+
continue;
|
|
993
|
+
}
|
|
994
|
+
options.push({ value: String(risk.clinicalDiseaseId), label: risk.clinicalDiseaseName });
|
|
995
|
+
}
|
|
996
|
+
return options;
|
|
997
|
+
}, [assistanceRisks, selectedRisks]);
|
|
998
|
+
return /* @__PURE__ */ jsxs4(
|
|
999
|
+
Modal2,
|
|
1000
|
+
{
|
|
1001
|
+
opened: isOpen,
|
|
1002
|
+
onClose,
|
|
1003
|
+
title: "Importancias asistenciales",
|
|
1004
|
+
withCloseButton: false,
|
|
1005
|
+
children: [
|
|
1006
|
+
/* @__PURE__ */ jsx5(FocusTrap2.InitialFocus, {}),
|
|
1007
|
+
/* @__PURE__ */ jsx5(
|
|
1008
|
+
Select3,
|
|
1009
|
+
{
|
|
1010
|
+
data: assistanceRiskOptions,
|
|
1011
|
+
value: riskValue,
|
|
1012
|
+
onChange: handleChangeRisk,
|
|
1013
|
+
"data-testid": "patient-assistance-risks-select"
|
|
1014
|
+
}
|
|
1015
|
+
),
|
|
1016
|
+
/* @__PURE__ */ jsx5(ScrollArea3.Autosize, { mah: 228, mt: "lg", children: /* @__PURE__ */ jsxs4(Paper4, { withBorder: true, mx: "xs", children: [
|
|
1017
|
+
selectedRisks.map((risk, index) => /* @__PURE__ */ jsxs4(Flex4, { align: "center", justify: "space-between", p: "xs", children: [
|
|
1018
|
+
/* @__PURE__ */ jsx5(Text3, { lineClamp: 2, title: risk.clinicalDiseaseName, children: risk.clinicalDiseaseName }),
|
|
1019
|
+
/* @__PURE__ */ jsx5(
|
|
1020
|
+
ActionIcon4,
|
|
1021
|
+
{
|
|
1022
|
+
variant: "subtle",
|
|
1023
|
+
onClick: () => handleRemoveRisk(risk.clinicalDiseaseId),
|
|
1024
|
+
"data-testid": `patient-assistance-risks-remove-button-${index}`,
|
|
1025
|
+
children: /* @__PURE__ */ jsx5(IconX4, { style: { width: 20, height: 20 } })
|
|
1026
|
+
}
|
|
1027
|
+
)
|
|
1028
|
+
] }, risk.clinicalDiseaseId)),
|
|
1029
|
+
selectedRisks.length === 0 && /* @__PURE__ */ jsx5(Text3, { c: "dimmed", p: "xs", children: "No hay importancias seleccionadas." })
|
|
1030
|
+
] }) }),
|
|
1031
|
+
/* @__PURE__ */ jsxs4(Group2, { justify: "flex-end", gap: "md", mt: "xl", children: [
|
|
1032
|
+
/* @__PURE__ */ jsx5(
|
|
1033
|
+
Button2,
|
|
1034
|
+
{
|
|
1035
|
+
variant: "outline",
|
|
1036
|
+
onClick: onClose,
|
|
1037
|
+
"data-testid": "patient-assistance-risks-cancel-button",
|
|
1038
|
+
children: "Cancelar"
|
|
1039
|
+
}
|
|
1040
|
+
),
|
|
1041
|
+
/* @__PURE__ */ jsx5(
|
|
1042
|
+
Button2,
|
|
1043
|
+
{
|
|
1044
|
+
type: "submit",
|
|
1045
|
+
onClick: handleSaveRisks,
|
|
1046
|
+
"data-testid": "patient-assistance-risks-save-button",
|
|
1047
|
+
children: "Guardar"
|
|
1048
|
+
}
|
|
1049
|
+
)
|
|
1050
|
+
] })
|
|
1051
|
+
]
|
|
1052
|
+
}
|
|
1053
|
+
);
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// src/hooks/appointment.ts
|
|
1057
|
+
import { useQuery as useQuery5 } from "@tanstack/react-query";
|
|
1058
|
+
|
|
1059
|
+
// src/services/appointment.ts
|
|
1060
|
+
var getAppointments = async (token, baseURL, filters) => {
|
|
1061
|
+
const response = await HTTP_MEDICAL(token, baseURL).get(
|
|
1062
|
+
"/appointment/",
|
|
1063
|
+
{ params: filters }
|
|
1064
|
+
);
|
|
1065
|
+
return response.data;
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
// src/hooks/appointment.ts
|
|
1069
|
+
var useAppointments = ({
|
|
1070
|
+
enabled = true,
|
|
1071
|
+
filters
|
|
1072
|
+
}) => {
|
|
1073
|
+
const { token, baseUrl } = useTTNSharedContext();
|
|
1074
|
+
const query = useQuery5({
|
|
1075
|
+
queryKey: [
|
|
1076
|
+
"appointments",
|
|
1077
|
+
filters?.idAccount,
|
|
1078
|
+
filters?.page,
|
|
1079
|
+
filters?.perpage,
|
|
1080
|
+
filters?.idPatient
|
|
1081
|
+
],
|
|
1082
|
+
queryFn: () => getAppointments(token, baseUrl, filters),
|
|
1083
|
+
enabled
|
|
1084
|
+
});
|
|
1085
|
+
return { data: query.data?.results, rowTotal: query.data?.rowTotal };
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
// src/components/PatientAppointmentHistory.tsx
|
|
1089
|
+
import {
|
|
1090
|
+
ActionIcon as ActionIcon5,
|
|
1091
|
+
Badge,
|
|
1092
|
+
Box as Box2,
|
|
1093
|
+
Flex as Flex5,
|
|
1094
|
+
Grid as Grid2,
|
|
1095
|
+
Modal as Modal3,
|
|
1096
|
+
Table,
|
|
1097
|
+
Text as Text5,
|
|
1098
|
+
TextInput as TextInput2,
|
|
1099
|
+
Title as Title3
|
|
1100
|
+
} from "@mantine/core";
|
|
1101
|
+
import { IconSearch } from "@tabler/icons-react";
|
|
1102
|
+
import { useState as useState4 } from "react";
|
|
1103
|
+
|
|
1104
|
+
// src/components/AppPagination.tsx
|
|
1105
|
+
import { Group as Group3, Pagination, Text as Text4, useMantineTheme } from "@mantine/core";
|
|
1106
|
+
import * as TI from "@tabler/icons-react";
|
|
1107
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1108
|
+
var SkipPrevIcon = () => /* @__PURE__ */ jsx6(TI.IconPlayerSkipBackFilled, { style: { width: 12, height: 12 } });
|
|
1109
|
+
var PrevIcon = () => /* @__PURE__ */ jsx6(TI.IconCaretLeftFilled, { style: { width: 15, height: 15 } });
|
|
1110
|
+
var NextIcon = () => /* @__PURE__ */ jsx6(TI.IconCaretRightFilled, { style: { width: 15, height: 15 } });
|
|
1111
|
+
var SkipNextIcon = () => /* @__PURE__ */ jsx6(TI.IconPlayerSkipForwardFilled, { style: { width: 12, height: 12 } });
|
|
1112
|
+
function AppPagination(props) {
|
|
1113
|
+
const theme = useMantineTheme();
|
|
1114
|
+
const total = Math.ceil(Math.ceil(props.total || 0) / 10);
|
|
1115
|
+
const chunkedTotal = props.chunkedTotal;
|
|
1116
|
+
const renderComponent = () => {
|
|
1117
|
+
return /* @__PURE__ */ jsxs5(
|
|
1118
|
+
Group3,
|
|
1119
|
+
{
|
|
1120
|
+
w: "100%",
|
|
1121
|
+
py: "xl",
|
|
1122
|
+
align: "center",
|
|
1123
|
+
justify: props.withDetails ? "space-between" : "flex-end",
|
|
1124
|
+
mt: "lg",
|
|
1125
|
+
"data-testid": "apppagination-main-group",
|
|
1126
|
+
children: [
|
|
1127
|
+
props.withDetails && /* @__PURE__ */ jsxs5(Text4, { "data-testid": "apppagination-details-text", children: [
|
|
1128
|
+
"P\xE1g. ",
|
|
1129
|
+
Number(props?.value),
|
|
1130
|
+
" de ",
|
|
1131
|
+
chunkedTotal ?? total,
|
|
1132
|
+
" ",
|
|
1133
|
+
props.total ? `(${props.total} encontrados)` : ""
|
|
1134
|
+
] }),
|
|
1135
|
+
/* @__PURE__ */ jsx6(
|
|
1136
|
+
Pagination.Root,
|
|
1137
|
+
{
|
|
1138
|
+
total: chunkedTotal ?? total,
|
|
1139
|
+
value: props.value,
|
|
1140
|
+
onChange: (page) => {
|
|
1141
|
+
props.onChange?.(page);
|
|
1142
|
+
},
|
|
1143
|
+
onFirstPage: () => props.onChange?.(1),
|
|
1144
|
+
onLastPage: () => props.onChange?.(total),
|
|
1145
|
+
onNextPage: () => props.onChange?.(Number(props?.value) + 1),
|
|
1146
|
+
onPreviousPage: () => props.onChange?.(Number(props?.value) - 1),
|
|
1147
|
+
size: "sm",
|
|
1148
|
+
"data-testid": "apppagination-root",
|
|
1149
|
+
children: /* @__PURE__ */ jsxs5(Group3, { gap: 5, justify: "center", "data-testid": "apppagination-buttons-group", children: [
|
|
1150
|
+
/* @__PURE__ */ jsx6(
|
|
1151
|
+
Pagination.First,
|
|
1152
|
+
{
|
|
1153
|
+
icon: SkipPrevIcon,
|
|
1154
|
+
style: {
|
|
1155
|
+
backgroundColor: "#00b4cc",
|
|
1156
|
+
color: theme.white
|
|
1157
|
+
},
|
|
1158
|
+
"data-testid": "apppagination-first"
|
|
1159
|
+
}
|
|
1160
|
+
),
|
|
1161
|
+
/* @__PURE__ */ jsx6(
|
|
1162
|
+
Pagination.Previous,
|
|
1163
|
+
{
|
|
1164
|
+
icon: PrevIcon,
|
|
1165
|
+
style: {
|
|
1166
|
+
backgroundColor: "#00b4cc",
|
|
1167
|
+
color: theme.white
|
|
1168
|
+
},
|
|
1169
|
+
"data-testid": "apppagination-previous"
|
|
1170
|
+
}
|
|
1171
|
+
),
|
|
1172
|
+
/* @__PURE__ */ jsx6(Pagination.Items, { "data-testid": "apppagination-items" }),
|
|
1173
|
+
/* @__PURE__ */ jsx6(
|
|
1174
|
+
Pagination.Next,
|
|
1175
|
+
{
|
|
1176
|
+
icon: NextIcon,
|
|
1177
|
+
style: {
|
|
1178
|
+
backgroundColor: "#00b4cc",
|
|
1179
|
+
color: theme.white
|
|
1180
|
+
},
|
|
1181
|
+
"data-testid": "apppagination-next"
|
|
1182
|
+
}
|
|
1183
|
+
),
|
|
1184
|
+
/* @__PURE__ */ jsx6(
|
|
1185
|
+
Pagination.Last,
|
|
1186
|
+
{
|
|
1187
|
+
icon: SkipNextIcon,
|
|
1188
|
+
style: {
|
|
1189
|
+
backgroundColor: "#00b4cc",
|
|
1190
|
+
color: theme.white
|
|
1191
|
+
},
|
|
1192
|
+
"data-testid": "apppagination-last"
|
|
1193
|
+
}
|
|
1194
|
+
)
|
|
1195
|
+
] })
|
|
1196
|
+
}
|
|
1197
|
+
)
|
|
1198
|
+
]
|
|
1199
|
+
}
|
|
1200
|
+
);
|
|
1201
|
+
};
|
|
1202
|
+
return renderComponent();
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// src/components/PatientAppointmentHistory.tsx
|
|
1206
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1207
|
+
var PatientAppointmentHistory = ({ patientId }) => {
|
|
1208
|
+
const { userAccountId } = useTTNSharedContext();
|
|
1209
|
+
const [currentPage, setCurrentPage] = useState4(1);
|
|
1210
|
+
const [selectedAppointment, setSelectedAppointment] = useState4();
|
|
1211
|
+
const { data: appointments, rowTotal } = useAppointments({
|
|
1212
|
+
enabled: Boolean(patientId),
|
|
1213
|
+
filters: {
|
|
1214
|
+
idPatient: patientId,
|
|
1215
|
+
page: currentPage,
|
|
1216
|
+
perpage: 10,
|
|
1217
|
+
idAccount: userAccountId ?? 0
|
|
1218
|
+
}
|
|
1219
|
+
});
|
|
1220
|
+
return /* @__PURE__ */ jsxs6(Fragment, { children: [
|
|
1221
|
+
/* @__PURE__ */ jsxs6(Box2, { children: [
|
|
1222
|
+
/* @__PURE__ */ jsx7(Title3, { order: 6, c: "brand-color", mb: "xs", children: "Historial de citas" }),
|
|
1223
|
+
/* @__PURE__ */ jsxs6(Table, { children: [
|
|
1224
|
+
/* @__PURE__ */ jsx7(Table.Thead, { children: /* @__PURE__ */ jsxs6(Table.Tr, { children: [
|
|
1225
|
+
/* @__PURE__ */ jsx7(Table.Th, { ta: "center", children: "Fecha" }),
|
|
1226
|
+
/* @__PURE__ */ jsx7(Table.Th, { ta: "start", children: " Servicio" }),
|
|
1227
|
+
/* @__PURE__ */ jsx7(Table.Th, { ta: "center", children: "Estado" }),
|
|
1228
|
+
/* @__PURE__ */ jsx7(Table.Th, {})
|
|
1229
|
+
] }) }),
|
|
1230
|
+
/* @__PURE__ */ jsxs6(Table.Tbody, { children: [
|
|
1231
|
+
appointments?.map((appointment) => /* @__PURE__ */ jsxs6(Table.Tr, { children: [
|
|
1232
|
+
/* @__PURE__ */ jsx7(Table.Td, { ta: "center", children: appointment.dateApp }),
|
|
1233
|
+
/* @__PURE__ */ jsx7(Table.Td, { ta: "start", tt: "capitalize", children: appointment.serviceName?.toLowerCase() }),
|
|
1234
|
+
/* @__PURE__ */ jsx7(Table.Td, { miw: 132, ta: "center", children: /* @__PURE__ */ jsx7(
|
|
1235
|
+
Badge,
|
|
1236
|
+
{
|
|
1237
|
+
variant: "light",
|
|
1238
|
+
style: {
|
|
1239
|
+
maxWidth: 150,
|
|
1240
|
+
width: "100%",
|
|
1241
|
+
color: appointment.fontColorStatus,
|
|
1242
|
+
background: appointment.bgColorStatus
|
|
1243
|
+
},
|
|
1244
|
+
children: appointment.status
|
|
1245
|
+
}
|
|
1246
|
+
) }),
|
|
1247
|
+
/* @__PURE__ */ jsx7(Table.Td, { ta: "center", children: /* @__PURE__ */ jsx7(
|
|
1248
|
+
ActionIcon5,
|
|
1249
|
+
{
|
|
1250
|
+
variant: "subtle",
|
|
1251
|
+
onClick: () => setSelectedAppointment(appointment),
|
|
1252
|
+
"data-testid": "patient-appointment-history-view-details-button",
|
|
1253
|
+
children: /* @__PURE__ */ jsx7(IconSearch, {})
|
|
1254
|
+
}
|
|
1255
|
+
) })
|
|
1256
|
+
] }, appointment.id)),
|
|
1257
|
+
!appointments?.length && /* @__PURE__ */ jsx7(Table.Tr, { children: /* @__PURE__ */ jsx7(Table.Td, { ta: "center", colSpan: 4, children: "No hay informaci\xF3n para mostrar." }) })
|
|
1258
|
+
] })
|
|
1259
|
+
] }),
|
|
1260
|
+
/* @__PURE__ */ jsx7(
|
|
1261
|
+
AppPagination,
|
|
1262
|
+
{
|
|
1263
|
+
value: currentPage,
|
|
1264
|
+
total: rowTotal,
|
|
1265
|
+
rowTotal,
|
|
1266
|
+
onChange: setCurrentPage
|
|
1267
|
+
}
|
|
1268
|
+
)
|
|
1269
|
+
] }),
|
|
1270
|
+
/* @__PURE__ */ jsxs6(
|
|
1271
|
+
Modal3.Root,
|
|
1272
|
+
{
|
|
1273
|
+
opened: Boolean(selectedAppointment),
|
|
1274
|
+
onClose: () => setSelectedAppointment(void 0),
|
|
1275
|
+
size: "100%",
|
|
1276
|
+
children: [
|
|
1277
|
+
/* @__PURE__ */ jsx7(Modal3.Overlay, {}),
|
|
1278
|
+
/* @__PURE__ */ jsxs6(Modal3.Content, { children: [
|
|
1279
|
+
/* @__PURE__ */ jsxs6(Modal3.Header, { style: { alignItems: "flex-start" }, children: [
|
|
1280
|
+
/* @__PURE__ */ jsxs6(Modal3.Title, { children: [
|
|
1281
|
+
/* @__PURE__ */ jsx7(Text5, { c: "brand-color", ta: "center", fz: 24, fw: 700, children: "Detalles de la cita" }),
|
|
1282
|
+
/* @__PURE__ */ jsxs6(Text5, { c: selectedAppointment?.fontColorStatus, ta: "center", fz: 20, children: [
|
|
1283
|
+
"Estado - ",
|
|
1284
|
+
selectedAppointment?.status
|
|
1285
|
+
] })
|
|
1286
|
+
] }),
|
|
1287
|
+
/* @__PURE__ */ jsx7(Modal3.CloseButton, {})
|
|
1288
|
+
] }),
|
|
1289
|
+
/* @__PURE__ */ jsxs6(Modal3.Body, { children: [
|
|
1290
|
+
/* @__PURE__ */ jsxs6(Text5, { ta: "center", c: "secondary-color", fz: 16, fw: 700, children: [
|
|
1291
|
+
"Identificador de la cita no. ",
|
|
1292
|
+
selectedAppointment?.id
|
|
1293
|
+
] }),
|
|
1294
|
+
/* @__PURE__ */ jsxs6(Flex5, { gap: "lg", mt: "md", children: [
|
|
1295
|
+
/* @__PURE__ */ jsxs6(Box2, { miw: 228, children: [
|
|
1296
|
+
/* @__PURE__ */ jsx7(
|
|
1297
|
+
TextInput2,
|
|
1298
|
+
{
|
|
1299
|
+
readOnly: true,
|
|
1300
|
+
label: "Identificaci\xF3n del paciente",
|
|
1301
|
+
value: selectedAppointment?.cluDocument ?? "",
|
|
1302
|
+
mb: "xs"
|
|
1303
|
+
}
|
|
1304
|
+
),
|
|
1305
|
+
/* @__PURE__ */ jsx7(
|
|
1306
|
+
TextInput2,
|
|
1307
|
+
{
|
|
1308
|
+
readOnly: true,
|
|
1309
|
+
label: "Primer nombre",
|
|
1310
|
+
value: selectedAppointment?.cluFirstName ?? "",
|
|
1311
|
+
mb: "xs"
|
|
1312
|
+
}
|
|
1313
|
+
),
|
|
1314
|
+
/* @__PURE__ */ jsx7(
|
|
1315
|
+
TextInput2,
|
|
1316
|
+
{
|
|
1317
|
+
readOnly: true,
|
|
1318
|
+
label: "Primer apellido",
|
|
1319
|
+
value: selectedAppointment?.cluLastName ?? "",
|
|
1320
|
+
mb: "xs"
|
|
1321
|
+
}
|
|
1322
|
+
),
|
|
1323
|
+
/* @__PURE__ */ jsx7(
|
|
1324
|
+
TextInput2,
|
|
1325
|
+
{
|
|
1326
|
+
readOnly: true,
|
|
1327
|
+
label: "Fecha de nacimiento",
|
|
1328
|
+
value: selectedAppointment?.cluBirhDate ?? "",
|
|
1329
|
+
mb: "xs"
|
|
1330
|
+
}
|
|
1331
|
+
),
|
|
1332
|
+
/* @__PURE__ */ jsx7(
|
|
1333
|
+
TextInput2,
|
|
1334
|
+
{
|
|
1335
|
+
readOnly: true,
|
|
1336
|
+
label: "WhatsApp",
|
|
1337
|
+
value: selectedAppointment?.cluWhatasapp ?? "",
|
|
1338
|
+
mb: "xs"
|
|
1339
|
+
}
|
|
1340
|
+
),
|
|
1341
|
+
/* @__PURE__ */ jsx7(
|
|
1342
|
+
TextInput2,
|
|
1343
|
+
{
|
|
1344
|
+
readOnly: true,
|
|
1345
|
+
label: "Correo electr\xF3nico",
|
|
1346
|
+
value: selectedAppointment?.cluEmail ?? ""
|
|
1347
|
+
}
|
|
1348
|
+
)
|
|
1349
|
+
] }),
|
|
1350
|
+
/* @__PURE__ */ jsx7(Box2, { style: { flexGrow: 1 }, children: /* @__PURE__ */ jsxs6(Grid2, { children: [
|
|
1351
|
+
/* @__PURE__ */ jsxs6(Grid2.Col, { span: 6, children: [
|
|
1352
|
+
/* @__PURE__ */ jsx7(Text5, { c: "secondary-color", fw: 700, children: "Informaci\xF3n de la cita" }),
|
|
1353
|
+
/* @__PURE__ */ jsxs6(Grid2, { children: [
|
|
1354
|
+
/* @__PURE__ */ jsxs6(Grid2.Col, { span: 6, children: [
|
|
1355
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Sede" }),
|
|
1356
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "M\xE9dico" }),
|
|
1357
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Servicio" }),
|
|
1358
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Fecha" }),
|
|
1359
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "No. Historia cl\xEDnica" }),
|
|
1360
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Diagn\xF3stico" })
|
|
1361
|
+
] }),
|
|
1362
|
+
/* @__PURE__ */ jsxs6(Grid2.Col, { span: 6, children: [
|
|
1363
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.siteName, children: selectedAppointment?.siteName ?? "-" }),
|
|
1364
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.fullNameDoctor, children: selectedAppointment?.fullNameDoctor ?? "-" }),
|
|
1365
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.serviceName, children: selectedAppointment?.serviceName ?? "-" }),
|
|
1366
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.dateApp, children: selectedAppointment?.dateApp ?? "-" }),
|
|
1367
|
+
/* @__PURE__ */ jsx7(
|
|
1368
|
+
Text5,
|
|
1369
|
+
{
|
|
1370
|
+
lineClamp: 1,
|
|
1371
|
+
title: String(selectedAppointment?.clinicalHistoryID ?? ""),
|
|
1372
|
+
children: selectedAppointment?.clinicalHistoryID ?? "-"
|
|
1373
|
+
}
|
|
1374
|
+
),
|
|
1375
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.dxName, children: selectedAppointment?.dxName ?? "-" })
|
|
1376
|
+
] })
|
|
1377
|
+
] })
|
|
1378
|
+
] }),
|
|
1379
|
+
/* @__PURE__ */ jsxs6(Grid2.Col, { span: 6, children: [
|
|
1380
|
+
/* @__PURE__ */ jsx7(Text5, { c: "secondary-color", fw: 700, children: "Aseguradora" }),
|
|
1381
|
+
/* @__PURE__ */ jsxs6(Grid2, { children: [
|
|
1382
|
+
/* @__PURE__ */ jsxs6(Grid2.Col, { span: 6, children: [
|
|
1383
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Aseguradora" }),
|
|
1384
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Contrato" }),
|
|
1385
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Poblaci\xF3n" }),
|
|
1386
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Grupo de ingreso" }),
|
|
1387
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Observaciones" })
|
|
1388
|
+
] }),
|
|
1389
|
+
/* @__PURE__ */ jsxs6(Grid2.Col, { span: 6, children: [
|
|
1390
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.ccName, children: selectedAppointment?.ccName ?? "-" }),
|
|
1391
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.contractName, children: selectedAppointment?.contractName ?? "-" }),
|
|
1392
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.popName, children: selectedAppointment?.popName ?? "-" }),
|
|
1393
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.crtName, children: selectedAppointment?.crtName ?? "-" }),
|
|
1394
|
+
/* @__PURE__ */ jsx7(Text5, { lineClamp: 1, title: selectedAppointment?.appObservations, children: selectedAppointment?.appObservations || "-" })
|
|
1395
|
+
] })
|
|
1396
|
+
] })
|
|
1397
|
+
] }),
|
|
1398
|
+
/* @__PURE__ */ jsxs6(Grid2.Col, { span: 6, children: [
|
|
1399
|
+
/* @__PURE__ */ jsx7(Text5, { c: "secondary-color", fw: 700, children: "Recaudo" }),
|
|
1400
|
+
/* @__PURE__ */ jsxs6(Grid2, { children: [
|
|
1401
|
+
/* @__PURE__ */ jsxs6(Grid2.Col, { span: 6, children: [
|
|
1402
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Efectivo" }),
|
|
1403
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Total d\xE9bito" }),
|
|
1404
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Total" }),
|
|
1405
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Asesor" }),
|
|
1406
|
+
/* @__PURE__ */ jsx7(Text5, { c: "dimmed", fw: 700, children: "Fecha" })
|
|
1407
|
+
] }),
|
|
1408
|
+
/* @__PURE__ */ jsxs6(Grid2.Col, { span: 6, children: [
|
|
1409
|
+
/* @__PURE__ */ jsx7(Text5, { children: "-" }),
|
|
1410
|
+
/* @__PURE__ */ jsx7(Text5, { children: "-" }),
|
|
1411
|
+
/* @__PURE__ */ jsx7(Text5, { children: "-" }),
|
|
1412
|
+
/* @__PURE__ */ jsx7(Text5, { children: "-" }),
|
|
1413
|
+
/* @__PURE__ */ jsx7(Text5, { children: "-" }),
|
|
1414
|
+
/* @__PURE__ */ jsx7(Text5, { children: "-" })
|
|
1415
|
+
] })
|
|
1416
|
+
] })
|
|
1417
|
+
] })
|
|
1418
|
+
] }) })
|
|
1419
|
+
] })
|
|
1420
|
+
] })
|
|
1421
|
+
] })
|
|
1422
|
+
]
|
|
1423
|
+
}
|
|
1424
|
+
)
|
|
1425
|
+
] });
|
|
1426
|
+
};
|
|
1427
|
+
|
|
1428
|
+
// src/components/PatientForm.tsx
|
|
1429
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1430
|
+
var PatientForm = ({
|
|
1431
|
+
defaultMode,
|
|
1432
|
+
patientId,
|
|
1433
|
+
onSavePatient,
|
|
1434
|
+
onSaveError,
|
|
1435
|
+
onBack
|
|
1436
|
+
}) => {
|
|
1437
|
+
const { userAccountId } = useTTNSharedContext();
|
|
1438
|
+
const [mode, setMode] = useState5(defaultMode);
|
|
1439
|
+
const [openPatientNotes, setOpenPatientNotes] = useState5(false);
|
|
1440
|
+
const [openPatientAssistanceRisks, setOpenPatientAssistanceRisks] = useState5(false);
|
|
1441
|
+
const [openPatientAdministrativeRisks, setOpenPatientAdministrativeRisks] = useState5(false);
|
|
1442
|
+
const form = useForm({
|
|
1443
|
+
mode: "controlled",
|
|
1444
|
+
initialValues: {
|
|
1445
|
+
documentTypeId: "",
|
|
1446
|
+
documentNumber: "",
|
|
1447
|
+
firstName: "",
|
|
1448
|
+
middleName: "",
|
|
1449
|
+
surname: "",
|
|
1450
|
+
secondSurname: "",
|
|
1451
|
+
birthDate: "",
|
|
1452
|
+
age: "",
|
|
1453
|
+
whatsapp: "",
|
|
1454
|
+
gender: "",
|
|
1455
|
+
affiliationTypeId: "",
|
|
1456
|
+
bloodType: "",
|
|
1457
|
+
email: "",
|
|
1458
|
+
provinceId: "",
|
|
1459
|
+
cityId: "",
|
|
1460
|
+
homeAddress: "",
|
|
1461
|
+
neighborhood: "",
|
|
1462
|
+
cellphone: "",
|
|
1463
|
+
homephone: "",
|
|
1464
|
+
emergencyContact: "",
|
|
1465
|
+
maritalStatus: "",
|
|
1466
|
+
occupation: "",
|
|
1467
|
+
use_glasses: "",
|
|
1468
|
+
use_contact_lens: "",
|
|
1469
|
+
isDataPolicyAccepted: false,
|
|
1470
|
+
stratumId: "",
|
|
1471
|
+
educationLevelId: "",
|
|
1472
|
+
ethnicGroupId: "",
|
|
1473
|
+
mandatoryInsurance: {
|
|
1474
|
+
companyId: "",
|
|
1475
|
+
plan: "",
|
|
1476
|
+
population: "",
|
|
1477
|
+
groupId: "",
|
|
1478
|
+
policyNumber: ""
|
|
1479
|
+
},
|
|
1480
|
+
voluntaryInsurance: []
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
form.watch("birthDate", ({ value }) => {
|
|
1484
|
+
if (!value) {
|
|
1485
|
+
form.setFieldValue("age", "");
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
const birthDate = dayjs(value);
|
|
1489
|
+
const today = dayjs();
|
|
1490
|
+
const age = today.diff(birthDate, "year");
|
|
1491
|
+
form.setFieldValue("age", String(age));
|
|
1492
|
+
});
|
|
1493
|
+
const { data: patientInfo, refetch: refetchPatientInfo } = usePatientDetail({
|
|
1494
|
+
enabled: Boolean(patientId) && mode !== "create",
|
|
1495
|
+
filters: {
|
|
1496
|
+
eaccount: userAccountId,
|
|
1497
|
+
id: patientId
|
|
1498
|
+
}
|
|
1499
|
+
});
|
|
1500
|
+
const { data: documentTypes } = useDocumentTypes({});
|
|
1501
|
+
const { data: affiliationTypes } = useAffiliationTypes({
|
|
1502
|
+
filters: { eaccount: userAccountId }
|
|
1503
|
+
});
|
|
1504
|
+
const { data: provinces } = useProvinces({
|
|
1505
|
+
filters: { eaccount: userAccountId }
|
|
1506
|
+
});
|
|
1507
|
+
const { data: cities } = useCities({
|
|
1508
|
+
enabled: Boolean(form.values.provinceId),
|
|
1509
|
+
provinceId: Number(form.values.provinceId) || void 0
|
|
1510
|
+
});
|
|
1511
|
+
const { data: stratums } = useStratums({});
|
|
1512
|
+
const { data: ethnicGroups } = useEthnicGroups({
|
|
1513
|
+
filters: { eaccount: userAccountId }
|
|
1514
|
+
});
|
|
1515
|
+
const { data: educationLevels } = useEducationLevels({
|
|
1516
|
+
filters: { eaccount: userAccountId }
|
|
1517
|
+
});
|
|
1518
|
+
const { data: companyClients } = useCompanyClients({
|
|
1519
|
+
filters: { eaccount: userAccountId }
|
|
1520
|
+
});
|
|
1521
|
+
const { data: contracts } = useContracts({
|
|
1522
|
+
enabled: Boolean(form.values.mandatoryInsurance.companyId),
|
|
1523
|
+
filters: {
|
|
1524
|
+
eaccount: userAccountId,
|
|
1525
|
+
client: Number(form.values.mandatoryInsurance.companyId) || void 0
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
const { data: contractPopulations } = useContractPopulations({
|
|
1529
|
+
enabled: Boolean(form.values.mandatoryInsurance.plan),
|
|
1530
|
+
filters: {
|
|
1531
|
+
eaccount: userAccountId,
|
|
1532
|
+
contract: Number(form.values.mandatoryInsurance.plan) || void 0
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
const { data: incomeGroups } = useIncomeGroups({
|
|
1536
|
+
enabled: Boolean(form.values.mandatoryInsurance.companyId),
|
|
1537
|
+
filters: {
|
|
1538
|
+
eaccount: userAccountId,
|
|
1539
|
+
corpclientId: Number(form.values.mandatoryInsurance.companyId) || void 0
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
const handleSubmit = (values) => {
|
|
1543
|
+
const requiredFields = [
|
|
1544
|
+
{
|
|
1545
|
+
value: values.documentTypeId,
|
|
1546
|
+
message: "El campo Tipo de Documento es obligatorio."
|
|
1547
|
+
},
|
|
1548
|
+
{
|
|
1549
|
+
value: values.documentNumber,
|
|
1550
|
+
message: "El campo N\xFAmero de Documento es obligatorio."
|
|
1551
|
+
},
|
|
1552
|
+
{
|
|
1553
|
+
value: values.firstName,
|
|
1554
|
+
message: "El campo Primer Nombre es obligatorio."
|
|
1555
|
+
},
|
|
1556
|
+
{
|
|
1557
|
+
value: values.surname,
|
|
1558
|
+
message: "El campo Primer Apellido es obligatorio."
|
|
1559
|
+
},
|
|
1560
|
+
{
|
|
1561
|
+
value: values.birthDate,
|
|
1562
|
+
message: "El campo Fecha de Nacimiento es obligatorio."
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
value: values.whatsapp,
|
|
1566
|
+
message: "El campo WhatsApp es obligatorio."
|
|
1567
|
+
},
|
|
1568
|
+
{
|
|
1569
|
+
value: values.gender,
|
|
1570
|
+
message: "El campo G\xE9nero es obligatorio."
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
value: values.affiliationTypeId,
|
|
1574
|
+
message: "El campo Tipo de afiliado es obligatorio."
|
|
1575
|
+
},
|
|
1576
|
+
{
|
|
1577
|
+
value: values.maritalStatus,
|
|
1578
|
+
message: "El campo Estado civil es obligatorio."
|
|
1579
|
+
},
|
|
1580
|
+
{
|
|
1581
|
+
value: values.provinceId,
|
|
1582
|
+
message: "El campo Departamento es obligatorio."
|
|
1583
|
+
},
|
|
1584
|
+
{
|
|
1585
|
+
value: values.cityId,
|
|
1586
|
+
message: "El campo Municipio es obligatorio."
|
|
1587
|
+
},
|
|
1588
|
+
{
|
|
1589
|
+
value: values.cellphone,
|
|
1590
|
+
message: "El campo Celular es obligatorio."
|
|
1591
|
+
},
|
|
1592
|
+
{
|
|
1593
|
+
value: values.stratumId,
|
|
1594
|
+
message: "El campo Estrato es obligatorio."
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
value: values.ethnicGroupId,
|
|
1598
|
+
message: "El campo Pertenencia \xE9tnica es obligatorio."
|
|
1599
|
+
},
|
|
1600
|
+
{
|
|
1601
|
+
value: values.educationLevelId,
|
|
1602
|
+
message: "El campo Nivel educativo es obligatorio."
|
|
1603
|
+
},
|
|
1604
|
+
{
|
|
1605
|
+
value: values.mandatoryInsurance.companyId,
|
|
1606
|
+
message: "Aseguradora obligatoria: El campo Seguro es obligatorio."
|
|
1607
|
+
},
|
|
1608
|
+
{
|
|
1609
|
+
value: values.mandatoryInsurance.plan,
|
|
1610
|
+
message: "Aseguradora obligatoria: El campo Plan es obligatorio."
|
|
1611
|
+
},
|
|
1612
|
+
{
|
|
1613
|
+
value: values.mandatoryInsurance.population,
|
|
1614
|
+
message: "Aseguradora obligatoria: El campo Poblaci\xF3n es obligatorio."
|
|
1615
|
+
},
|
|
1616
|
+
{
|
|
1617
|
+
value: values.mandatoryInsurance.groupId,
|
|
1618
|
+
message: "Aseguradora obligatoria: El campo Grupo de ingreso es obligatorio."
|
|
1619
|
+
}
|
|
1620
|
+
];
|
|
1621
|
+
for (const field of requiredFields) {
|
|
1622
|
+
if (!field.value) {
|
|
1623
|
+
onSaveError?.(field.message);
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
const voluntaryRequiredFields = values.voluntaryInsurance.map((insurance, index) => {
|
|
1628
|
+
const fields = [
|
|
1629
|
+
{
|
|
1630
|
+
value: insurance.companyType,
|
|
1631
|
+
message: `Aseguradora voluntaria #${index + 1}: El campo Tipo de seguro es obligatorio.`
|
|
1632
|
+
},
|
|
1633
|
+
{
|
|
1634
|
+
value: insurance.companyId,
|
|
1635
|
+
message: `Aseguradora voluntaria #${index + 1}: El campo Seguro es obligatorio.`
|
|
1636
|
+
},
|
|
1637
|
+
{
|
|
1638
|
+
value: insurance.plan,
|
|
1639
|
+
message: `Aseguradora voluntaria #${index + 1}: El campo Plan es obligatorio.`
|
|
1640
|
+
},
|
|
1641
|
+
{
|
|
1642
|
+
value: insurance.population,
|
|
1643
|
+
message: `Aseguradora voluntaria #${index + 1}: El campo Poblaci\xF3n es obligatorio.`
|
|
1644
|
+
}
|
|
1645
|
+
];
|
|
1646
|
+
if (VOLUNTARY_INSURANCE_TAGS.includes(insurance.companyTypeTag)) {
|
|
1647
|
+
fields.push({
|
|
1648
|
+
value: insurance.groupId,
|
|
1649
|
+
message: `Aseguradora voluntaria #${index + 1}: El campo Grupo de ingreso es obligatorio.`
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
return fields;
|
|
1653
|
+
});
|
|
1654
|
+
for (const insuranceFields of voluntaryRequiredFields) {
|
|
1655
|
+
for (const field of insuranceFields) {
|
|
1656
|
+
if (!field.value) {
|
|
1657
|
+
onSaveError?.(field.message);
|
|
1658
|
+
return;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
if (!values.isDataPolicyAccepted) {
|
|
1663
|
+
onSaveError?.("Debe aceptar la pol\xEDtica de tratamiento de datos.");
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
onSavePatient?.(createPatientPayload(values), mode);
|
|
1667
|
+
};
|
|
1668
|
+
const handleCancelForm = () => {
|
|
1669
|
+
if (mode === "edit") {
|
|
1670
|
+
setMode("view");
|
|
1671
|
+
refetchPatientInfo();
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
onBack?.();
|
|
1675
|
+
};
|
|
1676
|
+
const handleAddVoluntaryInsurance = () => {
|
|
1677
|
+
form.insertListItem("voluntaryInsurance", {
|
|
1678
|
+
companyTypeTag: "",
|
|
1679
|
+
id: Date.now().toString(),
|
|
1680
|
+
companyType: "",
|
|
1681
|
+
companyId: "",
|
|
1682
|
+
plan: "",
|
|
1683
|
+
population: "",
|
|
1684
|
+
groupId: "",
|
|
1685
|
+
policyNumber: ""
|
|
1686
|
+
});
|
|
1687
|
+
};
|
|
1688
|
+
useEffect3(() => {
|
|
1689
|
+
if (!patientInfo || mode === "create") return;
|
|
1690
|
+
const patientForm = createPatientForm(patientInfo);
|
|
1691
|
+
form.setValues(patientForm);
|
|
1692
|
+
}, [patientInfo, mode]);
|
|
1693
|
+
const documentTypeOptions = useMemo4(() => {
|
|
1694
|
+
return documentTypes?.map((dt) => ({
|
|
1695
|
+
value: String(dt.id),
|
|
1696
|
+
label: dt.description
|
|
1697
|
+
}));
|
|
1698
|
+
}, [documentTypes]);
|
|
1699
|
+
const affiliationTypeOptions = useMemo4(() => {
|
|
1700
|
+
return affiliationTypes?.map((at) => ({
|
|
1701
|
+
value: String(at.affiliationTypeId),
|
|
1702
|
+
label: at.affiliationTypeName
|
|
1703
|
+
}));
|
|
1704
|
+
}, [affiliationTypes]);
|
|
1705
|
+
const provinceOptions = useMemo4(() => {
|
|
1706
|
+
return provinces?.map((p) => ({
|
|
1707
|
+
value: String(p.id),
|
|
1708
|
+
label: p.name
|
|
1709
|
+
}));
|
|
1710
|
+
}, [provinces]);
|
|
1711
|
+
const cityOptions = useMemo4(() => {
|
|
1712
|
+
return cities?.map((c) => ({
|
|
1713
|
+
value: String(c.id),
|
|
1714
|
+
label: `${c.name} - ${c.geocode}`
|
|
1715
|
+
}));
|
|
1716
|
+
}, [cities]);
|
|
1717
|
+
const stratumOptions = useMemo4(() => {
|
|
1718
|
+
return stratums?.map((s) => ({
|
|
1719
|
+
value: String(s.id),
|
|
1720
|
+
label: s.name
|
|
1721
|
+
}));
|
|
1722
|
+
}, [stratums]);
|
|
1723
|
+
const ethnicGroupOptions = useMemo4(() => {
|
|
1724
|
+
return ethnicGroups?.map((eg) => ({
|
|
1725
|
+
value: String(eg.id),
|
|
1726
|
+
label: eg.description
|
|
1727
|
+
}));
|
|
1728
|
+
}, [ethnicGroups]);
|
|
1729
|
+
const educationLevelOptions = useMemo4(() => {
|
|
1730
|
+
return educationLevels?.map((el) => ({
|
|
1731
|
+
value: String(el.id),
|
|
1732
|
+
label: el.description
|
|
1733
|
+
}));
|
|
1734
|
+
}, [educationLevels]);
|
|
1735
|
+
const companyClientOptions = useMemo4(() => {
|
|
1736
|
+
return companyClients?.map((cc) => ({
|
|
1737
|
+
value: String(cc.id),
|
|
1738
|
+
label: cc.name
|
|
1739
|
+
}));
|
|
1740
|
+
}, [companyClients]);
|
|
1741
|
+
const contractOptions = useMemo4(() => {
|
|
1742
|
+
return contracts?.map((c) => ({
|
|
1743
|
+
value: String(c.id),
|
|
1744
|
+
label: c.name
|
|
1745
|
+
}));
|
|
1746
|
+
}, [contracts]);
|
|
1747
|
+
const contractPopulationOptions = useMemo4(() => {
|
|
1748
|
+
return contractPopulations?.map((cp) => ({
|
|
1749
|
+
value: String(cp.idPopulation),
|
|
1750
|
+
label: cp.name
|
|
1751
|
+
}));
|
|
1752
|
+
}, [contractPopulations]);
|
|
1753
|
+
const incomeGroupOptions = useMemo4(() => {
|
|
1754
|
+
return incomeGroups?.map((ig) => ({
|
|
1755
|
+
value: String(ig.crtId),
|
|
1756
|
+
label: ig.copaymentRateName
|
|
1757
|
+
}));
|
|
1758
|
+
}, [incomeGroups]);
|
|
1759
|
+
return /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
1760
|
+
/* @__PURE__ */ jsx8(Flex6, { w: "100%", justify: "flex-end", children: /* @__PURE__ */ jsx8(
|
|
1761
|
+
ActionIcon6,
|
|
1762
|
+
{
|
|
1763
|
+
variant: "subtle",
|
|
1764
|
+
onClick: handleCancelForm,
|
|
1765
|
+
"data-testid": "patient-form-close-button",
|
|
1766
|
+
children: /* @__PURE__ */ jsx8(IconX5, { style: { width: 30, height: 30 } })
|
|
1767
|
+
}
|
|
1768
|
+
) }),
|
|
1769
|
+
/* @__PURE__ */ jsx8(Title4, { c: "secondary-color", mt: "xs", children: patientFormTitles[mode] }),
|
|
1770
|
+
mode !== "create" && /* @__PURE__ */ jsxs7(Flex6, { w: "100%", justify: "flex-end", gap: "xs", my: "xs", children: [
|
|
1771
|
+
mode === "view" && /* @__PURE__ */ jsx8(Tooltip, { label: "Editar", withArrow: true, children: /* @__PURE__ */ jsx8(
|
|
1772
|
+
ActionIcon6,
|
|
1773
|
+
{
|
|
1774
|
+
variant: "subtle",
|
|
1775
|
+
onClick: () => setMode("edit"),
|
|
1776
|
+
"data-testid": "patient-form-edit-button",
|
|
1777
|
+
children: /* @__PURE__ */ jsx8(IconPencil, { style: { width: 24, height: 24 } })
|
|
1778
|
+
}
|
|
1779
|
+
) }),
|
|
1780
|
+
/* @__PURE__ */ jsx8(Tooltip, { label: "Ver notas", withArrow: true, children: /* @__PURE__ */ jsx8(
|
|
1781
|
+
ActionIcon6,
|
|
1782
|
+
{
|
|
1783
|
+
variant: "subtle",
|
|
1784
|
+
onClick: () => setOpenPatientNotes(true),
|
|
1785
|
+
"data-testid": "patient-form-notes-button",
|
|
1786
|
+
children: /* @__PURE__ */ jsx8(IconMessage, { style: { width: 24, height: 24 } })
|
|
1787
|
+
}
|
|
1788
|
+
) }),
|
|
1789
|
+
/* @__PURE__ */ jsx8(Tooltip, { label: "Riesgo asistencial", withArrow: true, children: /* @__PURE__ */ jsx8(
|
|
1790
|
+
ActionIcon6,
|
|
1791
|
+
{
|
|
1792
|
+
variant: "subtle",
|
|
1793
|
+
color: "#83c036",
|
|
1794
|
+
onClick: () => setOpenPatientAssistanceRisks(true),
|
|
1795
|
+
"data-testid": "patient-form-assistance-risks-button",
|
|
1796
|
+
children: /* @__PURE__ */ jsx8(IconExclamationCircleFilled2, { style: { width: 24, height: 24 } })
|
|
1797
|
+
}
|
|
1798
|
+
) }),
|
|
1799
|
+
/* @__PURE__ */ jsx8(Tooltip, { label: "Riesgo administrativo", withArrow: true, children: /* @__PURE__ */ jsx8(
|
|
1800
|
+
ActionIcon6,
|
|
1801
|
+
{
|
|
1802
|
+
variant: "subtle",
|
|
1803
|
+
color: "#f39682",
|
|
1804
|
+
onClick: () => setOpenPatientAdministrativeRisks(true),
|
|
1805
|
+
"data-testid": "patient-form-administrative-risks-button",
|
|
1806
|
+
children: /* @__PURE__ */ jsx8(IconExclamationCircleFilled2, { style: { width: 24, height: 24 } })
|
|
1807
|
+
}
|
|
1808
|
+
) })
|
|
1809
|
+
] }),
|
|
1810
|
+
/* @__PURE__ */ jsxs7("form", { onSubmit: form.onSubmit(handleSubmit), children: [
|
|
1811
|
+
/* @__PURE__ */ jsxs7(Grid3, { children: [
|
|
1812
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1813
|
+
Select4,
|
|
1814
|
+
{
|
|
1815
|
+
readOnly: mode === "view",
|
|
1816
|
+
withAsterisk: mode !== "view",
|
|
1817
|
+
label: "Tipo de Documento",
|
|
1818
|
+
data: documentTypeOptions,
|
|
1819
|
+
...form.getInputProps("documentTypeId"),
|
|
1820
|
+
"data-testid": "patient-form-document-type-select"
|
|
1821
|
+
}
|
|
1822
|
+
) }),
|
|
1823
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1824
|
+
TextInput3,
|
|
1825
|
+
{
|
|
1826
|
+
readOnly: mode === "view",
|
|
1827
|
+
withAsterisk: mode !== "view",
|
|
1828
|
+
label: "N\xFAmero de Documento",
|
|
1829
|
+
...form.getInputProps("documentNumber"),
|
|
1830
|
+
"data-testid": "patient-form-document-number-input"
|
|
1831
|
+
}
|
|
1832
|
+
) }),
|
|
1833
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1834
|
+
TextInput3,
|
|
1835
|
+
{
|
|
1836
|
+
readOnly: mode === "view",
|
|
1837
|
+
withAsterisk: mode !== "view",
|
|
1838
|
+
label: "Primer Nombre",
|
|
1839
|
+
...form.getInputProps("firstName"),
|
|
1840
|
+
"data-testid": "patient-form-first-name-input"
|
|
1841
|
+
}
|
|
1842
|
+
) }),
|
|
1843
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1844
|
+
TextInput3,
|
|
1845
|
+
{
|
|
1846
|
+
readOnly: mode === "view",
|
|
1847
|
+
label: "Segundo Nombre",
|
|
1848
|
+
...form.getInputProps("middleName"),
|
|
1849
|
+
"data-testid": "patient-form-middle-name-input"
|
|
1850
|
+
}
|
|
1851
|
+
) }),
|
|
1852
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1853
|
+
TextInput3,
|
|
1854
|
+
{
|
|
1855
|
+
readOnly: mode === "view",
|
|
1856
|
+
withAsterisk: mode !== "view",
|
|
1857
|
+
label: "Primer Apellido",
|
|
1858
|
+
...form.getInputProps("surname"),
|
|
1859
|
+
"data-testid": "patient-form-surname-input"
|
|
1860
|
+
}
|
|
1861
|
+
) }),
|
|
1862
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1863
|
+
TextInput3,
|
|
1864
|
+
{
|
|
1865
|
+
readOnly: mode === "view",
|
|
1866
|
+
label: "Segundo Apellido",
|
|
1867
|
+
...form.getInputProps("secondSurname"),
|
|
1868
|
+
"data-testid": "patient-form-second-surname-input"
|
|
1869
|
+
}
|
|
1870
|
+
) }),
|
|
1871
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1872
|
+
TextInput3,
|
|
1873
|
+
{
|
|
1874
|
+
readOnly: mode === "view",
|
|
1875
|
+
withAsterisk: mode !== "view",
|
|
1876
|
+
label: "Fecha de Nacimiento",
|
|
1877
|
+
type: "date",
|
|
1878
|
+
...form.getInputProps("birthDate"),
|
|
1879
|
+
"data-testid": "patient-form-birth-date-input"
|
|
1880
|
+
}
|
|
1881
|
+
) }),
|
|
1882
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1883
|
+
NumberInput,
|
|
1884
|
+
{
|
|
1885
|
+
readOnly: true,
|
|
1886
|
+
label: "Edad",
|
|
1887
|
+
suffix: !form.values.age ? "" : " a\xF1os",
|
|
1888
|
+
...form.getInputProps("age"),
|
|
1889
|
+
"data-testid": "patient-form-age-input"
|
|
1890
|
+
}
|
|
1891
|
+
) }),
|
|
1892
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1893
|
+
NumberInput,
|
|
1894
|
+
{
|
|
1895
|
+
readOnly: mode === "view",
|
|
1896
|
+
withAsterisk: mode !== "view",
|
|
1897
|
+
label: "WhatsApp",
|
|
1898
|
+
allowNegative: false,
|
|
1899
|
+
allowDecimal: false,
|
|
1900
|
+
...form.getInputProps("whatsapp"),
|
|
1901
|
+
"data-testid": "patient-form-whatsapp-input"
|
|
1902
|
+
}
|
|
1903
|
+
) }),
|
|
1904
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1905
|
+
Select4,
|
|
1906
|
+
{
|
|
1907
|
+
readOnly: mode === "view",
|
|
1908
|
+
withAsterisk: mode !== "view",
|
|
1909
|
+
label: "G\xE9nero",
|
|
1910
|
+
data: genderOptions,
|
|
1911
|
+
...form.getInputProps("gender"),
|
|
1912
|
+
"data-testid": "patient-form-gender-select"
|
|
1913
|
+
}
|
|
1914
|
+
) }),
|
|
1915
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1916
|
+
Select4,
|
|
1917
|
+
{
|
|
1918
|
+
readOnly: mode === "view",
|
|
1919
|
+
withAsterisk: mode !== "view",
|
|
1920
|
+
label: "Tipo de afiliaci\xF3n",
|
|
1921
|
+
data: affiliationTypeOptions,
|
|
1922
|
+
...form.getInputProps("affiliationTypeId"),
|
|
1923
|
+
"data-testid": "patient-form-affiliation-type-select"
|
|
1924
|
+
}
|
|
1925
|
+
) }),
|
|
1926
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1927
|
+
TextInput3,
|
|
1928
|
+
{
|
|
1929
|
+
readOnly: mode === "view",
|
|
1930
|
+
label: "Correo electr\xF3nico",
|
|
1931
|
+
...form.getInputProps("email"),
|
|
1932
|
+
"data-testid": "patient-form-email-input"
|
|
1933
|
+
}
|
|
1934
|
+
) }),
|
|
1935
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1936
|
+
Select4,
|
|
1937
|
+
{
|
|
1938
|
+
readOnly: mode === "view",
|
|
1939
|
+
withAsterisk: mode !== "view",
|
|
1940
|
+
label: "Estado civil",
|
|
1941
|
+
data: maritalStatusOptions,
|
|
1942
|
+
...form.getInputProps("maritalStatus"),
|
|
1943
|
+
"data-testid": "patient-form-marital-status-select"
|
|
1944
|
+
}
|
|
1945
|
+
) }),
|
|
1946
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 12, mt: "sm", children: /* @__PURE__ */ jsx8(
|
|
1947
|
+
Checkbox,
|
|
1948
|
+
{
|
|
1949
|
+
readOnly: mode === "view",
|
|
1950
|
+
label: /* @__PURE__ */ jsxs7(Text6, { fz: "sm", children: [
|
|
1951
|
+
"Autorizo el tratamiento de mis datos personales conforme a la",
|
|
1952
|
+
" ",
|
|
1953
|
+
/* @__PURE__ */ jsx8(
|
|
1954
|
+
Text6,
|
|
1955
|
+
{
|
|
1956
|
+
span: true,
|
|
1957
|
+
c: "brand-color",
|
|
1958
|
+
td: "underline",
|
|
1959
|
+
style: { cursor: "pointer" },
|
|
1960
|
+
"data-testid": "patient-form-data-policy-link",
|
|
1961
|
+
children: "pol\xEDtica de tratamiento de datos."
|
|
1962
|
+
}
|
|
1963
|
+
)
|
|
1964
|
+
] }),
|
|
1965
|
+
...form.getInputProps("isDataPolicyAccepted", { type: "checkbox" }),
|
|
1966
|
+
styles: { inner: { marginTop: 2 } },
|
|
1967
|
+
"data-testid": "patient-form-data-policy-checkbox"
|
|
1968
|
+
}
|
|
1969
|
+
) }),
|
|
1970
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { mt: "md", span: 12, children: /* @__PURE__ */ jsx8(Title4, { order: 6, c: "brand-color", children: "Informaci\xF3n complementaria" }) }),
|
|
1971
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1972
|
+
Select4,
|
|
1973
|
+
{
|
|
1974
|
+
readOnly: mode === "view",
|
|
1975
|
+
withAsterisk: mode !== "view",
|
|
1976
|
+
label: "Departamento",
|
|
1977
|
+
data: provinceOptions,
|
|
1978
|
+
...form.getInputProps("provinceId"),
|
|
1979
|
+
onChange: (value) => {
|
|
1980
|
+
form.setFieldValue("provinceId", value || "");
|
|
1981
|
+
form.setFieldValue("cityId", "");
|
|
1982
|
+
},
|
|
1983
|
+
"data-testid": "patient-form-province-select"
|
|
1984
|
+
}
|
|
1985
|
+
) }),
|
|
1986
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1987
|
+
Select4,
|
|
1988
|
+
{
|
|
1989
|
+
readOnly: mode === "view",
|
|
1990
|
+
withAsterisk: mode !== "view",
|
|
1991
|
+
label: "Municipio",
|
|
1992
|
+
data: cityOptions,
|
|
1993
|
+
...form.getInputProps("cityId"),
|
|
1994
|
+
"data-testid": "patient-form-city-select"
|
|
1995
|
+
}
|
|
1996
|
+
) }),
|
|
1997
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
1998
|
+
TextInput3,
|
|
1999
|
+
{
|
|
2000
|
+
readOnly: mode === "view",
|
|
2001
|
+
label: "Direcci\xF3n",
|
|
2002
|
+
...form.getInputProps("homeAddress"),
|
|
2003
|
+
"data-testid": "patient-form-home-address-input"
|
|
2004
|
+
}
|
|
2005
|
+
) }),
|
|
2006
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2007
|
+
Select4,
|
|
2008
|
+
{
|
|
2009
|
+
readOnly: mode === "view",
|
|
2010
|
+
label: "Grupo sangu\xEDneo",
|
|
2011
|
+
data: bloodTypeOptions,
|
|
2012
|
+
...form.getInputProps("bloodType"),
|
|
2013
|
+
"data-testid": "patient-form-blood-type-select"
|
|
2014
|
+
}
|
|
2015
|
+
) }),
|
|
2016
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2017
|
+
NumberInput,
|
|
2018
|
+
{
|
|
2019
|
+
readOnly: mode === "view",
|
|
2020
|
+
withAsterisk: mode !== "view",
|
|
2021
|
+
label: "Celular",
|
|
2022
|
+
allowNegative: false,
|
|
2023
|
+
allowDecimal: false,
|
|
2024
|
+
decimalScale: 0,
|
|
2025
|
+
...form.getInputProps("cellphone"),
|
|
2026
|
+
"data-testid": "patient-form-cellphone-input"
|
|
2027
|
+
}
|
|
2028
|
+
) }),
|
|
2029
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2030
|
+
NumberInput,
|
|
2031
|
+
{
|
|
2032
|
+
readOnly: mode === "view",
|
|
2033
|
+
label: "Tel\xE9fono fijo",
|
|
2034
|
+
allowNegative: false,
|
|
2035
|
+
allowDecimal: false,
|
|
2036
|
+
decimalScale: 0,
|
|
2037
|
+
...form.getInputProps("homephone"),
|
|
2038
|
+
"data-testid": "patient-form-homephone-input"
|
|
2039
|
+
}
|
|
2040
|
+
) }),
|
|
2041
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2042
|
+
Select4,
|
|
2043
|
+
{
|
|
2044
|
+
readOnly: mode === "view",
|
|
2045
|
+
label: "Estrato",
|
|
2046
|
+
data: stratumOptions,
|
|
2047
|
+
...form.getInputProps("stratumId"),
|
|
2048
|
+
"data-testid": "patient-form-stratum-select"
|
|
2049
|
+
}
|
|
2050
|
+
) }),
|
|
2051
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2052
|
+
Select4,
|
|
2053
|
+
{
|
|
2054
|
+
readOnly: mode === "view",
|
|
2055
|
+
label: "Pertenencia \xE9tnica",
|
|
2056
|
+
data: ethnicGroupOptions,
|
|
2057
|
+
...form.getInputProps("ethnicGroupId"),
|
|
2058
|
+
"data-testid": "patient-form-ethnic-group-select"
|
|
2059
|
+
}
|
|
2060
|
+
) }),
|
|
2061
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2062
|
+
Select4,
|
|
2063
|
+
{
|
|
2064
|
+
readOnly: mode === "view",
|
|
2065
|
+
label: "Nivel educativo",
|
|
2066
|
+
data: educationLevelOptions,
|
|
2067
|
+
...form.getInputProps("educationLevelId"),
|
|
2068
|
+
"data-testid": "patient-form-education-level-select"
|
|
2069
|
+
}
|
|
2070
|
+
) }),
|
|
2071
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 12, children: /* @__PURE__ */ jsxs7(Paper5, { withBorder: true, p: "md", bg: "brand-color.0", shadow: "none", children: [
|
|
2072
|
+
/* @__PURE__ */ jsx8(Title4, { order: 6, c: "brand-color", mb: "sm", children: "Aseguradora obligatoria" }),
|
|
2073
|
+
/* @__PURE__ */ jsxs7(Grid3, { children: [
|
|
2074
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2075
|
+
Select4,
|
|
2076
|
+
{
|
|
2077
|
+
readOnly: mode === "view",
|
|
2078
|
+
withAsterisk: mode !== "view",
|
|
2079
|
+
label: "Seguro",
|
|
2080
|
+
data: companyClientOptions,
|
|
2081
|
+
...form.getInputProps("mandatoryInsurance.companyId"),
|
|
2082
|
+
onChange: (value) => {
|
|
2083
|
+
form.setFieldValue("mandatoryInsurance.companyId", value || "");
|
|
2084
|
+
form.setFieldValue("mandatoryInsurance.plan", "");
|
|
2085
|
+
form.setFieldValue("mandatoryInsurance.population", "");
|
|
2086
|
+
form.setFieldValue("mandatoryInsurance.groupId", "");
|
|
2087
|
+
form.setFieldValue("mandatoryInsurance.policyNumber", "");
|
|
2088
|
+
},
|
|
2089
|
+
"data-testid": "patient-form-mandatory-insurance-company-select"
|
|
2090
|
+
}
|
|
2091
|
+
) }),
|
|
2092
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2093
|
+
Select4,
|
|
2094
|
+
{
|
|
2095
|
+
readOnly: mode === "view",
|
|
2096
|
+
withAsterisk: mode !== "view",
|
|
2097
|
+
label: "Plan",
|
|
2098
|
+
data: contractOptions,
|
|
2099
|
+
...form.getInputProps("mandatoryInsurance.plan"),
|
|
2100
|
+
onChange: (value) => {
|
|
2101
|
+
form.setFieldValue("mandatoryInsurance.plan", value || "");
|
|
2102
|
+
form.setFieldValue("mandatoryInsurance.population", "");
|
|
2103
|
+
form.setFieldValue("mandatoryInsurance.groupId", "");
|
|
2104
|
+
form.setFieldValue("mandatoryInsurance.policyNumber", "");
|
|
2105
|
+
},
|
|
2106
|
+
"data-testid": "patient-form-mandatory-insurance-plan-select"
|
|
2107
|
+
}
|
|
2108
|
+
) }),
|
|
2109
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2110
|
+
Select4,
|
|
2111
|
+
{
|
|
2112
|
+
readOnly: mode === "view",
|
|
2113
|
+
withAsterisk: mode !== "view",
|
|
2114
|
+
label: "Poblaci\xF3n",
|
|
2115
|
+
data: contractPopulationOptions,
|
|
2116
|
+
...form.getInputProps("mandatoryInsurance.population"),
|
|
2117
|
+
"data-testid": "patient-form-mandatory-insurance-population-select"
|
|
2118
|
+
}
|
|
2119
|
+
) }),
|
|
2120
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2121
|
+
Select4,
|
|
2122
|
+
{
|
|
2123
|
+
readOnly: mode === "view",
|
|
2124
|
+
withAsterisk: mode !== "view",
|
|
2125
|
+
label: "Grupo de ingreso",
|
|
2126
|
+
data: incomeGroupOptions,
|
|
2127
|
+
...form.getInputProps("mandatoryInsurance.groupId"),
|
|
2128
|
+
"data-testid": "patient-form-mandatory-insurance-group-select"
|
|
2129
|
+
}
|
|
2130
|
+
) }),
|
|
2131
|
+
/* @__PURE__ */ jsx8(Grid3.Col, { span: 6, children: /* @__PURE__ */ jsx8(
|
|
2132
|
+
TextInput3,
|
|
2133
|
+
{
|
|
2134
|
+
readOnly: mode === "view",
|
|
2135
|
+
label: "N\xFAmero de p\xF3liza",
|
|
2136
|
+
...form.getInputProps("mandatoryInsurance.policyNumber"),
|
|
2137
|
+
"data-testid": "patient-form-mandatory-insurance-policy-number-input"
|
|
2138
|
+
}
|
|
2139
|
+
) })
|
|
2140
|
+
] })
|
|
2141
|
+
] }) }),
|
|
2142
|
+
/* @__PURE__ */ jsxs7(Grid3.Col, { span: 12, children: [
|
|
2143
|
+
form.values.voluntaryInsurance.map((insurance, index) => /* @__PURE__ */ jsx8(
|
|
2144
|
+
PatientVoluntaryInsuranceForm,
|
|
2145
|
+
{
|
|
2146
|
+
index,
|
|
2147
|
+
mode,
|
|
2148
|
+
form
|
|
2149
|
+
},
|
|
2150
|
+
insurance.id ?? index
|
|
2151
|
+
)),
|
|
2152
|
+
/* @__PURE__ */ jsx8(Flex6, { justify: "flex-end", children: mode !== "view" && /* @__PURE__ */ jsx8(
|
|
2153
|
+
Button3,
|
|
2154
|
+
{
|
|
2155
|
+
variant: "outline",
|
|
2156
|
+
color: "secondary",
|
|
2157
|
+
size: "xs",
|
|
2158
|
+
onClick: handleAddVoluntaryInsurance,
|
|
2159
|
+
leftSection: /* @__PURE__ */ jsx8(IconPlus, { style: { width: 16, height: 16 } }),
|
|
2160
|
+
"data-testid": "patient-form-add-voluntary-insurance-button",
|
|
2161
|
+
children: "Agregar aseguradora voluntaria"
|
|
2162
|
+
}
|
|
2163
|
+
) })
|
|
2164
|
+
] })
|
|
2165
|
+
] }),
|
|
2166
|
+
/* @__PURE__ */ jsx8(Flex6, { justify: "flex-end", mt: "lg", children: mode !== "view" && /* @__PURE__ */ jsx8(
|
|
2167
|
+
Button3,
|
|
2168
|
+
{
|
|
2169
|
+
type: "submit",
|
|
2170
|
+
color: "secondary-color",
|
|
2171
|
+
size: "sm",
|
|
2172
|
+
"data-testid": "patient-form-save-button",
|
|
2173
|
+
children: "Guardar"
|
|
2174
|
+
}
|
|
2175
|
+
) }),
|
|
2176
|
+
mode === "view" && /* @__PURE__ */ jsx8(PatientAppointmentHistory, { patientId })
|
|
2177
|
+
] }),
|
|
2178
|
+
/* @__PURE__ */ jsx8(
|
|
2179
|
+
PatientNotes,
|
|
2180
|
+
{
|
|
2181
|
+
isOpen: openPatientNotes,
|
|
2182
|
+
onClose: () => setOpenPatientNotes(false),
|
|
2183
|
+
patientId
|
|
2184
|
+
}
|
|
2185
|
+
),
|
|
2186
|
+
/* @__PURE__ */ jsx8(
|
|
2187
|
+
PatientAssistanceRisks,
|
|
2188
|
+
{
|
|
2189
|
+
isOpen: openPatientAssistanceRisks,
|
|
2190
|
+
onClose: () => setOpenPatientAssistanceRisks(false),
|
|
2191
|
+
patientId
|
|
2192
|
+
}
|
|
2193
|
+
),
|
|
2194
|
+
/* @__PURE__ */ jsx8(
|
|
2195
|
+
PatientAdministrativeRisks,
|
|
2196
|
+
{
|
|
2197
|
+
isOpen: openPatientAdministrativeRisks,
|
|
2198
|
+
onClose: () => setOpenPatientAdministrativeRisks(false),
|
|
2199
|
+
patientId
|
|
2200
|
+
}
|
|
2201
|
+
)
|
|
2202
|
+
] });
|
|
2203
|
+
};
|
|
2204
|
+
var createPatientPayload = (values) => {
|
|
2205
|
+
const mandatoryInsurance = {
|
|
2206
|
+
corporateClientId: Number(values.mandatoryInsurance.companyId),
|
|
2207
|
+
contractId: Number(values.mandatoryInsurance.plan),
|
|
2208
|
+
populationId: Number(values.mandatoryInsurance.population),
|
|
2209
|
+
crtId: Number(values.mandatoryInsurance.groupId),
|
|
2210
|
+
policy: values.mandatoryInsurance.policyNumber,
|
|
2211
|
+
isMain: 1
|
|
2212
|
+
};
|
|
2213
|
+
const voluntaryInsurance = values.voluntaryInsurance.map((insurance) => ({
|
|
2214
|
+
companyTypeId: insurance.companyType,
|
|
2215
|
+
corporateClientId: Number(insurance.companyId),
|
|
2216
|
+
contractId: Number(insurance.plan),
|
|
2217
|
+
populationId: Number(insurance.population),
|
|
2218
|
+
crtId: Number(insurance.groupId),
|
|
2219
|
+
policy: insurance.policyNumber,
|
|
2220
|
+
isMain: 0
|
|
2221
|
+
}));
|
|
2222
|
+
return {
|
|
2223
|
+
docTypeId: Number(values.documentTypeId),
|
|
2224
|
+
documentType: Number(values.documentTypeId),
|
|
2225
|
+
document: values.documentNumber,
|
|
2226
|
+
firstName: values.firstName,
|
|
2227
|
+
otherNames: values.middleName ?? "",
|
|
2228
|
+
lastName: values.surname,
|
|
2229
|
+
secondSurname: values.secondSurname ?? "",
|
|
2230
|
+
birthDate: values.birthDate,
|
|
2231
|
+
age: values.age,
|
|
2232
|
+
whatsapp: values.whatsapp,
|
|
2233
|
+
gender: values.gender,
|
|
2234
|
+
affiliationType: Number(values.affiliationTypeId),
|
|
2235
|
+
email: values.email,
|
|
2236
|
+
maritalStatus: values.maritalStatus,
|
|
2237
|
+
provinceId: Number(values.provinceId),
|
|
2238
|
+
cityId: Number(values.cityId),
|
|
2239
|
+
homeAddress: values.homeAddress,
|
|
2240
|
+
bloodType: values.bloodType,
|
|
2241
|
+
cellphone: String(values.cellphone),
|
|
2242
|
+
homephone: values.homephone,
|
|
2243
|
+
emergencyContact: values.emergencyContact,
|
|
2244
|
+
neighborhood: values.neighborhood,
|
|
2245
|
+
ocupation: values.occupation,
|
|
2246
|
+
use_contact_lens: values.use_contact_lens,
|
|
2247
|
+
use_glasses: values.use_glasses,
|
|
2248
|
+
stratumId: Number(values.stratumId),
|
|
2249
|
+
ethnicGroupId: Number(values.ethnicGroupId),
|
|
2250
|
+
educationLevelId: Number(values.educationLevelId),
|
|
2251
|
+
contracts: [mandatoryInsurance, ...voluntaryInsurance]
|
|
2252
|
+
};
|
|
2253
|
+
};
|
|
2254
|
+
var createPatientForm = (info) => {
|
|
2255
|
+
const mandatoryInsurance = info.contracts.find((c) => c.isMain === 1);
|
|
2256
|
+
const voluntaryInsurance = info.contracts.filter((c) => c.isMain === 0);
|
|
2257
|
+
return {
|
|
2258
|
+
documentTypeId: String(info.docTypeId ?? ""),
|
|
2259
|
+
documentNumber: info.document ?? "",
|
|
2260
|
+
firstName: info.firstName ?? "",
|
|
2261
|
+
middleName: info.otherNames ?? "",
|
|
2262
|
+
surname: info.lastName ?? "",
|
|
2263
|
+
secondSurname: info.secondSurname ?? "",
|
|
2264
|
+
birthDate: info.birthDate ?? "",
|
|
2265
|
+
age: info.age ?? "",
|
|
2266
|
+
whatsapp: info.whatsapp ?? "",
|
|
2267
|
+
gender: info.gender ?? "",
|
|
2268
|
+
affiliationTypeId: String(info.affiliationTypeId ?? ""),
|
|
2269
|
+
bloodType: info.bloodType ?? "",
|
|
2270
|
+
email: info.email ?? "",
|
|
2271
|
+
provinceId: String(info.provinceId ?? ""),
|
|
2272
|
+
cityId: String(info.cityId ?? ""),
|
|
2273
|
+
homeAddress: info.homeAddress ?? "",
|
|
2274
|
+
neighborhood: info.neighborhood ?? "",
|
|
2275
|
+
cellphone: info.cellphone ?? "",
|
|
2276
|
+
homephone: info.homephone ?? "",
|
|
2277
|
+
emergencyContact: info.emergencyContact ?? "",
|
|
2278
|
+
maritalStatus: info.maritalStatus ?? "",
|
|
2279
|
+
occupation: info.ocupation ?? "",
|
|
2280
|
+
use_glasses: info.use_glasses ?? "",
|
|
2281
|
+
use_contact_lens: info.use_contact_lens ?? "",
|
|
2282
|
+
isDataPolicyAccepted: info.processing_of_personal_data ?? false,
|
|
2283
|
+
stratumId: String(info.stratum_id ?? ""),
|
|
2284
|
+
educationLevelId: String(info.educationLevel.id ?? ""),
|
|
2285
|
+
ethnicGroupId: String(info.ethnicGroup.id ?? ""),
|
|
2286
|
+
mandatoryInsurance: {
|
|
2287
|
+
companyId: String(mandatoryInsurance?.corporateClientId ?? ""),
|
|
2288
|
+
plan: String(mandatoryInsurance?.contractId ?? ""),
|
|
2289
|
+
population: String(mandatoryInsurance?.populationId ?? ""),
|
|
2290
|
+
groupId: String(mandatoryInsurance?.crtId ?? ""),
|
|
2291
|
+
policyNumber: mandatoryInsurance?.policy ?? ""
|
|
2292
|
+
},
|
|
2293
|
+
voluntaryInsurance: (voluntaryInsurance ?? []).map((insurance) => ({
|
|
2294
|
+
id: Date.now().toString(),
|
|
2295
|
+
companyTypeTag: insurance.companyTypeTag ?? "",
|
|
2296
|
+
companyType: insurance.companyTypeId ?? "",
|
|
2297
|
+
companyId: String(insurance.corporateClientId ?? ""),
|
|
2298
|
+
plan: String(insurance.contractId ?? ""),
|
|
2299
|
+
population: String(insurance.populationId ?? ""),
|
|
2300
|
+
groupId: String(insurance.crtId ?? ""),
|
|
2301
|
+
policyNumber: insurance.policy ?? ""
|
|
2302
|
+
}))
|
|
2303
|
+
};
|
|
2304
|
+
};
|
|
2305
|
+
export {
|
|
2306
|
+
PatientAdministrativeRisks,
|
|
2307
|
+
PatientAppointmentHistory,
|
|
2308
|
+
PatientAssistanceRisks,
|
|
2309
|
+
PatientForm,
|
|
2310
|
+
PatientNotes,
|
|
2311
|
+
TTNSharedProvider,
|
|
2312
|
+
useTTNSharedContext
|
|
2313
|
+
};
|