Skip to content

Commit

Permalink
Medication Request redesign (#9848)
Browse files Browse the repository at this point in the history
  • Loading branch information
amjithtitus09 authored Jan 11, 2025
1 parent 44a96a5 commit 0d64505
Show file tree
Hide file tree
Showing 9 changed files with 611 additions and 246 deletions.
32 changes: 32 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
"add_skill": "Add Skill",
"add_spoke": "Add Spoke Facility",
"additional_information": "Additional Information",
"additional_instructions": "Additional Instructions",
"address": "Address",
"administer": "Administer",
"administer_medicine": "Administer Medicine",
Expand Down Expand Up @@ -406,6 +407,7 @@
"are_you_sure_want_to_remove": "Are you sure you want to remove {{name}} from the patient? This action cannot be undone",
"ari": "ARI - Acute Respiratory illness",
"arrived": "Arrived",
"as_needed_prn": "As Needed / PRN",
"asset_class": "Asset Class",
"asset_location": "Asset Location",
"asset_name": "Asset Name",
Expand Down Expand Up @@ -1089,12 +1091,14 @@
"information_source_user": "Hospital Staff",
"inidcator_event": "Indicator Event",
"instruction_on_titration": "Instruction on titration",
"instructions": "Instructions",
"insurance__insurer_id": "Insurer ID",
"insurance__insurer_name": "Insurer Name",
"insurance__member_id": "Member ID",
"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",
"intent": "Intent",
"international_mobile": "International Mobile",
"invalid_asset_id_msg": "Oops! The asset ID you entered does not appear to be valid.",
"invalid_date_format": "Invalid date format, expected {{format}}",
Expand Down Expand Up @@ -1241,6 +1245,7 @@
"medicines_administered": "Medicine(s) administered",
"medicines_administered_error": "Error administering medicine(s)",
"member_id_required": "Member Id is required",
"method": "Method",
"middleware_hostname": "Middleware Hostname",
"middleware_hostname_example": "e.g. example.ohc.network",
"middleware_hostname_sourced_from": "Middleware hostname sourced from {{ source }}",
Expand Down Expand Up @@ -1623,6 +1628,8 @@
"remarks": "Remarks",
"remarks_placeholder": "Enter remarks",
"remove": "Remove",
"remove_medication": "Remove Medication",
"remove_medication_confirmation": "Are you sure you want to remove {{medication}}?",
"remove_user": "Remove User",
"remove_user_organization": "Remove User from Organization",
"remove_user_warn": "Are you sure you want to remove {{firstName}} {{lastName}} from this organization? This action cannot be undone.",
Expand Down Expand Up @@ -1737,6 +1744,7 @@
"search_icd11_placeholder": "Search for ICD-11 Diagnoses",
"search_investigation_placeholder": "Search Investigation & Groups",
"search_medication": "Search Medication",
"search_medications": "Search for medications to add",
"search_patient_page_text": "Search for existing patients using their phone number or create a new patient record",
"search_patients": "Search Patients",
"search_resource": "Search Resource",
Expand All @@ -1745,6 +1753,7 @@
"searching": "Searching...",
"see_attachments": "See Attachments",
"select": "Select",
"select_additional_instructions": "Select additional instructions",
"select_all": "Select All",
"select_date": "Select date",
"select_department": "Select Department",
Expand All @@ -1753,19 +1762,25 @@
"select_facility": "Select Facility",
"select_facility_for_discharged_patients_warning": "Facility needs to be selected to view discharged patients.",
"select_for_administration": "Select for Administration",
"select_frequency": "Select frequency",
"select_groups": "Select Groups",
"select_intent": "Select intent",
"select_investigation": "Select Investigations (all investigations will be selected by default)",
"select_investigation_groups": "Select Investigation Groups",
"select_investigations": "Select Investigations",
"select_local_body": "Select Local Body",
"select_method": "Select method",
"select_new_role": "Select New Role",
"select_patient": "Select Patient",
"select_policy": "Select an Insurance Policy",
"select_policy_to_add_items": "Select a Policy to Add Items",
"select_practitioner": "Select Practicioner",
"select_prn_reason": "Select reason for PRN",
"select_register_patient": "Select/Register Patient",
"select_role": "Select Role",
"select_route": "Select route",
"select_seven_day_period": "Select a seven day period",
"select_site": "Select site",
"select_skills": "Select and add some skills",
"select_time": "Select time",
"select_time_slot": "Select time slot",
Expand Down Expand Up @@ -1817,6 +1832,7 @@
"showing_all_appointments": "Showing all appointments",
"sign_in": "Sign in",
"sign_out": "Sign out",
"site": "Site",
"skill_add_error": "Error while adding skill",
"skill_added_successfully": "Skill added successfully",
"skills": "Skills",
Expand Down Expand Up @@ -1921,6 +1937,22 @@
"unassign": "Unassign",
"unconfirmed": "Unconfirmed",
"unique_id": "Unique Id",
"unit_a": "Years",
"unit_ampule(s)": "Ampule(s)",
"unit_d": "Days",
"unit_drop(s)": "Drop(s)",
"unit_g": "g",
"unit_h": "Hours",
"unit_mcg": "mcg",
"unit_mg": "mg",
"unit_min": "Minutes",
"unit_ml": "ml",
"unit_mo": "Months",
"unit_ms": "Milliseconds",
"unit_s": "Seconds",
"unit_tsp": "Tsp",
"unit_unit(s)": "Unit(s)",
"unit_wk": "Weeks",
"unknown": "Unknown",
"unlink_asset_bed_and_presets": "Delete linked presets and unlink bed",
"unlink_asset_bed_caution": "This action will also delete all presets that are associated to this camera and bed.",
Expand Down
7 changes: 6 additions & 1 deletion src/components/Common/QuantityInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { t } from "i18next";

import { Input } from "@/components/ui/input";
import {
Select,
Expand All @@ -18,6 +20,7 @@ interface Props<TUnit extends string> {
units: readonly TUnit[];
disabled?: boolean;
placeholder?: string;
autoFocus?: boolean;
}

const QuantityInput = <TUnit extends string>({
Expand All @@ -26,6 +29,7 @@ const QuantityInput = <TUnit extends string>({
onChange,
disabled,
placeholder,
autoFocus,
}: Props<TUnit>) => {
const handleChange = (update: Partial<QuantityValue<TUnit>>) => {
onChange({ ...quantity, ...update });
Expand All @@ -44,6 +48,7 @@ const QuantityInput = <TUnit extends string>({
value: e.target.value ? Number(e.target.value) : undefined,
})
}
autoFocus={autoFocus}
/>
<Select
disabled={disabled}
Expand All @@ -57,7 +62,7 @@ const QuantityInput = <TUnit extends string>({
<SelectContent>
{units.map((unit) => (
<SelectItem key={unit} value={unit}>
{unit}
{t(`unit_${unit}`)}
</SelectItem>
))}
</SelectContent>
Expand Down
9 changes: 9 additions & 0 deletions src/components/Medicine/MedicineAdministrationSheet/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { t } from "i18next";
import { Link } from "raviger";
import { useState } from "react";

Expand Down Expand Up @@ -324,6 +325,14 @@ const PrescriptionEntry = ({
</span>
)}
</div>
{instruction.timing?.repeat?.bounds_duration && (
<div className="mt-1 text-xs text-muted-foreground">
<span className="text-muted-foreground">{t("duration")}:</span>{" "}
{instruction.timing.repeat.bounds_duration.value}{" "}
{instruction.timing.repeat.bounds_duration.unit &&
t(`${instruction.timing.repeat.bounds_duration.unit}`)}
</div>
)}

{/* Additional Instructions */}
{additionalInstructions && additionalInstructions.length > 0 && (
Expand Down
20 changes: 19 additions & 1 deletion src/components/Questionnaire/QuestionRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { useEffect, useRef } from "react";

import { cn } from "@/lib/utils";

import { QuestionValidationError } from "@/types/questionnaire/batch";
import { QuestionnaireResponse } from "@/types/questionnaire/form";
import { Question } from "@/types/questionnaire/question";
import {
Question,
StructuredQuestionType,
} from "@/types/questionnaire/question";

import { QuestionGroup } from "./QuestionTypes/QuestionGroup";

// Questions that should be rendered full width
const FULL_WIDTH_QUESTION_TYPES: StructuredQuestionType[] = [
"medication_request",
];

interface QuestionRendererProps {
questions: Question[];
responses: QuestionnaireResponse[];
Expand Down Expand Up @@ -55,12 +65,20 @@ export function QuestionRenderer({
onResponseChange(newResponses);
};

const shouldBeFullWidth = (question: Question): boolean =>
question.type === "structured" &&
!!question.structured_type &&
FULL_WIDTH_QUESTION_TYPES.includes(question.structured_type);

return (
<div className="space-y-4">
{questions.map((question) => (
<div
key={question.id}
ref={(el) => (questionRefs.current[question.id] = el)}
className={cn(
shouldBeFullWidth(question) ? "md:w-auto" : "max-w-4xl",
)}
>
<QuestionGroup
facilityId={facilityId}
Expand Down
Loading

0 comments on commit 0d64505

Please sign in to comment.