Skip to content

Commit

Permalink
Merge branch 'replace-notification-with-toast' of https://github.com/…
Browse files Browse the repository at this point in the history
…Mahendar0701/care_fe into replace-notification-with-toast
  • Loading branch information
Mahendar0701 committed Jan 8, 2025
2 parents 4e309e5 + 58ae752 commit fb4ca67
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 34 deletions.
3 changes: 1 addition & 2 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
files:
- source: /public/locale/{{lang}}.json
- source: '/public/locale/{{lang}}.json'
translation: /public/locale/%two_letters_code%/%original_file_name%
bundles:
- 2

5 changes: 5 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
"all_changes_have_been_saved": "All changes have been saved",
"all_details": "All Details",
"all_patients": "All Patients",
"allergen": "Allergen",
"allergies": "Allergies",
"allow_transfer": "Allow Transfer",
"allowed_formats_are": "Allowed formats are",
Expand Down Expand Up @@ -650,6 +651,7 @@
"created_by": "Created By",
"created_date": "Created Date",
"created_on": "Created On",
"criticality": "Criticality",
"csv_file_in_the_specified_format": "Select a CSV file in the specified format",
"current_address": "Current Address",
"current_password": "Current Password",
Expand Down Expand Up @@ -829,6 +831,7 @@
"encounter_discharge_disposition__snf": "Skilled nursing facility",
"encounter_duration_confirmation": "The duration of this encounter would be",
"encounter_id": "Encounter ID",
"encounter_marked_as_complete": "Encounter Completed",
"encounter_notes__all_discussions": "All Discussions",
"encounter_notes__be_first_to_send": "Be the first to send a message",
"encounter_notes__choose_template": "Choose a template or enter a custom title",
Expand Down Expand Up @@ -901,6 +904,7 @@
"error_fetching_slots_data": "Error while fetching slots data",
"error_fetching_user_data": "Error while fetching user data",
"error_sending_otp": "Error while sending OTP, Please try again later",
"error_updating_encounter": "Error to Updating Encounter",
"error_verifying_otp": "Error while verifying OTP, Please request a new OTP",
"error_while_deleting_record": "Error while deleting record",
"escape": "Escape",
Expand Down Expand Up @@ -1173,6 +1177,7 @@
"manufacturer": "Manufacturer",
"map_acronym": "M.A.P.",
"mark_all_as_read": "Mark all as Read",
"mark_as_complete": "Mark as Complete",
"mark_as_fulfilled": "Mark as Fullfilled",
"mark_as_noshow": "Mark as no-show",
"mark_as_read": "Mark as Read",
Expand Down
48 changes: 24 additions & 24 deletions src/Routers/routes/ConsultationRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,6 @@ const consultationRoutes: AppRoutes = {
patientId={patientId}
/>
),
"/facility/:facilityId/patient/:patientId/consultation/:id/consent-records":
({ facilityId, patientId, id }) => (
<PatientConsentRecords
facilityId={facilityId}
patientId={patientId}
consultationId={id}
/>
),
"/facility/:facilityId/patient/:patientId/encounterId/:id/files/": ({
facilityId,
patientId,
id,
}) => (
<FileUploadPage
facilityId={facilityId}
patientId={patientId}
encounterId={id}
type="encounter"
/>
),
"/facility/:facilityId/patient/:patientId/questionnaire": ({
facilityId,
patientId,
Expand All @@ -80,10 +60,6 @@ const consultationRoutes: AppRoutes = {
patientId={patientId}
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire_response/:id":
({ patientId, id }) => (
<QuestionnaireResponseView responseId={id} patientId={patientId} />
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire/:slug":
({ facilityId, encounterId, slug, patientId }) => (
<EncounterQuestionnaire
Expand All @@ -93,6 +69,30 @@ const consultationRoutes: AppRoutes = {
patientId={patientId}
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire_response/:id":
({ patientId, id }) => (
<QuestionnaireResponseView responseId={id} patientId={patientId} />
),
"/facility/:facilityId/patient/:patientId/consultation/:id/consent-records":
({ facilityId, patientId, id }) => (
<PatientConsentRecords
facilityId={facilityId}
patientId={patientId}
consultationId={id}
/>
),
"/facility/:facilityId/patient/:patientId/encounterId/:id/files/": ({
facilityId,
patientId,
id,
}) => (
<FileUploadPage
facilityId={facilityId}
patientId={patientId}
encounterId={id}
type="encounter"
/>
),
};

export default consultationRoutes;
91 changes: 83 additions & 8 deletions src/components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import {
BedSingle,
Building,
Expand All @@ -9,8 +10,18 @@ import {
} from "lucide-react";
import { Link } from "raviger";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";

import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import {
Popover,
PopoverContent,
Expand All @@ -19,13 +30,29 @@ import {

import { Avatar } from "@/components/Common/Avatar";

import routes from "@/Utils/request/api";
import mutate from "@/Utils/request/mutate";
import { formatDateTime, formatPatientAge } from "@/Utils/utils";
import { Encounter, completedEncounterStatus } from "@/types/emr/encounter";
import { Patient } from "@/types/emr/newPatient";

import { Button } from "../ui/button";
import ManageEncounterOrganizations from "./ManageEncounterOrganizations";

const QUESTIONNAIRE_OPTIONS = [
{
slug: "encounter",
title: "Update Encounter",
},
{
slug: "community-nurse",
title: "Community Nurse Form",
},
{
slug: "recommend_discharge_v2",
title: "Recommend Discharge",
},
] as const;

export interface PatientInfoCardProps {
patient: Patient;
encounter: Encounter;
Expand All @@ -35,6 +62,36 @@ export interface PatientInfoCardProps {
export default function PatientInfoCard(props: PatientInfoCardProps) {
const { patient, encounter } = props;
const { t } = useTranslation();
const queryClient = useQueryClient();

const { mutate: updateEncounter } = useMutation({
mutationFn: mutate(routes.encounter.update, {
pathParams: { id: encounter.id },
}),
onSuccess: () => {
toast.success(t("encounter_marked_as_complete"));
queryClient.invalidateQueries({ queryKey: ["encounter", encounter.id] });
},
onError: () => {
toast.error(t("error_updating_encounter"));
},
});

const handleMarkAsComplete = () => {
updateEncounter({
...encounter,
status: "completed",
organizations: encounter.organizations.map((org) => org.id),
patient: encounter.patient.id,
encounter_class: encounter.encounter_class,
period: encounter.period,
hospitalization: encounter.hospitalization,
priority: encounter.priority,
external_identifier: encounter.external_identifier,
facility: encounter.facility.id,
});
};

return (
<>
<section className="flex flex-col lg:flex-row">
Expand Down Expand Up @@ -262,13 +319,31 @@ export default function PatientInfoCard(props: PatientInfoCardProps) {
>
{!completedEncounterStatus.includes(encounter.status) && (
<div className="flex w-full flex-col gap-3 lg:w-auto 2xl:flex-row">
<Button asChild variant="primary">
<Link
href={`/facility/${encounter.facility.id}/patient/${patient.id}/encounter/${encounter.id}/edit_encounter`}
>
Update Encounter
</Link>
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="primary">
{t("update")}
<ChevronDown className="ml-2 h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{QUESTIONNAIRE_OPTIONS.map((option) => (
<DropdownMenuItem key={option.slug} asChild>
<Link
href={`/facility/${encounter.facility.id}/patient/${patient.id}/encounter/${encounter.id}/questionnaire/${option.slug}`}
className="cursor-pointer text-gray-800"
>
{t(option.title)}
</Link>
</DropdownMenuItem>
))}
<DropdownMenuSeparator />
<DropdownMenuLabel>{t("actions")}</DropdownMenuLabel>
<DropdownMenuItem onClick={handleMarkAsComplete}>
{t("mark_as_complete")}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
)}
</div>
Expand Down

0 comments on commit fb4ca67

Please sign in to comment.