From 2a0eec61e7d4efb8fc49aa5b7c94c2b2c9ba9080 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Thu, 21 Dec 2023 11:02:23 +0530 Subject: [PATCH 1/2] Rename "Admission Date" to encounter specific labels (#6719) * Rename `admission_date` to `encounter_date` * Whitelabel fields * fix colaescing issue * fix minor bug * minor fix --- src/Common/constants.tsx | 5 +- src/Components/DeathReport/DeathReport.tsx | 4 +- src/Components/Facility/ConsultationCard.tsx | 4 +- .../Facility/ConsultationDetails/index.tsx | 12 +-- src/Components/Facility/ConsultationForm.tsx | 75 ++++++++++--------- src/Components/Facility/DischargeModal.tsx | 6 +- src/Components/Facility/TreatmentSummary.tsx | 2 +- src/Components/Facility/models.tsx | 5 +- src/Components/Patient/ManagePatients.tsx | 18 ++--- src/Components/Patient/PatientFilter.tsx | 30 ++++---- src/Components/Patient/PatientInfoCard.tsx | 8 +- src/Components/Shifting/ShiftDetails.tsx | 5 +- 12 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 069a39e1539..23c02e389f3 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -330,7 +330,10 @@ export const CONSULTATION_SUGGESTION = [ { id: "OP", text: "OP Consultation" }, { id: "DC", text: "Domiciliary Care" }, { id: "DD", text: "Declare Death" }, -]; +] as const; + +export type ConsultationSuggestionValue = + (typeof CONSULTATION_SUGGESTION)[number]["id"]; export const ADMITTED_TO = [ { id: "1", text: "Isolation" }, diff --git a/src/Components/DeathReport/DeathReport.tsx b/src/Components/DeathReport/DeathReport.tsx index 9908b4fa852..3901996e119 100644 --- a/src/Components/DeathReport/DeathReport.tsx +++ b/src/Components/DeathReport/DeathReport.tsx @@ -115,8 +115,8 @@ export default function PrintDeathReport(props: { id: string }) { date_declared_positive: res.data?.date_declared_positive ? dayjs(res.data?.date_declared_positive).toDate() : "", - date_of_admission: res.data?.last_consultation?.admission_date - ? dayjs(res.data?.last_consultation?.admission_date).toDate() + date_of_admission: res.data?.last_consultation?.encounter_date + ? dayjs(res.data?.last_consultation?.encounter_date).toDate() : "", date_of_test: res.data?.date_of_test ? dayjs(res.data?.date_of_test).toDate() diff --git a/src/Components/Facility/ConsultationCard.tsx b/src/Components/Facility/ConsultationCard.tsx index 2c0fa54db21..c402853f366 100644 --- a/src/Components/Facility/ConsultationCard.tsx +++ b/src/Components/Facility/ConsultationCard.tsx @@ -63,14 +63,14 @@ export const ConsultationCard = (props: ConsultationProps) => { )} - {itemData.admitted && itemData.admission_date && ( + {itemData.admitted && itemData.encounter_date && (
Admitted on
- {formatDateTime(itemData.admission_date)} + {formatDateTime(itemData.encounter_date)} {itemData.is_readmission && ( { name: consultationData.suggestion === "A" ? `Admitted on ${formatDateTime( - consultationData.admission_date! + consultationData.encounter_date! )}` : consultationData.suggestion_text, }, @@ -345,19 +345,19 @@ export const ConsultationDetails = (props: any) => { {consultationData.admitted_to}
- {(consultationData.admission_date ?? - consultationData.discharge_date) && ( + {(consultationData.discharge_date ?? + consultationData.encounter_date) && (
{relativeTime( consultationData.discharge_date ? consultationData.discharge_date - : consultationData.admission_date + : consultationData.encounter_date )}
)}
- {consultationData.admission_date && - formatDateTime(consultationData.admission_date)} + {consultationData.encounter_date && + formatDateTime(consultationData.encounter_date)} {consultationData.discharge_date && ` - ${formatDateTime(consultationData.discharge_date)}`}
diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 3207787a27d..72944389235 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -3,6 +3,7 @@ import * as Notification from "../../Utils/Notifications.js"; import { BedModel, FacilityModel } from "./models"; import { CONSULTATION_SUGGESTION, + ConsultationSuggestionValue, PATIENT_CATEGORIES, REVIEW_AT_CHOICES, TELEMEDICINE_ACTIONS, @@ -82,14 +83,14 @@ type FormDetails = { symptoms: number[]; other_symptoms: string; symptoms_onset_date?: Date; - suggestion: string; + suggestion: ConsultationSuggestionValue; route_to_facility?: RouteToFacility; patient: string; facility: string; admitted: BooleanStrings; admitted_to: string; category: string; - admission_date?: Date; + encounter_date?: Date; icu_admission_date?: Date; discharge_date: null; referred_to?: string; @@ -139,7 +140,7 @@ const initForm: FormDetails = { admitted: "false", admitted_to: "", category: "", - admission_date: new Date(), + encounter_date: new Date(), icu_admission_date: undefined, discharge_date: null, referred_to: "", @@ -375,7 +376,7 @@ export const ConsultationForm = (props: any) => { const formData = { ...res.data, symptoms_onset_date: isoStringToDate(res.data.symptoms_onset_date), - admission_date: isoStringToDate(res.data.admission_date), + encounter_date: isoStringToDate(res.data.encounter_date), icu_admission_date: isoStringToDate(res.data.icu_admission_date), admitted: res.data.admitted ? String(res.data.admitted) : "false", admitted_to: res.data.admitted_to ? res.data.admitted_to : "", @@ -485,15 +486,12 @@ export const ConsultationForm = (props: any) => { invalidForm = true; } return; - case "admission_date": - if ( - ["A", "DC"].includes(state.form.suggestion) && - !state.form[field] - ) { + case "encounter_date": + if (!state.form[field]) { errors[field] = "Field is required"; invalidForm = true; } - if (dayjs(state.form.admission_date).isBefore(dayjs("2000-01-01"))) { + if (dayjs(state.form.encounter_date).isBefore(dayjs("2000-01-01"))) { errors[field] = "Admission date cannot be before 01/01/2000"; invalidForm = true; } @@ -685,9 +683,7 @@ export const ConsultationForm = (props: any) => { suggestion: state.form.suggestion, route_to_facility: state.form.route_to_facility, admitted: state.form.suggestion === "A", - admission_date: ["A", "DC"].includes(state.form.suggestion) - ? state.form.admission_date - : undefined, + encounter_date: state.form.encounter_date, category: state.form.category, is_kasp: state.form.is_kasp, kasp_enabled_date: JSON.parse(state.form.is_kasp) ? new Date() : null, @@ -1134,7 +1130,7 @@ export const ConsultationForm = (props: any) => { label="Decision after consultation" {...selectField("suggestion")} options={CONSULTATION_SUGGESTION.filter( - ({ deprecated }) => !deprecated + (option) => !("deprecated" in option) )} />
@@ -1200,30 +1196,35 @@ export const ConsultationForm = (props: any) => { )} - {["A", "DC"].includes(state.form.suggestion) && ( -
+ - -
- )} + label={ + { + A: "Date & Time of Admission to the Facility", + DC: "Date & Time of Domiciliary Care commencement", + OP: "Date & Time of Out-patient visit", + DD: "Date & Time of Encounter", + HI: "Date & Time of Encounter", + R: "Date & Time of Encounter", + }[state.form.suggestion] + } + type="datetime-local" + value={dayjs(state.form.encounter_date).format( + "YYYY-MM-DDTHH:mm" + )} + max={dayjs().format("YYYY-MM-DDTHH:mm")} + /> +
{state.form.route_to_facility === 30 && (
({ ...form, ...updates })); }} required - min={dayjs( - consultationData?.admission_date ?? consultationData?.created_date - ).format("YYYY-MM-DDTHH:mm")} + min={dayjs(consultationData?.encounter_date).format( + "YYYY-MM-DDTHH:mm" + )} max={dayjs().format("YYYY-MM-DDTHH:mm")} error={ preDischargeForm.discharge_reason === "EXP" diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx index 7adb4dcfbe2..8291e0e8ba4 100644 --- a/src/Components/Facility/TreatmentSummary.tsx +++ b/src/Components/Facility/TreatmentSummary.tsx @@ -140,7 +140,7 @@ const TreatmentSummary = (props: any) => { Date of admission : {consultationData.admitted - ? formatDateTime(consultationData.admission_date) + ? formatDateTime(consultationData.encounter_date) : " --/--/----"}
diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 0cf0a4da986..c4a5196511d 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -5,6 +5,7 @@ import { AssetData, AssetLocationType } from "../Assets/AssetTypes"; import { UserBareMinimum } from "../Users/models"; import { RouteToFacility } from "../Common/RouteToFacilitySelect"; import { ConsultationDiagnosis, CreateDiagnosis } from "../Diagnosis/types"; +import { ConsultationSuggestionValue } from "../../Common/constants"; export interface LocalBodyModel { id: number; @@ -93,7 +94,7 @@ export type PatientCategory = | "Critical"; export interface ConsultationModel { - admission_date?: string; + encounter_date: string; icu_admission_date?: string; admitted?: boolean; test_id?: string; @@ -123,7 +124,7 @@ export interface ConsultationModel { referred_by_external?: string; transferred_from_location?: LocationModel["id"]; transferred_from_location_object?: LocationModel; - suggestion?: string; + suggestion?: ConsultationSuggestionValue; patient_no?: string; route_to_facility?: RouteToFacility; is_kasp?: boolean; diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index 9113e8654bf..e1d982148f1 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -194,10 +194,10 @@ export const PatientManager = () => { date_of_result_after: qParams.date_of_result_after || undefined, last_consultation_medico_legal_case: qParams.last_consultation_medico_legal_case || undefined, - last_consultation_admission_date_before: - qParams.last_consultation_admission_date_before || undefined, - last_consultation_admission_date_after: - qParams.last_consultation_admission_date_after || undefined, + last_consultation_encounter_date_before: + qParams.last_consultation_encounter_date_before || undefined, + last_consultation_encounter_date_after: + qParams.last_consultation_encounter_date_after || undefined, last_consultation_discharge_date_before: qParams.last_consultation_discharge_date_before || undefined, last_consultation_discharge_date_after: @@ -239,8 +239,8 @@ export const PatientManager = () => { [params.date_of_result_before, params.date_of_result_after], [params.last_vaccinated_date_before, params.last_vaccinated_date_after], [ - params.last_consultation_admission_date_before, - params.last_consultation_admission_date_after, + params.last_consultation_encounter_date_before, + params.last_consultation_encounter_date_after, ], [ params.last_consultation_discharge_date_before, @@ -345,8 +345,8 @@ export const PatientManager = () => { }, [ dispatch, qParams.last_consultation_medico_legal_case, - qParams.last_consultation_admission_date_before, - qParams.last_consultation_admission_date_after, + qParams.last_consultation_encounter_date_before, + qParams.last_consultation_encounter_date_after, qParams.last_consultation_discharge_date_before, qParams.last_consultation_discharge_date_after, qParams.age_max, @@ -967,7 +967,7 @@ export const PatientManager = () => { badge("IP/OP number", "patient_no"), ...dateRange("Modified", "modified_date"), ...dateRange("Created", "created_date"), - ...dateRange("Admitted", "last_consultation_admission_date"), + ...dateRange("Admitted", "last_consultation_encounter_date"), ...dateRange("Discharged", "last_consultation_discharge_date"), // Admitted to type badges badge("No. of vaccination doses", "number_of_doses"), diff --git a/src/Components/Patient/PatientFilter.tsx b/src/Components/Patient/PatientFilter.tsx index 0599cb2625b..481d2dcc67b 100644 --- a/src/Components/Patient/PatientFilter.tsx +++ b/src/Components/Patient/PatientFilter.tsx @@ -67,10 +67,10 @@ export default function PatientFilter(props: any) { date_declared_positive: filter.date_declared_positive || null, last_consultation_medico_legal_case: filter.last_consultation_medico_legal_case || null, - last_consultation_admission_date_before: - filter.last_consultation_admission_date_before || null, - last_consultation_admission_date_after: - filter.last_consultation_admission_date_after || null, + last_consultation_encounter_date_before: + filter.last_consultation_encounter_date_before || null, + last_consultation_encounter_date_after: + filter.last_consultation_encounter_date_after || null, last_consultation_discharge_date_before: filter.last_consultation_discharge_date_before || null, last_consultation_discharge_date_after: @@ -125,8 +125,8 @@ export default function PatientFilter(props: any) { date_of_result: null, date_declared_positive: null, last_consultation_medico_legal_case: null, - last_consultation_admission_date_before: "", - last_consultation_admission_date_after: "", + last_consultation_encounter_date_before: "", + last_consultation_encounter_date_after: "", last_consultation_discharge_date_before: "", last_consultation_discharge_date_after: "", last_consultation_admitted_to_list: [], @@ -236,8 +236,8 @@ export default function PatientFilter(props: any) { age_max, date_of_result, last_consultation_medico_legal_case, - last_consultation_admission_date_before, - last_consultation_admission_date_after, + last_consultation_encounter_date_before, + last_consultation_encounter_date_after, last_consultation_discharge_date_before, last_consultation_discharge_date_after, last_consultation_admitted_bed_type_list, @@ -278,11 +278,11 @@ export default function PatientFilter(props: any) { date_of_result: dateQueryString(date_of_result), last_consultation_medico_legal_case: last_consultation_medico_legal_case || "", - last_consultation_admission_date_before: dateQueryString( - last_consultation_admission_date_before + last_consultation_encounter_date_before: dateQueryString( + last_consultation_encounter_date_before ), - last_consultation_admission_date_after: dateQueryString( - last_consultation_admission_date_after + last_consultation_encounter_date_after: dateQueryString( + last_consultation_encounter_date_after ), last_consultation_discharge_date_before: dateQueryString( last_consultation_discharge_date_before @@ -537,13 +537,13 @@ export default function PatientFilter(props: any) { /> {" "} diff --git a/src/Components/Shifting/ShiftDetails.tsx b/src/Components/Shifting/ShiftDetails.tsx index a898b0cde15..493c56e71c0 100644 --- a/src/Components/Shifting/ShiftDetails.tsx +++ b/src/Components/Shifting/ShiftDetails.tsx @@ -22,6 +22,7 @@ import { useTranslation } from "react-i18next"; import useQuery from "../../Utils/request/useQuery.js"; import routes from "../../Redux/api.js"; import request from "../../Utils/request/request.js"; +import { ConsultationModel } from "../Facility/models.js"; const Loading = lazy(() => import("../Common/Loading")); @@ -316,7 +317,7 @@ export default function ShiftDetails(props: { id: string }) { const printData = (data: any) => { const patientData = data.patient_object; - const consultation = data.patient.last_consultation; + const consultation = data.patient.last_consultation as ConsultationModel; const patientGender = GENDER_TYPES.find( (i) => i.id === patientData?.gender )?.text; @@ -409,7 +410,7 @@ export default function ShiftDetails(props: { id: string }) { {t("date_of_admission")}:{" "} {formatDateTime( - consultation.admission_date || consultation.created_date + consultation.encounter_date || consultation.created_date ) || "-"}
From 9fc041c5ecf7f48172286b8c4b9f3752e82934b9 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Thu, 21 Dec 2023 11:05:25 +0530 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A7=B9=20Remove=20unused=20redux=20ac?= =?UTF-8?q?tions,=20fireRequest=20for=20file=20utility=20method,=20hooks?= =?UTF-8?q?=20and=20components=20(#6887)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove unused redux actions * Remove unused `fireRequestForFiles` method * remove unused `useIsInitialRender` hook * remove unused components --- src/Common/hooks/useIsInitialRender.ts | 9 - src/Components/Common/NavTabs.tsx | 52 ---- .../Common/WardAutocompleteFormField.tsx | 52 ---- src/Redux/actions.tsx | 260 +----------------- src/Redux/fireRequest.tsx | 102 ------- 5 files changed, 1 insertion(+), 474 deletions(-) delete mode 100644 src/Common/hooks/useIsInitialRender.ts delete mode 100644 src/Components/Common/NavTabs.tsx delete mode 100644 src/Components/Common/WardAutocompleteFormField.tsx diff --git a/src/Common/hooks/useIsInitialRender.ts b/src/Common/hooks/useIsInitialRender.ts deleted file mode 100644 index cfbfe71734d..00000000000 --- a/src/Common/hooks/useIsInitialRender.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { useEffect, useRef } from "react"; - -export default function useIsInitialRender() { - const isInitialRender = useRef(true); - useEffect(() => { - isInitialRender.current = false; - }, []); - return isInitialRender.current; -} diff --git a/src/Components/Common/NavTabs.tsx b/src/Components/Common/NavTabs.tsx deleted file mode 100644 index 1b913d888ce..00000000000 --- a/src/Components/Common/NavTabs.tsx +++ /dev/null @@ -1,52 +0,0 @@ -interface TabValue { - value: number; - label: string; -} -interface TabChange { - (value: number): void; -} -interface NavTabsProps { - active?: number; - options?: TabValue[]; - onChange: TabChange; -} - -export default function NavTabs(props: NavTabsProps) { - const { active, options, onChange } = props; - return ( -
-
- -
-
-
- -
-
-
- ); -} diff --git a/src/Components/Common/WardAutocompleteFormField.tsx b/src/Components/Common/WardAutocompleteFormField.tsx deleted file mode 100644 index 47298dd27b2..00000000000 --- a/src/Components/Common/WardAutocompleteFormField.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { useDispatch } from "react-redux"; -import { FormFieldBaseProps } from "../Form/FormFields/Utils"; -import AutocompleteFormField from "../Form/FormFields/Autocomplete"; -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { useCallback, useState } from "react"; -import { getWardByLocalBody } from "../../Redux/actions"; -import { ILocalBody } from "./LocalBodyAutocompleteFormField"; - -export type IWard = { - id: number; - name: string; -}; - -type Props = FormFieldBaseProps & { - placeholder?: string; - local_body?: ILocalBody["id"]; -}; - -export default function WardAutocompleteFormField(props: Props) { - const dispatch = useDispatch(); - const [Ward, setWard] = useState(); - - const fetchWard = useCallback( - async (status: any) => { - setWard(undefined); - if (!props.local_body) { - return; - } - const res = await dispatch(getWardByLocalBody({ id: props.local_body })); - if (!status.aborted && res.data) { - setWard(res.data); - } - }, - [dispatch, props.local_body] - ); - - useAbortableEffect( - (status: statusType) => fetchWard(status), - [props.local_body] - ); - - return ( - option.name} - optionValue={(option) => option.id} - isLoading={!!(props.local_body && Ward === undefined)} - disabled={!props.local_body} - /> - ); -} diff --git a/src/Redux/actions.tsx b/src/Redux/actions.tsx index 2395c9ad163..32af9609263 100644 --- a/src/Redux/actions.tsx +++ b/src/Redux/actions.tsx @@ -1,43 +1,6 @@ import { HCXClaimModel, HCXPolicyModel } from "../Components/HCX/models"; import { MedibaseMedicine } from "../Components/Medicine/models"; -import { fireRequest, fireRequestForFiles } from "./fireRequest"; - -export const getConfig = () => { - return fireRequestForFiles("config"); -}; -// User -export const postLogin = (params: object) => { - return fireRequest("login", [], params); -}; -export const getCurrentUser = () => { - return fireRequest("currentUser"); -}; -export const signupUser = (params: object) => { - return fireRequest("createUser", [], params); -}; -export const deleteUser = (username: string) => { - return fireRequest("deleteUser", [], {}, { username }); -}; - -export const checkResetToken = (params: object) => { - return fireRequest("checkResetToken", [], params); -}; - -export const postResetPassword = (form: object) => { - return fireRequest("resetPassword", [], form); -}; - -export const postForgotPassword = (form: object) => { - return fireRequest("forgotPassword", [], form); -}; - -export const getUserPnconfig = (pathParams: object) => { - return fireRequest("getUserPnconfig", [], {}, pathParams); -}; - -export const updateUserPnconfig = (params: object, pathParams: object) => { - return fireRequest("updateUserPnconfig", [], params, pathParams); -}; +import { fireRequest } from "./fireRequest"; // Facility export const createFacility = (params: object) => { @@ -46,39 +9,12 @@ export const createFacility = (params: object) => { export const updateFacility = (id: string, params: object) => { return fireRequest("updateFacility", [id], params); }; -export const partialUpdateFacility = (id: string, params: object) => { - return fireRequest("partialUpdateFacility", [id], params); -}; export const deleteFacilityCoverImage = (id: string) => { return fireRequest("deleteFacilityCoverImage", [], {}, { id }); }; export const getUserList = (params: object, key?: string) => { return fireRequest("userList", [], params, null, key); }; -export const getUserListFacility = (pathParam: object) => { - return fireRequest("userListFacility", [], {}, pathParam); -}; - -export const addUserSkill = (username: string, skill: string) => { - return fireRequest("addUserSkill", [], { skill }, { username }); -}; - -export const addUserFacility = (username: string, facility: string) => { - return fireRequest("addUserFacility", [], { facility }, { username }); -}; - -export const deleteUserSkill = (username: string, id: string) => { - return fireRequest("deleteUserSkill", [], {}, { username, id }); -}; - -export const deleteUserFacility = (username: string, facility: string) => { - return fireRequest( - "deleteUserFacility", - [], - { data: { facility } }, - { username } - ); -}; export const getPermittedFacilities = (params: object) => { return fireRequest("getPermittedFacilities", [], params); @@ -108,9 +44,6 @@ export const getFacilityUsers = (id: string, params?: object) => { { facility_id: id } ); }; -export const getOnlineDoctors = () => { - return fireRequest("getOnlineDoctors", [], {}, {}); -}; export const listFacilityAssetLocation = (params: object, pathParam: object) => fireRequest("listFacilityAssetLocation", [], params, pathParam); @@ -140,15 +73,6 @@ export const updateFacilityAssetLocation = ( facility_external_id, external_id, }); -export const partialUpdateFacilityAssetLocation = ( - params: object, - facility_external_id: string, - external_id: string -) => - fireRequest("partialUpdateFacilityAssetLocation", [], params, { - facility_external_id, - external_id, - }); // asset bed export const listAssetBeds = (params: object, altKey?: string) => @@ -165,17 +89,6 @@ export const createAssetBed = ( {} ); -export const getAssetBed = ( - asset_external_id: string, - bed_id: string, - external_id: string -) => - fireRequest( - "getAssetBed", - [], - { asset: asset_external_id, bed: bed_id }, - { external_id } - ); export const partialUpdateAssetBed = (params: object, asset_id: string) => fireRequest( "partialUpdateAssetBed", @@ -186,21 +99,6 @@ export const partialUpdateAssetBed = (params: object, asset_id: string) => } ); -export const updateAssetBed = ( - params: object, - asset_external_id: string, - external_id: string, - bed_id: string -) => - fireRequest( - "updateAssetBed", - [], - { ...params, asset: asset_external_id, bed: bed_id }, - { - external_id, - } - ); - export const deleteAssetBed = (asset_id: string) => fireRequest( "deleteAssetBed", @@ -260,47 +158,6 @@ export const deleteFacilityBed = (external_id: string) => { return fireRequest("deleteFacilityBed", [], {}, { external_id }); }; -// Consultation Beds -export const listConsultationBeds = (params: object) => - fireRequest("listConsultationBeds", [], params, {}); -export const createConsultationBed = ( - params: object, - consultation_id: string, - bed_id: string -) => - fireRequest( - "createConsultationBed", - [], - { ...params, consultation: consultation_id, bed: bed_id }, - {} - ); - -export const getConsultationBed = ( - consultation_external_id: string, - bed_id: string, - external_id: string -) => - fireRequest( - "getConsultationBed", - [], - { consultation: consultation_external_id, bed: bed_id }, - { external_id } - ); -export const updateConsultationBed = ( - params: object, - consultation_external_id: string, - external_id: string, - bed_id: string -) => - fireRequest( - "updateConsultationBed", - [], - { ...params, consultation: consultation_external_id, bed: bed_id }, - { - external_id, - } - ); - // Download Actions export const downloadFacility = () => { return fireRequest("downloadFacility"); @@ -318,9 +175,6 @@ export const downloadFacilityTriage = () => { return fireRequest("downloadFacilityTriage"); }; -export const downloadPatients = () => { - return fireRequest("downloadPatients"); -}; // Capacity/Triage/Doctor export const createCapacity = ( id: number | undefined, @@ -377,9 +231,6 @@ export const deleteCapacity = (pathParam: object) => { export const searchPatient = (params: object) => { return fireRequest("searchPatient", [], params); }; -export const searchUser = (params: object) => { - return fireRequest("searchUser", [], params); -}; export const getAllPatient = (params: object, altKey: string) => { return fireRequest("patientList", [], params, null, altKey); }; @@ -398,23 +249,9 @@ export const patchPatient = (params: object, pathParam: object) => { export const transferPatient = (params: object, pathParam: object) => { return fireRequest("transferPatient", [], params, pathParam); }; -export const getPatientNotes = ( - patientId: string, - limit: number, - offset: number -) => { - return fireRequest("getPatientNotes", [], { limit, offset }, { patientId }); -}; -export const addPatientNote = (patientId: string, params: object) => { - return fireRequest("addPatientNote", [], params, { patientId }); -}; - export const getStates = () => { return fireRequest("statesList", []); }; -export const getStatesByText = (params: object) => { - return fireRequest("statesList", [], params); -}; export const getState = (id: number) => { return fireRequest("getState", [], {}, { id: id }); }; @@ -433,20 +270,10 @@ export const getDistrict = (id: number, key?: string) => { export const getLocalbodyByDistrict = (pathParam: object) => { return fireRequest("getLocalbodyByDistrict", [], {}, pathParam); }; -export const getLocalbodyByName = (params: object) => { - return fireRequest("getLocalbodyByName", [], params, null); -}; export const getWardByLocalBody = (pathParam: object) => { return fireRequest("getWardByLocalBody", [], {}, pathParam); }; -export const getWards = (params: object) => { - return fireRequest("getWards", [], params); -}; - -export const getAllLocalBodyByDistrict = (pathParam: object) => { - return fireRequest("getAllLocalBodyByDistrict", [], {}, pathParam); -}; // Local Body export const getLocalBody = (pathParam: object) => { @@ -460,10 +287,6 @@ export const getAllLocalBody = (params: object) => { export const getSampleTestList = (params: object, pathParam: object) => { return fireRequest("sampleTestList", [], params, pathParam); }; - -export const sampleSearch = (params: object) => { - return fireRequest("getTestSampleList", [], params); -}; export const createSampleTest = (params: object, pathParam: object) => { return fireRequest("createSampleTest", [], params, pathParam); }; @@ -497,9 +320,6 @@ export const getDailyReport = (params: object, pathParam: object) => { export const getConsultationDailyRoundsDetails = (pathParam: object) => { return fireRequest("getDailyReport", [], {}, pathParam); }; -export const dailyRoundsAnalyse = (params: object, pathParam: object) => { - return fireRequest("dailyRoundsAnalyse", [], params, pathParam); -}; // Consultation export const createConsultation = (params: object) => { @@ -552,10 +372,6 @@ export const getInventorySummary = (facilityId: number, params: object) => { params ); }; -export const getItemName = (id: number) => { - return fireRequest("getItemName", [id], {}); -}; - export const flagInventoryItem = (params: object) => { return fireRequest("flagInventoryItem", [], {}, params); }; @@ -584,12 +400,6 @@ export const dischargePatient = (params: object, pathParams: object) => { return fireRequest("dischargePatient", [], params, pathParams); }; -//Profile - -export const updateUserDetails = (username: string, data: object) => { - return fireRequest("updateUserDetails", [username], data); -}; - //Shift export const createShift = (params: object) => { return fireRequest("createShift", [], params); @@ -615,36 +425,6 @@ export const externalResult = (pathParam: object) => { return fireRequest("externalResult", [], {}, pathParam); }; -export const updateExternalResult = (id: number, params: object) => { - return fireRequest("updateExternalResult", [], params, { id }); -}; - -export const partialUpdateExternalResult = (id: number, params: object) => { - return fireRequest("partialUpdateExternalResult", [], params, { id }); -}; - -// Notifications -export const getNotifications = (params: object, altKey?: string) => { - return fireRequest("getNotifications", [], params, {}, altKey); -}; - -export const getNotificationData = (pathParam: object) => { - return fireRequest("getNotificationData", [], {}, pathParam); -}; - -export const markNotificationAsRead = (id: string) => { - return fireRequest( - "markNotificationAsRead", - [], - { read_at: new Date() }, - { id } - ); -}; - -export const getPublicKey = () => { - return fireRequest("getPublicKey", [], {}, {}); -}; - // FileUpload export const createUpload = (params: object) => { @@ -659,10 +439,6 @@ export const retrieveUpload = (params: object, fileId: string) => { return fireRequest("retrieveUpload", [], params, { fileId: fileId }); }; -export const retrieveUploadFilesURL = (params: object, fileId: string) => { - return fireRequestForFiles("retrieveUpload", [], params, { fileId: fileId }); -}; - export const editUpload = ( params: object, fileId: string, @@ -757,47 +533,13 @@ export const createAsset = (params: object) => fireRequest("createAsset", [], params); export const getAsset = (id: string) => fireRequest("getAsset", [], {}, { external_id: id }); -export const deleteAsset = (id: string) => - fireRequest("deleteAsset", [], {}, { external_id: id }); export const updateAsset = (id: string, params: object) => fireRequest("updateAsset", [], params, { external_id: id }); export const operateAsset = (id: string, params: object) => fireRequest("operateAsset", [], params, { external_id: id }); -// ABDM related - -export const resentAadhaarOtp = (txnId: string) => - fireRequest("resendAadhaarOtp", [], { txnId }); - -export const generateMobileOtp = (txnId: string, mobile: string) => - fireRequest("generateMobileOtp", [], { txnId, mobile }); - -export const linkCareContext = ( - consultationId: string, - data: { name?: string; gender?: "M" | "F" | "O"; dob?: string } -) => { - return fireRequest("linkCareContext", [], { - consultation: consultationId, - ...data, - }); -}; - -export const healthFacilityActions = { - list: (params: object) => { - return fireRequest("listHealthFacilities", [], params); - }, - - update: (id: string, data: object) => { - return fireRequest("updateHealthFacility", [], data, { - facility_id: id, - }); - }, -}; - export const listAssetAvailability = (params: object) => fireRequest("listAssetAvailability", [], params); -export const getAssetAvailability = (id: string) => - fireRequest("getAssetAvailability", [], {}, { id }); export const listPMJYPackages = (query?: string) => fireRequest("listPMJYPackages", [], { query }); diff --git a/src/Redux/fireRequest.tsx b/src/Redux/fireRequest.tsx index 876877799d8..6c3aee7c12a 100644 --- a/src/Redux/fireRequest.tsx +++ b/src/Redux/fireRequest.tsx @@ -274,105 +274,3 @@ export const fireRequestV2 = ( } }); }; - -export const fireRequestForFiles = ( - key: string, - path: any = [], - params: any = {}, - pathParam?: any, - altKey?: string -) => { - return (dispatch: any) => { - // cancel previous api call - if (isRunning[altKey ? altKey : key]) { - isRunning[altKey ? altKey : key].cancel(); - } - isRunning[altKey ? altKey : key] = axios.CancelToken.source(); - // get api url / method - const request = Object.assign({}, requestMap[key]); - if (path.length > 0) { - request.path += "/" + path.join("/"); - } - if (request.method === undefined || request.method === "GET") { - request.method = "GET"; - const qs = new URLSearchParams(omitBy(params, isEmpty)).toString(); - if (qs !== "") { - request.path += `?${qs}`; - } - } - // set dynamic params in the URL - if (pathParam) { - Object.keys(pathParam).forEach((param: any) => { - request.path = request.path.replace(`{${param}}`, pathParam[param]); - }); - } - - // set authorization header in the request header - const config: any = { - headers: { - "Content-type": "application/pdf", - "Content-disposition": "inline", - }, - }; - // Content-Type: application/pdf - // Content-Disposition: inline; filename="filename.pdf" - if (!request.noAuth && localStorage.getItem(LocalStorageKeys.accessToken)) { - config.headers["Authorization"] = - "Bearer " + localStorage.getItem(LocalStorageKeys.accessToken); - } - const axiosApiCall: any = axios.create(config); - - dispatch(fetchDataRequest(key)); - return axiosApiCall[request.method.toLowerCase()](request.path, { - ...params, - cancelToken: isRunning[altKey ? altKey : key].token, - }) - .then((response: any) => { - dispatch(fetchResponseSuccess(key, response.data)); - return response; - }) - .catch((error: any) => { - dispatch(fetchDataRequestError(key, error)); - - if (error.response) { - // temporarily don't show invalid phone number error on duplicate patient check - if (error.response.status === 400 && key === "searchPatient") { - return; - } - - // currentUser is ignored because on the first page load - // 403 error is displayed for invalid credential. - if (error.response.status === 403 && key === "currentUser") { - if (localStorage.getItem(LocalStorageKeys.accessToken)) { - localStorage.removeItem(LocalStorageKeys.accessToken); - } - return; - } - - // 400 Bad Request Error - if (error.response.status === 400 || error.response.status === 406) { - Notification.BadRequest({ - errs: error.response.data, - }); - return error.response; - } - - // 4xx Errors - if (error.response.status > 400 && error.response.status < 600) { - if (error.response.status === 429) { - return error.response; - } else if (error.response.data && error.response.data.detail) { - Notification.Error({ - msg: error.response.data.detail, - }); - } else { - Notification.Error({ - msg: "Something went wrong...!", - }); - } - return; - } - } - }); - }; -};