Skip to content

Commit

Permalink
Merge branch 'develop' into issue#5271
Browse files Browse the repository at this point in the history
  • Loading branch information
aeswibon authored May 4, 2023
2 parents b31a104 + 9628624 commit 087b040
Show file tree
Hide file tree
Showing 49 changed files with 2,202 additions and 1,357 deletions.
29 changes: 22 additions & 7 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PatientCategory } from "../Components/Facility/models";
import { parsePhoneNumberFromString } from "libphonenumber-js";
import moment from "moment";
import { IConfig } from "./hooks/useConfig";
import { PatientCategory } from "../Components/Facility/models";
import { SortOption } from "../Components/Common/SortDropdown";
import moment from "moment";
import { parsePhoneNumberFromString } from "libphonenumber-js";

export const RESULTS_PER_PAGE_LIMIT = 14;
export const PAGINATION_LIMIT = 36;
Expand All @@ -17,6 +17,7 @@ export const LocalStorageKeys = {
export interface OptionsType {
id: number;
text: string;
label?: string;
desc?: string;
disabled?: boolean;
}
Expand Down Expand Up @@ -135,8 +136,8 @@ export const FACILITY_TYPES: Array<OptionsType> = [
// { id: 1600, text: "District War Room" },
];

export const SHIFTING_CHOICES: Array<OptionsType> = [
{ id: 10, text: "PENDING" },
export const SHIFTING_CHOICES_WARTIME: Array<OptionsType> = [
{ id: 10, text: "PENDING", label: "SHIFTING APPROVAL PENDING" },
{ id: 15, text: "ON HOLD" },
{ id: 20, text: "APPROVED" },
{ id: 30, text: "REJECTED" },
Expand All @@ -146,6 +147,19 @@ export const SHIFTING_CHOICES: Array<OptionsType> = [
{ id: 60, text: "PATIENT TO BE PICKED UP" },
{ id: 70, text: "TRANSFER IN PROGRESS" },
{ id: 80, text: "COMPLETED" },
{ id: 90, text: "PATIENT EXPIRED" },
{ id: 100, text: "CANCELLED" },
];

export const SHIFTING_CHOICES_PEACETIME: Array<OptionsType> = [
{ id: 20, text: "APPROVED", label: "PATIENTS TO BE SHIFTED" },
{ id: 40, text: "DESTINATION APPROVED" },
// { id: 50, text: "DESTINATION REJECTED" },
{ id: 60, text: "PATIENT TO BE PICKED UP", label: "TRANSPORTATION ARRANGED" },
{ id: 70, text: "TRANSFER IN PROGRESS" },
{ id: 80, text: "COMPLETED" },
{ id: 90, text: "PATIENT EXPIRED" },
{ id: 100, text: "CANCELLED" },
];

export const SHIFTING_VEHICLE_CHOICES: Array<OptionsType> = [
Expand Down Expand Up @@ -474,7 +488,8 @@ export const ICMR_CATEGORY = [
];

export const TELEMEDICINE_ACTIONS = [
{ id: 10, text: "PENDING", desc: "Pending" },
{ id: 10, text: "NO_ACTION", desc: "No Action" },
{ id: 20, text: "PENDING", desc: "Pending" },
{ id: 30, text: "SPECIALIST_REQUIRED", desc: "Specialist Required" },
{ id: 40, text: "PLAN_FOR_HOME_CARE", desc: "Plan for Home Care" },
{ id: 50, text: "FOLLOW_UP_NOT_REQUIRED", desc: "Follow Up Not Required" },
Expand Down Expand Up @@ -676,7 +691,7 @@ export const CONSULTATION_TABS: Array<OptionsType> = [
{ id: 6, text: "ABG", desc: "ABG" },
{ id: 7, text: "NURSING", desc: "Nursing" },
{ id: 8, text: "NEUROLOGICAL_MONITORING", desc: "Neurological Monitoring" },
{ id: 9, text: "VENTILATOR", desc: "Ventilator" },
{ id: 9, text: "VENTILATOR", desc: "Respiratory Support" },
{ id: 10, text: "NUTRITION", desc: "Nutrition" },
{ id: 11, text: "PRESSURE_SORE", desc: "Pressure Sore" },
{ id: 12, text: "DIALYSIS", desc: "Dialysis" },
Expand Down
4 changes: 4 additions & 0 deletions src/Common/hooks/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export interface IConfig {
* Env to enable HCX features
*/
enable_hcx: boolean;
/**
* Env to toggle peacetime and wartime shifting
*/
wartime_shifting: boolean;
}

const useConfig = () => {
Expand Down
12 changes: 8 additions & 4 deletions src/Components/Assets/AssetManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useTranslation } from "react-i18next";
const PageTitle = loadable(() => import("../Common/PageTitle"));
const Loading = loadable(() => import("../Common/Loading"));
import * as Notification from "../../Utils/Notifications.js";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";

interface AssetManageProps {
assetId: string;
Expand Down Expand Up @@ -324,9 +325,10 @@ const AssetManage = (props: AssetManageProps) => {
)
}
id="update-asset"
authorizeFor={NonReadOnlyUsers}
>
<CareIcon className="care-l-pen h-4 mr-1" />
Update
{t("update")}
</ButtonV2>
{asset?.asset_class && (
<ButtonV2
Expand All @@ -336,19 +338,21 @@ const AssetManage = (props: AssetManageProps) => {
)
}
id="configure-asset"
authorizeFor={NonReadOnlyUsers}
>
<CareIcon className="care-l-setting h-4" />
Configure
{t("configure")}
</ButtonV2>
)}
{checkAuthority(user_type, "DistrictAdmin") && (
<ButtonV2
authorizeFor={NonReadOnlyUsers}
onClick={() => setShowDeleteDialog(true)}
variant={"danger"}
variant="danger"
className="inline-flex"
>
<CareIcon className="care-l-trash h-4" />
<span className="md:hidden">Delete</span>
<span className="md:hidden">{t("delete")}</span>
</ButtonV2>
)}
</div>
Expand Down
20 changes: 16 additions & 4 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ import useFilters from "../../Common/hooks/useFilters";
import { FacilityModel } from "../Facility/models";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { useIsAuthorized } from "../../Common/hooks/useIsAuthorized";
import AuthorizeFor from "../../Utils/AuthorizeFor";
import AuthorizeFor, { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import ButtonV2 from "../Common/components/ButtonV2";
import FacilitiesSelectDialogue from "../ExternalResult/FacilitiesSelectDialogue";
import ExportMenu from "../Common/Export";
import CountBlock from "../../CAREUI/display/Count";
import AssetImportModal from "./AssetImportModal";
import Page from "../Common/components/Page";
import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover";
import { useTranslation } from "react-i18next";

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

const AssetsList = () => {
const { t } = useTranslation();
const {
qParams,
updateQuery,
Expand All @@ -48,6 +50,7 @@ const AssetsList = () => {
const [totalCount, setTotalCount] = useState(0);
const [facility, setFacility] = useState<FacilityModel>();
const [asset_type, setAssetType] = useState<string>();
const [facilityName, setFacilityName] = useState<string>();
const [asset_class, setAssetClass] = useState<string>();
const [locationName, setLocationName] = useState<string>();
const [importAssetModalOpen, setImportAssetModalOpen] = useState(false);
Expand Down Expand Up @@ -118,6 +121,14 @@ const AssetsList = () => {
},
[dispatch, fetchData]
);
useEffect(() => {
async function fetchFacilityName() {
if (!qParams.facility) return setFacilityName("");
const res = await dispatch(getAnyFacility(qParams.facility, "facility"));
setFacilityName(res?.data?.name);
}
fetchFacilityName();
}, [dispatch, qParams.facility]);

const fetchFacility = useCallback(
async (status: statusType) => {
Expand Down Expand Up @@ -352,6 +363,7 @@ const AssetsList = () => {
</div>
<div className="flex flex-col md:flex-row w-full">
<ButtonV2
authorizeFor={NonReadOnlyUsers}
className="w-full inline-flex items-center justify-center"
onClick={() => {
if (qParams.facility) {
Expand All @@ -362,19 +374,19 @@ const AssetsList = () => {
}}
>
<CareIcon className="care-l-plus-circle text-lg" />
<span>Create Asset</span>
<span>{t("create_asset")}</span>
</ButtonV2>
</div>
</div>
</div>
<AssetFilter {...advancedFilter} />
<AssetFilter {...advancedFilter} key={window.location.search} />
{isLoading ? (
<Loading />
) : (
<>
<FilterBadges
badges={({ badge, value }) => [
value("Facility", ["facility", "location"], facility?.name || ""),
value("Facility", "facility", facilityName || ""),
badge("Name/Serial No./QR ID", "search"),
value("Asset Type", "asset_type", asset_type || ""),
value("Asset Class", "asset_class", asset_class || ""),
Expand Down
69 changes: 46 additions & 23 deletions src/Components/Common/components/ButtonV2.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Link } from "raviger";
import { useTranslation } from "react-i18next";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import AuthorizedChild from "../../../CAREUI/misc/AuthorizedChild";
import { AuthorizedElementProps } from "../../../Utils/AuthorizeFor";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import { Link } from "raviger";
import { classNames } from "../../../Utils/utils";
import { useTranslation } from "react-i18next";

export type ButtonSize = "small" | "default" | "large";
export type ButtonShape = "square" | "circle";
Expand Down Expand Up @@ -75,6 +75,14 @@ export type ButtonProps = RawButtonProps &
* Whether the button should be having a Id.
*/
id?: string | undefined;
/**
* Tooltip showed when hovered over.
*/
tooltip?: string;
/**
* Class for tooltip
*/
tooltipClassName?: string;
};

const ButtonV2 = ({
Expand All @@ -91,6 +99,8 @@ const ButtonV2 = ({
children,
href,
target,
tooltip,
tooltipClassName,
...props
}: ButtonProps) => {
const className = classNames(
Expand All @@ -101,36 +111,49 @@ const ButtonV2 = ({
`button-shape-${circle ? "circle" : "square"}`,
ghost ? `button-${variant}-ghost` : `button-${variant}-default`,
border && `button-${variant}-border`,
shadow && "shadow enabled:hover:shadow-lg"
shadow && "shadow enabled:hover:shadow-lg",
tooltip && "tooltip"
);

if (authorizeFor) {
<AuthorizedChild authorizeFor={authorizeFor}>
{({ isAuthorized }) => (
<button
{...props}
disabled={disabled || !isAuthorized || loading}
className={className}
>
{children}
</button>
)}
</AuthorizedChild>;
if (tooltip) {
children = (
<>
{tooltip && (
<span className={classNames("tooltip-text", tooltipClassName)}>
{tooltip}
</span>
)}
{children}
</>
);
}

if (href && !(disabled || loading)) {
return (
<Link
{...(props as any)}
href={href}
target={target}
className={className}
>
{children}
<Link href={href} target={target}>
<button {...props} disabled={disabled || loading} className={className}>
{children}
</button>
</Link>
);
}

if (authorizeFor) {
return (
<AuthorizedChild authorizeFor={authorizeFor}>
{({ isAuthorized }) => (
<button
{...props}
disabled={disabled || !isAuthorized || loading}
className={className}
>
{children}
</button>
)}
</AuthorizedChild>
);
}

return (
<button {...props} disabled={disabled || loading} className={className}>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type editor =
| PressureSoreEditor
| NursingCareEditor
| MedicineEditor
| OthersEditor

type state = {
visibleEditor: option<editor>,
Expand Down Expand Up @@ -55,7 +54,6 @@ let editorNameToString = editor => {
| PressureSoreEditor => "Pressure Sore"
| NursingCareEditor => "Nursing Care"
| MedicineEditor => "Medicine"
| OthersEditor => "Others"
}
}

Expand Down Expand Up @@ -221,13 +219,6 @@ let make = (~id, ~facilityId, ~patientId, ~consultationId, ~dailyRound) => {
id
consultationId
/>
| OthersEditor =>
<CriticalCare__OthersEditor
others={CriticalCare__DailyRound.others(state.dailyRound)}
updateCB={updateDailyRound(send, OthersEditor)}
id
consultationId
/>
}}
</div>
</div>
Expand All @@ -249,7 +240,6 @@ let make = (~id, ~facilityId, ~patientId, ~consultationId, ~dailyRound) => {
PressureSoreEditor,
NursingCareEditor,
MedicineEditor,
OthersEditor,
])->React.array}
</div>
<Link
Expand Down
Loading

0 comments on commit 087b040

Please sign in to comment.