@argusoft/medplat-duplicate-member-data 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1909 @@
1
+ import { n as mergeMembers, t as ManualDuplicateEntryModal } from "./ManualDuplicateEntryModal-CLECgPAF.js";
2
+ import { Suspense, lazy, useCallback, useEffect, useRef, useState } from "react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { useSelector } from "react-redux";
5
+ import { useNavigate, useSearchParams } from "react-router-dom";
6
+ import Grid from "@mui/material/Grid2";
7
+ import { FormProvider, useForm } from "react-hook-form";
8
+ import { Accordion, AccordionDetails, AccordionSummary, Backdrop, Box, Button, Chip, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, FormControlLabel, FormLabel, IconButton, Paper, Radio, RadioGroup, TextField, Tooltip, Typography } from "@mui/material";
9
+ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
10
+ import ArrowBackIcon from "@mui/icons-material/ArrowBack";
11
+ import "@mui/icons-material/ArrowForward";
12
+ import DragIndicatorIcon from "@mui/icons-material/DragIndicator";
13
+ import CloseIcon from "@mui/icons-material/Close";
14
+ import "@mui/icons-material/Search";
15
+ import CheckCircleIcon from "@mui/icons-material/CheckCircle";
16
+ import "@mui/icons-material/Cancel";
17
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
18
+ import { faChartLine, faChevronLeft, faChevronRight, faMinusCircle, faPlusCircle } from "@fortawesome/free-solid-svg-icons";
19
+ import { execute } from "@/common/services/QueryBuilder";
20
+ import { showToast } from "@/common/toaster/toaster";
21
+ import SideOverlay from "@/views/custom-components/SideOverlay";
22
+ import { getAssignedFeatures } from "@/utils/feature";
23
+ import GeneralUtil from "@/common/services/util/GeneralUtil";
24
+ import { toAppLocaleDateString, toAppLocaleString } from "@/utils/appTime";
25
+ const DEMOGRAPHICS_KEYS = [
26
+ "id",
27
+ "first_name",
28
+ "middle_name",
29
+ "last_name",
30
+ "dob",
31
+ "unique_health_id",
32
+ "family_id",
33
+ "phone_number",
34
+ "name_as_per_aadhar",
35
+ "abha_number",
36
+ "aadhaar_reference_key",
37
+ "health_id",
38
+ "hof",
39
+ "address",
40
+ "father_name",
41
+ "mother_name",
42
+ "mother_id",
43
+ "registered_by",
44
+ "registered_by_contact_number",
45
+ "created_by",
46
+ "role_name"
47
+ ], HEALTH_STATUS_KEYS = ["lmp", "cbac_score"];
48
+ var MERGED_RESULT_INIT = {
49
+ aadhaar_reference_key: null,
50
+ abha_number: null,
51
+ health_id: null,
52
+ address: null,
53
+ age: null,
54
+ basic_state: null,
55
+ cbac_score: null,
56
+ dob: null,
57
+ family_id: null,
58
+ father_name: null,
59
+ first_name: null,
60
+ hof: null,
61
+ id: null,
62
+ imdp_record_id: null,
63
+ is_aadhar_verified: null,
64
+ last_name: null,
65
+ last_visit_date: null,
66
+ lmp: null,
67
+ member_validity: null,
68
+ middle_name: null,
69
+ mother_name: null,
70
+ mother_id: null,
71
+ name_as_per_aadhar: null,
72
+ no_of_family_members: null,
73
+ no_of_services_given: null,
74
+ phone_number: null,
75
+ registered_by: null,
76
+ registered_by_contact_number: null,
77
+ role_name: null,
78
+ unique_health_id: null,
79
+ created_by: null
80
+ }, VISIBILITY_INIT = {
81
+ first_name: null,
82
+ middle_name: null,
83
+ last_name: null,
84
+ dob: null,
85
+ unique_health_id: null,
86
+ family_id: null,
87
+ phone_number: null,
88
+ name_as_per_aadhar: null,
89
+ abha_number: null,
90
+ hof: null,
91
+ address: null,
92
+ father_name: null,
93
+ mother_name: null,
94
+ registered_by: null,
95
+ lmp: null,
96
+ cbac_score: null
97
+ };
98
+ function useDuplicateMemberData() {
99
+ let { user: e } = useSelector((e) => e.Authenticate), [t, n] = useState(0), [r, a] = useState(() => parseInt(localStorage.getItem("recordResolvedSessionCount") || "0", 10)), [o, s] = useState(0), [ie, c] = useState(0), [u, ae] = useState({
100
+ searchBy: null,
101
+ searchString: null
102
+ }), [oe, se] = useState(null), [ce, le] = useState(null), [d, ue] = useState([]), [de, fe] = useState(0), [f, pe] = useState(0), [me] = useState(10), [he, ge] = useState(0), [_e, ve] = useState(!1), [p, m] = useState({}), [h, g] = useState([]), [_, v] = useState(null), [ye, be] = useState([]), [xe, y] = useState([]), [Se, b] = useState([]), [Ce, x] = useState(!1), [S, C] = useState(!1), [we, w] = useState({ ...MERGED_RESULT_INIT }), [Te, T] = useState({ ...VISIBILITY_INIT }), [Ee, Oe] = useState(0), [ke, Ae] = useState(!1), [je, Me] = useState(!1), [Fe, Ie] = useState(""), [Le, Re] = useState(!1), [ze, Be] = useState(!0), [E, D] = useState({}), [O, k] = useState(!1), [A, Ve] = useState(null), j = useCallback(async (t) => {
103
+ let r = t || u;
104
+ try {
105
+ if (r.searchBy === "uniqueHealthId" || r.searchBy === "familyId") {
106
+ let e = await execute({
107
+ code: "get_count_of_duplicate_records_based_on_unique_health_id_and_family_id",
108
+ parameters: {
109
+ searchBy: r.searchBy,
110
+ searchString: r.searchString
111
+ }
112
+ }), t = 0;
113
+ (e.data?.result || []).forEach((e) => {
114
+ t += e.record_count;
115
+ }), n(t);
116
+ } else n((await execute({
117
+ code: "get_count_of_duplicate_records_user_based",
118
+ parameters: {
119
+ logged_in_user: e?.id,
120
+ searchBy: r.searchBy,
121
+ searchString: r.searchString
122
+ }
123
+ })).data?.result?.[0]?.count_of_duplicate_probables || 0);
124
+ let t = await execute({ code: "get_count_of_duplicate_records" });
125
+ s(t.data?.result?.[0]?.cumulative_duplicates || 0), c(t.data?.result?.[0]?.cumulative_duplicates_resolved || 0);
126
+ } catch (e) {
127
+ console.error(e);
128
+ }
129
+ }, [u, e]), He = useCallback(async (e) => {
130
+ try {
131
+ return ((await execute({
132
+ code: "retreive_duplicate_probables_of_family_members",
133
+ parameters: { main_member_ids: e }
134
+ })).data?.result || []).map((e) => {
135
+ let t = e.array_of_duplicates.replace("{", "[").replace("}", "]");
136
+ return {
137
+ ...e,
138
+ array_of_duplicates: JSON.parse(t)
139
+ };
140
+ });
141
+ } catch (e) {
142
+ return console.error(e), [];
143
+ }
144
+ }, []), Ue = useCallback(async (t, n, r) => {
145
+ k(!0);
146
+ let i = n || u, a = r ?? he;
147
+ try {
148
+ let n;
149
+ n = i.searchBy === "uniqueHealthId" || i.searchBy === "familyId" ? await execute({
150
+ code: "get_members_with_duplicate_records_based_on_unique_health_id_and_family_id",
151
+ parameters: {
152
+ searchBy: i.searchBy,
153
+ searchString: i.searchString
154
+ }
155
+ }) : await execute({
156
+ code: "get_members_with_duplicate_records",
157
+ parameters: {
158
+ logged_in_user: e?.id,
159
+ limit: me,
160
+ offset: a,
161
+ searchString: i.searchString,
162
+ searchBy: i.searchBy
163
+ }
164
+ });
165
+ let r = n.data?.result || [];
166
+ if (r.length === 0) return t && (ue([]), m({}), g([]), v(null)), showToast({
167
+ message: "No more records",
168
+ type: "error"
169
+ }), ve(!0), [];
170
+ let o = t ? r : [...d, ...r];
171
+ return ue(o), ge(o.length), o;
172
+ } catch (e) {
173
+ return console.error(e), [];
174
+ } finally {
175
+ k(!1);
176
+ }
177
+ }, [
178
+ u,
179
+ e,
180
+ me,
181
+ he,
182
+ d
183
+ ]), We = useCallback(async (e, t, n) => {
184
+ let r = e || d, i = t ?? de;
185
+ if (r[i]) {
186
+ k(!0);
187
+ try {
188
+ let e = r[i].record_value, t = r[i].duplicate_ids.replace(/[{}]/g, "").split(",").map((e) => parseInt(e.trim(), 10)), a = t[n ?? f]?.toString(), o = (await execute({
189
+ code: "retrieve_main_member_info",
190
+ parameters: { memberId: e }
191
+ })).data?.result?.[0] || {};
192
+ o.imdp_record_id = t, o.member_validity = (await execute({
193
+ code: "retrieve_main_member_validity",
194
+ parameters: {
195
+ id: parseInt(a, 10),
196
+ memberId: e
197
+ }
198
+ })).data?.result?.[0]?.member_validity;
199
+ let re = (await execute({
200
+ code: "retrieve_all_services_of_member",
201
+ parameters: { member_id: e }
202
+ })).data?.result || [];
203
+ o.no_of_services_given = re.length, be(re), m(o);
204
+ let s = (await execute({
205
+ code: "retrieve_duplicate_members_info",
206
+ parameters: {
207
+ memberId: e,
208
+ duplicateRecordIdsString: a
209
+ }
210
+ })).data?.result || [], ie = 2;
211
+ for (let e of s) {
212
+ e.imdp_record_id = [e.imdp_record_id], e.index = ie++;
213
+ let t = (await execute({
214
+ code: "retrieve_all_services_of_member",
215
+ parameters: { member_id: e.id }
216
+ })).data?.result || [];
217
+ e.no_of_services_given = t.length, y(t);
218
+ }
219
+ g(s);
220
+ let c = s[0] || null;
221
+ if (v(c), Re(o.family_id === c?.family_id), c) {
222
+ let e = {};
223
+ for (let [t, n] of Object.entries(o)) {
224
+ let r = !0;
225
+ for (let e of s) if (e[t] !== n || e[t] == null) {
226
+ r = !1;
227
+ break;
228
+ }
229
+ e[t] = r;
230
+ }
231
+ D(e), M(o, c);
232
+ }
233
+ } catch (e) {
234
+ console.error(e);
235
+ } finally {
236
+ k(!1);
237
+ }
238
+ }
239
+ }, [
240
+ d,
241
+ de,
242
+ f
243
+ ]), M = (e, t) => {
244
+ let n = [
245
+ "first_name",
246
+ "middle_name",
247
+ "last_name",
248
+ "name_as_per_aadhar",
249
+ "dob",
250
+ "gender"
251
+ ], r = 0;
252
+ n.forEach((n) => {
253
+ [
254
+ "first_name",
255
+ "middle_name",
256
+ "last_name",
257
+ "name_as_per_aadhar"
258
+ ].includes(n) ? (e[n] && t[n] && e[n].toLowerCase() === t[n].toLowerCase() || e[n] === null && t[n] === null) && r++ : e[n] === t[n] && r++;
259
+ }), Oe((r / n.length * 100).toFixed(2)), Ae(!!(e.aadhaar_reference_key && t.aadhaar_reference_key && e.aadhaar_reference_key === t.aadhaar_reference_key)), Me(!!(e.no_of_family_members && t.no_of_family_members && e.no_of_family_members === t.no_of_family_members && e.no_of_family_members > 1));
260
+ }, N = useCallback((e, t) => {
261
+ w((n) => ({
262
+ ...n,
263
+ [e]: t === "left" ? p[e] : _?.[e]
264
+ })), T((n) => ({
265
+ ...n,
266
+ [e]: t === "left" ? 0 : 1
267
+ }));
268
+ }, [p, _]), P = useCallback((e, t) => {
269
+ w((n) => {
270
+ let r = { ...n };
271
+ return e.forEach((e) => {
272
+ S && [
273
+ "unique_health_id",
274
+ "family_id",
275
+ "abha_number",
276
+ "hof"
277
+ ].includes(e) || (r[e] = t === "left" ? p[e] : _?.[e]);
278
+ }), r;
279
+ }), T((n) => {
280
+ let r = { ...n };
281
+ return e.forEach((e) => {
282
+ S && [
283
+ "unique_health_id",
284
+ "family_id",
285
+ "abha_number",
286
+ "hof"
287
+ ].includes(e) || (r[e] = t === "left" ? 0 : 1);
288
+ }), r;
289
+ });
290
+ }, [
291
+ p,
292
+ _,
293
+ S
294
+ ]), F = useCallback((e) => {
295
+ w((t) => ({
296
+ ...t,
297
+ [e]: null
298
+ })), T((t) => ({
299
+ ...t,
300
+ [e]: null
301
+ }));
302
+ }, []), I = useCallback(() => {
303
+ T({ ...VISIBILITY_INIT });
304
+ }, []), Ge = useCallback(() => {
305
+ x(!1), w({ ...MERGED_RESULT_INIT }), b([]);
306
+ }, []), Ke = useCallback((e, t) => {
307
+ let n = e || p, r = t || _;
308
+ if (n.abha_number && !r?.abha_number) {
309
+ C(!0), w({ ...n });
310
+ return;
311
+ }
312
+ if (!n.abha_number && r?.abha_number) {
313
+ C(!0), w({ ...r });
314
+ return;
315
+ }
316
+ C(!1);
317
+ }, [p, _]), qe = useCallback((e, t) => {
318
+ b((t) => t.some((t) => t === e) ? t : [...t, e]), t === "left" ? be((t) => t.filter((t) => t !== e)) : y((t) => t.filter((t) => t !== e));
319
+ }, []), Je = useCallback((e) => {
320
+ b((t) => t.filter((t) => t !== e)), e.member_id === p.id ? be((t) => [...t, e]) : y((t) => [...t, e]);
321
+ }, [p]), Ye = useCallback((e, t) => {
322
+ let n = (e || h).map((e) => e.member_validity);
323
+ n.push((t || p).member_validity), n.includes(null) && (n.includes(!0) || n.includes(!1)) ? Be(!1) : Be(!0);
324
+ }, [h, p]), Xe = useCallback(async (e) => {
325
+ try {
326
+ return await execute({
327
+ code: "save_duplicate_probables",
328
+ parameters: { membersToSave: JSON.stringify(e) }
329
+ }), showToast({
330
+ message: "Members added successfully",
331
+ type: "success"
332
+ }), !0;
333
+ } catch (e) {
334
+ return console.error(e), showToast({
335
+ message: "Error saving duplicate members",
336
+ type: "error"
337
+ }), !1;
338
+ }
339
+ }, []), L = useCallback(async (e) => {
340
+ try {
341
+ let t = (await execute({
342
+ code: "get_count_of_duplicate_records_resolved_for_member",
343
+ parameters: { memberId: e }
344
+ })).data?.result?.[0]?.resolved_records_count || 0;
345
+ a((e) => {
346
+ let n = e + t;
347
+ return localStorage.setItem("recordResolvedSessionCount", n.toString()), n;
348
+ });
349
+ } catch (e) {
350
+ console.error(e);
351
+ }
352
+ }, []);
353
+ return {
354
+ user: e,
355
+ isLoading: O,
356
+ search: u,
357
+ setSearch: ae,
358
+ paramType: oe,
359
+ setParamType: se,
360
+ paramString: ce,
361
+ setParamString: le,
362
+ duplicateProbableCount: t,
363
+ recordResolvedSessionCount: r,
364
+ cumulativeDuplicateCount: o,
365
+ cumulativeDuplicateCountResolved: ie,
366
+ membersWithDuplicateRecords: d,
367
+ setMembersWithDuplicateRecords: ue,
368
+ currentIndex: de,
369
+ setCurrentIndex: fe,
370
+ recordIterator: f,
371
+ setRecordIterator: pe,
372
+ offSet: he,
373
+ setOffSet: ge,
374
+ noMoreRecords: _e,
375
+ setNoMoreRecords: ve,
376
+ members: p,
377
+ setMembers: m,
378
+ duplicateMembers: h,
379
+ setDuplicateMembers: g,
380
+ selectedDuplicateMember: _,
381
+ setSelectedDuplicateMember: v,
382
+ firstMemberServices: ye,
383
+ secondMemberServices: xe,
384
+ mergedServices: Se,
385
+ setMergedServices: b,
386
+ showMergingBox: Ce,
387
+ setShowMergingBox: x,
388
+ isUHIDDisabled: S,
389
+ setIsUHIDDisabled: C,
390
+ mergedResult: we,
391
+ setMergedResult: w,
392
+ visibilityObject: Te,
393
+ setVisibilityObject: T,
394
+ matchingPercentage: Ee,
395
+ isAadhaarSimilar: ke,
396
+ isFamilyMemberSimilar: je,
397
+ registeredOnDifference: Fe,
398
+ isFamilyIdSame: Le,
399
+ canMove: ze,
400
+ markForSimilarity: E,
401
+ reportUUID: A,
402
+ getCount: j,
403
+ getFamilyDuplicateProbables: He,
404
+ retrieveMembersWithDuplicateData: Ue,
405
+ retrieveMemberData: We,
406
+ computeSimilarity: M,
407
+ handleMove: N,
408
+ handleMoveSection: P,
409
+ clearMergeBoxField: F,
410
+ clearVisibilityObject: I,
411
+ hideMergingBox: Ge,
412
+ preselectUniqueHealthId: Ke,
413
+ handleMoveService: qe,
414
+ clearMergeService: Je,
415
+ updateCanMoveFlag: Ye,
416
+ getRecordResolvedSessionCount: L,
417
+ saveDuplicateProbables: Xe,
418
+ markBothMembersValid: useCallback(async (t, n) => {
419
+ k(!0);
420
+ try {
421
+ let r = async (t) => {
422
+ if (!t?.imdp_record_id || !t?.id) return;
423
+ let n = (await execute({
424
+ code: "mark_a_member_valid_for_specific_record",
425
+ parameters: {
426
+ recordId: t.imdp_record_id[0],
427
+ memberId: t.id,
428
+ mergedBy: e?.id
429
+ }
430
+ })).data?.result || [], r = {}, i = (await execute({
431
+ code: "get_resolution_state_by_member_id",
432
+ parameters: { memberId: t.id }
433
+ })).data?.result || [];
434
+ if (i.length > 0 && i[0].resolution_state) try {
435
+ r = JSON.parse(i[0].resolution_state);
436
+ } catch (e) {
437
+ console.error(e);
438
+ }
439
+ n.forEach((e) => {
440
+ r[e.id] = "valid";
441
+ }), await execute({
442
+ code: "upsert_resolution_state_by_member_id",
443
+ parameters: {
444
+ memberId: t.id,
445
+ resolutionState: JSON.stringify(r)
446
+ }
447
+ }), await L(t.id);
448
+ };
449
+ return await r(t), await r(n), m((e) => ({
450
+ ...e,
451
+ member_validity: !0
452
+ })), v((e) => e ? {
453
+ ...e,
454
+ member_validity: !0
455
+ } : null), g((e) => e.map((e) => e.id === n?.id ? {
456
+ ...e,
457
+ member_validity: !0
458
+ } : e)), Ye(h.map((e) => e.id === n?.id ? {
459
+ ...e,
460
+ member_validity: !0
461
+ } : e), {
462
+ ...p,
463
+ member_validity: !0
464
+ }), await j(), showToast({
465
+ message: "Both members marked valid successfully",
466
+ type: "success"
467
+ }), !0;
468
+ } catch (e) {
469
+ return console.error(e), showToast({
470
+ message: "Error marking members valid",
471
+ type: "error"
472
+ }), !1;
473
+ } finally {
474
+ k(!1);
475
+ }
476
+ }, [
477
+ e,
478
+ p,
479
+ _,
480
+ h,
481
+ Ye,
482
+ L,
483
+ j
484
+ ]),
485
+ DEMOGRAPHICS_KEYS,
486
+ HEALTH_STATUS_KEYS
487
+ };
488
+ }
489
+ function MemberServicesModal({ open: e, onClose: t, services: n = [] }) {
490
+ return /* @__PURE__ */ jsxs(Dialog, {
491
+ open: e,
492
+ onClose: t,
493
+ maxWidth: "sm",
494
+ fullWidth: !0,
495
+ children: [
496
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Member Services" }),
497
+ /* @__PURE__ */ jsx(DialogContent, {
498
+ dividers: !0,
499
+ children: n.length === 0 ? /* @__PURE__ */ jsx(Typography, {
500
+ color: "text.secondary",
501
+ textAlign: "center",
502
+ py: 3,
503
+ children: "No services found"
504
+ }) : n.map((e, t) => /* @__PURE__ */ jsxs(Box, {
505
+ className: "p-2 mb-2 border border-gray-200 rounded-lg",
506
+ children: [/* @__PURE__ */ jsx(Typography, {
507
+ variant: "body2",
508
+ fontWeight: "bold",
509
+ children: e.type
510
+ }), /* @__PURE__ */ jsx(Typography, {
511
+ variant: "caption",
512
+ color: "text.secondary",
513
+ children: e.service_date || "No date"
514
+ })]
515
+ }, t))
516
+ }),
517
+ /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsx(Button, {
518
+ onClick: t,
519
+ variant: "contained",
520
+ color: "error",
521
+ children: "Close"
522
+ }) })
523
+ ]
524
+ });
525
+ }
526
+ var LocationSelectionComponent = lazy(() => import("@/views/feature-components/LocationDirective/LocationDirectiveV2")), FIELD_LABELS = {
527
+ id: "ID",
528
+ first_name: "First Name",
529
+ middle_name: "Middle Name",
530
+ last_name: "Last Name",
531
+ dob: "Date of Birth",
532
+ unique_health_id: "Unique Health ID",
533
+ family_id: "Family ID",
534
+ phone_number: "Phone Number",
535
+ name_as_per_aadhar: "Name as per Aadhaar",
536
+ abha_number: "ABHA Number",
537
+ aadhaar_reference_key: "Aadhaar Ref Key",
538
+ health_id: "Health ID",
539
+ hof: "Head of Family",
540
+ address: "Address",
541
+ father_name: "Father Name",
542
+ mother_name: "Mother Name",
543
+ mother_id: "Mother ID",
544
+ registered_by: "Registered By",
545
+ registered_by_contact_number: "Reg. Contact",
546
+ created_by: "Created By",
547
+ role_name: "Role",
548
+ lmp: "LMP",
549
+ cbac_score: "CBAC Score"
550
+ };
551
+ function DraggableField({ label: e, value: t, fieldKey: n, side: r, onDrop: i, disabled: a, faded: o }) {
552
+ return /* @__PURE__ */ jsxs(Box, {
553
+ draggable: !a,
554
+ onDragEnd: () => !a && i(n, r),
555
+ className: `${a ? "opacity-40 cursor-not-allowed" : "cursor-grab"} ${o ? "opacity-30" : ""}`,
556
+ sx: {
557
+ border: "1px solid #E8F2FF",
558
+ borderRadius: 1,
559
+ p: 1,
560
+ bgcolor: a ? "var(--color-gray4)" : "#fff",
561
+ "&:hover": { borderColor: a ? "var(--color-gray4)" : "#86BEFF" },
562
+ height: "100%",
563
+ display: "flex",
564
+ flexDirection: "column",
565
+ justifyContent: "center",
566
+ minHeight: 48
567
+ },
568
+ children: [/* @__PURE__ */ jsx(Typography, {
569
+ variant: "caption",
570
+ color: "text.secondary",
571
+ children: e
572
+ }), /* @__PURE__ */ jsxs(Box, {
573
+ sx: {
574
+ display: "flex",
575
+ alignItems: "center",
576
+ gap: 1
577
+ },
578
+ children: [!a && /* @__PURE__ */ jsx(DragIndicatorIcon, {
579
+ fontSize: "small",
580
+ sx: { color: "var(--color-gray3)" }
581
+ }), /* @__PURE__ */ jsx(Typography, {
582
+ variant: "body2",
583
+ fontWeight: 500,
584
+ children: t ?? "—"
585
+ })]
586
+ })]
587
+ });
588
+ }
589
+ function DropZoneField({ label: e, value: t, fieldKey: n, onClear: r, locked: i }) {
590
+ return /* @__PURE__ */ jsxs(Box, {
591
+ sx: {
592
+ p: 1,
593
+ bgcolor: "var(--color-gray4)",
594
+ border: "1px dashed var(--color-gray3)",
595
+ borderRadius: 1,
596
+ position: "relative",
597
+ textAlign: "center",
598
+ minHeight: 48,
599
+ height: "100%",
600
+ display: "flex",
601
+ flexDirection: "column",
602
+ justifyContent: "center"
603
+ },
604
+ children: [
605
+ /* @__PURE__ */ jsx(Typography, {
606
+ variant: "caption",
607
+ color: "text.secondary",
608
+ sx: {
609
+ position: "absolute",
610
+ top: 2,
611
+ left: 6
612
+ },
613
+ children: e
614
+ }),
615
+ /* @__PURE__ */ jsx(Typography, {
616
+ variant: "body2",
617
+ fontWeight: 500,
618
+ sx: { mt: 1.5 },
619
+ children: t ?? ""
620
+ }),
621
+ t != null && !i && /* @__PURE__ */ jsx(IconButton, {
622
+ size: "small",
623
+ onClick: () => r(n),
624
+ sx: {
625
+ position: "absolute",
626
+ top: 0,
627
+ right: 0
628
+ },
629
+ children: /* @__PURE__ */ jsx(CloseIcon, { fontSize: "small" })
630
+ })
631
+ ]
632
+ });
633
+ }
634
+ function DuplicateMemberData() {
635
+ let r = useNavigate(), [i] = useSearchParams(), { user: l, isLoading: _, members: b, duplicateMembers: Ce, selectedDuplicateMember: x, setSelectedDuplicateMember: De, showMergingBox: Ne, setShowMergingBox: Pe, isUHIDDisabled: E, mergedResult: D, visibilityObject: O, firstMemberServices: k, secondMemberServices: A, mergedServices: Ve, duplicateProbableCount: j, recordResolvedSessionCount: He, cumulativeDuplicateCount: Ue, cumulativeDuplicateCountResolved: We, membersWithDuplicateRecords: M, currentIndex: N, setCurrentIndex: P, recordIterator: F, setRecordIterator: I, offSet: Ge, setOffSet: Ke, noMoreRecords: qe, setNoMoreRecords: Je, canMove: Ye, matchingPercentage: Xe, isAadhaarSimilar: L, isFamilyMemberSimilar: Ze, markForSimilarity: Qe, getCount: R, retrieveMembersWithDuplicateData: z, retrieveMemberData: B, handleMove: V, handleMoveSection: H, clearMergeBoxField: $e, clearVisibilityObject: U, hideMergingBox: W, preselectUniqueHealthId: et, handleMoveService: tt, clearMergeService: nt, updateCanMoveFlag: rt, getRecordResolvedSessionCount: it, search: G, setSearch: at, setMembers: ot, setDuplicateMembers: st, setOffSet: ct, markBothMembersValid: lt } = useDuplicateMemberData(), [ut, dt] = useState(!1), [ft, pt] = useState([]), [mt, ht] = useState(!1), [gt, K] = useState(!1), [_t, vt] = useState(null), [q, yt] = useState(null), bt = async () => {
636
+ try {
637
+ let { data: e } = await getAssignedFeatures("techo.manage.duplicateMemberData"), t = JSON.parse(e);
638
+ t && yt(t);
639
+ } catch (e) {
640
+ console.error(e);
641
+ }
642
+ }, xt = GeneralUtil.hasCheckRights(q?.["view.manage.duplicateMemberData"]), St = GeneralUtil.hasCheckRights(q?.["view.manage.duplicateMemberData"]), J = GeneralUtil.hasCheckRights(q?.["view.manage.duplicateMemberData"]), Ct = GeneralUtil.hasCheckRights(q?.["view.manage.duplicateMemberData"]), wt = GeneralUtil.hasCheckRights(q?.["view.manage.duplicateMemberData"]), Tt = () => {
643
+ Ct && (vt(() => async () => {
644
+ await lt(b, x);
645
+ }), K(!0));
646
+ }, [Et, Y] = useState(!1);
647
+ useEffect(() => {
648
+ if (!l) return;
649
+ let e = {
650
+ searchBy: i.get("searchBy"),
651
+ searchString: i.get("searchString")
652
+ }, t = e.searchBy ? e : {
653
+ searchBy: null,
654
+ searchString: null
655
+ };
656
+ at(t), R(t), z(!0, t, 0).then((e) => {
657
+ e?.length > 0 && B(e, 0, 0);
658
+ }), bt();
659
+ }, [l]);
660
+ let Dt = async () => {
661
+ if (F < (M[N]?.duplicate_ids?.replace(/[{}]/g, "").split(",") || []).length - 1) {
662
+ let e = F + 1;
663
+ I(e), B(null, N, e);
664
+ return;
665
+ }
666
+ I(0);
667
+ let e = N + 1;
668
+ if (e >= M.length) {
669
+ let t = await z(!1, G, M.length);
670
+ t?.length > M.length && (P(e), B(t, e, 0));
671
+ } else P(e), B(null, e, 0);
672
+ }, Ot = () => {
673
+ if (F > 0) {
674
+ let e = F - 1;
675
+ I(e), B(null, N, e);
676
+ return;
677
+ }
678
+ if (N > 0) {
679
+ let e = N - 1;
680
+ P(e), I(0), B(null, e, 0);
681
+ }
682
+ }, kt = (e, t) => {
683
+ V(e, t), e === "registered_by" && (V("role_name", t), V("registered_by_contact_number", t), V("created_by", t)), e === "abha_number" && (V("aadhaar_reference_key", t), V("health_id", t)), e === "unique_health_id" && (V("family_id", t), V("hof", t), V("id", t)), e === "family_id" && (V("unique_health_id", t), V("hof", t), V("id", t)), e === "mother_name" && V("mother_id", t), e === "hof" && (V("unique_health_id", t), V("family_id", t), V("id", t));
684
+ }, At = () => {
685
+ J && (Pe(!0), et());
686
+ }, jt = () => {
687
+ St && window.open("/ui/medplat/manage/duplicateMemberData/manual-report", "_blank");
688
+ }, Mt = () => {
689
+ xt && r("/ui/medplat/manage/duplicateMemberData/analysis");
690
+ }, Nt = (e, t) => {
691
+ if (!t) return;
692
+ let n = "";
693
+ if (e === "unique_health_id") n = "uniqueHealthId";
694
+ else if (e === "family_id") n = "familyId";
695
+ else return;
696
+ let r = `/ui/medplat/manage/duplicateMemberData?searchBy=${n}&searchString=${t}`;
697
+ window.open(r, "_blank");
698
+ }, [X, Pt] = useState("orgUnit"), [Ft, It] = useState(""), [Lt, Rt] = useState({}), zt = useRef({}), [Bt, Vt] = useState([]), [Ht, Ut] = useState(void 0), Wt = useForm(), Gt = () => {
699
+ let e = Ft || null;
700
+ if (X === "orgUnit" && (e = Lt?.finalSelected?.optionSelected?.id || null, !e)) {
701
+ showToast({
702
+ message: "Please select an Organization Unit",
703
+ type: "error"
704
+ });
705
+ return;
706
+ }
707
+ let t = {
708
+ searchBy: X,
709
+ searchString: e
710
+ };
711
+ at(t), P(0), I(0), Ke(0), U(), W(), R(t), z(!0, t, 0).then((e) => {
712
+ e?.length > 0 && B(e, 0, 0);
713
+ }), Y(!1);
714
+ }, Kt = () => {
715
+ Pt("orgUnit"), It(""), Rt({}), zt.current = {}, Ut(Date.now()), Wt.reset();
716
+ let e = {
717
+ searchBy: null,
718
+ searchString: null
719
+ };
720
+ at(e), P(0), I(0), Ke(0), U(), W(), R(e), z(!0, e, 0).then((e) => {
721
+ e?.length > 0 && B(e, 0, 0);
722
+ }), Y(!1);
723
+ }, qt = /* @__PURE__ */ jsx(FormProvider, {
724
+ ...Wt,
725
+ children: /* @__PURE__ */ jsxs(Box, {
726
+ className: "p-4",
727
+ children: [
728
+ /* @__PURE__ */ jsxs(FormControl, {
729
+ component: "fieldset",
730
+ className: "mb-4 w-full",
731
+ children: [/* @__PURE__ */ jsx(FormLabel, {
732
+ component: "legend",
733
+ children: "Search By"
734
+ }), /* @__PURE__ */ jsxs(RadioGroup, {
735
+ value: X,
736
+ onChange: (e) => {
737
+ Pt(e.target.value), e.target.value !== "orgUnit" && It("");
738
+ },
739
+ children: [
740
+ /* @__PURE__ */ jsx(FormControlLabel, {
741
+ value: "orgUnit",
742
+ control: /* @__PURE__ */ jsx(Radio, {}),
743
+ label: "Organization Unit"
744
+ }),
745
+ /* @__PURE__ */ jsx(FormControlLabel, {
746
+ value: "uniqueHealthId",
747
+ control: /* @__PURE__ */ jsx(Radio, {}),
748
+ label: "Unique Health ID"
749
+ }),
750
+ /* @__PURE__ */ jsx(FormControlLabel, {
751
+ value: "familyId",
752
+ control: /* @__PURE__ */ jsx(Radio, {}),
753
+ label: "Family ID"
754
+ })
755
+ ]
756
+ })]
757
+ }),
758
+ (X === "uniqueHealthId" || X === "familyId") && /* @__PURE__ */ jsx(TextField, {
759
+ fullWidth: !0,
760
+ size: "small",
761
+ className: "mb-4",
762
+ label: X === "uniqueHealthId" ? "Enter Unique Health ID" : "Enter Family ID",
763
+ value: Ft,
764
+ onChange: (e) => It(e.target.value),
765
+ required: !0
766
+ }),
767
+ X === "orgUnit" && /* @__PURE__ */ jsx(Box, {
768
+ className: "mb-4",
769
+ children: /* @__PURE__ */ jsx(Suspense, {
770
+ fallback: /* @__PURE__ */ jsx(CircularProgress, { size: 20 }),
771
+ children: /* @__PURE__ */ jsx(LocationSelectionComponent, {
772
+ selectedLocation: Lt,
773
+ setSelectedLocation: Rt,
774
+ selectedLocationRef: zt,
775
+ locations: Bt,
776
+ setLocations: Vt,
777
+ templateType: "twoPart",
778
+ fetchAccordingToUserAoi: !0,
779
+ requiredUptoLevel: 1,
780
+ fetchUptoLevel: 6,
781
+ childForm: !0,
782
+ triggerFirstRun: Ht
783
+ })
784
+ })
785
+ }),
786
+ /* @__PURE__ */ jsxs(Box, {
787
+ className: "flex gap-2 justify-end mt-4",
788
+ children: [/* @__PURE__ */ jsx(Button, {
789
+ variant: "outlined",
790
+ color: "error",
791
+ onClick: Kt,
792
+ children: "Clear"
793
+ }), /* @__PURE__ */ jsx(Button, {
794
+ variant: "contained",
795
+ color: "primary",
796
+ onClick: Gt,
797
+ disabled: ["uniqueHealthId", "familyId"].includes(X) && !Ft,
798
+ children: "Search"
799
+ })]
800
+ })
801
+ ]
802
+ })
803
+ }), Z = (e, t) => {
804
+ if (!t) return "—";
805
+ let n = t[e];
806
+ return n == null ? "—" : e === "registered_by" ? /* @__PURE__ */ jsxs("span", {
807
+ style: { whiteSpace: "pre-wrap" },
808
+ children: [
809
+ n,
810
+ t.role_name ? ` (${t.role_name})` : "",
811
+ t.registered_by_contact_number ? `\n[${t.registered_by_contact_number}]` : ""
812
+ ]
813
+ }) : e === "dob" && n ? toAppLocaleDateString(new Date(n), "en-GB") : String(n);
814
+ }, [Jt, Yt] = useState(!1), Xt = async () => {
815
+ if (!J) return;
816
+ Yt(!0);
817
+ let t = [];
818
+ D.id === b.id ? k.forEach((e) => t.push(e)) : D.id === x.id && A.forEach((e) => t.push(e));
819
+ let n = [];
820
+ Ve.forEach((e) => {
821
+ D.id !== e.member_id && n.push(e);
822
+ });
823
+ try {
824
+ await mergeMembers({
825
+ firstMemberDto: b,
826
+ secondMemberDto: x,
827
+ mergedResultDto: D,
828
+ servicesToDeleteDto: t,
829
+ servicesToTransferDto: n,
830
+ mergedBy: l.id
831
+ }), showToast({
832
+ message: "Members merged successfully",
833
+ type: "success"
834
+ }), W(), U(), await it(b.id), R(G), z(!0, G, 0).then((e) => {
835
+ P(0), I(0), e?.length > 0 ? B(e, 0, 0) : (ot({}), st([]), De(null));
836
+ });
837
+ } catch (e) {
838
+ showToast({
839
+ message: e?.response?.data?.message || "Error merging members",
840
+ type: "error"
841
+ });
842
+ } finally {
843
+ Yt(!1);
844
+ }
845
+ };
846
+ if (!l) return /* @__PURE__ */ jsx(Box, {
847
+ className: "flex justify-center items-center min-h-[50vh]",
848
+ children: /* @__PURE__ */ jsx(CircularProgress, {})
849
+ });
850
+ if (q !== null && !GeneralUtil.hasCheckRights(q?.["view.manage.duplicateMemberData"])) return /* @__PURE__ */ jsx(Box, {
851
+ className: "flex justify-center items-center w-full h-[80vh]",
852
+ children: /* @__PURE__ */ jsx(Box, {
853
+ className: "h-80 w-150 flex justify-center items-center border rounded",
854
+ style: { borderColor: "var(--color-gray3)" },
855
+ children: /* @__PURE__ */ jsx(Typography, {
856
+ variant: "h5",
857
+ className: "text-customBlue",
858
+ children: "You dont have permission to view Duplicate Member Data"
859
+ })
860
+ })
861
+ });
862
+ let Zt = [
863
+ {
864
+ key: "first_name",
865
+ label: "First Name",
866
+ compare: "lowercase"
867
+ },
868
+ {
869
+ key: "middle_name",
870
+ label: "Middle Name",
871
+ compare: "lowercase"
872
+ },
873
+ {
874
+ key: "last_name",
875
+ label: "Last Name",
876
+ compare: "lowercase"
877
+ },
878
+ {
879
+ key: "dob",
880
+ label: "Date of Birth (Age)",
881
+ compare: "exact",
882
+ format: "date"
883
+ },
884
+ {
885
+ key: "gender",
886
+ label: "Gender",
887
+ compare: "exact"
888
+ },
889
+ {
890
+ key: "unique_health_id",
891
+ label: "Unique Health ID",
892
+ compare: "exact",
893
+ isLink: !0
894
+ },
895
+ {
896
+ key: "family_id",
897
+ label: "Family ID",
898
+ compare: "exact",
899
+ isLink: !0
900
+ },
901
+ {
902
+ key: "phone_number",
903
+ label: "Phone Number",
904
+ compare: "exact"
905
+ },
906
+ {
907
+ key: "name_as_per_aadhar",
908
+ label: "Name as per Aadhar",
909
+ compare: "lowercase"
910
+ },
911
+ {
912
+ key: "abha_number",
913
+ label: "ABHA Number",
914
+ compare: "exact"
915
+ },
916
+ {
917
+ key: "health_id",
918
+ label: "Health ID",
919
+ compare: "exact"
920
+ },
921
+ {
922
+ key: "hof",
923
+ label: "Head of Family",
924
+ compare: "exact"
925
+ },
926
+ {
927
+ key: "address",
928
+ label: "Address",
929
+ compare: "exact"
930
+ },
931
+ {
932
+ key: "location",
933
+ label: "Location",
934
+ compare: "exact"
935
+ },
936
+ {
937
+ key: "father_name",
938
+ label: "Father Name",
939
+ compare: "lowercase"
940
+ },
941
+ {
942
+ key: "mother_name",
943
+ label: "Mother Name",
944
+ compare: "lowercase"
945
+ },
946
+ {
947
+ key: "registered_by",
948
+ label: "Registered By",
949
+ compare: "exact"
950
+ },
951
+ {
952
+ key: "no_of_family_members",
953
+ label: "No. of family members",
954
+ compare: "exact"
955
+ },
956
+ {
957
+ key: "no_of_services_given",
958
+ label: "No. of services given",
959
+ compare: "exact"
960
+ },
961
+ {
962
+ key: "registered_on",
963
+ label: "Registered On",
964
+ compare: "exact",
965
+ format: "datetime"
966
+ }
967
+ ], Qt = (e, t, n) => t == null || n == null ? !1 : e.compare === "lowercase" ? String(t).toLowerCase() === String(n).toLowerCase() : t === n, $t = (e, t) => {
968
+ if (!e) return "";
969
+ let n = e[t.key];
970
+ if (n == null) return "";
971
+ if (t.key === "registered_by") return /* @__PURE__ */ jsxs("span", {
972
+ style: { whiteSpace: "pre-wrap" },
973
+ children: [
974
+ n,
975
+ e.role_name ? ` (${e.role_name})` : "",
976
+ e.registered_by_contact_number ? `\n[${e.registered_by_contact_number}]` : ""
977
+ ]
978
+ });
979
+ if (t.format === "date") {
980
+ let e = new Date(n), t = Math.floor((Date.now() - e.getTime()) / (365.25 * 24 * 60 * 60 * 1e3));
981
+ return `${toAppLocaleDateString(e, "en-GB")} (${t})`;
982
+ }
983
+ return t.format === "datetime" ? toAppLocaleString(new Date(n), "en-GB") : String(n);
984
+ }, Q = (e) => e != null && e !== "", [en, tn] = useState(!0), $ = [];
985
+ b?.id && x && ($.push(/* @__PURE__ */ jsxs(Fragment, { children: [
986
+ "Considering the Demographics details ",
987
+ /* @__PURE__ */ jsx("strong", { children: "Duplicate 1" }),
988
+ " and ",
989
+ /* @__PURE__ */ jsx("strong", { children: "Duplicate 2" }),
990
+ " are",
991
+ " ",
992
+ /* @__PURE__ */ jsxs("strong", { children: [Xe, "%"] }),
993
+ " similar."
994
+ ] })), b.abha_number && x.abha_number && b.abha_number === x.abha_number && $.push(/* @__PURE__ */ jsxs(Fragment, { children: [
995
+ /* @__PURE__ */ jsx("strong", { children: "Duplicate 1" }),
996
+ " and ",
997
+ /* @__PURE__ */ jsx("strong", { children: "Duplicate 2" }),
998
+ " have same ABHA number."
999
+ ] })), L && $.push(/* @__PURE__ */ jsxs(Fragment, { children: [
1000
+ /* @__PURE__ */ jsx("strong", { children: "Duplicate 1" }),
1001
+ " and ",
1002
+ /* @__PURE__ */ jsx("strong", { children: "Duplicate 2" }),
1003
+ " have same Aadhar reference key, so they are duplicate."
1004
+ ] })), Ze && $.push(/* @__PURE__ */ jsxs(Fragment, { children: [
1005
+ /* @__PURE__ */ jsx("strong", { children: "Duplicate 1" }),
1006
+ " and ",
1007
+ /* @__PURE__ */ jsx("strong", { children: "Duplicate 2" }),
1008
+ " have equal number of family members, so this can be a case of duplicate family entries."
1009
+ ] })));
1010
+ let nn = DEMOGRAPHICS_KEYS.filter((e) => e !== "id" && FIELD_LABELS[e] && (Q(b?.[e]) || Q(x?.[e]))), rn = HEALTH_STATUS_KEYS.filter((e) => Q(b?.[e]) || Q(x?.[e])), an = [...nn, ...rn].every((e) => (console.log(e), E && [
1011
+ "unique_health_id",
1012
+ "family_id",
1013
+ "abha_number",
1014
+ "hof"
1015
+ ].includes(e) ? D[e] !== null && D[e] !== void 0 : O[e] !== null && O[e] !== void 0)), on = !an || Jt || D?.unique_health_id === null;
1016
+ return /* @__PURE__ */ jsxs("div", {
1017
+ className: "container-fluid report-view",
1018
+ style: { padding: "0 15px" },
1019
+ children: [
1020
+ /* @__PURE__ */ jsx(Backdrop, {
1021
+ open: _,
1022
+ sx: {
1023
+ color: "#fff",
1024
+ zIndex: 1300
1025
+ },
1026
+ children: /* @__PURE__ */ jsx(CircularProgress, { color: "inherit" })
1027
+ }),
1028
+ /* @__PURE__ */ jsxs(Grid, {
1029
+ container: !0,
1030
+ spacing: 2,
1031
+ sx: { margin: "15px 0" },
1032
+ children: [[
1033
+ {
1034
+ label: "Duplicate probable",
1035
+ value: j,
1036
+ clickable: St,
1037
+ onClick: St ? jt : void 0
1038
+ },
1039
+ {
1040
+ label: "Duplicates resolve this session",
1041
+ value: He
1042
+ },
1043
+ {
1044
+ label: "Cumulative Duplicates",
1045
+ value: Ue
1046
+ },
1047
+ {
1048
+ label: "Cumulative Duplicates Resolved",
1049
+ value: We
1050
+ }
1051
+ ].map((e, t) => /* @__PURE__ */ jsx(Grid, {
1052
+ size: {
1053
+ xs: 12,
1054
+ sm: 6,
1055
+ md: 3,
1056
+ lg: 2.4
1057
+ },
1058
+ children: /* @__PURE__ */ jsxs(Box, {
1059
+ onClick: e.onClick,
1060
+ sx: {
1061
+ bgcolor: "white",
1062
+ borderRadius: 1.5,
1063
+ display: "flex",
1064
+ height: 95,
1065
+ flexDirection: "column",
1066
+ justifyContent: "center",
1067
+ alignItems: "center",
1068
+ padding: "10px 16px",
1069
+ border: e.clickable ? "2px solid var(--color-primary)" : "1px solid var(--color-gray3)",
1070
+ boxShadow: "0 1px 3px rgba(0,0,0,0.05)",
1071
+ cursor: e.clickable ? "pointer" : "default",
1072
+ transition: "all 0.2s ease-in-out",
1073
+ "&:hover": e.clickable ? {
1074
+ boxShadow: "0 4px 12px rgba(37, 99, 235, 0.12)",
1075
+ transform: "translateY(-2px)"
1076
+ } : {}
1077
+ },
1078
+ children: [/* @__PURE__ */ jsx(Typography, {
1079
+ sx: {
1080
+ fontSize: "1.8rem",
1081
+ fontWeight: 800,
1082
+ color: "var(--color-text)",
1083
+ lineHeight: 1.1
1084
+ },
1085
+ children: e.value
1086
+ }), /* @__PURE__ */ jsx(Typography, {
1087
+ sx: {
1088
+ fontSize: "0.85rem",
1089
+ color: "var(--color-gray1)",
1090
+ fontWeight: 500,
1091
+ mt: .5,
1092
+ textAlign: "center"
1093
+ },
1094
+ children: e.label
1095
+ })]
1096
+ })
1097
+ }, t)), xt && /* @__PURE__ */ jsx(Grid, {
1098
+ size: {
1099
+ xs: 12,
1100
+ sm: 12,
1101
+ md: 12,
1102
+ lg: 2.4
1103
+ },
1104
+ children: /* @__PURE__ */ jsxs(Box, {
1105
+ onClick: Mt,
1106
+ sx: {
1107
+ display: "flex",
1108
+ height: 95,
1109
+ flexDirection: "column",
1110
+ justifyContent: "center",
1111
+ alignItems: "center",
1112
+ background: "linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%)",
1113
+ color: "white",
1114
+ borderRadius: 1.5,
1115
+ cursor: "pointer",
1116
+ padding: "10px 16px",
1117
+ boxShadow: "0 4px 6px rgba(79, 70, 229, 0.15)",
1118
+ transition: "all 0.2s ease-in-out",
1119
+ "&:hover": {
1120
+ transform: "translateY(-2px)",
1121
+ boxShadow: "0 6px 20px rgba(79, 70, 229, 0.3)"
1122
+ }
1123
+ },
1124
+ children: [
1125
+ /* @__PURE__ */ jsx(FontAwesomeIcon, {
1126
+ icon: faChartLine,
1127
+ style: {
1128
+ fontSize: "1.2rem",
1129
+ marginBottom: 4
1130
+ }
1131
+ }),
1132
+ /* @__PURE__ */ jsx(Typography, {
1133
+ sx: {
1134
+ fontWeight: 700,
1135
+ fontSize: "0.85rem",
1136
+ textAlign: "center"
1137
+ },
1138
+ children: "View Analytics Dashboard"
1139
+ }),
1140
+ /* @__PURE__ */ jsx(Typography, {
1141
+ sx: {
1142
+ color: "rgba(255,255,255,0.7)",
1143
+ fontSize: "0.7rem",
1144
+ mt: .2,
1145
+ textAlign: "center"
1146
+ },
1147
+ children: "Click to explore detailed insights"
1148
+ })
1149
+ ]
1150
+ })
1151
+ })]
1152
+ }),
1153
+ M.length === 0 && !_ && !Ne && /* @__PURE__ */ jsxs("div", {
1154
+ style: {
1155
+ padding: 40,
1156
+ textAlign: "center"
1157
+ },
1158
+ children: [/* @__PURE__ */ jsx("h5", {
1159
+ style: { color: "var(--color-gray1)" },
1160
+ children: "Sorry No Records available!"
1161
+ }), wt && /* @__PURE__ */ jsx(Button, {
1162
+ variant: "contained",
1163
+ size: "small",
1164
+ startIcon: /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faPlusCircle }),
1165
+ onClick: () => ht(!0),
1166
+ sx: {
1167
+ bgcolor: "var(--color-primary)",
1168
+ "&:hover": { bgcolor: "#0b5ed7" },
1169
+ textTransform: "none"
1170
+ },
1171
+ children: "Add Duplicates"
1172
+ })]
1173
+ }),
1174
+ b?.id && !Ne && M.length > 0 && /* @__PURE__ */ jsxs("div", {
1175
+ style: { margin: "0 8px" },
1176
+ children: [
1177
+ /* @__PURE__ */ jsx("div", {
1178
+ style: {
1179
+ display: "flex",
1180
+ justifyContent: "flex-end",
1181
+ gap: 8,
1182
+ marginBottom: 8,
1183
+ flexWrap: "wrap"
1184
+ },
1185
+ children: wt && /* @__PURE__ */ jsx(Button, {
1186
+ variant: "contained",
1187
+ size: "small",
1188
+ startIcon: /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faPlusCircle }),
1189
+ onClick: () => ht(!0),
1190
+ sx: {
1191
+ bgcolor: "var(--color-primary)",
1192
+ "&:hover": { bgcolor: "#0b5ed7" },
1193
+ textTransform: "none"
1194
+ },
1195
+ children: "Add Duplicates"
1196
+ })
1197
+ }),
1198
+ /* @__PURE__ */ jsxs("div", {
1199
+ style: {
1200
+ display: "flex",
1201
+ justifyContent: "space-between",
1202
+ alignItems: "center",
1203
+ marginBottom: 8,
1204
+ flexWrap: "wrap",
1205
+ gap: 10
1206
+ },
1207
+ children: [/* @__PURE__ */ jsxs("h5", {
1208
+ style: {
1209
+ margin: "0",
1210
+ fontWeight: "bold",
1211
+ flex: "1 1 auto"
1212
+ },
1213
+ children: ["NAME: ", [
1214
+ b.first_name,
1215
+ b.middle_name,
1216
+ b.last_name
1217
+ ].filter(Boolean).join(" ")]
1218
+ }), /* @__PURE__ */ jsxs("div", {
1219
+ style: {
1220
+ display: "flex",
1221
+ alignItems: "center",
1222
+ gap: 6,
1223
+ flexWrap: "wrap"
1224
+ },
1225
+ children: [
1226
+ /* @__PURE__ */ jsxs(Box, {
1227
+ sx: {
1228
+ display: "flex",
1229
+ gap: .5
1230
+ },
1231
+ children: [/* @__PURE__ */ jsx(IconButton, {
1232
+ size: "small",
1233
+ onClick: Ot,
1234
+ disabled: N === 0 && F === 0,
1235
+ sx: {
1236
+ border: "1px solid #ccc",
1237
+ borderRadius: 1,
1238
+ bgcolor: "white",
1239
+ width: 32,
1240
+ height: 32
1241
+ },
1242
+ children: /* @__PURE__ */ jsx(FontAwesomeIcon, {
1243
+ icon: faChevronLeft,
1244
+ style: { fontSize: 12 }
1245
+ })
1246
+ }), /* @__PURE__ */ jsx(IconButton, {
1247
+ size: "small",
1248
+ onClick: Dt,
1249
+ sx: {
1250
+ border: "1px solid #ccc",
1251
+ borderRadius: 1,
1252
+ bgcolor: "white",
1253
+ width: 32,
1254
+ height: 32
1255
+ },
1256
+ children: /* @__PURE__ */ jsx(FontAwesomeIcon, {
1257
+ icon: faChevronRight,
1258
+ style: { fontSize: 12 }
1259
+ })
1260
+ })]
1261
+ }),
1262
+ b.member_validity === !0 && /* @__PURE__ */ jsx(Chip, {
1263
+ icon: /* @__PURE__ */ jsx(CheckCircleIcon, { style: { color: "#1b5e20" } }),
1264
+ label: "Valid",
1265
+ size: "small",
1266
+ sx: {
1267
+ bgcolor: "#e8f5e9",
1268
+ color: "#1b5e20",
1269
+ fontWeight: "bold",
1270
+ border: "1px solid #c8e6c9",
1271
+ mr: .5
1272
+ }
1273
+ }),
1274
+ /* @__PURE__ */ jsx(Button, {
1275
+ variant: "contained",
1276
+ size: "small",
1277
+ onClick: Tt,
1278
+ disabled: b.member_validity === !0 || !Ct,
1279
+ sx: {
1280
+ bgcolor: "#ffc107",
1281
+ color: "#000",
1282
+ "&:hover": { bgcolor: "#e0a800" },
1283
+ textTransform: "none",
1284
+ fontWeight: "bold",
1285
+ "&.Mui-disabled": {
1286
+ bgcolor: "var(--color-gray4)",
1287
+ color: "var(--color-gray1)"
1288
+ }
1289
+ },
1290
+ children: "Mark Valid"
1291
+ }),
1292
+ /* @__PURE__ */ jsx(Button, {
1293
+ variant: "contained",
1294
+ size: "small",
1295
+ onClick: At,
1296
+ disabled: b.member_validity === !0 || !!b.abha_number && !!x?.abha_number || !J,
1297
+ sx: {
1298
+ bgcolor: "#0dcaf0",
1299
+ color: "#000",
1300
+ "&:hover": { bgcolor: "#0bb3d6" },
1301
+ textTransform: "none",
1302
+ fontWeight: "bold",
1303
+ "&.Mui-disabled": {
1304
+ bgcolor: "var(--color-gray4)",
1305
+ color: "var(--color-gray1)"
1306
+ }
1307
+ },
1308
+ children: "Merge"
1309
+ })
1310
+ ]
1311
+ })]
1312
+ }),
1313
+ /* @__PURE__ */ jsx("div", {
1314
+ style: {
1315
+ backgroundColor: "var(--color-background2)",
1316
+ boxShadow: "0 4px 6px rgba(0,0,0,0.1)",
1317
+ borderRadius: 6,
1318
+ overflow: "hidden",
1319
+ marginBottom: 15
1320
+ },
1321
+ children: /* @__PURE__ */ jsx("div", {
1322
+ style: { padding: "10px 15px" },
1323
+ children: /* @__PURE__ */ jsx("ul", {
1324
+ style: {
1325
+ listStyleType: "disc",
1326
+ marginLeft: 20,
1327
+ paddingLeft: 0,
1328
+ marginBottom: 0
1329
+ },
1330
+ children: $.map((e, t) => /* @__PURE__ */ jsx("li", {
1331
+ style: {
1332
+ fontSize: 14,
1333
+ color: "#555",
1334
+ marginBottom: 2
1335
+ },
1336
+ children: e
1337
+ }, t))
1338
+ })
1339
+ })
1340
+ }),
1341
+ /* @__PURE__ */ jsx(Box, {
1342
+ sx: {
1343
+ overflowX: "auto",
1344
+ width: "100%",
1345
+ border: "1px solid var(--color-gray3)",
1346
+ borderRadius: 1,
1347
+ marginBottom: 3
1348
+ },
1349
+ children: /* @__PURE__ */ jsxs("table", {
1350
+ style: {
1351
+ minWidth: 700,
1352
+ width: "100%",
1353
+ borderCollapse: "collapse"
1354
+ },
1355
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
1356
+ style: { backgroundColor: "var(--color-gray4)" },
1357
+ children: [
1358
+ /* @__PURE__ */ jsx("th", {
1359
+ style: {
1360
+ width: "30%",
1361
+ padding: "12px 16px",
1362
+ borderBottom: "2px solid var(--color-gray3)",
1363
+ borderRight: "1px solid var(--color-gray3)",
1364
+ textAlign: "left"
1365
+ },
1366
+ children: "#"
1367
+ }),
1368
+ /* @__PURE__ */ jsx("th", {
1369
+ style: {
1370
+ width: "35%",
1371
+ padding: "12px 16px",
1372
+ borderBottom: "2px solid var(--color-gray3)",
1373
+ borderRight: "1px solid var(--color-gray3)",
1374
+ textAlign: "left"
1375
+ },
1376
+ children: "Duplicate 1"
1377
+ }),
1378
+ /* @__PURE__ */ jsx("th", {
1379
+ style: {
1380
+ width: "35%",
1381
+ padding: "12px 16px",
1382
+ borderBottom: "2px solid var(--color-gray3)",
1383
+ textAlign: "left"
1384
+ },
1385
+ children: "Duplicate 2"
1386
+ })
1387
+ ]
1388
+ }) }), /* @__PURE__ */ jsxs("tbody", { children: [/* @__PURE__ */ jsx("tr", {
1389
+ onClick: () => tn((e) => !e),
1390
+ style: {
1391
+ cursor: "pointer",
1392
+ backgroundColor: "var(--color-gray4)"
1393
+ },
1394
+ children: /* @__PURE__ */ jsxs("td", {
1395
+ colSpan: 3,
1396
+ style: {
1397
+ padding: "10px 16px",
1398
+ borderBottom: "1px solid var(--color-gray3)",
1399
+ verticalAlign: "middle"
1400
+ },
1401
+ children: [/* @__PURE__ */ jsx("strong", {
1402
+ style: {
1403
+ display: "inline-block",
1404
+ marginRight: 8
1405
+ },
1406
+ children: "DEMOGRAPHICS"
1407
+ }), /* @__PURE__ */ jsx(FontAwesomeIcon, {
1408
+ icon: en ? faMinusCircle : faPlusCircle,
1409
+ style: {
1410
+ fontSize: 18,
1411
+ verticalAlign: "middle",
1412
+ color: en ? "#dc3545" : "#28a745"
1413
+ }
1414
+ })]
1415
+ })
1416
+ }), en && Zt.map((e, t) => {
1417
+ let n = b[e.key], r = x?.[e.key];
1418
+ if (!Q(n) && !Q(r)) return null;
1419
+ let i = Qt(e, n, r), a = i ? {
1420
+ backgroundColor: "var(--color-gray1)",
1421
+ color: "white",
1422
+ fontWeight: "bold"
1423
+ } : {}, o = e.isLink ? {
1424
+ cursor: "pointer",
1425
+ color: i ? "white" : "var(--color-primary)"
1426
+ } : {};
1427
+ return /* @__PURE__ */ jsxs("tr", {
1428
+ style: !i && t % 2 == 0 ? { backgroundColor: "var(--color-gray4)" } : {},
1429
+ children: [
1430
+ /* @__PURE__ */ jsx("td", {
1431
+ style: {
1432
+ padding: "8px 12px",
1433
+ borderBottom: "1px solid var(--color-gray3)",
1434
+ borderRight: "1px solid var(--color-gray3)",
1435
+ fontWeight: "bold",
1436
+ fontSize: 14
1437
+ },
1438
+ children: e.label
1439
+ }),
1440
+ /* @__PURE__ */ jsx("td", {
1441
+ style: {
1442
+ padding: "8px 12px",
1443
+ borderBottom: "1px solid var(--color-gray3)",
1444
+ borderRight: "1px solid var(--color-gray3)",
1445
+ fontSize: 14,
1446
+ ...a
1447
+ },
1448
+ children: /* @__PURE__ */ jsx("span", {
1449
+ style: o,
1450
+ onClick: () => e.isLink && Nt(e.key, n),
1451
+ children: $t(b, e)
1452
+ })
1453
+ }),
1454
+ /* @__PURE__ */ jsx("td", {
1455
+ style: {
1456
+ padding: "8px 12px",
1457
+ borderBottom: "1px solid var(--color-gray3)",
1458
+ fontSize: 14,
1459
+ ...a
1460
+ },
1461
+ children: /* @__PURE__ */ jsx("span", {
1462
+ style: o,
1463
+ onClick: () => e.isLink && Nt(e.key, r),
1464
+ children: x ? $t(x, e) : ""
1465
+ })
1466
+ })
1467
+ ]
1468
+ }, e.key);
1469
+ })] })]
1470
+ })
1471
+ })
1472
+ ]
1473
+ }),
1474
+ Ne && /* @__PURE__ */ jsxs(Box, {
1475
+ className: "bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden mb-6",
1476
+ children: [/* @__PURE__ */ jsxs(Box, {
1477
+ className: "bg-gray-50 p-4 border-b border-gray-200 text-center",
1478
+ children: [
1479
+ /* @__PURE__ */ jsx(Typography, {
1480
+ variant: "h6",
1481
+ className: E ? "text-orange-500 font-bold" : "text-red-500 font-bold",
1482
+ children: E ? "Notice: Prefilled Member Data" : "Attention: Duplicate Data Detected"
1483
+ }),
1484
+ /* @__PURE__ */ jsx(Typography, {
1485
+ variant: "body2",
1486
+ className: "text-gray-600 mt-1 max-w-2xl mx-auto",
1487
+ children: E ? "One member has a valid ABHA number. Data has been prefilled. Other fields remain editable." : "Drag and drop the data items to consolidate into the final dataset."
1488
+ }),
1489
+ /* @__PURE__ */ jsx(Button, {
1490
+ variant: "outlined",
1491
+ color: "error",
1492
+ size: "small",
1493
+ className: "mt-2",
1494
+ onClick: () => {
1495
+ U(), W();
1496
+ },
1497
+ children: "Back"
1498
+ })
1499
+ ]
1500
+ }), /* @__PURE__ */ jsxs(Box, {
1501
+ className: "p-4",
1502
+ children: [
1503
+ /* @__PURE__ */ jsxs(Grid, {
1504
+ container: !0,
1505
+ spacing: 1,
1506
+ className: "mb-3 text-center text-sm font-bold text-gray-600",
1507
+ children: [
1508
+ /* @__PURE__ */ jsxs(Grid, {
1509
+ size: { xs: 4 },
1510
+ children: ["MEMBER 1 ", /* @__PURE__ */ jsx(Chip, {
1511
+ label: "DUPLICATE 1",
1512
+ size: "small",
1513
+ color: "error",
1514
+ variant: "outlined",
1515
+ className: "ml-1"
1516
+ })]
1517
+ }),
1518
+ /* @__PURE__ */ jsxs(Grid, {
1519
+ size: { xs: 4 },
1520
+ children: ["FINAL ", /* @__PURE__ */ jsx(Chip, {
1521
+ label: "DROP ZONE",
1522
+ size: "small",
1523
+ color: "success",
1524
+ className: "ml-1"
1525
+ })]
1526
+ }),
1527
+ /* @__PURE__ */ jsxs(Grid, {
1528
+ size: { xs: 4 },
1529
+ children: ["MEMBER 2 ", /* @__PURE__ */ jsx(Chip, {
1530
+ label: "DUPLICATE 2",
1531
+ size: "small",
1532
+ color: "error",
1533
+ variant: "outlined",
1534
+ className: "ml-1"
1535
+ })]
1536
+ })
1537
+ ]
1538
+ }),
1539
+ /* @__PURE__ */ jsxs(Accordion, {
1540
+ defaultExpanded: !0,
1541
+ className: "shadow-none border border-gray-200 mb-2",
1542
+ children: [/* @__PURE__ */ jsx(AccordionSummary, {
1543
+ expandIcon: /* @__PURE__ */ jsx(ExpandMoreIcon, {}),
1544
+ className: "bg-gray-100",
1545
+ children: /* @__PURE__ */ jsxs(Box, {
1546
+ className: "flex justify-between w-full items-center",
1547
+ children: [/* @__PURE__ */ jsx(Typography, {
1548
+ fontWeight: "bold",
1549
+ color: "text.secondary",
1550
+ children: "Demographics"
1551
+ }), /* @__PURE__ */ jsxs(Box, {
1552
+ className: "flex gap-1",
1553
+ children: [/* @__PURE__ */ jsx(Button, {
1554
+ size: "small",
1555
+ variant: "outlined",
1556
+ onClick: (e) => {
1557
+ e.stopPropagation(), H(DEMOGRAPHICS_KEYS, "left");
1558
+ },
1559
+ children: "← All Left"
1560
+ }), /* @__PURE__ */ jsx(Button, {
1561
+ size: "small",
1562
+ variant: "outlined",
1563
+ onClick: (e) => {
1564
+ e.stopPropagation(), H(DEMOGRAPHICS_KEYS, "right");
1565
+ },
1566
+ children: "All Right →"
1567
+ })]
1568
+ })]
1569
+ })
1570
+ }), /* @__PURE__ */ jsx(AccordionDetails, {
1571
+ sx: {
1572
+ overflowX: "auto",
1573
+ p: 1
1574
+ },
1575
+ children: /* @__PURE__ */ jsx(Box, {
1576
+ sx: { minWidth: 600 },
1577
+ children: DEMOGRAPHICS_KEYS.filter((e) => e !== "id" && FIELD_LABELS[e] && (Q(b[e]) || Q(x?.[e]))).map((e, t) => /* @__PURE__ */ jsxs(Grid, {
1578
+ container: !0,
1579
+ spacing: 2,
1580
+ sx: {
1581
+ mb: 1.5,
1582
+ alignItems: "stretch"
1583
+ },
1584
+ children: [
1585
+ /* @__PURE__ */ jsx(Grid, {
1586
+ size: { xs: 4 },
1587
+ children: /* @__PURE__ */ jsx(DraggableField, {
1588
+ label: FIELD_LABELS[e],
1589
+ value: Z(e, b),
1590
+ fieldKey: e,
1591
+ side: "left",
1592
+ onDrop: kt,
1593
+ disabled: b[e] === null || E && [
1594
+ "unique_health_id",
1595
+ "family_id",
1596
+ "abha_number",
1597
+ "hof"
1598
+ ].includes(e),
1599
+ faded: O[e] === 0
1600
+ })
1601
+ }),
1602
+ /* @__PURE__ */ jsx(Grid, {
1603
+ size: { xs: 4 },
1604
+ sx: t === 0 ? {
1605
+ borderTop: "4px solid #59D87C",
1606
+ borderRadius: "8px 8px 0 0"
1607
+ } : {},
1608
+ children: /* @__PURE__ */ jsx(DropZoneField, {
1609
+ label: FIELD_LABELS[e],
1610
+ value: Z(e, D),
1611
+ fieldKey: e,
1612
+ onClear: $e,
1613
+ locked: E && [
1614
+ "unique_health_id",
1615
+ "family_id",
1616
+ "abha_number",
1617
+ "hof"
1618
+ ].includes(e)
1619
+ })
1620
+ }),
1621
+ /* @__PURE__ */ jsx(Grid, {
1622
+ size: { xs: 4 },
1623
+ children: /* @__PURE__ */ jsx(DraggableField, {
1624
+ label: FIELD_LABELS[e],
1625
+ value: Z(e, x),
1626
+ fieldKey: e,
1627
+ side: "right",
1628
+ onDrop: kt,
1629
+ disabled: x?.[e] === null || E && [
1630
+ "unique_health_id",
1631
+ "family_id",
1632
+ "abha_number",
1633
+ "hof"
1634
+ ].includes(e),
1635
+ faded: O[e] === 1
1636
+ })
1637
+ })
1638
+ ]
1639
+ }, e))
1640
+ })
1641
+ })]
1642
+ }),
1643
+ /* @__PURE__ */ jsxs(Accordion, {
1644
+ className: "shadow-none border border-gray-200 mb-2",
1645
+ children: [/* @__PURE__ */ jsx(AccordionSummary, {
1646
+ expandIcon: /* @__PURE__ */ jsx(ExpandMoreIcon, {}),
1647
+ className: "bg-gray-100",
1648
+ children: /* @__PURE__ */ jsxs(Box, {
1649
+ className: "flex justify-between w-full items-center",
1650
+ children: [/* @__PURE__ */ jsx(Typography, {
1651
+ fontWeight: "bold",
1652
+ color: "text.secondary",
1653
+ children: "Health Status"
1654
+ }), /* @__PURE__ */ jsxs(Box, {
1655
+ className: "flex gap-1",
1656
+ children: [/* @__PURE__ */ jsx(Button, {
1657
+ size: "small",
1658
+ variant: "outlined",
1659
+ onClick: (e) => {
1660
+ e.stopPropagation(), H(HEALTH_STATUS_KEYS, "left");
1661
+ },
1662
+ children: "← All Left"
1663
+ }), /* @__PURE__ */ jsx(Button, {
1664
+ size: "small",
1665
+ variant: "outlined",
1666
+ onClick: (e) => {
1667
+ e.stopPropagation(), H(HEALTH_STATUS_KEYS, "right");
1668
+ },
1669
+ children: "All Right →"
1670
+ })]
1671
+ })]
1672
+ })
1673
+ }), /* @__PURE__ */ jsx(AccordionDetails, {
1674
+ sx: {
1675
+ overflowX: "auto",
1676
+ p: 1
1677
+ },
1678
+ children: /* @__PURE__ */ jsx(Box, {
1679
+ sx: { minWidth: 600 },
1680
+ children: HEALTH_STATUS_KEYS.filter((e) => Q(b[e]) || Q(x?.[e])).map((e, t) => /* @__PURE__ */ jsxs(Grid, {
1681
+ container: !0,
1682
+ spacing: 2,
1683
+ sx: {
1684
+ mb: 1.5,
1685
+ alignItems: "stretch"
1686
+ },
1687
+ children: [
1688
+ /* @__PURE__ */ jsx(Grid, {
1689
+ size: { xs: 4 },
1690
+ children: /* @__PURE__ */ jsx(DraggableField, {
1691
+ label: FIELD_LABELS[e] || e,
1692
+ value: Z(e, b),
1693
+ fieldKey: e,
1694
+ side: "left",
1695
+ onDrop: (e, t) => V(e, t),
1696
+ disabled: b[e] === null,
1697
+ faded: O[e] === 0
1698
+ })
1699
+ }),
1700
+ /* @__PURE__ */ jsx(Grid, {
1701
+ size: { xs: 4 },
1702
+ sx: t === 0 ? {
1703
+ borderTop: "4px solid #59D87C",
1704
+ borderRadius: "8px 8px 0 0"
1705
+ } : {},
1706
+ children: /* @__PURE__ */ jsx(DropZoneField, {
1707
+ label: FIELD_LABELS[e] || e,
1708
+ value: Z(e, D),
1709
+ fieldKey: e,
1710
+ onClear: $e
1711
+ })
1712
+ }),
1713
+ /* @__PURE__ */ jsx(Grid, {
1714
+ size: { xs: 4 },
1715
+ children: /* @__PURE__ */ jsx(DraggableField, {
1716
+ label: FIELD_LABELS[e] || e,
1717
+ value: Z(e, x),
1718
+ fieldKey: e,
1719
+ side: "right",
1720
+ onDrop: (e, t) => V(e, t),
1721
+ disabled: x?.[e] === null,
1722
+ faded: O[e] === 1
1723
+ })
1724
+ })
1725
+ ]
1726
+ }, e))
1727
+ })
1728
+ })]
1729
+ }),
1730
+ /* @__PURE__ */ jsxs(Accordion, {
1731
+ className: "shadow-none border border-gray-200 mb-2",
1732
+ children: [/* @__PURE__ */ jsx(AccordionSummary, {
1733
+ expandIcon: /* @__PURE__ */ jsx(ExpandMoreIcon, {}),
1734
+ className: "bg-gray-100",
1735
+ children: /* @__PURE__ */ jsx(Typography, {
1736
+ fontWeight: "bold",
1737
+ color: "text.secondary",
1738
+ children: "Service Information"
1739
+ })
1740
+ }), /* @__PURE__ */ jsx(AccordionDetails, {
1741
+ sx: {
1742
+ overflowX: "auto",
1743
+ p: 1
1744
+ },
1745
+ children: /* @__PURE__ */ jsx(Box, {
1746
+ sx: { minWidth: 600 },
1747
+ children: /* @__PURE__ */ jsxs(Grid, {
1748
+ container: !0,
1749
+ spacing: 2,
1750
+ children: [
1751
+ /* @__PURE__ */ jsxs(Grid, {
1752
+ size: { xs: 4 },
1753
+ children: [k.map((e, t) => /* @__PURE__ */ jsx(Chip, {
1754
+ label: `${e.type} (${e.service_date || ""})`,
1755
+ className: "m-1 cursor-grab",
1756
+ draggable: !0,
1757
+ onDragEnd: () => tt(e, "left")
1758
+ }, t)), k.length === 0 && /* @__PURE__ */ jsx(Typography, {
1759
+ variant: "body2",
1760
+ color: "text.secondary",
1761
+ children: "No services"
1762
+ })]
1763
+ }),
1764
+ /* @__PURE__ */ jsxs(Grid, {
1765
+ size: { xs: 4 },
1766
+ sx: {
1767
+ bgcolor: "var(--color-gray4)",
1768
+ borderRadius: 1,
1769
+ p: 1
1770
+ },
1771
+ children: [Ve.map((e, t) => /* @__PURE__ */ jsx(Chip, {
1772
+ label: `${e.type} (${e.service_date || ""})`,
1773
+ className: "m-1",
1774
+ onDelete: () => nt(e),
1775
+ color: "primary",
1776
+ variant: "outlined"
1777
+ }, t)), Ve.length === 0 && /* @__PURE__ */ jsx(Typography, {
1778
+ variant: "body2",
1779
+ color: "text.secondary",
1780
+ textAlign: "center",
1781
+ children: "Drop services here"
1782
+ })]
1783
+ }),
1784
+ /* @__PURE__ */ jsxs(Grid, {
1785
+ size: { xs: 4 },
1786
+ children: [A.map((e, t) => /* @__PURE__ */ jsx(Chip, {
1787
+ label: `${e.type} (${e.service_date || ""})`,
1788
+ className: "m-1 cursor-grab",
1789
+ draggable: !0,
1790
+ onDragEnd: () => tt(e, "right")
1791
+ }, t)), A.length === 0 && /* @__PURE__ */ jsx(Typography, {
1792
+ variant: "body2",
1793
+ color: "text.secondary",
1794
+ children: "No services"
1795
+ })]
1796
+ })
1797
+ ]
1798
+ })
1799
+ })
1800
+ })]
1801
+ }),
1802
+ /* @__PURE__ */ jsxs(Box, {
1803
+ className: "flex justify-center gap-4 mt-4",
1804
+ children: [/* @__PURE__ */ jsx(Tooltip, {
1805
+ title: an ? "" : "Please select a value for all demographic and health status fields before submitting",
1806
+ children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Button, {
1807
+ variant: "contained",
1808
+ color: "success",
1809
+ onClick: Xt,
1810
+ disabled: on || !J,
1811
+ children: Jt ? /* @__PURE__ */ jsx(CircularProgress, {
1812
+ size: 24,
1813
+ color: "inherit"
1814
+ }) : "Submit Merge"
1815
+ }) })
1816
+ }), /* @__PURE__ */ jsx(Button, {
1817
+ variant: "outlined",
1818
+ color: "error",
1819
+ onClick: () => {
1820
+ U(), W();
1821
+ },
1822
+ children: "Cancel"
1823
+ })]
1824
+ })
1825
+ ]
1826
+ })]
1827
+ }),
1828
+ /* @__PURE__ */ jsx(MemberServicesModal, {
1829
+ open: ut,
1830
+ onClose: () => dt(!1),
1831
+ services: ft
1832
+ }),
1833
+ /* @__PURE__ */ jsx(ManualDuplicateEntryModal, {
1834
+ open: mt,
1835
+ onClose: () => ht(!1),
1836
+ onSuccess: () => {
1837
+ R(G), z(!0, G, 0).then((e) => {
1838
+ P(0), I(0), e?.length > 0 && B(e, 0, 0);
1839
+ });
1840
+ },
1841
+ user: l,
1842
+ canSave: wt
1843
+ }),
1844
+ /* @__PURE__ */ jsxs(Dialog, {
1845
+ open: gt,
1846
+ onClose: () => K(!1),
1847
+ PaperProps: { style: {
1848
+ borderRadius: 12,
1849
+ padding: "8px",
1850
+ boxShadow: "0 8px 30px rgba(0,0,0,0.12)"
1851
+ } },
1852
+ children: [
1853
+ /* @__PURE__ */ jsx(DialogTitle, {
1854
+ style: {
1855
+ fontWeight: "bold",
1856
+ fontSize: "1.2rem",
1857
+ color: "#333"
1858
+ },
1859
+ children: "Confirm Action"
1860
+ }),
1861
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Typography, {
1862
+ style: {
1863
+ color: "#555",
1864
+ fontSize: "0.95rem"
1865
+ },
1866
+ children: "Are you sure you want to mark both members as valid? This action will update the validity of both duplicate records in the system."
1867
+ }) }),
1868
+ /* @__PURE__ */ jsxs(DialogActions, {
1869
+ style: { padding: "12px 24px" },
1870
+ children: [/* @__PURE__ */ jsx(Button, {
1871
+ onClick: () => K(!1),
1872
+ sx: {
1873
+ color: "var(--color-gray1)",
1874
+ fontWeight: "bold",
1875
+ textTransform: "none"
1876
+ },
1877
+ children: "Cancel"
1878
+ }), /* @__PURE__ */ jsx(Button, {
1879
+ onClick: async () => {
1880
+ K(!1), _t && await _t();
1881
+ },
1882
+ variant: "contained",
1883
+ sx: {
1884
+ bgcolor: "#ffc107",
1885
+ color: "#000",
1886
+ fontWeight: "bold",
1887
+ textTransform: "none",
1888
+ "&:hover": { bgcolor: "#e0a800" }
1889
+ },
1890
+ children: "Confirm"
1891
+ })]
1892
+ })
1893
+ ]
1894
+ }),
1895
+ /* @__PURE__ */ jsx(SideOverlay, {
1896
+ title: "Search Members",
1897
+ FormBody: qt,
1898
+ isForm: !1,
1899
+ handleOverlayState: () => Y((e) => !e),
1900
+ overlayOpen: Et,
1901
+ dataTestId: "duplicate-member-search-overlay",
1902
+ ModalProps: { keepMounted: !0 }
1903
+ })
1904
+ ]
1905
+ });
1906
+ }
1907
+ export { DuplicateMemberData as default };
1908
+
1909
+ //# sourceMappingURL=DuplicateMemberData-C4MSJxcL.js.map