Skip to content

Commit

Permalink
Merge branch 'develop' into eslint_no_relative_path
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaJ2305 authored Jan 20, 2025
2 parents 56bafb2 + 02a0558 commit 7eae09e
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 157 deletions.
18 changes: 16 additions & 2 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,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 @@ -763,11 +764,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 @@ -931,6 +934,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 @@ -1130,6 +1134,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 @@ -1191,6 +1197,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 @@ -1253,6 +1260,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 @@ -1393,8 +1401,7 @@
"no_notices_for_you": "No notices for you.",
"no_observations": "No Observations",
"no_ongoing_medications": "No Ongoing Medications",
"no_organizations_found": "No organizations found",
"no_organizations_found_matching": "No organizations found matching {{searchQuery}}",
"no_organizations_found": "No Organizations Found",
"no_organizations_selected": "No organizations selected",
"no_patient_record_found": "No Patient Records Found",
"no_patient_record_text": "No existing records found with this phone number. Would you like to register a new patient?",
Expand Down Expand Up @@ -1683,6 +1690,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 @@ -1848,11 +1856,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 @@ -1877,12 +1889,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 @@ -15,6 +16,12 @@ import { Switch } from "@/components/ui/switch";
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 @@ -60,6 +67,7 @@ export function EncounterQuestion({
}),
enabled: !!encounterId,
});
const { t } = useTranslation();

const [encounter, setEncounter] = useState<EncounterEditRequest>({
status: "unknown" as EncounterStatus,
Expand Down Expand Up @@ -123,15 +131,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 @@ -142,24 +150,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 @@ -170,21 +174,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 @@ -195,37 +198,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 @@ -235,7 +228,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 @@ -259,11 +252,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 @@ -284,27 +277,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 @@ -325,31 +313,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 @@ -370,17 +357,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

0 comments on commit 7eae09e

Please sign in to comment.