Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OH2-222 | Align with they latest api spec file and add ward in visit form and table #507

Merged
merged 7 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,383 changes: 2,623 additions & 2,760 deletions api/oh.yaml

Large diffs are not rendered by default.

21 changes: 3 additions & 18 deletions src/components/accessories/laboratory/Exams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const Exams: FC = () => {
};

const onEdit = (row: LaboratoryDTO) => {
if (row.status === LaboratoryDTOStatusEnum.DRAFT) {
if (row.status === LaboratoryDTOStatusEnum.Draft) {
setSelectedExamRow(row);
setShowStatusChangeModal(true);
} else {
Expand All @@ -111,7 +111,7 @@ export const Exams: FC = () => {
const onExamStatusChangeClick = () => {
if (selectedExamRow?.code) {
dispatch(
updateLabStatus(selectedExamRow?.code, LaboratoryDTOStatusEnum.OPEN)
updateLabStatus(selectedExamRow?.code, LaboratoryDTOStatusEnum.Open)
);
}
};
Expand Down Expand Up @@ -173,21 +173,6 @@ export const Exams: FC = () => {
<>
<div className="lab__header">
<div className="lab__title">{t("nav.laboratory")}</div>
<div className="lab__actions">
<Permission require="exam.create">
<Button
onClick={() => {
navigate(`${PATHS.laboratory}/new`);
}}
type="button"
variant="contained"
color="primary"
>
<Add fontSize="small" />
<span className="new__button__label">{t("lab.newlab")}</span>
</Button>
</Permission>
</div>
</div>
{status === "LOADING" && (
<CircularProgress
Expand Down Expand Up @@ -261,7 +246,7 @@ export const Exams: FC = () => {
<ChangeLabStatus
onClick={onExamStatusChangeClick}
onClose={onExamStatusChangeClose}
status={LaboratoryDTOStatusEnum.OPEN}
status={LaboratoryDTOStatusEnum.Open}
isOpen={true}
labCode={`${selectedExamRow.code}`}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/accessories/laboratory/examForm/ExamForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ const ExamForm: FC<ExamProps> = ({
};

if (rowsData.length > 0 || (lab.result && lab.result.length > 0)) {
lab.status = LaboratoryDTOStatusEnum.DONE;
lab.status = LaboratoryDTOStatusEnum.Done;
} else {
lab.status = LaboratoryDTOStatusEnum.OPEN;
lab.status = LaboratoryDTOStatusEnum.Open;
}
lab.material = "Undefined";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const ExamRequestForm: FC<ExamRequestProps> = ({
: LaboratoryDTOInOutPatientEnum.O;
lab.material = "Undefined";
lab.result = "";
lab.status = LaboratoryDTOStatusEnum.DRAFT;
lab.status = LaboratoryDTOStatusEnum.Draft;

dispatch(createLabRequest(lab));
};
Expand Down
24 changes: 12 additions & 12 deletions src/components/accessories/laboratory/table/ExamTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import { TActions } from "../../table/types";

export const statusLabel = (status: LaboratoryDTOStatusEnum) => {
switch (status) {
case LaboratoryDTOStatusEnum.DELETED:
case LaboratoryDTOStatusEnum.Deleted:
return <LabelBadge color="danger" label={status} />;
case LaboratoryDTOStatusEnum.INVALID:
case LaboratoryDTOStatusEnum.Invalid:
return <LabelBadge color="warning" label={status} />;

case LaboratoryDTOStatusEnum.OPEN:
case LaboratoryDTOStatusEnum.Open:
return <LabelBadge color="info" label={status} />;

case LaboratoryDTOStatusEnum.DONE:
case LaboratoryDTOStatusEnum.Done:
return <LabelBadge color="success" label={status} />;

default:
Expand Down Expand Up @@ -90,24 +90,24 @@ export const ExamTable: FC<IExamTableProps> = ({

const shouldDisplayAction = (row: any, action: TActions): boolean => {
if (
(row.statusText === LaboratoryDTOStatusEnum.DELETED ||
row.statusText === LaboratoryDTOStatusEnum.INVALID) &&
(row.statusText === LaboratoryDTOStatusEnum.Deleted ||
row.statusText === LaboratoryDTOStatusEnum.Invalid) &&
(action === "delete" || action === "edit")
) {
return false;
}

if (
row.statusText !== LaboratoryDTOStatusEnum.DRAFT &&
row.statusText !== LaboratoryDTOStatusEnum.OPEN &&
row.statusText !== LaboratoryDTOStatusEnum.Draft &&
row.statusText !== LaboratoryDTOStatusEnum.Open &&
action === "cancel"
) {
return false;
}

if (
(row.statusText === LaboratoryDTOStatusEnum.DRAFT ||
row.statusText === LaboratoryDTOStatusEnum.OPEN) &&
(row.statusText === LaboratoryDTOStatusEnum.Draft ||
row.statusText === LaboratoryDTOStatusEnum.Open) &&
action === "delete"
) {
return false;
Expand Down Expand Up @@ -151,8 +151,8 @@ export const ExamTable: FC<IExamTableProps> = ({

if (labExam) {
if (
labExam.status === LaboratoryDTOStatusEnum.DRAFT ||
labExam.status === LaboratoryDTOStatusEnum.OPEN
labExam.status === LaboratoryDTOStatusEnum.Draft ||
labExam.status === LaboratoryDTOStatusEnum.Open
) {
if (handleCancel !== undefined) handleCancel(labExam.code);
} else {
Expand Down
14 changes: 2 additions & 12 deletions src/components/accessories/opds/Opds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Permission } from "../../../libraries/permissionUtils/Permission";
import { useOpds } from "../../../libraries/hooks/api/useOpds";
import { TFilterValues } from "./filter/types";
import Pagination from "../pagination/Pagination";
import { getWards } from "../../../state/ward/actions";

export const Opds: FC = () => {
const fields = initialFilterFields;
Expand Down Expand Up @@ -56,26 +57,15 @@ export const Opds: FC = () => {
);
dispatch(getDiseasesOpd());
dispatch(getDiseaseTypes());
dispatch(getWards());
}, []);

return (
<Fragment>
<div className="opd_opds">
<div className="opd__header">
<div className="opd__title">{t("nav.visits")}</div>
<div className="opd__actions">
<Button
onClick={() => navigate("/search")}
type="button"
variant="contained"
color="primary"
>
<Add fontSize="small" />
<span className="new__button__label">{t("opd.newopd")}</span>
</Button>
</div>
</div>

{(() => {
switch (status) {
case "FAIL":
Expand Down
1 change: 1 addition & 0 deletions src/components/accessories/opds/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export const initialFilterFields: TFields<OpdFilterFormFieldName> = {
sex: { type: "text", value: "" },
newPatient: { type: "text", value: "" },
patientCode: { type: "number", value: "" },
wardCode: { type: "text", value: "" },
};
28 changes: 26 additions & 2 deletions src/components/accessories/opds/filter/OpdFilterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import React, { useCallback, useState } from "react";
import { FC, useMemo } from "react";
import { useTranslation } from "react-i18next";
import { date, number, object, string } from "yup";
import { DiseaseDTO, DiseaseTypeDTO, PatientDTO } from "../../../../generated";
import {
DiseaseDTO,
DiseaseTypeDTO,
PatientDTO,
WardDTO,
} from "../../../../generated";
import {
getFromFields,
formatAllFieldValues,
Expand Down Expand Up @@ -170,7 +175,7 @@ export const OpdFilterForm: FC<IOpdFilterProps> = ({ fields, onSubmit }) => {

const { setFieldValue, handleBlur } = formik;

const mapToOptions = (value: DiseaseTypeDTO | DiseaseDTO) => ({
const mapToOptions = (value: DiseaseTypeDTO | DiseaseDTO | WardDTO) => ({
value: value.code ?? "",
label: value.description ?? "",
});
Expand All @@ -192,6 +197,14 @@ export const OpdFilterForm: FC<IOpdFilterProps> = ({ fields, onSubmit }) => {
);
});

const wards = useSelector<IState, WardDTO[]>((state: IState) => {
return state.wards.allWards.data?.filter((e) => e.opd) ?? [];
});

const wardOptions = useMemo(() => {
return wards.map((e) => mapToOptions(e));
}, [wards]);

const dateFieldHandleOnChange = useCallback(
(fieldName: string) => (val: Date | null) => {
setFieldValue(fieldName, val);
Expand Down Expand Up @@ -363,6 +376,17 @@ export const OpdFilterForm: FC<IOpdFilterProps> = ({ fields, onSubmit }) => {
options={diseaseOptions}
/>
</div>
<div className="filterOpdForm__item">
<AutocompleteField
fieldName="wardCode"
fieldValue={formik.values.wardCode}
label={t("opd.ward")}
isValid={isValid("wardCode")}
errorText={getErrorText("wardCode")}
onBlur={onBlurCallback("wardCode")}
options={wardOptions}
/>
</div>
</div>
</div>
<div className="filterOpdForm__section">
Expand Down
4 changes: 3 additions & 1 deletion src/components/accessories/opds/filter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type TFilterValues = {
patientCode?: number;
page?: number;
size?: number;
wardCode?: string;
};

export type TOpdFilterValues = Record<OpdFilterFormFieldName, string>;
Expand All @@ -32,7 +33,8 @@ export type OpdFilterFormFieldName =
| "patientCode"
| "diseaseCode"
| "diseaseTypeCode"
| "sex";
| "sex"
| "wardCode";

export interface IFilterAction {
type: "update";
Expand Down
13 changes: 12 additions & 1 deletion src/components/accessories/opds/table/OpdTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const OpdTable: FC<IOpdTableProps> = ({ data }) => {
const header = [
"id",
"date",
"ward",
"patientCode",
"patientName",
"sex",
Expand All @@ -37,8 +38,17 @@ export const OpdTable: FC<IOpdTableProps> = ({ data }) => {
referralTo: t("opd.referralto"),
nextVisitDate: t("opd.nextvisitdate"),
age: t("opd.age"),
ward: t("opd.ward"),
};
const order = ["id", "date", "patientCode", "patientName", "age", "disease"];
const order = [
"id",
"date",
"ward",
"patientCode",
"patientName",
"age",
"disease",
];
const [opd, setOpd] = useState({} as OpdDTO);

const formatDataToDisplay = (data: OpdDTO[]) => {
Expand All @@ -58,6 +68,7 @@ export const OpdTable: FC<IOpdTableProps> = ({ data }) => {
disease3: e.disease3?.description ?? "",
referralFrom: e.referralFrom ?? "",
referralTo: e.referralTo ?? "",
ward: e.ward?.description ?? "",
newPatient:
e.newPatient === "R"
? t("opd.reattendance")
Expand Down
4 changes: 2 additions & 2 deletions src/components/accessories/patientExams/PatientExams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ const PatientExams: FC = () => {
// Fix status according to results
lab.status =
(lab.result && lab.result.length > 0) || rows.length > 0
? LaboratoryDTOStatusEnum.DONE
: LaboratoryDTOStatusEnum.OPEN;
? LaboratoryDTOStatusEnum.Done
: LaboratoryDTOStatusEnum.Open;

if (!creationMode && labToEdit.code) {
dispatch(updateLab(labToEdit.code, labWithRowsDTO));
Expand Down
Loading
Loading