Skip to content

Commit

Permalink
update area of specialisation of doctor (#7664)
Browse files Browse the repository at this point in the history
* update area of specialisation

* fixed

* update

* fix filtered

* fix filter logic

* Update src/Common/constants.tsx

* Update src/Common/constants.tsx

* remove unused color definitions

* fix cypress and messages

* fix error

---------

Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
Co-authored-by: rithviknishad <mail@rithviknishad.dev>
  • Loading branch information
3 people committed May 15, 2024
1 parent 0d83e5f commit c8a1549
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 73 deletions.
8 changes: 4 additions & 4 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,26 @@ describe("Facility Manage Functions", () => {
it("Modify doctor capacity in Facility detail page", () => {
// Add a doctor capacity
facilityManage.clickFacilityAddDoctorTypeButton();
facilityPage.selectAreaOfSpecialization("General Medicine");
facilityPage.selectAreaOfSpecialization("Pulmonology");
facilityPage.fillDoctorCount(doctorCapacity);
facilityPage.saveAndExitDoctorForm();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Doctor count added successfully",
"Staff count added successfully",
);
facilityManage.verifyTotalDoctorCapacity(doctorCapacity);
// edit a existing doctor
facilityManage.clickEditFacilityDoctorCapacity();
facilityPage.fillDoctorCount(doctorModifiedCapacity);
facilityPage.clickdoctorcapacityaddmore();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Doctor count updated successfully",
"Staff count updated successfully",
);
facilityManage.verifyTotalDoctorCapacity(doctorModifiedCapacity);
// delete a bed
facilityManage.clickDeleteFacilityDoctorCapacity();
facilityManage.clickButtonWithText("Delete");
facilityManage.verifySuccessMessageVisibilityAndContent(
"Doctor specialization type deleted successfully",
"Staff specialization type deleted successfully",
);
});

Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/resource_spec/resources.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ describe("Resource Page", () => {
"Dummy",
"Test title",
"10",
"Test description"
"Test description",
);
facilityPage.clickSubmitRequestButton();
facilityPage.verifySuccessNotification(
"Resource request created successfully"
"Resource request created successfully",
);
facilityPage.verifyresourcenewurl();
cy.url().then((url) => {
Expand All @@ -71,7 +71,7 @@ describe("Resource Page", () => {
resourcePage.updateStatus("APPROVED");
resourcePage.clickSubmitButton();
resourcePage.verifySuccessNotification(
"Resource request updated successfully"
"Resource request updated successfully",
);
});

Expand Down
59 changes: 54 additions & 5 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,60 @@ export const getBedTypes = ({
};

export const DOCTOR_SPECIALIZATION: Array<OptionsType> = [
{ id: 1, text: "General Medicine", desc: "bg-doctors-general" },
{ id: 2, text: "Pulmonology", desc: "bg-doctors-pulmonology" },
{ id: 3, text: "Critical Care", desc: "bg-doctors-critical" },
{ id: 4, text: "Paediatrics", desc: "bg-doctors-paediatrics" },
{ id: 5, text: "Other Speciality", desc: "bg-doctors-other" },
{ id: 1, text: "General Medicine" },
{ id: 2, text: "Pulmonology" },
{ id: 3, text: "Intensivist" },
{ id: 4, text: "Pediatrician" },
{ id: 6, text: "Anesthesiologist" },
{ id: 7, text: "Cardiac Surgeon" },
{ id: 8, text: "Cardiologist" },
{ id: 9, text: "Dentist" },
{ id: 10, text: "Dermatologist" },
{ id: 11, text: "Diabetologist" },
{ id: 12, text: "Emergency Medicine Physician" },
{ id: 13, text: "Endocrinologist" },
{ id: 14, text: "Family Physician" },
{ id: 15, text: "Gastroenterologist" },
{ id: 16, text: "General Surgeon" },
{ id: 17, text: "Geriatrician" },
{ id: 18, text: "Hematologist" },
{ id: 29, text: "Immunologist" },
{ id: 20, text: "Infectious Disease Specialist" },
{ id: 21, text: "MBBS doctor" },
{ id: 22, text: "Medical Officer" },
{ id: 23, text: "Nephrologist" },
{ id: 24, text: "Neuro Surgeon" },
{ id: 25, text: "Neurologist" },
{ id: 26, text: "Obstetrician and Gynecologist" },
{ id: 27, text: "Oncologist" },
{ id: 28, text: "Oncology Surgeon" },
{ id: 29, text: "Ophthalmologist" },
{
id: 30,
text: "Oral and Maxillofacial Surgeon",
},
{ id: 31, text: "Orthopedic" },
{ id: 32, text: "Orthopedic Surgeon" },
{ id: 33, text: "Otolaryngologist (ENT)" },
{ id: 34, text: "Palliative care Physician" },
{ id: 35, text: "Pathologist" },
{ id: 36, text: "Pediatric Surgeon" },
{ id: 37, text: "Physician" },
{ id: 38, text: "Plastic Surgeon" },
{ id: 39, text: "Psychiatrist" },
{ id: 40, text: "Pulmonologist" },
{ id: 41, text: "Radio technician" },
{ id: 42, text: "Radiologist" },
{ id: 43, text: "Rheumatologist" },
{ id: 44, text: "Sports Medicine Specialist" },
{ id: 45, text: "Thoraco-Vascular Surgeon" },
{
id: 46,
text: "Transfusion Medicine Specialist",
},
{ id: 47, text: "Urologist" },
{ id: 48, text: "Nurse" },
{ id: 5, text: "Others" },
];

export const MEDICAL_HISTORY_CHOICES: Array<OptionsType> = [
Expand Down
14 changes: 7 additions & 7 deletions src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import { BedCapacity } from "./BedCapacity";
import BedTypeCard from "./BedTypeCard";
import Card from "../../CAREUI/display/Card.js";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { DoctorCapacity } from "./DoctorCapacity";
import DoctorsCountCard from "./DoctorsCountCard";
import { StaffCapacity } from "./StaffCapacity.js";
import StaffCountCard from "./StaffCountCard.js";
import { FieldChangeEvent } from "../Form/FormFields/Utils";
import { FormAction } from "../Form/Utils.js";
import GLocationPicker from "../Common/GLocationPicker";
Expand Down Expand Up @@ -223,7 +223,7 @@ export const FacilityCreate = (props: FacilityProps) => {
},
{
id: 3,
name: "Doctor Capacity",
name: "Staff Capacity",
onClick: () => {
setCurrentStep(3);
},
Expand Down Expand Up @@ -597,7 +597,7 @@ export const FacilityCreate = (props: FacilityProps) => {
if (!doctorData || !doctorData.length) {
doctorList = (
<h5 className="flex w-full items-center justify-center rounded-lg bg-white p-4 text-xl font-bold text-gray-500 shadow">
{t("no_doctors")}
{t("no_staff")}
</h5>
);
} else {
Expand All @@ -612,7 +612,7 @@ export const FacilityCreate = (props: FacilityProps) => {
};

return (
<DoctorsCountCard
<StaffCountCard
facilityId={createdFacilityId || ""}
key={`bed_${data.id}`}
handleUpdate={async () => {
Expand Down Expand Up @@ -654,7 +654,7 @@ export const FacilityCreate = (props: FacilityProps) => {
>
<Steps steps={getSteps()} />
<div className="mt-3">
<DoctorCapacity
<StaffCapacity
key={docCapacityKey}
className="mx-auto w-full max-w-2xl"
facilityId={createdFacilityId || ""}
Expand All @@ -673,7 +673,7 @@ export const FacilityCreate = (props: FacilityProps) => {
</div>
<div className="mt-5 rounded bg-white p-3 shadow-sm md:p-6">
<div className="justify-between md:flex md:pb-2">
<div className="mb-2 text-xl font-bold">{t("doctors_list")}</div>
<div className="mb-2 text-xl font-bold">{t("staff_list")}</div>
</div>
<div className="mt-4" id="total-doctor-capacity">
{doctorList}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import request from "../../Utils/request/request.js";
import routes from "../../Redux/api.js";
import useQuery from "../../Utils/request/useQuery.js";
import { FacilityHomeTriage } from "./FacilityHomeTriage.js";
import { FacilityDoctorList } from "./FacilityDoctorList.js";
import { FacilityBedCapacity } from "./FacilityBedCapacity.js";
import useSlug from "../../Common/hooks/useSlug.js";
import { Popover, Transition } from "@headlessui/react";
import { FieldLabel } from "../Form/FormFields/FormField.js";
import { LocationSelect } from "../Common/LocationSelect.js";
import { CameraFeedPermittedUserTypes } from "../../Utils/permissions.js";
import { FacilityStaffList } from "./FacilityStaffList.js";

const Loading = lazy(() => import("../Common/Loading"));

Expand Down Expand Up @@ -463,7 +463,7 @@ export const FacilityHome = (props: any) => {
</div>
</div>
<FacilityBedCapacity facilityId={facilityId} />
<FacilityDoctorList facilityId={facilityId} />
<FacilityStaffList facilityId={facilityId} />

<div className="mt-5 rounded bg-white p-3 shadow-sm md:p-6">
<h1 className="mb-6 text-xl font-bold">Oxygen Information</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { DOCTOR_SPECIALIZATION } from "../../Common/constants";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import ButtonV2 from "../Common/components/ButtonV2";
import DialogModal from "../Common/Dialog";
import { DoctorCapacity } from "./DoctorCapacity";
import { StaffCapacity } from "./StaffCapacity";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";
import { DoctorModal } from "./models";
import DoctorsCountCard from "./DoctorsCountCard";
import DoctorsCountCard from "./StaffCountCard";
import { DoctorIcon } from "../TeleIcu/Icons/DoctorIcon";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { useTranslation } from "react-i18next";

export const FacilityDoctorList = (props: any) => {
export const FacilityStaffList = (props: any) => {
const { t } = useTranslation();
const [doctorCapacityModalOpen, setDoctorCapacityModalOpen] = useState(false);
const [totalDoctors, setTotalDoctors] = useState(0);

Expand All @@ -34,13 +36,12 @@ export const FacilityDoctorList = (props: any) => {
if (!doctorQuery.data || !doctorQuery.data.results.length) {
doctorList = (
<h5 className="flex w-full items-center justify-center rounded-lg bg-white p-4 text-xl font-bold text-gray-500 shadow">
No Doctors Found
{t("no_staff")}
</h5>
);
} else {
doctorList = (
<div className="mt-4 grid gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{/* Total Doctors Count Card */}
<div className="w-full">
<div className="flex h-full flex-col rounded-sm border border-primary-500 bg-primary-100 shadow-sm">
<div className="flex flex-1 items-center justify-start gap-3 px-4 py-6">
Expand All @@ -49,7 +50,7 @@ export const FacilityDoctorList = (props: any) => {
</div>
<div id="facility-doctor-totalcapacity">
<div className="text-sm font-medium text-[#808080]">
Total Doctors
Total Staff
</div>
<h2 className="mt-2 text-xl font-bold">{totalDoctors}</h2>
</div>
Expand Down Expand Up @@ -87,7 +88,7 @@ export const FacilityDoctorList = (props: any) => {
<section id="facility-doctor-capacity-details">
<div className="mt-5 rounded bg-white p-3 shadow-sm md:p-6">
<div className="justify-between md:flex md:pb-2">
<div className="mb-2 text-xl font-bold">Doctors List</div>
<div className="mb-2 text-xl font-bold">Staff Capacity</div>
<ButtonV2
id="facility-add-doctortype"
className="w-full md:w-auto"
Expand All @@ -96,7 +97,7 @@ export const FacilityDoctorList = (props: any) => {
authorizeFor={NonReadOnlyUsers}
>
<CareIcon icon="l-user-md" className="mr-2 text-base text-white" />
Add Doctor Types
Add Staff Types
</ButtonV2>
</div>
<div className="mt-4" id="facility-totaldoctor-capacity">
Expand All @@ -108,10 +109,10 @@ export const FacilityDoctorList = (props: any) => {
<DialogModal
show={doctorCapacityModalOpen}
onClose={() => setDoctorCapacityModalOpen(false)}
title="Add Doctor Capacity"
title="Add Staff Capacity"
className="max-w-md md:min-w-[600px]"
>
<DoctorCapacity
<StaffCapacity
facilityId={props.facilityId}
handleClose={() => setDoctorCapacityModalOpen(false)}
handleUpdate={async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useReducer, useState } from "react";
import { DOCTOR_SPECIALIZATION } from "../../Common/constants";
import { DOCTOR_SPECIALIZATION } from "../../Common/constants.js";
import * as Notification from "../../Utils/Notifications.js";
import ButtonV2, { Cancel } from "../Common/components/ButtonV2";
import { FieldErrorText, FieldLabel } from "../Form/FormFields/FormField";
import TextFormField from "../Form/FormFields/TextFormField";
import { FieldChangeEventHandler } from "../Form/FormFields/Utils";
import SelectMenuV2 from "../Form/SelectMenuV2";
import { DoctorModal } from "./models";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";
import request from "../../Utils/request/request";
import ButtonV2, { Cancel } from "../Common/components/ButtonV2.js";
import { FieldErrorText, FieldLabel } from "../Form/FormFields/FormField.js";
import TextFormField from "../Form/FormFields/TextFormField.js";
import { FieldChangeEventHandler } from "../Form/FormFields/Utils.js";
import SelectMenuV2 from "../Form/SelectMenuV2.js";
import { DoctorModal } from "./models.js";
import useQuery from "../../Utils/request/useQuery.js";
import routes from "../../Redux/api.js";
import request from "../../Utils/request/request.js";

interface DoctorCapacityProps extends DoctorModal {
facilityId: string;
Expand Down Expand Up @@ -57,7 +57,7 @@ const getAllowedDoctorTypes = (existing?: DoctorModal[]) => {
});
};

export const DoctorCapacity = (props: DoctorCapacityProps) => {
export const StaffCapacity = (props: DoctorCapacityProps) => {
const { facilityId, handleClose, handleUpdate, className, id } = props;
const [state, dispatch] = useReducer(doctorCapacityReducer, initialState);
const [isLoading, setIsLoading] = useState(false);
Expand All @@ -84,10 +84,10 @@ export const DoctorCapacity = (props: DoctorCapacityProps) => {
doctorTypes.filter((i) => i.disabled).length ===
DOCTOR_SPECIALIZATION.length - 1;

const headerText = !id ? "Add Doctor Capacity" : "Edit Doctor Capacity";
const headerText = !id ? "Add Staff Capacity" : "Edit Staff Capacity";
const buttonText = !id
? `Save ${!isLastOptionType ? "& Add More" : "Doctor Capacity"}`
: "Update Doctor Capacity";
? `Save ${!isLastOptionType ? "& Add More" : "Staff Capacity"}`
: "Update Staff Capacity";

const validateData = () => {
const errors = { ...initForm };
Expand All @@ -98,7 +98,7 @@ export const DoctorCapacity = (props: DoctorCapacityProps) => {
invalidForm = true;
}
if (field === "count" && state.form[field] < 0) {
errors[field] = "Doctor count cannot be negative";
errors[field] = "Staff count cannot be negative";
invalidForm = true;
}
});
Expand Down Expand Up @@ -139,9 +139,9 @@ export const DoctorCapacity = (props: DoctorCapacityProps) => {
specializationsQuery.refetch();
dispatch({ type: "set_form", form: initForm });
if (!id) {
Notification.Success({ msg: "Doctor count added successfully" });
Notification.Success({ msg: "Staff count added successfully" });
} else {
Notification.Success({ msg: "Doctor count updated successfully" });
Notification.Success({ msg: "Staff count updated successfully" });
}
}
handleUpdate();
Expand Down Expand Up @@ -177,13 +177,15 @@ export const DoctorCapacity = (props: DoctorCapacityProps) => {
) : (
<div className={className}>
<div>
<FieldLabel className="mb-2" required={true}>
Area of specialization
<FieldLabel className="mb-2" required>
Staff Type
</FieldLabel>
<SelectMenuV2
id="area-of-specialization"
value={doctorTypes.find((type) => type.id == state.form.area)?.id}
options={doctorTypes.filter((type) => !type.disabled)}
options={
id ? doctorTypes : doctorTypes.filter((type) => !type.disabled)
}
optionLabel={(option) => option.text}
optionValue={(option) => option.id}
requiredError={state.errors.area.length !== 0}
Expand Down Expand Up @@ -212,9 +214,9 @@ export const DoctorCapacity = (props: DoctorCapacityProps) => {
</div>
<div className="cui-form-button-group mt-4">
<Cancel onClick={() => handleClose()} />
{!isLastOptionType && headerText === "Add Doctor Capacity" && (
{!isLastOptionType && headerText === "Add Staff Capacity" && (
<ButtonV2 id="save-and-exit" onClick={handleSubmit}>
Save Doctor Capacity
Save Staff Capacity
</ButtonV2>
)}
<ButtonV2 id="doctor-save" onClick={handleSubmit}>
Expand Down

0 comments on commit c8a1549

Please sign in to comment.