diff --git a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts index 2969d2ddb93..b1211bddb6e 100644 --- a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts +++ b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts @@ -368,6 +368,11 @@ describe("Patient Consultation in multiple combination", () => { cy.clickSubmitButton("Create Consultation"); // Create a shifting request cy.closeNotification(); + // cy.clickSubmitButton("Shift Patient"); + cy.get("#shift_create_button", { timeout: 10000 }) + .should("be.visible") + .click(); + shiftCreation.typeCurrentFacilityPerson("Current Facility Person"); shiftCreation.typeCurrentFacilityPhone("9999999999"); shiftCreation.typeShiftReason("reason for shift"); diff --git a/package-lock.json b/package-lock.json index fa8c7e1aa72..7388e76ecc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,8 +17,10 @@ "@googlemaps/typescript-guards": "^2.0.3", "@headlessui/react": "^2.2.0", "@hello-pangea/dnd": "^17.0.0", + "@hookform/resolvers": "^3.9.1", "@pnotify/core": "^5.2.0", "@pnotify/mobile": "^5.2.0", + "@radix-ui/react-checkbox": "^1.1.3", "@radix-ui/react-dialog": "^1.1.4", "@radix-ui/react-dropdown-menu": "^2.1.4", "@radix-ui/react-icons": "^1.3.2", @@ -56,6 +58,7 @@ "react-copy-to-clipboard": "^5.1.0", "react-dom": "18.3.1", "react-google-recaptcha": "^3.1.0", + "react-hook-form": "^7.54.2", "react-i18next": "^15.2.0", "react-infinite-scroll-component": "^6.1.0", "react-pdf": "^9.2.1", @@ -2646,6 +2649,14 @@ "react-dom": "^18.0.0" } }, + "node_modules/@hookform/resolvers": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-3.9.1.tgz", + "integrity": "sha512-ud2HqmGBM0P0IABqoskKWI6PEf6ZDDBZkFqe2Vnl+mTHCEHzr3ISjjZyCwTjC/qpL25JC9aIDkloQejvMeq0ug==", + "peerDependencies": { + "react-hook-form": "^7.0.0" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.13.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", @@ -3671,6 +3682,99 @@ } } }, + "node_modules/@radix-ui/react-checkbox": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.1.3.tgz", + "integrity": "sha512-HD7/ocp8f1B3e6OHygH0n7ZKjONkhciy1Nh0yuBgObqThc3oyx+vuMfFHKAknXRHHWVE9XvXStxJFyjUmB8PIw==", + "dependencies": { + "@radix-ui/primitive": "1.1.1", + "@radix-ui/react-compose-refs": "1.1.1", + "@radix-ui/react-context": "1.1.1", + "@radix-ui/react-presence": "1.1.2", + "@radix-ui/react-primitive": "2.0.1", + "@radix-ui/react-use-controllable-state": "1.1.0", + "@radix-ui/react-use-previous": "1.1.0", + "@radix-ui/react-use-size": "1.1.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/primitive": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.1.tgz", + "integrity": "sha512-SJ31y+Q/zAyShtXJc8x83i9TYdbAfHZ++tUZnvjJJqFjzsdUnKsxPL6IEtBlxKkU7yzer//GQtZSV4GbldL3YA==" + }, + "node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-compose-refs": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.1.tgz", + "integrity": "sha512-Y9VzoRDSJtgFMUCoiZBDVo084VQ5hfpXxVE+NgkdNsjiDBByiImMZKKhxMwCbdHvhlENG6a833CbFkOQvTricw==", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-presence": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@radix-ui/react-presence/-/react-presence-1.1.2.tgz", + "integrity": "sha512-18TFr80t5EVgL9x1SwF/YGtfG+l0BS0PRAlCWBDoBEiDQjeKgnNZRVJp/oVBl24sr3Gbfwc/Qpj4OcWTQMsAEg==", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.1", + "@radix-ui/react-use-layout-effect": "1.1.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-primitive": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.0.1.tgz", + "integrity": "sha512-sHCWTtxwNn3L3fH8qAfnF3WbUZycW93SM1j3NFDzXBiz8D6F5UTTy8G1+WFEaiCdvCVRJWj6N2R4Xq6HdiHmDg==", + "dependencies": { + "@radix-ui/react-slot": "1.1.1" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-compose-refs": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.0.tgz", @@ -4996,6 +5100,20 @@ } } }, + "node_modules/@radix-ui/react-use-previous": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-previous/-/react-use-previous-1.1.0.tgz", + "integrity": "sha512-Z/e78qg2YFnnXcW88A4JmTtm4ADckLno6F7OXotmkQfeuCVaKuYzqAATPhVzl3delXE7CxIV8shofPn3jPc5Og==", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-use-rect": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.0.tgz", @@ -16660,6 +16778,21 @@ "react": ">=16.4.1" } }, + "node_modules/react-hook-form": { + "version": "7.54.2", + "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.54.2.tgz", + "integrity": "sha512-eHpAUgUjWbZocoQYUHposymRb4ZP6d0uwUnooL2uOybA9/3tPUvoAKqEWK1WaSiTxxOfTpffNZP7QwlnM3/gEg==", + "engines": { + "node": ">=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/react-hook-form" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17 || ^18 || ^19" + } + }, "node_modules/react-i18next": { "version": "15.2.0", "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-15.2.0.tgz", diff --git a/package.json b/package.json index b768b4893aa..a64ebcca019 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,10 @@ "@googlemaps/typescript-guards": "^2.0.3", "@headlessui/react": "^2.2.0", "@hello-pangea/dnd": "^17.0.0", + "@hookform/resolvers": "^3.9.1", "@pnotify/core": "^5.2.0", "@pnotify/mobile": "^5.2.0", + "@radix-ui/react-checkbox": "^1.1.3", "@radix-ui/react-dialog": "^1.1.4", "@radix-ui/react-dropdown-menu": "^2.1.4", "@radix-ui/react-icons": "^1.3.2", @@ -95,6 +97,7 @@ "react-copy-to-clipboard": "^5.1.0", "react-dom": "18.3.1", "react-google-recaptcha": "^3.1.0", + "react-hook-form": "^7.54.2", "react-i18next": "^15.2.0", "react-infinite-scroll-component": "^6.1.0", "react-pdf": "^9.2.1", diff --git a/public/locale/en.json b/public/locale/en.json index 758ef1965db..1c8b13a5afc 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -320,6 +320,7 @@ "allow_transfer": "Allow Transfer", "allowed_formats_are": "Allowed formats are", "already_a_member": "Already a member?", + "ambulance_details": "Ambulance Details", "ambulance_driver_name": "Name of ambulance driver", "ambulance_number": "Ambulance No", "ambulance_phone_number": "Phone number of Ambulance", @@ -575,6 +576,7 @@ "csv_file_in_the_specified_format": "Select a CSV file in the specified format", "current_address": "Current Address", "current_password": "Current Password", + "current_shifting": "Current Shifting", "customer_support_email": "Customer Support Email", "customer_support_name": "Customer Support Name", "customer_support_number": "Customer support number", @@ -773,6 +775,7 @@ "forget_password": "Forgot password?", "forget_password_instruction": "Enter your username, and if it exists, we will send you a link to reset your password.", "frequency": "Frequency", + "from": "From", "from_user": "from User", "full_name": "Full Name", "full_screen": "Full Screen", @@ -1005,6 +1008,7 @@ "no_beds_available": "No beds available", "no_changes": "No changes", "no_changes_made": "No changes made", + "no_comments_available": "No comments available", "no_consultation_filed": "No consultation filed", "no_consultation_history": "No consultation history available", "no_consultation_updates": "No consultation updates", @@ -1196,6 +1200,7 @@ "preset_name_placeholder": "Specify an identifiable name for the new preset", "preset_updated": "Preset updated", "prev_sessions": "Prev Sessions", + "previous_shifting": "Previous Shifting", "principal": "Principal", "principal_diagnosis": "Principal diagnosis", "print": "Print", @@ -1413,6 +1418,7 @@ "third_party_software_licenses": "Third Party Software Licenses", "title_of_request": "Title of Request", "titrate_dosage": "Titrate Dosage", + "to": "To", "to_be_conducted": "To be conducted", "total_amount": "Total Amount", "total_beds": "Total Beds", diff --git a/src/CAREUI/interactive/SlideOver.tsx b/src/CAREUI/interactive/SlideOver.tsx index d979be77f99..71a5913a108 100644 --- a/src/CAREUI/interactive/SlideOver.tsx +++ b/src/CAREUI/interactive/SlideOver.tsx @@ -98,7 +98,7 @@ export default function SlideOver({ className={classNames( "pointer-events-auto fixed", directionClasses[slideFrom].stick, - !onlyChild && "md:p-2", + !onlyChild && "md:p-2 ", )} > {onlyChild ? ( @@ -106,7 +106,7 @@ export default function SlideOver({ ) : (
{children} diff --git a/src/CAREUI/misc/PrintPreview.tsx b/src/CAREUI/misc/PrintPreview.tsx index daf79ecbb34..0f027f8ee4d 100644 --- a/src/CAREUI/misc/PrintPreview.tsx +++ b/src/CAREUI/misc/PrintPreview.tsx @@ -29,7 +29,7 @@ export default function PrintPreview(props: Props) { return ( -
+
+ +
+ - navigate(`/facility/${facilityId}/patient/${id}/shift/new`) - } + onClick={() => setIsSlideOverOpen(true)} authorizeFor={NonReadOnlyUsers} > {t("shift")} - + +
- + +
- -
{" "} + +
); }; diff --git a/src/components/Patient/PatientDetailsTab/index.tsx b/src/components/Patient/PatientDetailsTab/index.tsx index 55c292438ca..354c4cf13af 100644 --- a/src/components/Patient/PatientDetailsTab/index.tsx +++ b/src/components/Patient/PatientDetailsTab/index.tsx @@ -31,7 +31,7 @@ export const patientTabs = [ component: ImmunisationRecords, }, { - route: "shift", + route: "shifting", component: ShiftingHistory, }, { diff --git a/src/components/Patient/ShiftCreate.tsx b/src/components/Patient/ShiftCreate.tsx index 2190cbefac4..15c9df321f9 100644 --- a/src/components/Patient/ShiftCreate.tsx +++ b/src/components/Patient/ShiftCreate.tsx @@ -1,14 +1,15 @@ import careConfig from "@careConfig"; +import { useQuery } from "@tanstack/react-query"; import { navigate } from "raviger"; -import { useReducer, useState } from "react"; +import { useEffect, useReducer, useState } from "react"; import { useTranslation } from "react-i18next"; -import Card from "@/CAREUI/display/Card"; +import SlideOver from "@/CAREUI/interactive/SlideOver"; + +import { Button } from "@/components/ui/button"; -import { Cancel, Submit } from "@/components/Common/ButtonV2"; import { FacilitySelect } from "@/components/Common/FacilitySelect"; import Loading from "@/components/Common/Loading"; -import Page from "@/components/Common/Page"; import { PhoneNumberValidator } from "@/components/Form/FieldValidators"; import CheckBoxFormField from "@/components/Form/FormFields/CheckBoxFormField"; import { FieldLabel } from "@/components/Form/FormFields/FormField"; @@ -31,18 +32,20 @@ import { phonePreg } from "@/common/validation"; import * as Notification from "@/Utils/Notifications"; import routes from "@/Utils/request/api"; +import query from "@/Utils/request/query"; import request from "@/Utils/request/request"; -import useTanStackQueryInstead from "@/Utils/request/useQuery"; import { parsePhoneNumber } from "@/Utils/utils"; interface patientShiftProps { facilityId: string; patientId: string; + open: boolean; + setOpen: (state: boolean) => void; } export const ShiftCreate = (props: patientShiftProps) => { const { goBack } = useAppHistory(); - const { facilityId, patientId } = props; + const { patientId } = props; const [isLoading, setIsLoading] = useState(false); const [patientCategory, setPatientCategory] = useState(); const { t } = useTranslation(); @@ -108,23 +111,28 @@ export const ShiftCreate = (props: patientShiftProps) => { errors: { ...initError }, }; - const { data: patientData } = useTanStackQueryInstead(routes.getPatient, { - pathParams: { - id: patientId, - }, - prefetch: !!patientId, - onResponse: ({ data }) => { - if (data) { - const patient_category = - data.last_consultation?.last_daily_round?.patient_category ?? - data.last_consultation?.category; - setPatientCategory( - PATIENT_CATEGORIES.find((c) => c.text === patient_category)?.id, - ); - } - }, + const { data: patientData } = useQuery({ + queryKey: ["getPatient", patientId], + queryFn: query(routes.getPatient, { + pathParams: { id: patientId }, + }), + enabled: !!patientId, }); + useEffect(() => { + if (patientData) { + const patient_category = + patientData.last_consultation?.last_daily_round?.patient_category ?? + patientData.last_consultation?.category; + + const matchedCategory = PATIENT_CATEGORIES.find( + (c) => c.text === patient_category, + )?.id; + + setPatientCategory(matchedCategory); + } + }, [patientData]); + const shiftFormReducer = (state = initialState, action: any) => { switch (action.type) { case "set_form": { @@ -261,142 +269,142 @@ export const ShiftCreate = (props: patientShiftProps) => { }); return ( - - - - - - - {careConfig.wartimeShifting && ( -
- - Name of shifting approving facility - +
+
+ + + {careConfig.wartimeShifting && ( +
+ + Name of shifting approving facility + + + handleFormFieldChange({ + name: "shifting_approving_facility", + value, + }) + } + errors={state.errors.shifting_approving_facility} + /> +
+ )} +
+ {t("what_facility_assign_the_patient_to")} handleFormFieldChange({ - name: "shifting_approving_facility", + name: "assigned_facility", value, }) } - errors={state.errors.shifting_approving_facility} + freeText={true} + errors={state.errors.assigned_facility} />
- )} - -
- {t("what_facility_assign_the_patient_to")} - - handleFormFieldChange({ name: "assigned_facility", value }) - } - freeText={true} - errors={state.errors.assigned_facility} - /> -
- - - - - setPatientCategory(e.value)} - label="Patient Category" - /> - - {careConfig.wartimeShifting && ( - <> - option.text} - optionValue={(option) => option.text} - /> - option.text} - optionValue={(option) => option.text} + + + setPatientCategory(e.value)} + label="Patient Category" + /> + {careConfig.wartimeShifting && ( + <> + option.text} + optionValue={(option) => option.text} + /> + option.text} + optionValue={(option) => option.text} + /> + option} + optionValue={(option) => option} + /> + + )} + + + + +
+ - option} - optionValue={(option) => option} + rows={5} + placeholder="Type your reason here" /> - - )} - - - - - - - - - - +
+
- goBack()} /> - + +
- - +
+ ); }; diff --git a/src/components/Patient/ShiftCreate1.tsx b/src/components/Patient/ShiftCreate1.tsx new file mode 100644 index 00000000000..fb7d0776f98 --- /dev/null +++ b/src/components/Patient/ShiftCreate1.tsx @@ -0,0 +1,540 @@ +import careConfig from "@careConfig"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useQuery } from "@tanstack/react-query"; +import { useEffect, useState } from "react"; +import { useForm } from "react-hook-form"; +import { useTranslation } from "react-i18next"; +import * as z from "zod"; + +import SlideOver from "@/CAREUI/interactive/SlideOver"; + +import { Button } from "@/components/ui/button"; +import { Checkbox } from "@/components/ui/checkbox"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { Textarea } from "@/components/ui/textarea"; + +import { FacilitySelect } from "@/components/Common/FacilitySelect"; +import Loading from "@/components/Common/Loading"; +import PhoneNumberFormField from "@/components/Form/FormFields/PhoneNumberFormField"; +import { SelectFormField } from "@/components/Form/FormFields/SelectFormField"; +import PatientCategorySelect from "@/components/Patient/PatientCategorySelect"; + +import useAppHistory from "@/hooks/useAppHistory"; + +import { + BREATHLESSNESS_LEVEL, + FACILITY_TYPES, + PATIENT_CATEGORIES, + SHIFTING_VEHICLE_CHOICES, +} from "@/common/constants"; + +// import { phonePreg } from "@/common/validation"; +import * as Notification from "@/Utils/Notifications"; +import routes from "@/Utils/request/api"; +import query from "@/Utils/request/query"; +import request from "@/Utils/request/request"; +import { parsePhoneNumber } from "@/Utils/utils"; + +interface patientShiftProps { + facilityId: string; + patientId: string; + open: boolean; + setOpen: (state: boolean) => void; +} + +export const ShiftCreate = (props: patientShiftProps) => { + const { goBack } = useAppHistory(); + const { patientId } = props; + const [isLoading, setIsLoading] = useState(false); + // const [phoneNumber, setPhoneNumber] = useState("+91"); + const [patientCategory, setPatientCategory] = useState(); + const { t } = useTranslation(); + + const shiftSchema = z.object({ + shifting_approving_facility: z + .object({ + id: z.string().optional(), + name: z.string().optional(), + }) + .nullable(), + assigned_facility: z + .object({ + id: z.string().optional(), + name: z.string().optional(), + }) + .nullable(), + emergency: z.enum(["true", "false"]), + is_up_shift: z.enum(["true", "false"]), + reason: z + .string() + .min(1, "Reason for shifting is mandatory") + .refine((value) => value.trim().length > 0, { + message: "Please enter a reason for shifting", + }), + vehicle_preference: z.string().optional(), + comments: z.string().optional(), + refering_facility_contact_name: z + .string() + .min(1, "Name of contact of the current facility"), + refering_facility_contact_number: z + .string() + .regex(/^[0-9]{10}$/, "Please enter a valid phone number"), + assigned_facility_type: z.string().optional(), + preferred_vehicle_choice: z.string().optional(), + breathlessness_level: z.string().optional(), + patient_category: z.string().optional(), + ambulance_driver_name: z.string().optional(), + ambulance_phone_number: z + .string() + .regex(/^[0-9]{10}$/, "Please enter a valid phone number") + .optional(), + ambulance_number: z.string().optional(), + }); + + type ShiftFormData = z.infer; + const formResolver = zodResolver(shiftSchema); + + const initForm: ShiftFormData = { + shifting_approving_facility: null, + assigned_facility: null, + emergency: "false", + is_up_shift: "true", + reason: "", + vehicle_preference: "", + comments: "", + refering_facility_contact_name: "", + refering_facility_contact_number: "", + assigned_facility_type: "", + preferred_vehicle_choice: "", + breathlessness_level: "", + patient_category: "", + ambulance_driver_name: "", + ambulance_phone_number: "", + ambulance_number: "", + }; + + const form = useForm({ + resolver: formResolver, + defaultValues: initForm, + }); + + const { data: patientData } = useQuery({ + queryKey: ["getPatient", patientId], + queryFn: query(routes.getPatient, { + pathParams: { id: patientId }, + }), + enabled: !!patientId, + }); + + useEffect(() => { + if (patientData) { + const patient_category = + patientData.last_consultation?.last_daily_round?.patient_category ?? + patientData.last_consultation?.category; + + const matchedCategory = PATIENT_CATEGORIES.find( + (c) => c.text === patient_category, + )?.id; + + setPatientCategory(matchedCategory); + } + }, [patientData]); + + const handleSubmit = async (data: ShiftFormData) => { + setIsLoading(true); + + const payload = { + ...data, + status: careConfig.wartimeShifting ? "PENDING" : "APPROVED", + origin_facility: props.facilityId, + shifting_approving_facility: + data.shifting_approving_facility?.id || undefined, + assigned_facility: data?.assigned_facility?.id || undefined, + assigned_facility_external: !data?.assigned_facility?.id + ? data?.assigned_facility?.name || undefined + : undefined, + patient: props.patientId, + emergency: data.emergency === "true", + is_up_shift: data.is_up_shift === "true", + reason: data.reason, + vehicle_preference: data.vehicle_preference, + comments: data.comments, + assigned_facility_type: data.assigned_facility_type || undefined, + preferred_vehicle_choice: data.preferred_vehicle_choice || undefined, + refering_facility_contact_name: data.refering_facility_contact_name, + refering_facility_contact_number: parsePhoneNumber( + data.refering_facility_contact_number, + ), + breathlessness_level: data.breathlessness_level, + patient_category: patientCategory, + ambulance_driver_name: data.ambulance_driver_name, + ambulance_phone_number: parsePhoneNumber( + data.ambulance_phone_number || "", + ), + ambulance_number: data.ambulance_number, + }; + + await request(routes.createShift, { + body: payload, + onResponse: ({ res, data }) => { + setIsLoading(false); + if (res?.ok && data) { + form.reset(); + Notification.Success({ msg: "Shift request created successfully" }); + goBack(`/shifting/${data.id}`); + } + }, + }); + }; + + if (isLoading) { + return ; + } + + return ( + +
+ +
+
+ ( + + + {t("Name of Contact person at the current facility")} + + + + + + + )} + /> + + ( + + + {t("Contact Number of Referring Facility")} + + + field.onChange(newValue)} + required + types={["mobile", "landline"]} + placeholder={t("Enter Contact Number")} + name={field.name} + /> + + + + )} + /> + {careConfig.wartimeShifting && ( +
+ ( + + + {t("Name of shifting approving facility")} + + + field.onChange(value)} + placeholder={t("Select a facility")} + /> + + + + )} + /> +
+ )} +
+ ( + + + {t("what_facility_assign_the_patient_to")} + + + field.onChange(value)} + freeText={true} + placeholder={t("Select a facility")} + /> + + + + )} + /> +
+ + ( + + + + field.onChange(value ? "true" : "false") + } + /> + +
+ This is an emergency +
+
+ )} + /> + ( + + + + field.onChange(value ? "true" : "false") + } + /> + +
+ This is an upshift +
+
+ )} + /> + + ( + + {t("Patient Category")} + + setPatientCategory(e.value)} + label={t("Patient Category")} + /> + + + + )} + /> + + {careConfig.wartimeShifting && ( + <> + ( + + {t("Preferred Vehicle")} + + option.text} + optionValue={(option) => option.text} + /> + + + + )} + /> + + ( + + {t("Preferred Facility Type")} + + option.text} + optionValue={(option) => option.text} + /> + + + + )} + /> + + ( + + {t("Severity of Breathlessness")} + + option} + optionValue={(option) => option} + /> + + + + )} + /> + + )} + + ( + + Name of ambulance driver + + + + + + )} + /> + {/* */} + ( + + {t("Ambulance Phone Number")} + + + + + + )} + /> + ( + + Ambulance No. + + + + + + )} + /> +
+ ( + + Any other comments + +