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

Encounter Qustions dropdown values moved to constants and i18 applied for all strings #9859

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
"administered_on": "Administered on",
"administration_dosage_range_error": "Dosage should be between start and target dosage",
"administration_notes": "Administration Notes",
"admit_source": "Admit Source",
"admitted": "Admitted",
"admitted_on": "Admitted On",
"advanced_filters": "Advanced Filters",
Expand Down Expand Up @@ -759,11 +760,13 @@
"diagnosis_at_discharge": "Diagnosis at Discharge",
"diastolic": "Diastolic",
"didnt_receive_a_message": "Didn't receive a message?",
"diet_preference": "Diet Preference",
"differential": "Differential",
"differential_diagnosis": "Differential diagnosis",
"disable_transfer": "Disable Transfer",
"discard": "Discard",
"discharge": "Discharge",
"discharge_disposition": "Discharge Disposition",
"discharge_from_care": "Discharge from CARE",
"discharge_prescription": "Discharge Prescription",
"discharge_summary": "Discharge Summary",
Expand Down Expand Up @@ -926,6 +929,7 @@
"encounter_priority__timing_critical": "Timing critical",
"encounter_priority__urgent": "Urgent",
"encounter_priority__use_as_directed": "Use as directed",
"encounter_status": "Encounter Status",
"encounter_status__cancelled": "Cancelled",
"encounter_status__completed": "Completed",
"encounter_status__discharged": "Discharged",
Expand Down Expand Up @@ -1119,6 +1123,8 @@
"home_facility_cleared_success": "Home Facility cleared successfully",
"home_facility_updated_error": "Error while updating Home Facility",
"home_facility_updated_success": "Home Facility updated successfully",
"hospital_identifier": "Hospital Identifier",
"hospitalization_details": "Hospitalization Details",
"hubs": "Hub Facilities",
"i_declare": "I hereby declare that:",
"icd11_as_recommended": "As per ICD-11 recommended by WHO",
Expand Down Expand Up @@ -1178,6 +1184,7 @@
"investigations_suggested": "Investigations Suggested",
"investigations_summary": "Investigations Summary",
"ip_encounter": "IP Encounter",
"ip_op_obs_emr_number": "Ip/op/obs/emr number",
"is": "Is",
"is_antenatal": "Is Antenatal",
"is_atypical_presentation": "Is Atypical presentation",
Expand Down Expand Up @@ -1240,6 +1247,7 @@
"live_patients_total_beds": "Live Patients / Total beds",
"load_more": "Load More",
"loading": "Loading...",
"loading_encounter": "Loading encounter...",
"local_body": "Local body",
"local_ip_address": "Local IP Address",
"local_ip_address_example": "e.g. 192.168.0.123",
Expand Down Expand Up @@ -1665,6 +1673,7 @@
"ration_card__BPL": "BPL",
"ration_card__NO_CARD": "Non-card holder",
"ration_card_category": "Ration Card Category",
"readmission": "Re-admission",
"reason": "Reason",
"reason_for_discontinuation": "Reason for discontinuation",
"reason_for_edit": "Reason for edit",
Expand Down Expand Up @@ -1829,11 +1838,15 @@
"see_attachments": "See Attachments",
"select": "Select",
"select_additional_instructions": "Select additional instructions",
"select_admit_source": "Select Admit Source",
"select_all": "Select All",
"select_category": "Select a category",
"select_class": "Select Class",
"select_date": "Select date",
"select_department": "Select Department",
"select_diff_role": "Please select a different role",
"select_diet_preference": "Select diet preference",
"select_discharge_disposition": "Select discharge disposition",
"select_eligible_policy": "Select an Eligible Insurance Policy",
"select_facility": "Select Facility",
"select_facility_description": "Select the healthcare facility that will provide the requested resource.",
Expand All @@ -1857,12 +1870,14 @@
"select_practitioner": "Select Practitioner",
"select_previous": "Select Previous Fields",
"select_prn_reason": "Select reason for PRN",
"select_priority": "Select Priority",
"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_status": "Select Status",
"select_time": "Select time",
"select_time_slot": "Select time slot",
"select_user": "Select user",
Expand Down
144 changes: 64 additions & 80 deletions src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery } from "@tanstack/react-query";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
Expand All @@ -14,6 +15,12 @@ import {
import routes from "@/Utils/request/api";
import query from "@/Utils/request/query";
import {
ENCOUNTER_ADMIT_SOURCE,
ENCOUNTER_CLASS,
ENCOUNTER_DIET_PREFERENCE,
ENCOUNTER_DISCHARGE_DISPOSITION,
ENCOUNTER_PRIORITY,
ENCOUNTER_STATUS,
type EncounterAdmitSources,
type EncounterClass,
type EncounterDietPreference,
Expand Down Expand Up @@ -61,6 +68,7 @@ export function EncounterQuestion({
}),
enabled: !!encounterId,
});
const { t } = useTranslation();

