Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiValueSetField for Medication Request Instructions #9996

Merged
merged 15 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,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 @@ -1151,6 +1152,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 @@ -1300,6 +1302,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 @@ -1434,6 +1437,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 @@ -1457,6 +1462,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 @@ -1654,6 +1660,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 @@ -1708,6 +1715,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 @@ -1968,6 +1976,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
Loading