Skip to content

Commit

Permalink
Merge branch 'develop' into livekit
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Oct 24, 2024
2 parents c1f1c57 + 7eee0ff commit 17b4824
Show file tree
Hide file tree
Showing 20 changed files with 267 additions and 146 deletions.
8 changes: 0 additions & 8 deletions cypress/e2e/patient_spec/PatientRegistration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,6 @@ describe("Patient Creation with consultation", () => {
.contains("member id")
.scrollIntoView();
cy.wait(2000);
patientInsurance.verifyPatientPolicyDetails(
patientOneFirstSubscriberId,
patientOneFirstPolicyId,
patientOneFirstInsurerId,
patientOneFirstInsurerName,
isHCXEnabled,
);

patientInsurance.clickPatientInsuranceViewDetail();
cy.wait(3000);
patientInsurance.verifyPatientPolicyDetails(
Expand Down
7 changes: 2 additions & 5 deletions cypress/e2e/users_spec/UsersCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,10 @@ describe("User Creation", () => {
);
userCreationPage.typeIntoElementByIdPostClear("lastName", "Cypress");
userCreationPage.selectDropdownOption("gender", "Male");
userCreationPage.typeIntoElementByIdPostClear(
"phoneNumber",
"+91" + phone_number,
);
userCreationPage.typeIntoElementByIdPostClear("phoneNumber", phone_number);
userCreationPage.typeIntoElementByIdPostClear(
"altPhoneNumber",
"+91" + emergency_phone_number,
emergency_phone_number,
);
userCreationPage.typeIntoElementByIdPostClear("email", "test@test.com");
userCreationPage.typeIntoElementByIdPostClear("weekly_working_hours", "14");
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/users_spec/UsersProfile.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("Manage User Profile", () => {
const date_of_birth = "01011999";
const gender = "Male";
const email = "test@example.com";
const phone = "+918899887788";
const phone = "8899887788";
const workinghours = "8";
const qualification = "MBBS";
const doctorYoE = "10";
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Facility/FacilityLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class FacilityLocation {
}

clickNotification() {
cy.get(".pnotify").click();
cy.get(".pnotify-container").click();
}

enterBedName(name: string) {
Expand Down
5 changes: 5 additions & 0 deletions src/Locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
"abha_address_validation_length_error": "Should be atleast 4 character long",
"abha_address_validation_start_error": "Shouldn't start with a number or dot (.)",
"abha_details": "ABHA Details",
"abha_disabled_due_to_no_health_facility": "ABHA Number generation and linking is disabled for this facility, Please link a health facility to enable this feature.",
"abha_link_options__create_with_aadhaar__description": "Create New ABHA Number Using Aadhaar Number",
"abha_link_options__create_with_aadhaar__title": "Create with Aadhaar",
"abha_link_options__create_with_driving_license__description": "Create New ABHA Number Using Driving License",
Expand Down Expand Up @@ -379,6 +380,7 @@
"checking_eligibility": "Checking Eligibility",
"checking_for_update": "Checking for update",
"checking_policy_eligibility": "Checking Policy Eligibility",
"choose_date_time": "Choose Date and Time",
"choose_file": "Upload From Device",
"choose_location": "Choose Location",
"claim__add_item": "Add Item",
Expand Down Expand Up @@ -668,6 +670,7 @@
"full_name": "Full Name",
"full_screen": "Full Screen",
"gender": "Gender",
"generate_link_abha": "Generate/Link ABHA Number",
"generate_report": "Generate Report",
"generated_summary_caution": "This is a computer generated summary using the information captured in the CARE system.",
"generating": "Generating",
Expand Down Expand Up @@ -871,6 +874,7 @@
"no_tests_taken": "No tests taken",
"no_treating_physicians_available": "This facility does not have any home facility doctors. Please contact your admin.",
"no_users_found": "No Users Found",
"no_vitals_present": "No Vitals Monitor present in this location or facility",
"none": "None",
"normal": "Normal",
"not_eligible": "Not Eligible",
Expand Down Expand Up @@ -1242,6 +1246,7 @@
"virtual_nursing_assistant": "Virtual Nursing Assistant",
"vitals": "Vitals",
"vitals_monitor": "Vitals Monitor",
"vitals_present": "Vitals Monitor present",
"ward": "Ward",
"warranty_amc_expiry": "Warranty / AMC Expiry",
"what_facility_assign_the_patient_to": "What facility would you like to assign the patient to",
Expand Down
41 changes: 41 additions & 0 deletions src/Utils/request/useMutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import request from "@/Utils/request/request";
import {
MutationRoute,
RequestOptions,
RequestResult,
} from "@/Utils/request/types";
import { mergeRequestOptions } from "@/Utils/request/utils";
import React from "react";

export default function useMutation<TData, TBody>(
route: MutationRoute<TData, TBody>,
options: RequestOptions<TData>,
) {
const [response, setResponse] = React.useState<RequestResult<TData>>();
const [isProcessing, setIsProcessing] = React.useState(false);

const controllerRef = React.useRef<AbortController>();

const runQuery = React.useCallback(
async (overrides?: RequestOptions<TData>) => {
controllerRef.current?.abort();

const controller = new AbortController();
controllerRef.current = controller;

const resolvedOptions =
options && overrides
? mergeRequestOptions(options, overrides)
: (overrides ?? options);

setIsProcessing(true);
const response = await request(route, { ...resolvedOptions, controller });
setResponse(response);
setIsProcessing(false);
return response;
},
[route, JSON.stringify(options)],
);

return { ...response, isProcessing, mutate: runQuery };
}
8 changes: 8 additions & 0 deletions src/components/Common/LocationSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface LocationSelectProps {
selected: string | string[] | null;
setSelected: (selected: string | string[] | null) => void;
errorClassName?: string;
bedIsOccupied?: boolean;
disableOnOneOrFewer?: boolean;
}

export const LocationSelect = (props: LocationSelectProps) => {
Expand All @@ -23,6 +25,8 @@ export const LocationSelect = (props: LocationSelectProps) => {
{
query: {
limit: 14,
bed_is_occupied:
props.bedIsOccupied === undefined ? undefined : !props.bedIsOccupied,
},
pathParams: {
facility_external_id: props.facilityId,
Expand All @@ -31,6 +35,10 @@ export const LocationSelect = (props: LocationSelectProps) => {
},
);

if (props.disableOnOneOrFewer && data && data.count <= 1) {
props = { ...props, disabled: true };
}

return props.multiple ? (
<AutocompleteMultiSelectFormField
name={props.name}
Expand Down
29 changes: 17 additions & 12 deletions src/components/Facility/CentralNursingStation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ export default function CentralNursingStation({ facilityId }: Props) {
collapseSidebar
options={
<div className="flex flex-row-reverse items-center gap-4 md:flex-row">
<Pagination
className=""
cPage={qParams.page}
defaultPerPage={PER_PAGE_LIMIT}
data={{ totalCount }}
onChange={(page) => updatePage(page)}
/>
<Popover className="relative">
<PopoverButton>
<ButtonV2
Expand Down Expand Up @@ -109,8 +116,8 @@ export default function CentralNursingStation({ facilityId }: Props) {
<div className="rounded-t-lg bg-secondary-100 px-6 py-4">
<div className="flow-root rounded-md">
<span className="block text-sm text-secondary-800">
<span className="font-bold">{totalCount}</span> Vitals
Monitor present
<span className="font-bold">{totalCount}</span>{" "}
{t("vitals_present")}
</span>
</div>
</div>
Expand All @@ -134,6 +141,10 @@ export default function CentralNursingStation({ facilityId }: Props) {
facilityId={facilityId}
errors=""
errorClassName="hidden"
bedIsOccupied={JSON.parse(
qParams.monitors_without_patient ?? "false",
)}
disableOnOneOrFewer
/>
</div>
</div>
Expand Down Expand Up @@ -164,7 +175,9 @@ export default function CentralNursingStation({ facilityId }: Props) {
value={JSON.parse(
qParams.monitors_without_patient ?? "false",
)}
onChange={(e) => updateQuery({ [e.name]: `${e.value}` })}
onChange={(e) =>
updateQuery({ [e.name]: `${e.value}`, location: "" })
}
labelClassName="text-sm"
errorClassName="hidden"
/>
Expand All @@ -189,22 +202,14 @@ export default function CentralNursingStation({ facilityId }: Props) {
</PopoverPanel>
</Transition>
</Popover>

<Pagination
className=""
cPage={qParams.page}
defaultPerPage={PER_PAGE_LIMIT}
data={{ totalCount }}
onChange={(page) => updatePage(page)}
/>
</div>
}
>
{data === undefined || query.loading ? (
<Loading />
) : data.length === 0 ? (
<div className="flex h-[80vh] w-full items-center justify-center text-center text-black">
No Vitals Monitor present in this location or facility.
{t("no_vitals_present")}
</div>
) : (
<div className="3xl:grid-cols-3 mt-1 grid grid-cols-1 gap-1 lg:grid-cols-2">
Expand Down
8 changes: 4 additions & 4 deletions src/components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const ConsultationDetails = (props: any) => {
}
const [showDoctors, setShowDoctors] = useState(false);
const [qParams, _] = useQueryParams();
const [patientData, setPatientData] = useState<PatientModel>({});
const [patientData, setPatientData] = useState<PatientModel>();
const [abhaNumberData, setAbhaNumberData] = useState<AbhaNumberModel>();
const [activeShiftingData, setActiveShiftingData] = useState<Array<any>>([]);

Expand Down Expand Up @@ -135,7 +135,7 @@ export const ConsultationDetails = (props: any) => {
address: getPatientAddress(data),
comorbidities: getPatientComorbidities(data),
is_declared_positive: data.is_declared_positive ? "Yes" : "No",
is_vaccinated: patientData.is_vaccinated ? "Yes" : "No",
is_vaccinated: patientData?.is_vaccinated ? "Yes" : "No",
} as any);
},
});
Expand All @@ -160,7 +160,7 @@ export const ConsultationDetails = (props: any) => {
setActiveShiftingData(shiftRequestsQuery.data.results);
}
},
[consultationId, patientData.is_vaccinated],
[consultationId, patientData?.is_vaccinated],
);

useEffect(() => {
Expand All @@ -176,7 +176,7 @@ export const ConsultationDetails = (props: any) => {
});
}, [patientDataQuery.data?.id]);

if (!consultationData || patientDataQuery.loading) {
if (!patientData || !consultationData || patientDataQuery.loading) {
return <Loading />;
}

Expand Down
58 changes: 21 additions & 37 deletions src/components/Facility/Consultations/PainDiagrams.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,41 @@
import { useEffect, useState } from "react";
import routes from "../../../Redux/api";
import request from "../../../Utils/request/request";
import { formatDateTime } from "../../../Utils/utils";
import PainChart from "../../LogUpdate/components/PainChart";
import { PainDiagramsFields } from "../models";
import { useTranslation } from "react-i18next";

export const PainDiagrams = (props: any) => {
const { consultationId } = props;
const [isLoading, setIsLoading] = useState(false);
const [results, setResults] = useState<any>({});
const [selectedData, setData] = useState<any>({
const { dailyRound } = props;
const [results, setResults] = useState({});
const [selectedData, setData] = useState({
data: [],
id: "",
});
const { t } = useTranslation();

useEffect(() => {
const fetchDailyRounds = async (consultationId: string) => {
setIsLoading(true);
const { res, data: dailyRound } = await request(
routes.dailyRoundsAnalyse,
{
body: { fields: PainDiagramsFields },
pathParams: {
consultationId,
},
},
);
if (res && res.ok && dailyRound?.results) {
const keys = Object.keys(dailyRound.results || {}).filter(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
(key) => dailyRound.results[key].pain_scale_enhanced.length,
const filterDailyRounds = () => {
if (dailyRound) {
const keys = Object.keys(dailyRound || {}).filter(
(key) => dailyRound[key].pain_scale_enhanced.length,
);
const data: any = {};
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
keys.forEach((key) => (data[key] = dailyRound.results[key]));
keys.forEach(
(key) =>
(data[key] = Object.assign(
{},
{ pain_scale_enhanced: dailyRound[key].pain_scale_enhanced },
)),
);

setResults(data);
if (keys.length > 0) {
setSelectedDateData(data, keys[0]);
}
}
setIsLoading(false);
};

fetchDailyRounds(consultationId);
}, [consultationId]);

useEffect(() => {
if (Object.keys(results).length > 0)
setSelectedDateData(results, Object.keys(results)[0]);
}, [results]);
filterDailyRounds();
}, [dailyRound]);

useEffect(() => {
if (Object.keys(results).length > 0)
Expand All @@ -73,7 +57,7 @@ export const PainDiagrams = (props: any) => {
const dropdown = (dates: Array<any>) => {
return dates && dates.length > 0 ? (
<div className="mx-auto flex flex-wrap">
<div className="p-2">Choose Date and Time</div>
<div className="p-2">{t("choose_date_time")}</div>
<select
title="date"
className="relative rounded border-secondary-200 bg-white py-2 pl-3 pr-8 text-slate-600 shadow outline-none focus:border-secondary-300 focus:outline-none focus:ring-1 focus:ring-secondary-300"
Expand All @@ -97,7 +81,7 @@ export const PainDiagrams = (props: any) => {
className="border-2 border-secondary-400 py-2 pl-3 pr-8"
disabled={true}
>
<option>No Data Found</option>
<option>{t("no_data_found")}</option>
</select>
</div>
);
Expand All @@ -106,7 +90,7 @@ export const PainDiagrams = (props: any) => {
return (
<div className="space-y-4">
{dates && dropdown(dates)}
{!isLoading && selectedData.data ? (
{selectedData.data ? (
<PainChart pain={selectedData.data} />
) : (
<div className="h-screen" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export const PrimaryParametersPlot = ({
</div>
<div>
<PageTitle title="Pain Scale" hideBack={true} breadcrumbs={false} />
<PainDiagrams consultationId={consultationId} />
<PainDiagrams dailyRound={results} />
</div>
{totalCount > PAGINATION_LIMIT && (
<div className="mt-4 flex w-full justify-center">
Expand Down
1 change: 1 addition & 0 deletions src/components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ export const PrimaryParametersPlotFields = [
"ventilator_fio2",
"rhythm",
"rhythm_detail",
"pain_scale_enhanced",
] as const satisfies (keyof DailyRoundsModel)[];

export type PrimaryParametersPlotRes = {
Expand Down
Loading

0 comments on commit 17b4824

Please sign in to comment.