diff --git a/README.md b/README.md
index 7f2c3e926bd..c1dd7f37564 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ Authenticate to staging API with any of the following credentials
- username: staffdev
password: Coronasafe@123
- role: Staff
+ role: Nurse
- username: doctordev
password: Coronasafe@123
diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx
index 55a35bef9ab..3cb972641b5 100644
--- a/src/Common/constants.tsx
+++ b/src/Common/constants.tsx
@@ -28,6 +28,8 @@ export type UserRole =
| "Volunteer"
| "StaffReadOnly"
| "Staff"
+ | "NurseReadOnly"
+ | "Nurse"
| "Doctor"
| "WardAdmin"
| "LocalBodyAdmin"
@@ -47,6 +49,8 @@ export const USER_TYPE_OPTIONS: {
{ id: "Volunteer", role: "Volunteer", readOnly: false },
{ id: "StaffReadOnly", role: "Staff", readOnly: true },
{ id: "Staff", role: "Staff", readOnly: false },
+ { id: "NurseReadOnly", role: "Nurse", readOnly: true },
+ { id: "Nurse", role: "Nurse", readOnly: false },
{ id: "Doctor", role: "Doctor", readOnly: false },
{ id: "WardAdmin", role: "Ward Admin", readOnly: false },
{ id: "LocalBodyAdmin", role: "Local Body Admin", readOnly: false },
@@ -418,24 +422,6 @@ export const SAMPLE_FLOW_RULES = {
RECEIVED_AT_LAB: ["COMPLETED"],
};
-export const ROLE_STATUS_MAP = {
- Staff: ["SENT_TO_COLLECTON_CENTRE"],
- DistrictAdmin: [
- "APPROVED",
- "DENIED",
- "SENT_TO_COLLECTON_CENTRE",
- "RECEIVED_AND_FORWARED",
- ],
- StateLabAdmin: [
- "APPROVED",
- "DENIED",
- "SENT_TO_COLLECTON_CENTRE",
- "RECEIVED_AND_FORWARED",
- "RECEIVED_AT_LAB",
- "COMPLETED",
- ],
-};
-
export const DISEASE_STATUS = [
"POSITIVE",
"SUSPECTED",
diff --git a/src/Components/Common/Sidebar/Sidebar.tsx b/src/Components/Common/Sidebar/Sidebar.tsx
index fa809571772..9d378df4267 100644
--- a/src/Components/Common/Sidebar/Sidebar.tsx
+++ b/src/Components/Common/Sidebar/Sidebar.tsx
@@ -8,6 +8,7 @@ import useConfig from "../../../Common/hooks/useConfig";
import SlideOver from "../../../CAREUI/interactive/SlideOver";
import { classNames } from "../../../Utils/utils";
import { Link } from "raviger";
+import useAuthUser from "../../../Common/hooks/useAuthUser";
export const SIDEBAR_SHRINK_PREFERENCE_KEY = "sidebarShrinkPreference";
@@ -27,28 +28,36 @@ type StatelessSidebarProps =
onItemClick: (open: boolean) => void;
};
-const NavItems = [
- { text: "Facilities", to: "/facility", icon: "care-l-hospital" },
- { text: "Patients", to: "/patients", icon: "care-l-user-injured" },
- { text: "Assets", to: "/assets", icon: "care-l-shopping-cart-alt" },
- { text: "Sample Test", to: "/sample", icon: "care-l-medkit" },
- { text: "Shifting", to: "/shifting", icon: "care-l-ambulance" },
- { text: "Resource", to: "/resource", icon: "care-l-heart-medical" },
- {
- text: "External Results",
- to: "/external_results",
- icon: "care-l-clipboard-notes",
- },
- { text: "Users", to: "/users", icon: "care-l-users-alt" },
- { text: "Notice Board", to: "/notice_board", icon: "care-l-meeting-board" },
-];
-
const StatelessSidebar = ({
shrinkable = false,
shrinked = false,
setShrinked,
onItemClick,
}: StatelessSidebarProps) => {
+ const authUser = useAuthUser();
+
+ const NavItems = [
+ { text: "Facilities", to: "/facility", icon: "care-l-hospital" },
+ { text: "Patients", to: "/patients", icon: "care-l-user-injured" },
+ { text: "Assets", to: "/assets", icon: "care-l-shopping-cart-alt" },
+ { text: "Sample Test", to: "/sample", icon: "care-l-medkit" },
+ { text: "Shifting", to: "/shifting", icon: "care-l-ambulance" },
+ { text: "Resource", to: "/resource", icon: "care-l-heart-medical" },
+ ...(!["Nurse", "NurseReadOnly", "Staff", "StaffReadOnly"].includes(
+ authUser.user_type
+ )
+ ? [
+ {
+ text: "External Results",
+ to: "/external_results",
+ icon: "care-l-clipboard-notes",
+ },
+ ]
+ : []),
+ { text: "Users", to: "/users", icon: "care-l-users-alt" },
+ { text: "Notice Board", to: "/notice_board", icon: "care-l-meeting-board" },
+ ];
+
const { main_logo } = useConfig();
const activeLink = useActiveLink();
const Item = shrinked ? ShrinkedSidebarItem : SidebarItem;
diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx
index 8fddc7cadc9..9a04fcf38b6 100644
--- a/src/Components/ExternalResult/ResultList.tsx
+++ b/src/Components/ExternalResult/ResultList.tsx
@@ -16,9 +16,12 @@ import Page from "../Common/components/Page";
import routes from "../../Redux/api";
import useQuery from "../../Utils/request/useQuery";
import { parsePhoneNumber } from "../../Utils/utils";
+import useAuthUser from "../../Common/hooks/useAuthUser";
+import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
const Loading = lazy(() => import("../Common/Loading"));
export default function ResultList() {
+ const authUser = useAuthUser();
const {
qParams,
updateQuery,
@@ -165,6 +168,10 @@ export default function ResultList() {
{
@@ -226,13 +233,18 @@ export default function ResultList() {
navigate("/external_results/upload"),
- options: {
- icon: ,
- },
- },
+ ...(authUser.user_type !== "Nurse" &&
+ authUser.user_type !== "Staff"
+ ? [
+ {
+ label: "Import Results",
+ action: () => navigate("/external_results/upload"),
+ options: {
+ icon: ,
+ },
+ },
+ ]
+ : []),
{
label: "Export Results",
action: () =>
diff --git a/src/Components/Facility/DoctorVideoSlideover.tsx b/src/Components/Facility/DoctorVideoSlideover.tsx
index f16b7ba1811..c2cd94e0ded 100644
--- a/src/Components/Facility/DoctorVideoSlideover.tsx
+++ b/src/Components/Facility/DoctorVideoSlideover.tsx
@@ -62,8 +62,8 @@ export default function DoctorVideoSlideover(props: {
home: true,
},
{
- title: "Staff",
- user_type: "Staff",
+ title: "Nurse",
+ user_type: "Nurse",
home: true,
},
{
diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx
index af5c5398cb0..0f9a6656f67 100644
--- a/src/Components/Patient/ManagePatients.tsx
+++ b/src/Components/Patient/ManagePatients.tsx
@@ -537,12 +537,9 @@ export const PatientManager = () => {
? PATIENT_CATEGORIES.find((c) => c.text === category)?.twClass
: "patient-unknown";
- return (
-
{
)}
+
+ );
+
+ if (
+ authUser.user_type === "Staff" ||
+ authUser.user_type === "StaffReadOnly"
+ ) {
+ return children;
+ }
+
+ return (
+
+ {children}
);
});
diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx
index 546d35cc487..ce63d5019de 100644
--- a/src/Components/Patient/PatientRegister.tsx
+++ b/src/Components/Patient/PatientRegister.tsx
@@ -70,6 +70,7 @@ import useConfig from "../../Common/hooks/useConfig";
import { useDispatch } from "react-redux";
import { validatePincode } from "../../Common/validation";
import { FormContextValue } from "../Form/FormContext.js";
+import useAuthUser from "../../Common/hooks/useAuthUser.js";
const Loading = lazy(() => import("../Common/Loading"));
const PageTitle = lazy(() => import("../Common/PageTitle"));
@@ -180,6 +181,7 @@ const patientFormReducer = (state = initialState, action: any) => {
};
export const PatientRegister = (props: PatientRegisterProps) => {
+ const authUser = useAuthUser();
const { goBack } = useAppHistory();
const { gov_data_api_key, enable_hcx, enable_abdm } = useConfig();
const dispatchAction: any = useDispatch();
@@ -1173,6 +1175,10 @@ export const PatientRegister = (props: PatientRegisterProps) => {
{
setShowImport({
show: true,
diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx
index 26ba9e44b4b..2c5319e67f3 100644
--- a/src/Components/Users/UserAdd.tsx
+++ b/src/Components/Users/UserAdd.tsx
@@ -99,6 +99,13 @@ const initForm: UserForm = {
doctor_medical_council_registration: undefined,
};
+const STAFF_OR_NURSE_USER = [
+ "Staff",
+ "StaffReadOnly",
+ "Nurse",
+ "NurseReadOnly",
+];
+
const initError = Object.assign(
{},
...Object.keys(initForm).map((k) => ({ [k]: "" }))
@@ -234,15 +241,19 @@ export const UserAdd = (props: UserProps) => {
: // Exception to allow Staff to Create Doctors
defaultAllowedUserTypes;
+ // TODO: refactor lines 227 through 248 to be more readable. This is messy.
+ if (authUser.user_type === "Nurse" || authUser.user_type === "Staff") {
+ userTypes.push(USER_TYPE_OPTIONS[6]); // Temperorily allows creation of users with elevated permissions due to introduction of new roles.
+ }
+
const headerText = !userId ? "Add User" : "Update User";
const buttonText = !userId ? "Save User" : "Update Details";
- const showLocalbody = !(
- state.form.user_type === "Pharmacist" ||
- state.form.user_type === "Volunteer" ||
- state.form.user_type === "Doctor" ||
- state.form.user_type === "Staff" ||
- state.form.user_type === "StaffReadOnly"
- );
+ const showLocalbody = ![
+ "Pharmacist",
+ "Volunteer",
+ "Doctor",
+ ...STAFF_OR_NURSE_USER,
+ ].includes(state.form.user_type);
const { loading: isDistrictLoading } = useQuery(routes.getDistrictByState, {
prefetch: !!(selectedStateId > 0),
@@ -332,10 +343,8 @@ export const UserAdd = (props: UserProps) => {
case "facilities":
if (
state.form[field].length === 0 &&
- (authUser.user_type === "Staff" ||
- authUser.user_type === "StaffReadOnly") &&
- (state.form["user_type"] === "Staff" ||
- state.form["user_type"] === "StaffReadOnly")
+ STAFF_OR_NURSE_USER.includes(authUser.user_type) &&
+ STAFF_OR_NURSE_USER.includes(state.form.user_type)
) {
errors[field] =
"Please select atleast one of the facilities you are linked to";
diff --git a/src/Routers/AppRouter.tsx b/src/Routers/AppRouter.tsx
index 5e238627bc8..56d8b31573b 100644
--- a/src/Routers/AppRouter.tsx
+++ b/src/Routers/AppRouter.tsx
@@ -25,13 +25,13 @@ import AssetRoutes from "./routes/AssetRoutes";
import ResourceRoutes from "./routes/ResourceRoutes";
import ExternalResultRoutes from "./routes/ExternalResultRoutes";
import { DetailRoute } from "./types";
+import useAuthUser from "../Common/hooks/useAuthUser";
const Routes = {
"/": () => ,
...AssetRoutes,
...ConsultationRoutes,
- ...ExternalResultRoutes,
...FacilityRoutes,
...PatientRoutes,
...ResourceRoutes,
@@ -49,6 +49,7 @@ const Routes = {
};
export default function AppRouter() {
+ const authUser = useAuthUser();
const { main_logo, enable_hcx } = useConfig();
let routes = Routes;
@@ -57,6 +58,14 @@ export default function AppRouter() {
routes = { ...routes, ...HCXRoutes };
}
+ if (
+ !["Nurse", "NurseReadOnly", "Staff", "StaffReadOnly"].includes(
+ authUser.user_type
+ )
+ ) {
+ routes = { ...routes, ...ExternalResultRoutes };
+ }
+
useRedirect("/user", "/users");
const pages = useRoutes(routes) || ;
const path = usePath();
|