From 837270c665cfa2e065984037bc2ced1a2aa350d9 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 2 Jan 2025 17:01:49 +0530 Subject: [PATCH 1/8] fix alignments --- src/components/Schedule/Appointments/AppointmentCreatePage.tsx | 2 +- src/components/Schedule/Appointments/AppointmentsPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Schedule/Appointments/AppointmentCreatePage.tsx b/src/components/Schedule/Appointments/AppointmentCreatePage.tsx index f7a75d3397e..fa5fc3538c3 100644 --- a/src/components/Schedule/Appointments/AppointmentCreatePage.tsx +++ b/src/components/Schedule/Appointments/AppointmentCreatePage.tsx @@ -328,7 +328,7 @@ export default function AppointmentCreatePage(props: Props) { slot.allocated === availability.tokens_per_slot } - className="flex flex-col items-center group" + className="flex flex-col items-center group gap-0" > {format(slot.start_datetime, "HH:mm")} diff --git a/src/components/Schedule/Appointments/AppointmentsPage.tsx b/src/components/Schedule/Appointments/AppointmentsPage.tsx index 770f0186bd0..562338f5311 100644 --- a/src/components/Schedule/Appointments/AppointmentsPage.tsx +++ b/src/components/Schedule/Appointments/AppointmentsPage.tsx @@ -385,7 +385,7 @@ function AppointmentColumn(props: { ) : ( -
    +
      {appointments.map((appointment) => (
    • Date: Thu, 2 Jan 2025 17:25:16 +0530 Subject: [PATCH 2/8] fix alignment --- src/components/Questionnaire/QuestionnaireForm.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/Questionnaire/QuestionnaireForm.tsx b/src/components/Questionnaire/QuestionnaireForm.tsx index bb11c82ee77..59854bab2fb 100644 --- a/src/components/Questionnaire/QuestionnaireForm.tsx +++ b/src/components/Questionnaire/QuestionnaireForm.tsx @@ -304,7 +304,7 @@ export function QuestionnaireForm({ key={`${form.questionnaire.id}-${index}`} className="border rounded-lg p-6 space-y-6" > -
      +

      {form.questionnaire.title} @@ -321,7 +321,6 @@ export function QuestionnaireForm({ type="button" variant="ghost" size="sm" - className="self-end" onClick={() => { setQuestionnaireForms((prev) => prev.filter( From ba8708303532621c4d6755f0688805521335f720 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 2 Jan 2025 19:12:56 +0530 Subject: [PATCH 3/8] appointment action checks, use same day check instead of is past --- .../Schedule/Appointments/AppointmentDetailsPage.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Schedule/Appointments/AppointmentDetailsPage.tsx b/src/components/Schedule/Appointments/AppointmentDetailsPage.tsx index 410f5ba7dee..634e2651720 100644 --- a/src/components/Schedule/Appointments/AppointmentDetailsPage.tsx +++ b/src/components/Schedule/Appointments/AppointmentDetailsPage.tsx @@ -11,7 +11,7 @@ import { PlusCircledIcon, } from "@radix-ui/react-icons"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { differenceInYears, format, isPast } from "date-fns"; +import { differenceInYears, format, isSameDay } from "date-fns"; import { useTranslation } from "react-i18next"; import { toast } from "sonner"; @@ -338,7 +338,7 @@ const AppointmentActions = ({ }: AppointmentActionsProps) => { const { t } = useTranslation(); const currentStatus = appointment.status; - const hasStarted = isPast(appointment.token_slot.start_datetime); + const isToday = isSameDay(appointment.token_slot.start_datetime, new Date()); if (["fulfilled", "cancelled", "entered_in_error"].includes(currentStatus)) { return null; @@ -369,7 +369,7 @@ const AppointmentActions = ({
      {currentStatus === "booked" && (
      -
      - {/* TODO: use navigator.share */} +
      +
      @@ -340,11 +350,13 @@ const AppointmentDetails = ({ interface AppointmentActionsProps { appointment: Appointment; onChange: (status: Appointment["status"]) => void; + onViewPatient: () => void; } const AppointmentActions = ({ appointment, onChange, + onViewPatient, }: AppointmentActionsProps) => { const { t } = useTranslation(); const currentStatus = appointment.status; @@ -378,15 +390,21 @@ const AppointmentActions = ({ return (
      {currentStatus === "booked" && ( - + <> + + + )} {["booked", "checked_in"].includes(currentStatus) && ( diff --git a/src/components/Schedule/types.ts b/src/components/Schedule/types.ts index 207a04bf6d9..c1ec5a671a1 100644 --- a/src/components/Schedule/types.ts +++ b/src/components/Schedule/types.ts @@ -105,4 +105,7 @@ export interface AvailabilityHeatmap { [date: string]: { total_slots: number; booked_slots: number }; } -export interface FollowUpAppointmentQuestionRequest {} +export interface FollowUpAppointmentQuestionRequest { + resource: UserBase["id"]; + reason_for_visit: string; +} From d4e7846808b030f5581bdeb33a2490e58cbfb592 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 2 Jan 2025 20:38:37 +0530 Subject: [PATCH 6/8] error free; but doesn't work --- public/locale/en.json | 3 + .../QuestionTypes/FollowUpVisitQuestion.tsx | 234 ++++++++++++++++++ .../Questionnaire/structured/handlers.ts | 5 + .../Appointments/AppointmentsPage.tsx | 25 +- src/components/Schedule/types.ts | 2 +- 5 files changed, 263 insertions(+), 6 deletions(-) create mode 100644 src/components/Questionnaire/QuestionTypes/FollowUpVisitQuestion.tsx diff --git a/public/locale/en.json b/public/locale/en.json index 2afefadec85..6d2d774c921 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -1588,6 +1588,8 @@ "select_register_patient": "Select/Register Patient", "select_seven_day_period": "Select a seven day period", "select_skills": "Select and add some skills", + "select_time": "Select time", + "select_time_slot": "Select time slot", "select_wards": "Select wards", "self_booked": "Self-booked", "send": "Send", @@ -1631,6 +1633,7 @@ "skill_add_error": "Error while adding skill", "skill_added_successfully": "Skill added successfully", "skills": "Skills", + "slots_left": "slots left", "social_profile": "Social Profile", "social_profile_detail": "Include occupation, ration card category, socioeconomic status, and domestic healthcare support for a complete profile.", "socioeconomic_status": "Socioeconomic status", diff --git a/src/components/Questionnaire/QuestionTypes/FollowUpVisitQuestion.tsx b/src/components/Questionnaire/QuestionTypes/FollowUpVisitQuestion.tsx new file mode 100644 index 00000000000..3131cc4a8ed --- /dev/null +++ b/src/components/Questionnaire/QuestionTypes/FollowUpVisitQuestion.tsx @@ -0,0 +1,234 @@ +import { useQuery } from "@tanstack/react-query"; +import { format } from "date-fns"; +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; + +import { DatePicker } from "@/components/ui/date-picker"; +import { Label } from "@/components/ui/label"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { Textarea } from "@/components/ui/textarea"; + +import { Avatar } from "@/components/Common/Avatar"; +import { groupSlotsByAvailability } from "@/components/Schedule/Appointments/utils"; +import { ScheduleAPIs } from "@/components/Schedule/api"; +import { FollowUpAppointmentQuestionRequest } from "@/components/Schedule/types"; + +import useSlug from "@/hooks/useSlug"; + +import query from "@/Utils/request/query"; +import { dateQueryString, formatDisplayName, formatName } from "@/Utils/utils"; +import { QuestionnaireResponse } from "@/types/questionnaire/form"; +import { Question } from "@/types/questionnaire/question"; +import { UserBase } from "@/types/user/user"; + +interface FollowUpVisitQuestionProps { + question: Question; + questionnaireResponse: QuestionnaireResponse; + updateQuestionnaireResponseCB: (response: QuestionnaireResponse) => void; + disabled?: boolean; +} + +export function FollowUpVisitQuestion({ + question, + questionnaireResponse, + updateQuestionnaireResponseCB, + disabled, +}: FollowUpVisitQuestionProps) { + const { t } = useTranslation(); + const [resource, setResource] = useState(); + const [selectedDate, setSelectedDate] = useState(); + + const value = + (questionnaireResponse.values?.[0] + ?.value as FollowUpAppointmentQuestionRequest) || {}; + + const handleUpdate = ( + updates: Partial, + ) => { + updateQuestionnaireResponseCB({ + ...questionnaireResponse, + values: [ + { + type: "follow_up_appointment", + value: { ...value, ...updates }, + }, + ], + }); + }; + + const facilityId = useSlug("facility"); + + const resourcesQuery = useQuery({ + queryKey: ["availableResources", facilityId], + queryFn: query(ScheduleAPIs.appointments.availableDoctors, { + pathParams: { facility_id: facilityId }, + }), + }); + + const slotsQuery = useQuery({ + queryKey: [ + "slots", + facilityId, + resource?.id, + dateQueryString(selectedDate), + ], + queryFn: query(ScheduleAPIs.slots.getSlotsForDay, { + pathParams: { facility_id: facilityId }, + body: { + resource: resource?.id, + day: dateQueryString(selectedDate), + }, + }), + enabled: !!resource && !!selectedDate, + }); + + return ( +
      + +
      +
      + +