const [encounter, setEncounter] = useState<EncounterEditRequest>({
status: "unknown" as EncounterStatus,
Expand Down Expand Up @@ -124,15 +132,15 @@ export function EncounterQuestion({
};

if (isLoading) {
return <div>Loading encounter...</div>;
return <div>{t("loading_encounter")}</div>;
}

return (
<div className="space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
{/* Basic Details */}
<div className="space-y-2">
<Label>Encounter Status</Label>
<Label>{t("encounter_status")}</Label>
<Select
value={encounter.status}
onValueChange={(value) =>
Expand All @@ -143,24 +151,20 @@ export function EncounterQuestion({
disabled={disabled}
>
<SelectTrigger>
<SelectValue placeholder="Select status" />
<SelectValue placeholder={t("select_status")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="planned">Planned</SelectItem>
<SelectItem value="in_progress">In Progress</SelectItem>
<SelectItem value="on_hold">On Hold</SelectItem>
<SelectItem value="discharged">Discharged</SelectItem>
<SelectItem value="completed">Completed</SelectItem>
<SelectItem value="cancelled">Cancelled</SelectItem>
<SelectItem value="discontinued">Discontinued</SelectItem>
<SelectItem value="entered_in_error">Entered in Error</SelectItem>
<SelectItem value="unknown">Unknown</SelectItem>
{ENCOUNTER_STATUS.map((encounterStatus) => (
<SelectItem key={encounterStatus} value={encounterStatus}>
{t(`encounter_status__${encounterStatus}`)}
</SelectItem>
))}
</SelectContent>
</Select>
</div>

<div className="space-y-2">
<Label>Encounter Class</Label>
<Label>{t("encounter_class")}</Label>
<Select
value={encounter.encounter_class}
onValueChange={(value) =>
Expand All @@ -171,21 +175,20 @@ export function EncounterQuestion({
disabled={disabled}
>
<SelectTrigger>
<SelectValue placeholder="Select class" />
<SelectValue placeholder={t("select_class")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="imp">Inpatient (IP)</SelectItem>
<SelectItem value="amb">Ambulatory (OP)</SelectItem>
<SelectItem value="obsenc">Observation Room</SelectItem>
<SelectItem value="emer">Emergency</SelectItem>
<SelectItem value="vr">Virtual</SelectItem>
<SelectItem value="hh">Home Health</SelectItem>
{ENCOUNTER_CLASS.map((encounterClass) => (
<SelectItem key={encounterClass} value={encounterClass}>
{t(`encounter_class__${encounterClass}`)}
</SelectItem>
))}
</SelectContent>
</Select>
</div>

<div className="space-y-2">
<Label>Priority</Label>
<Label>{t("priority")}</Label>
<Select
value={encounter.priority}
onValueChange={(value) =>
Expand All @@ -196,37 +199,27 @@ export function EncounterQuestion({
disabled={disabled}
>
<SelectTrigger>
<SelectValue placeholder="Select priority" />
<SelectValue placeholder={t("select_priority")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="ASAP">ASAP</SelectItem>
<SelectItem value="callback_results">Callback Results</SelectItem>
<SelectItem value="callback_for_scheduling">
Callback for Scheduling
</SelectItem>
<SelectItem value="elective">Elective</SelectItem>
<SelectItem value="emergency">Emergency</SelectItem>
<SelectItem value="preop">Pre-op</SelectItem>
<SelectItem value="as_needed">As Needed</SelectItem>
<SelectItem value="routine">Routine</SelectItem>
<SelectItem value="rush_reporting">Rush Reporting</SelectItem>
<SelectItem value="stat">Stat</SelectItem>
<SelectItem value="timing_critical">Timing Critical</SelectItem>
<SelectItem value="use_as_directed">Use as Directed</SelectItem>
<SelectItem value="urgent">Urgent</SelectItem>
{ENCOUNTER_PRIORITY.map((priority) => (
<SelectItem key={priority} value={priority}>
{t(`encounter_priority__${priority}`)}
</SelectItem>
))}
</SelectContent>
</Select>
</div>

<div className="space-y-2">
<Label>Hospital Identifier</Label>
<Label>{t("hospital_identifier")}</Label>
<Input
value={encounter.external_identifier || ""}
onChange={(e) =>
handleUpdateEncounter({ external_identifier: e.target.value })
}
disabled={disabled}
placeholder="Ip/op/obs/emr number"
placeholder={t("ip_op_obs_emr_number")}
/>
</div>
</div>
Expand All @@ -236,7 +229,7 @@ export function EncounterQuestion({
encounter.encounter_class === "emer") && (
<div className="col-span-2 border rounded-lg p-4 space-y-4">
<h3 className="text-lg font-semibold break-words">
Hospitalization Details
{t("hospitalization_details")}
</h3>

<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
Expand All @@ -260,11 +253,11 @@ export function EncounterQuestion({
}
disabled={disabled}
/>
<Label>Re-admission</Label>
<Label>{t("readmission")}</Label>
</div>

<div className="space-y-2">
<Label>Admit Source</Label>
<Label>{t("admit_source")}</Label>
<Select
value={encounter.hospitalization?.admit_source}
onValueChange={(value) =>
Expand All @@ -285,27 +278,22 @@ export function EncounterQuestion({
disabled={disabled}
>
<SelectTrigger>
<SelectValue placeholder="Select admit source" />
<SelectValue placeholder={t("select_admit_source")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="hosp_trans">Hospital Transfer</SelectItem>
<SelectItem value="emd">Emergency Department</SelectItem>
<SelectItem value="outp">Outpatient Department</SelectItem>
<SelectItem value="born">Born</SelectItem>
<SelectItem value="gp">General Practitioner</SelectItem>
<SelectItem value="mp">Medical Practitioner</SelectItem>
<SelectItem value="nursing">Nursing Home</SelectItem>
<SelectItem value="psych">Psychiatric Hospital</SelectItem>
<SelectItem value="rehab">Rehabilitation Facility</SelectItem>
<SelectItem value="other">Other</SelectItem>
{ENCOUNTER_ADMIT_SOURCE.map((admitSource) => (
<SelectItem key={admitSource} value={admitSource}>
{t(`encounter_admit_sources__${admitSource}`)}
</SelectItem>
))}
</SelectContent>
</Select>
</div>

{/* Show discharge disposition only when status is completed */}
{encounter.status === "completed" && (
<div className="space-y-2">
<Label>Discharge Disposition</Label>
<Label>{t("Discharge Disposition")}</Label>
<Select
value={encounter.hospitalization?.discharge_disposition}
onValueChange={(value) =>
Expand All @@ -326,31 +314,30 @@ export function EncounterQuestion({
disabled={disabled}
>
<SelectTrigger>
<SelectValue placeholder="Select discharge disposition" />
<SelectValue
placeholder={t("select_discharge_disposition")}
/>
</SelectTrigger>
<SelectContent>
<SelectItem value="home">Home</SelectItem>
<SelectItem value="alt_home">Alternate Home</SelectItem>
<SelectItem value="other_hcf">
Other Healthcare Facility
</SelectItem>
<SelectItem value="hosp">Hospice</SelectItem>
<SelectItem value="long">Long Term Care</SelectItem>
<SelectItem value="aadvice">Left Against Advice</SelectItem>
<SelectItem value="exp">Expired</SelectItem>
<SelectItem value="psy">Psychiatric Hospital</SelectItem>
<SelectItem value="rehab">Rehabilitation</SelectItem>
<SelectItem value="snf">
Skilled Nursing Facility
</SelectItem>
<SelectItem value="oth">Other</SelectItem>
{ENCOUNTER_DISCHARGE_DISPOSITION.map(
(dischargeDisposition) => (
<SelectItem
key={dischargeDisposition}
value={dischargeDisposition}
>
{t(
`encounter_discharge_disposition__${dischargeDisposition}`,
)}
</SelectItem>
),
)}
</SelectContent>
</Select>
</div>
)}

<div className="space-y-2">
<Label>Diet Preference</Label>
<Label>{t("diet_preference")}</Label>
<Select
value={encounter.hospitalization?.diet_preference}
onValueChange={(value) =>
Expand All @@ -371,17 +358,14 @@ export function EncounterQuestion({
disabled={disabled}
>
<SelectTrigger>
<SelectValue placeholder="Select diet preference" />
<SelectValue placeholder={t("select_diet_preference")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="vegetarian">Vegetarian</SelectItem>
<SelectItem value="diary_free">Dairy Free</SelectItem>
<SelectItem value="nut_free">Nut Free</SelectItem>
<SelectItem value="gluten_free">Gluten Free</SelectItem>
<SelectItem value="vegan">Vegan</SelectItem>
<SelectItem value="halal">Halal</SelectItem>
<SelectItem value="kosher">Kosher</SelectItem>
<SelectItem value="none">None</SelectItem>
{ENCOUNTER_DIET_PREFERENCE.map((dietPreference) => (
<SelectItem key={dietPreference} value={dietPreference}>
{t(`encounter_diet_preference__${dietPreference}`)}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
Expand Down
Loading
Loading