diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index cd99d169544..7a88c478bba 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -37,7 +37,27 @@ import { Mews } from "../Facility/Consultations/Mews.js"; import DischargeSummaryModal from "../Facility/DischargeSummaryModal.js"; import DischargeModal from "../Facility/DischargeModal.js"; import { useTranslation } from "react-i18next"; +import useQuery from "../../Utils/request/useQuery.js"; import FetchRecordsModal from "../ABDM/FetchRecordsModal.js"; +import { SkillModel } from "../Users/models.js"; + +const formatSkills = (arr: SkillModel[]) => { + const skills = arr.map((skill) => skill.skill_object.name); + + if (skills.length === 1) { + return skills[0]; + } + + if (skills.length === 2) { + return `${skills[0]} and ${skills[1]}`; + } + + if (skills.length === 3) { + return `${skills[0]}, ${skills[1]} and ${skills[2]}`; + } + + return `${skills[0]}, ${skills[1]} and ${skills.length - 2} other skills...`; +}; export default function PatientInfoCard(props: { patient: PatientModel; @@ -113,6 +133,12 @@ export default function PatientInfoCard(props: { return false; }; + const skillsQuery = useQuery(routes.userListSkill, { + pathParams: { + username: consultation?.treating_physician_object?.username ?? "", + }, + prefetch: !!consultation?.treating_physician_object?.username, + }); return ( <> @@ -450,7 +476,7 @@ export default function PatientInfoCard(props: { : null} {(consultation?.treating_physician_object || consultation?.deprecated_verified_by) && ( -