From 94e7975cd0c63bf8ac635d540547c91ff552e8e8 Mon Sep 17 00:00:00 2001 From: TuanVT Date: Mon, 17 Aug 2026 15:48:39 +0700 Subject: [PATCH] feat:update-project --- .../DetailConsultation/DetailConsultation.tsx | 134 ++++++++++++---- .../MainPageConsultation.tsx | 148 +++++++++--------- .../TableHistoryPatient.tsx | 41 +++++ .../patient/DetailPatient/DetailPatient.tsx | 18 ++- .../CreatePrescription/CreatePrescription.tsx | 2 +- .../DetailPrescription/DetailPrescription.tsx | 19 ++- .../MainPrescription/MainPrescription.tsx | 43 ++++- src/constant/config/index.ts | 43 +++++ src/hooks/useSpecialtyTabs.ts | 121 ++++++++++++++ src/services/consultationServices.ts | 1 + src/services/prescriptionServices.ts | 5 +- 11 files changed, 453 insertions(+), 122 deletions(-) create mode 100644 src/hooks/useSpecialtyTabs.ts diff --git a/src/components/page/consultation/DetailConsultation/DetailConsultation.tsx b/src/components/page/consultation/DetailConsultation/DetailConsultation.tsx index ddca924..944f63b 100644 --- a/src/components/page/consultation/DetailConsultation/DetailConsultation.tsx +++ b/src/components/page/consultation/DetailConsultation/DetailConsultation.tsx @@ -28,6 +28,7 @@ import { TooltipProvider, TooltipTrigger, } from "@radix-ui/react-tooltip"; +import { SPECIALTY_DISPLAY_NAME, SPECIALTY_ORDER } from "@/constant/config"; const DetailConsultation = () => { const params = useParams(); @@ -37,9 +38,12 @@ const DetailConsultation = () => { const consultationId = params?.id as string; + const [openTooltip, setOpenTooltip] = useState(false); const [prescriptionPage, setPrescriptionPage] = useState(1); const [prescriptionPageSize, setPrescriptionPageSize] = useState(10); + const normalize = (text?: string) => (text ?? "").trim().toLowerCase(); + const consulDetailQuery = useQuery({ queryKey: [QUERY_KEY.chi_tiet_phien_kham, consultationId], @@ -79,15 +83,72 @@ const DetailConsultation = () => { consultation?.status !== TYPE_STATUS.Completed && consultation?.status !== TYPE_STATUS.Cancelled; + // const specialtyTabs = useMemo(() => { + // return ( + // consultation?.specialtyClinics?.map((item) => ({ + // pathname: `/consultation/${consultationId}`, + // query: item.id, + // title: item.specialtyName, + // })) || [] + // ); + // }, [consultation?.specialtyClinics, consultationId]); + const specialtyTabs = useMemo(() => { - return ( - consultation?.specialtyClinics?.map((item) => ({ - pathname: `/consultation/${consultationId}`, - query: item.id, - title: item.specialtyName, - })) || [] - ); + if (!consultation?.specialtyClinics?.length) return []; + + //------------------------------------ + // Chuẩn hóa tên + //------------------------------------ + + const specialties = consultation.specialtyClinics.map((item) => ({ + ...item, + + displayName: + SPECIALTY_DISPLAY_NAME[item.specialtyName] ?? item.specialtyName, + })); + + //------------------------------------ + // Ưu tiên chuyên khoa đã khám + //------------------------------------ + + specialties.sort((a, b) => { + const aVisited = a.specialtyStatus === 3; + const bVisited = b.specialtyStatus === 3; + + // Đã khám lên trước + + if (aVisited !== bVisited) { + return aVisited ? -1 : 1; + } + + // Sau đó theo SPECIALTY_ORDER + + const indexA = SPECIALTY_ORDER.findIndex( + (x) => normalize(x) === normalize(a.displayName), + ); + + const indexB = SPECIALTY_ORDER.findIndex( + (x) => normalize(x) === normalize(b.displayName), + ); + + if (indexA === -1 && indexB === -1) { + return a.displayName.localeCompare(b.displayName); + } + + if (indexA === -1) return 1; + + if (indexB === -1) return -1; + + return indexA - indexB; + }); + + return specialties.map((item) => ({ + pathname: `/consultation/${consultationId}`, + query: item.id, + title: item.displayName, + })); }, [consultation?.specialtyClinics, consultationId]); + // Tính toán cắt mảng dữ liệu thuốc để hiển thị phân trang trên Client const paginatedPrescriptionItems = useMemo(() => { const items = consultation?.aggregatedPrescriptionItems || []; @@ -153,18 +214,18 @@ const DetailConsultation = () => { return (
-
+
{/* HEADER */} -
+
router.back()} > - + -

+

Chi tiết phiên khám

@@ -265,7 +326,7 @@ const DetailConsultation = () => { {/* CHẨN ĐOÁN */}

- CHUẨN ĐOÁN + CHẨN ĐOÁN

@@ -338,18 +399,24 @@ const DetailConsultation = () => {

{consultation.generalAttachmentUrls?.length > 0 ? ( - + -
+
setOpenTooltip((prev) => !prev)} + className="inline-flex cursor-pointer items-center gap-2 rounded-lg border border-blue-100 bg-blue-50 px-3 py-2 text-sm font-medium text-blue-600 transition hover:bg-blue-100 active:bg-blue-200" + > 📎 - Chi tiết các file + + Chi tiết các file ( + {consultation.generalAttachmentUrls.length}) +

@@ -383,10 +450,10 @@ const DetailConsultation = () => { href={file.path} target="_blank" rel="noopener noreferrer" - className="flex items-center justify-between rounded-lg border border-gray-200 p-3 transition hover:bg-gray-50" + className="flex items-center justify-between rounded-lg border border-gray-200 p-3 transition hover:bg-gray-50 active:bg-gray-100" >
- + {isImage ? "🖼️" : "📄"} @@ -401,7 +468,7 @@ const DetailConsultation = () => {

- + Mở @@ -414,7 +481,9 @@ const DetailConsultation = () => { ) : ( -
Không có file nào được tải lên
+
+ Không có file nào được tải lên +
)}
@@ -546,7 +615,7 @@ const DetailConsultation = () => { )}
-
+ {/* TAB CHUYÊN KHOA */} {specialtyTabs.length > 0 && (
@@ -556,8 +625,8 @@ const DetailConsultation = () => { {/* CHI TIẾT CHUYÊN KHOA */} {selectedSpecialty && (
-
-

+
+

Thông tin chuyên khoa: {selectedSpecialty.specialtyName}

{canUpdateConsultation && ( @@ -611,9 +680,12 @@ const DetailConsultation = () => {

{selectedSpecialty.attachmentUrls?.length > 0 ? ( - + -
+
setOpenTooltip((prev) => !prev)} + className="inline-flex cursor-pointer items-center gap-2 rounded-lg border border-blue-100 bg-blue-50 px-3 py-2 text-sm font-medium text-blue-600 transition hover:bg-blue-100 active:bg-blue-200" + > 📎 Chi tiết các file
@@ -622,7 +694,7 @@ const DetailConsultation = () => {

@@ -654,10 +726,10 @@ const DetailConsultation = () => { href={file.path} target="_blank" rel="noopener noreferrer" - className="flex items-center justify-between rounded-lg border border-gray-200 p-3 transition hover:bg-gray-50" + className="flex items-center justify-between rounded-lg border border-gray-200 p-3 transition hover:bg-gray-50 active:bg-gray-100" >
- + {isImage ? "🖼️" : "📄"} @@ -672,7 +744,7 @@ const DetailConsultation = () => {

- + Mở @@ -685,7 +757,9 @@ const DetailConsultation = () => { ) : ( -
Không có file nào được tải lên
+
+ Không có file nào được tải lên +
)}
diff --git a/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx b/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx index 77715c1..8a73f2f 100644 --- a/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx +++ b/src/components/page/consultation/MainPageConsultation/MainPageConsultation.tsx @@ -41,6 +41,7 @@ import * as Popover from "@radix-ui/react-popover"; import clsx from "clsx"; import TabNavLink from "@/components/customs/custom-tabs"; import { removeVietnameseTones } from "@/common/funcs/optionConvert"; +import useSpecialtyTabs from "@/hooks/useSpecialtyTabs"; const MainPageConsultation = () => { const router = useRouter(); @@ -98,6 +99,10 @@ const MainPageConsultation = () => { }, }); + const { tabs: specialtyTabs } = useSpecialtyTabs( + consultationQuery.data?.items ?? [], + ); + const specialtyQuery = useQuery({ queryKey: [QUERY_KEY.list_specialty_lookup], queryFn: async () => { @@ -183,30 +188,30 @@ const MainPageConsultation = () => { const consultation = consultationQuery.data; - const specialtyTabs = useMemo(() => { - const specialtyMap = new Map(); + // const specialtyTabs = useMemo(() => { + // const specialtyMap = new Map(); - consultation?.items?.forEach((consultationItem) => { - consultationItem.specialtyClinics?.forEach((specialty) => { - if (!specialtyMap.has(specialty.specialtyId)) { - specialtyMap.set(specialty.specialtyId, { - pathname: "/consultation", - query: specialty.specialtyId, - title: specialty.specialtyName, - }); - } - }); - }); + // consultation?.items?.forEach((consultationItem) => { + // consultationItem.specialtyClinics?.forEach((specialty) => { + // if (!specialtyMap.has(specialty.specialtyId)) { + // specialtyMap.set(specialty.specialtyId, { + // pathname: "/consultation", + // query: specialty.specialtyId, + // title: specialty.specialtyName, + // }); + // } + // }); + // }); - return [ - { - pathname: "/consultation", - query: "all", - title: "Tất cả", - }, - ...Array.from(specialtyMap.values()), - ]; - }, [consultation?.items]); + // return [ + // { + // pathname: "/consultation", + // query: "all", + // title: "Tất cả", + // }, + // ...Array.from(specialtyMap.values()), + // ]; + // }, [consultation?.items]); const handleOpenCancel = (item: ConsultationItem) => { setSelectedConsultationId(item.id); @@ -381,7 +386,6 @@ const MainPageConsultation = () => { column={[ { title: "TÊN BỆNH NHÂN", - render: (item: ConsultationItem) => ( @@ -393,9 +397,8 @@ const MainPageConsultation = () => { {item.patientName}
- -

+

Chi tiết bệnh nhân

@@ -427,7 +430,6 @@ const MainPageConsultation = () => { {item.sessionCode} -

Chi tiết phiên khám @@ -450,41 +452,72 @@ const MainPageConsultation = () => { ), }, - { + // 🔴 ẨN "DẤU HIỆU" khi KHÔNG PHẢI Tab All (!isAllTab) + isAllTab && { title: "DẤU HIỆU", - render: (item: ConsultationItem) => ( {item.symptomsText || "---"} ), }, { - title: "CHUẨN ĐOÁN", - - render: (item: ConsultationItem) => ( - {item.diagnosis || "---"} - ), + title: "CHẨN ĐOÁN", + render: (item: ConsultationItem) => { + if (!isAllTab) { + const specialty = item.specialtyClinics.find( + (x) => x.specialtyId === _type, + ); + return {specialty?.diagnosis || "---"}; + } + return {item.diagnosis || "---"}; + }, }, - { - title: "KẾ HOẠCH ĐIỀU TRỊ", + // 🔴 ẨN "DẤU HIỆU" khi KHÔNG PHẢI Tab All (!isAllTab) + // !isAllTab && { + // title: "BÁC SĨ KHÁM", + // render: (item: ConsultationItem) => { + // const doctorNames = item.doctors?.join(", "); + // return {doctorNames || "---"}; + // }, + // }, + + // 🔴 ẨN "KẾ HOẠCH ĐIỀU TRỊ" khi KHÔNG PHẢI Tab All (!isAllTab) + isAllTab && { + title: "KẾ HOẠCH ĐIỀU TRỊ", render: (item: ConsultationItem) => ( {item.treatmentPlan || "---"} ), }, { - title: "GHI CHÚ BÁC SĨ", - - render: (item: ConsultationItem) => ( - {item.doctorNotes || "---"} - ), + title: isAllTab ? "GHI CHÚ BÁC SĨ" : "GHI CHÚ KHÁM", + render: (item: ConsultationItem) => { + if (!isAllTab) { + const specialty = item.specialtyClinics.find( + (x) => x.specialtyId === _type, + ); + return {specialty?.specialtyNotes || "---"}; + } + return {item.doctorNotes || "---"}; + }, }, + + // 🔴 ẨN "THỦ THUẬT" khi LÀ Tab All (isAllTab) + !isAllTab && { + title: "THỦ THUẬT", + render: (item: ConsultationItem) => { + const specialty = item.specialtyClinics.find( + (x) => x.specialtyId === _type, + ); + return {specialty?.procedureNotes || "---"}; + }, + }, + { title: "TRẠNG THÁI", render: (item: ConsultationItem) => { - // ===== TAB CHUYÊN KHOA ===== if (!isAllTab) { const specialty = item.specialtyClinics.find( (x) => x.specialtyId === _type, @@ -517,7 +550,6 @@ const MainPageConsultation = () => { ); } - // ===== TAB TẤT CẢ ===== return ( { ); }, }, + { fixedRight: true, - title: "ACTION", - render: (item: ConsultationItem) => { const isCancelled = item.status === TYPE_STATUS.Cancelled; - const isCompleted = item.status === TYPE_STATUS.Completed; - const isDisabled = isCancelled || isCompleted; - // ===== TAB CHUYÊN KHOA ===== if (!isAllTab) { const specialty = item.specialtyClinics.find( (x) => x.specialtyId === _type, @@ -599,14 +627,7 @@ const MainPageConsultation = () => { ); } - // ===== TAB TẤT CẢ ===== return ( - /* - Chỉnh sửa tại đây: - - flex-col: xếp dọc trên màn mobile - - sm:flex-row: quay lại xếp ngang trên tablet / desktop (>= 640px) - - w-full sm:w-auto: mở rộng full chiều rộng ô khi ở màn mobile cho cân đối - */

@@ -628,27 +649,14 @@ const MainPageConsultation = () => { side="bottom" align="end" sideOffset={8} - className=" - z-50 - min-w-[300px] - rounded-xl - border - bg-white - p-2 - shadow-xl - " + className="z-50 min-w-[300px] rounded-xl border bg-white p-2 shadow-xl" >
{item.specialtyClinics.map((specialty) => ( {specialty.specialtyName} @@ -682,7 +690,7 @@ const MainPageConsultation = () => { ); }, }, - ]} + ].filter(Boolean)} // 💡 Lọc bỏ các giá trị false để ẩn cột /> { {item.diagnosis || "---"} ), }, + { + title: "KẾ HOẠCH ĐIỀU TRỊ", + + render: (item: ConsultationItem) => ( + {item.treatmentPlan || "---"} + ), + }, + + { + title: "CÁC CHUYÊN KHOA ĐANG CHỜ KHÁM", + + render: (item: ConsultationItem) => { + const waitingSpecialties = item.specialtyClinics + ?.filter((specialty) => specialty.specialtyStatus === 1) + .map((specialty) => specialty.specialtyName) + .join(", "); + + return {waitingSpecialties || "---"}; + }, + }, + { + title: "CÁC CHUYÊN KHOA ĐÃ KHÁM", + + render: (item: ConsultationItem) => { + const completedSpecialties = item.specialtyClinics + ?.filter((specialty) => specialty.specialtyStatus === 3) + .map((specialty) => specialty.specialtyName) + .join(", "); + + return {completedSpecialties || "---"}; + }, + }, + + { + title: "BÁC SĨ KHÁM", + render: (item: ConsultationItem) => { + const doctorNames = item.doctors?.join(", "); + + return {doctorNames || "---"}; + }, + }, { title: "TRẠNG THÁI", render: (item: ConsultationItem) => ( diff --git a/src/components/page/patient/DetailPatient/DetailPatient.tsx b/src/components/page/patient/DetailPatient/DetailPatient.tsx index c1e92e3..6b98c2f 100644 --- a/src/components/page/patient/DetailPatient/DetailPatient.tsx +++ b/src/components/page/patient/DetailPatient/DetailPatient.tsx @@ -324,7 +324,7 @@ const DetailPatient = () => { }, { - title: "CHUẨN ĐOÁN", + title: "CHẨN ĐOÁN", render: (item: ConsultationItem) => ( {item.diagnosis || "---"} @@ -339,13 +339,6 @@ const DetailPatient = () => { ), }, - { - title: "GHI CHÚ BÁC SĨ", - - render: (item: ConsultationItem) => ( - {item.doctorNotes || "---"} - ), - }, { title: "CÁC CHUYÊN KHOA ĐANG CHỜ KHÁM", @@ -370,6 +363,15 @@ const DetailPatient = () => { return {completedSpecialties || "---"}; }, }, + + { + title: "BÁC SĨ KHÁM", + render: (item: ConsultationItem) => { + const doctorNames = item.doctors?.join(", "); + + return {doctorNames || "---"}; + }, + }, { title: "TRẠNG THÁI", fixedRight: true, diff --git a/src/components/page/prescription/CreatePrescription/CreatePrescription.tsx b/src/components/page/prescription/CreatePrescription/CreatePrescription.tsx index 6d2f487..ab13ff6 100644 --- a/src/components/page/prescription/CreatePrescription/CreatePrescription.tsx +++ b/src/components/page/prescription/CreatePrescription/CreatePrescription.tsx @@ -509,7 +509,7 @@ const CreatePrescription = () => { - Thời gian dùng* + Số lượng thuốc* } isRequired diff --git a/src/components/page/prescription/DetailPrescription/DetailPrescription.tsx b/src/components/page/prescription/DetailPrescription/DetailPrescription.tsx index 4e4da0e..5ca042d 100644 --- a/src/components/page/prescription/DetailPrescription/DetailPrescription.tsx +++ b/src/components/page/prescription/DetailPrescription/DetailPrescription.tsx @@ -14,6 +14,7 @@ import { useParams, useRouter } from "next/navigation"; import React, { useState } from "react"; import CustomPopup from "@/components/customs/custom-popup"; import { ArrowLeft } from "lucide-react"; +import Link from "next/link"; const DetailPrescription = () => { const router = useRouter(); @@ -104,16 +105,25 @@ const DetailPrescription = () => {
Mã đơn thuốc: {data.prescriptionCode}
- +
+ Mã bệnh nhân: + + {data.patientCode || "---"} + +
{" "} +
+ Tên bệnh nhân: {data.patientName || "---"} +
Chuyên khoa:{" "} {specialtyName || data.examinationSessionSpecialtyId || "---"}
-
Ghi chú: {data.notes || "---"}
- {/* IMAGE */}
Ảnh đơn thuốc: @@ -152,7 +162,6 @@ const DetailPrescription = () => { )}
- {/* ITEMS */}
Danh sách thuốc: @@ -171,7 +180,7 @@ const DetailPrescription = () => { Tần suất: {item.frequency}

- Thời gian: {item.duration} + Số lượng thuốc: {item.quantity}

Hướng dẫn: {item.instructions} diff --git a/src/components/page/prescription/MainPrescription/MainPrescription.tsx b/src/components/page/prescription/MainPrescription/MainPrescription.tsx index 24d5f89..2738f8b 100644 --- a/src/components/page/prescription/MainPrescription/MainPrescription.tsx +++ b/src/components/page/prescription/MainPrescription/MainPrescription.tsx @@ -148,12 +148,37 @@ const MainPrescription = () => { ), }, - // ================= NOTES ================= { - title: "GHI CHÚ", - render: (item: any) => {item.notes || "-"}, - }, + title: "MÃ BỆNH NHÂN", + render: (item: any) => ( + + + + + {item.patientCode} + + + +

+ Chi tiết bệnh nhân +

+ + + + ), + }, + { + title: "TÊN BỆNH NHÂN", + render: (item: any) => {item.patientName || "-"}, + }, + { + title: "TÊN CHUYÊN KHOA", + render: (item: any) => {item.specialtyName || "-"}, + }, // ================= IMAGE ================= { title: "ẢNH ĐƠN THUỐC", @@ -174,11 +199,15 @@ const MainPrescription = () => { }, // ================= ITEMS COUNT ================= + // { + // title: "SỐ THUỐC", + // render: (item: any) => {item.items?.length || 0}, + // }, + // ================= NOTES ================= { - title: "SỐ THUỐC", - render: (item: any) => {item.items?.length || 0}, + title: "GHI CHÚ", + render: (item: any) => {item.notes || "-"}, }, - // ================= ACTION ================= { fixedRight: true, diff --git a/src/constant/config/index.ts b/src/constant/config/index.ts index 50d4b8c..fb4ed8d 100644 --- a/src/constant/config/index.ts +++ b/src/constant/config/index.ts @@ -113,4 +113,47 @@ export const ListOptionFilterDate: { }, ]; +export const SPECIALTY_ORDER = [ + "Khám Nội", + "Khám Răng", + "Khám Tai Mũi Họng", + "Khám Mắt", + "Khám Sản phụ khoa", + "Xét nghiệm máu", + "Xét nghiệm nước tiểu", + "X-quang", + "Điện tim", + "Siêu Âm", +]; + +export const SPECIALTY_DISPLAY_NAME: Record = { + Nội: "Khám Nội", + "Khám Nội": "Khám Nội", + + Răng: "Khám Răng", + "Khám Răng": "Khám Răng", + + "Tai Mũi Họng": "Khám Tai Mũi Họng", + "Khám Tai Mũi Họng": "Khám Tai Mũi Họng", + + Mắt: "Khám Mắt", + "Khám Mắt": "Khám Mắt", + + "Sản Phụ Khoa": "Khám Sản phụ khoa", + "Sản phụ khoa": "Khám Sản phụ khoa", + "Khám Sản phụ khoa": "Khám Sản phụ khoa", + + "Xét nghiệm máu": "Xét nghiệm máu", + + "Xét nghiệm nước tiểu": "Xét nghiệm nước tiểu", + + "X-Quang": "X-quang", + "X-quang": "X-quang", + + "Điện Tim": "Điện tim", + "Điện tim": "Điện tim", + + "Siêu Âm": "Siêu Âm", +}; + export const KEY_STORE = "management-kham-benh"; diff --git a/src/hooks/useSpecialtyTabs.ts b/src/hooks/useSpecialtyTabs.ts new file mode 100644 index 0000000..576f4f4 --- /dev/null +++ b/src/hooks/useSpecialtyTabs.ts @@ -0,0 +1,121 @@ +import { useMemo } from "react"; +import { useQuery } from "@tanstack/react-query"; + +import { QUERY_KEY } from "@/constant/config/enum"; +import { httpRequest } from "@/services"; +import specialtyServices, { SpecialtyItem } from "@/services/specialtyServices"; + +import { SPECIALTY_ORDER, SPECIALTY_DISPLAY_NAME } from "@/constant/config"; + +interface ConsultationSpecialty { + specialtyClinics?: { + specialtyId: string; + specialtyName: string; + }[]; +} + +const normalize = (text: string) => text.trim().toLowerCase(); + +export default function useSpecialtyTabs( + consultationItems: ConsultationSpecialty[] = [], +) { + const specialtyQuery = useQuery({ + queryKey: [QUERY_KEY.list_specialty_lookup], + + queryFn: async () => { + const res = await httpRequest({ + http: specialtyServices.getSpecialty(), + showMessageFailed: true, + }); + + return res || []; + }, + }); + + const tabs = useMemo(() => { + const lookup = [...(specialtyQuery.data ?? [])]; + + //----------------------------------------- + // Các chuyên khoa đã xuất hiện trong phiên khám + //----------------------------------------- + + const existed = new Set(); + + consultationItems.forEach((item) => { + item.specialtyClinics?.forEach((specialty) => { + const displayName = + SPECIALTY_DISPLAY_NAME[specialty.specialtyName] ?? + specialty.specialtyName; + + existed.add(displayName); + }); + }); + + //----------------------------------------- + // Chuẩn hóa tên + //----------------------------------------- + + const specialties = lookup.map((item) => ({ + ...item, + displayName: SPECIALTY_DISPLAY_NAME[item.name] ?? item.name, + })); + + //----------------------------------------- + // Sort + //----------------------------------------- + + specialties.sort((a, b) => { + const aVisited = existed.has(a.displayName); + const bVisited = existed.has(b.displayName); + + //--------------------------------- + // Ưu tiên chuyên khoa đã khám + //--------------------------------- + + if (aVisited !== bVisited) { + return aVisited ? -1 : 1; + } + + //--------------------------------- + // Sau đó theo SPECIALTY_ORDER + //--------------------------------- + + const orderA = SPECIALTY_ORDER.findIndex( + (x) => normalize(x) === normalize(a.displayName), + ); + + const orderB = SPECIALTY_ORDER.findIndex( + (x) => normalize(x) === normalize(b.displayName), + ); + + if (orderA === -1 && orderB === -1) { + return a.displayName.localeCompare(b.displayName); + } + + if (orderA === -1) return 1; + + if (orderB === -1) return -1; + + return orderA - orderB; + }); + + return [ + { + pathname: "/consultation", + query: "all", + title: "Tất cả", + }, + + ...specialties.map((item) => ({ + pathname: "/consultation", + query: item.id, + title: item.displayName, + })), + ]; + }, [specialtyQuery.data, consultationItems]); + + return { + tabs, + loading: specialtyQuery.isLoading, + }; +} diff --git a/src/services/consultationServices.ts b/src/services/consultationServices.ts index 120cd63..e4ceec6 100644 --- a/src/services/consultationServices.ts +++ b/src/services/consultationServices.ts @@ -45,6 +45,7 @@ export interface ConsultationItem { instructions: string; }[]; }[]; + doctors: string[] | null; aggregatedPrescriptionItems: { id: string; prescriptionId: string; diff --git a/src/services/prescriptionServices.ts b/src/services/prescriptionServices.ts index c970a98..c3c0b85 100644 --- a/src/services/prescriptionServices.ts +++ b/src/services/prescriptionServices.ts @@ -33,13 +33,16 @@ export interface PrescriptionDetail { prescriptionImg: string; notes: string; createdBy: string; + patientId: string; + patientCode: string; + patientName: string; items: { id: string; prescriptionId: string; medicineName: string; dosage: string; frequency: string; - duration: string; + quantity: string; instructions: string; }[]; }