Skip to content

Commit

Permalink
MultiValueSetField for Medication Request Instructions (#9996)
Browse files Browse the repository at this point in the history
  • Loading branch information
amjithtitus09 authored Jan 22, 2025
1 parent 2b215e2 commit c34d3ce
Show file tree
Hide file tree
Showing 13 changed files with 885 additions and 660 deletions.
9 changes: 9 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@
"enter_aadhaar_otp": "Enter OTP sent to the registered mobile with Aadhaar",
"enter_abha_address": "Enter ABHA Address",
"enter_any_id": "Enter any ID linked with your ABHA number",
"enter_dosage_instructions": "Enter Dosage Instructions",
"enter_file_name": "Enter File Name",
"enter_message": "Start typing...",
"enter_mobile_number": "Enter Mobile Number",
Expand Down Expand Up @@ -1161,6 +1162,7 @@
"insurance__policy_name": "Policy ID / Policy Name",
"insurance_details_detail": "Include details of all the Insurance Policies held by the Patient for smooth insurance processing",
"insurer_name_required": "Insurer Name is required",
"intended": "Intended",
"intent": "Intent",
"international_mobile": "International Mobile",
"invalid_asset_id_msg": "Oops! The asset ID you entered does not appear to be valid.",
Expand Down Expand Up @@ -1312,6 +1314,7 @@
"medical_council_registration_required": "Medical Council Registration is required",
"medical_records": "Medical Records",
"medical_worker": "Medical Worker",
"medication": "Medication",
"medication_taken_between": "Medication Taken Between",
"medicine": "Medicine",
"medicine_administration_history": "Medicine Administration History",
Expand Down Expand Up @@ -1445,6 +1448,8 @@
"noshow": "No-show",
"not_eligible": "Not Eligible",
"not_specified": "Not Specified",
"not_taken": "Not Taken",
"note": "Note",
"notes": "Notes",
"notes_placeholder": "Type your Notes",
"notice_board": "Notice Board",
Expand All @@ -1468,6 +1473,7 @@
"old_password": "Current Password",
"on": "on",
"on_emergency_basis": " on emergency basis",
"on_hold": "On Hold",
"ongoing_medications": "Ongoing Medications",
"only_indian_mobile_numbers_supported": "Currently only Indian numbers are supported",
"op_encounter": "OP Encounter",
Expand Down Expand Up @@ -1665,6 +1671,7 @@
"priority": "Priority",
"prn_prescription": "PRN Prescription",
"prn_prescriptions": "PRN Prescriptions",
"prn_reason": "PRN Reason",
"procedure_suggestions": "Procedure Suggestions",
"procedures_select_placeholder": "Select procedures to add details",
"professional_info": "Professional Information",
Expand Down Expand Up @@ -1720,6 +1727,7 @@
"register_patient": "Register Patient",
"reject": "Reject",
"rejected": "Rejected",
"related_person": "Related Person",
"reload": "Reload",
"remarks": "Remarks",
"remarks_placeholder": "Enter remarks",
Expand Down Expand Up @@ -1991,6 +1999,7 @@
"status": "Status",
"stop": "Stop",
"stop_recording": "Stop Recording",
"stopped": "Stopped",
"stream_stop_due_to_inativity": "The live feed will stop streaming due to inactivity",
"stream_stopped_due_to_inativity": "The live feed has stopped streaming due to inactivity",
"stream_uuid": "Stream UUID",
Expand Down
99 changes: 99 additions & 0 deletions src/components/Medicine/MedicationsTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { useTranslation } from "react-i18next";

import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";

import { reverseFrequencyOption } from "@/components/Questionnaire/QuestionTypes/MedicationRequestQuestion";

import {
MEDICATION_REQUEST_TIMING_OPTIONS,
MedicationRequestDosageInstruction,
MedicationRequestRead,
} from "@/types/emr/medicationRequest";

import { formatDosage, formatSig } from "./utils";

function getFrequencyDisplay(
timing?: MedicationRequestDosageInstruction["timing"],
) {
if (!timing) return undefined;
const code = reverseFrequencyOption(timing);
if (!code) return undefined;
return {
code,
meaning: MEDICATION_REQUEST_TIMING_OPTIONS[code].display,
};
}

interface MedicationsTableProps {
medications: MedicationRequestRead[];
}

export const MedicationsTable = ({ medications }: MedicationsTableProps) => {
const { t } = useTranslation();

if (!medications?.length) {
return (
<div className="flex h-[200px] items-center justify-center rounded-lg border-2 border-dashed p-4 text-muted-foreground">
{t("no_medications_found_for_this_encounter")}
</div>
);
}

return (
<div className="border rounded-lg overflow-hidden">
<Table>
<TableHeader>
<TableRow className="divide-x bg-gray-100">
<TableHead>{t("medicine")}</TableHead>
<TableHead>{t("dosage")}</TableHead>
<TableHead>{t("frequency")}</TableHead>
<TableHead>{t("duration")}</TableHead>
<TableHead>{t("instructions")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{medications.map((medication) => {
const instruction = medication.dosage_instruction[0];
const frequency = getFrequencyDisplay(instruction?.timing);
const dosage = formatDosage(instruction);
const duration = instruction?.timing?.repeat?.bounds_duration;
const remarks = formatSig(instruction);
const notes = medication.note;
return (
<TableRow key={medication.id} className="divide-x font-medium">
<TableCell className="py-2 px-3">
{medication.medication?.display}
</TableCell>
<TableCell className="py-2 px-3">{dosage}</TableCell>
<TableCell className="py-2 px-3">
{instruction?.as_needed_boolean
? `${t("as_needed_prn")} (${instruction?.as_needed_for?.display})`
: frequency?.meaning}
{instruction?.additional_instruction?.[0]?.display && (
<div className="text-sm text-gray-600">
{instruction.additional_instruction[0].display}
</div>
)}
</TableCell>
<TableCell className="py-2 px-3">
{duration ? `${duration.value} ${duration.unit}` : "-"}
</TableCell>
<TableCell className="py-2 px-3">
{remarks || "-"}
{notes ? ` (${t("note")}: ${notes})` : ""}
</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</div>
);
};
Loading

0 comments on commit c34d3ce

Please sign in to comment.