Skip to content

Commit

Permalink
Merge branch 'develop' into issues/7767/DiscontinuedPrescriptionColla…
Browse files Browse the repository at this point in the history
…psed
  • Loading branch information
rithviknishad committed May 22, 2024
2 parents 5b1965d + a9530a9 commit d83c537
Show file tree
Hide file tree
Showing 13 changed files with 166 additions and 274 deletions.
20 changes: 20 additions & 0 deletions src/CAREUI/misc/AuthorizedChild.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ReactNode } from "react";
import useAuthUser from "../../Common/hooks/useAuthUser";
import { useIsAuthorized } from "../../Common/hooks/useIsAuthorized";
import useSlug from "../../Common/hooks/useSlug";
import { AuthorizedForCB } from "../../Utils/AuthorizeFor";

interface Props {
Expand All @@ -12,3 +15,20 @@ const AuthorizedChild = (props: Props) => {
};

export default AuthorizedChild;

export const AuthorizedForConsultationRelatedActions = (props: {
children: ReactNode;
}) => {
const me = useAuthUser();
const facilityId = useSlug("facility");

if (
me.home_facility_object?.id === facilityId ||
me.user_type === "DistrictAdmin" ||
me.user_type === "StateAdmin"
) {
return props.children;
}

return null;
};
9 changes: 6 additions & 3 deletions src/Components/CriticalCareRecording/components/Slider.res
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ let make = (
let (text, setText) = React.useState(() => "Normal")
let (precision, setPrecision) = React.useState(() => 1)
let (displayValue, setDisplayValue) = React.useState(() => value)
let justifyContentClassName = title != "" ? "justify-between" : "justify-center"
let alignItemClassName = title != "" ? "items-end" : "items-center"
let boxWidthClassName = title != "" ? "" : "w-16"

React.useEffect1(() => {
let (text, color) = getLabel(value->Belt.Float.fromString->Belt.Option.getWithDefault(0.0))
Expand Down Expand Up @@ -76,11 +79,11 @@ let make = (

<>
<section className={"slider-box " ++ className}>
<div className="slider-head flex justify-between flex-col sm:flex-row sm:items-center">
<div className={"slider-head flex flex-col sm:flex-row sm:items-center " ++ justifyContentClassName}>
<div className="flex items-center">
<h1 className="m-2"> {title->str} </h1> titleNeighbour
</div>
<div className="flex flex-col items-end mt-2 sm:mt-0">
<div className={"flex flex-col mt-2 sm:mt-0 " ++ alignItemClassName}>
<label htmlFor="measure" style={ReactDOM.Style.make(~color=textColor, ())}>
{switch value->Belt.Float.fromString {
| Some(_) => text->str
Expand All @@ -93,7 +96,7 @@ let make = (
step={step}
max={end}
min={start}
className="focus:outline-none focus:bg-white focus:ring-primary-500"
className={"focus:outline-none focus:bg-white focus:ring-primary-500 " ++ boxWidthClassName}
value={displayValue}
onChange={event =>
setValue(
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Facility/CentralNursingStation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export default function CentralNursingStation({ facilityId }: Props) {
asset_class: "HL7MONITOR",
ordering: qParams.ordering || "bed__name",
bed_is_occupied:
(qParams.hide_monitors_without_patient ?? "true") === "true",
(qParams.hide_monitors_without_patient ?? "true") === "true" ||
undefined,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,13 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
<div className="overflow-x-auto overflow-y-hidden">
<PrescriptionsTable
is_prn={false}
readonly
prescription_type="DISCHARGE"
/>
</div>
<hr className="my-2 border border-gray-300"></hr>
<div className="overflow-x-auto overflow-y-hidden">
<PrescriptionsTable
is_prn
readonly
prescription_type="DISCHARGE"
/>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Facility/Consultations/Beds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ const Beds = (props: BedsProps) => {
loading={loading}
/>
) : (
<div className="bg-primary-100 py-2 text-center">
No beds allocated yet
<div className="flex w-full justify-center border-2 border-gray-200 bg-white p-5 text-center text-2xl font-bold text-gray-500">
<span className="flex justify-center rounded-lg bg-white p-3 text-gray-700">
No beds allocated yet
</span>
</div>
)}
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Facility/PatientConsultationNotesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => {

const fetchNotes = async () => {
setIsLoading(true);

const { data } = await request(routes.getPatientNotes, {
pathParams: {
patientId: props.state.patientId || "",
Expand Down Expand Up @@ -80,7 +81,7 @@ const PatientConsultationNotesList = (props: PatientNotesProps) => {
}
};

if (isLoading && !state.notes.length) {
if (isLoading) {
return (
<div className="flex h-full w-full items-center justify-center bg-white">
<CircularProgress />
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/PatientNotesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const PatientNotesList = (props: PatientNotesProps) => {
}
};

if (isLoading && !state.notes.length) {
if (isLoading) {
return (
<div className="flex h-full w-full items-center justify-center bg-white">
<CircularProgress />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import CareIcon from "../../../CAREUI/icons/CareIcon";
import EditPrescriptionForm from "../EditPrescriptionForm";
import AdministrationEventSeperator from "./AdministrationEventSeperator";
import AdministrationEventCell from "./AdministrationEventCell";
import { AuthorizedForConsultationRelatedActions } from "../../../CAREUI/misc/AuthorizedChild";

interface Props {
prescription: Prescription;
Expand Down Expand Up @@ -93,46 +94,48 @@ export default function MedicineAdministrationTableRow({
onClick={() => setShowDetails(false)}
label={t("close")}
/>
{!props.readonly && (
<>
<Submit
disabled={
prescription.discontinued ||
prescription.prescription_type === "DISCHARGE"
}
variant="danger"
onClick={() => setShowDiscontinue(true)}
>
<CareIcon icon="l-ban" className="text-lg" />
{t("discontinue")}
</Submit>
<Submit
disabled={
prescription.discontinued ||
prescription.prescription_type === "DISCHARGE"
}
variant="secondary"
border
onClick={() => {
setShowDetails(false);
setShowEdit(true);
}}
>
<CareIcon icon="l-pen" className="text-lg" />
{t("edit")}
</Submit>
<Submit
disabled={
prescription.discontinued ||
prescription.prescription_type === "DISCHARGE"
}
onClick={() => setShowAdminister(true)}
>
<CareIcon icon="l-syringe" className="text-lg" />
{t("administer")}
</Submit>
</>
)}
<AuthorizedForConsultationRelatedActions>
{!props.readonly && (
<>
<Submit
disabled={
prescription.discontinued ||
prescription.prescription_type === "DISCHARGE"
}
variant="danger"
onClick={() => setShowDiscontinue(true)}
>
<CareIcon icon="l-ban" className="text-lg" />
{t("discontinue")}
</Submit>
<Submit
disabled={
prescription.discontinued ||
prescription.prescription_type === "DISCHARGE"
}
variant="secondary"
border
onClick={() => {
setShowDetails(false);
setShowEdit(true);
}}
>
<CareIcon icon="l-pen" className="text-lg" />
{t("edit")}
</Submit>
<Submit
disabled={
prescription.discontinued ||
prescription.prescription_type === "DISCHARGE"
}
onClick={() => setShowAdminister(true)}
>
<CareIcon icon="l-syringe" className="text-lg" />
{t("administer")}
</Submit>
</>
)}
</AuthorizedForConsultationRelatedActions>
</div>
</div>
</DialogModal>
Expand Down Expand Up @@ -252,18 +255,20 @@ export default function MedicineAdministrationTableRow({

{/* Action Buttons */}
<td className="space-x-1 pr-2 text-right">
{!props.readonly && (
<ButtonV2
type="button"
size="small"
disabled={prescription.discontinued}
ghost
border
onClick={() => setShowAdminister(true)}
>
{t("administer")}
</ButtonV2>
)}
<AuthorizedForConsultationRelatedActions>
{!props.readonly && (
<ButtonV2
type="button"
size="small"
disabled={prescription.discontinued}
ghost
border
onClick={() => setShowAdminister(true)}
>
{t("administer")}
</ButtonV2>
)}
</AuthorizedForConsultationRelatedActions>
</td>
</tr>
</>
Expand Down
5 changes: 3 additions & 2 deletions src/Components/Medicine/MedicineAdministrationSheet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useRangePagination from "../../../Common/hooks/useRangePagination";
import MedicineAdministrationTable from "./AdministrationTable";
import Loading from "../../Common/Loading";
import ScrollOverlay from "../../../CAREUI/interactive/ScrollOverlay";
import { AuthorizedForConsultationRelatedActions } from "../../../CAREUI/misc/AuthorizedChild";

interface Props {
readonly?: boolean;
Expand Down Expand Up @@ -89,7 +90,7 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => {
options={
!readonly &&
!!data?.results && (
<>
<AuthorizedForConsultationRelatedActions>
<ButtonV2
id="edit-prescription"
variant="secondary"
Expand All @@ -107,7 +108,7 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => {
prescriptions={data.results}
onDone={() => refetch()}
/>
</>
</AuthorizedForConsultationRelatedActions>
)
}
/>
Expand Down
36 changes: 22 additions & 14 deletions src/Components/Medicine/PrescriptionBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useTranslation } from "react-i18next";
import useQuery from "../../Utils/request/useQuery";
import MedicineRoutes from "./routes";
import useSlug from "../../Common/hooks/useSlug";
import { AuthorizedForConsultationRelatedActions } from "../../CAREUI/misc/AuthorizedChild";

interface Props {
prescription_type?: Prescription["prescription_type"];
Expand Down Expand Up @@ -76,20 +77,27 @@ export default function PrescriptionBuilder({
/>
))}
</div>
<ButtonV2
type="button"
onClick={() => setShowCreate(true)}
variant="secondary"
className="mt-4 w-full bg-gray-200 text-gray-700 hover:bg-gray-300 hover:text-gray-900 focus:bg-gray-100 focus:text-gray-900"
disabled={disabled}
>
<div className="flex w-full justify-start gap-2" id="add-prescription">
<CareIcon icon="l-plus" className="text-lg" />
<span className="font-bold">
{t(is_prn ? "add_prn_prescription" : "add_prescription_medication")}
</span>
</div>
</ButtonV2>
<AuthorizedForConsultationRelatedActions>
<ButtonV2
type="button"
onClick={() => setShowCreate(true)}
variant="secondary"
className="mt-4 w-full bg-gray-200 text-gray-700 hover:bg-gray-300 hover:text-gray-900 focus:bg-gray-100 focus:text-gray-900"
disabled={disabled}
>
<div
className="flex w-full justify-start gap-2"
id="add-prescription"
>
<CareIcon icon="l-plus" className="text-lg" />
<span className="font-bold">
{t(
is_prn ? "add_prn_prescription" : "add_prescription_medication",
)}
</span>
</div>
</ButtonV2>
</AuthorizedForConsultationRelatedActions>
{showCreate && (
<DialogModal
onClose={() => setShowCreate(false)}
Expand Down
Loading

0 comments on commit d83c537

Please sign in to comment.