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-442 | Remove trans unit from opd context operation and update operation row form #704

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ import { object, string } from "yup";
import checkIcon from "../../../../assets/check-icon.png";
import warningIcon from "../../../../assets/warning-icon.png";
import { OpdWithOperationRowDTO, OperationRowDTO } from "../../../../generated";
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
import {
formatAllFieldValues,
getFromFields,
} from "../../../../libraries/formDataHandling/functions";
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
import {
createOperationRowReset,
deleteOperationRow,
Expand All @@ -58,8 +58,8 @@ import { CustomDialog } from "../../customDialog/CustomDialog";
import DateField from "../../dateField/DateField";
import ContentCutIcon from "../../icons/content-cut";
import InfoBox from "../../infoBox/InfoBox";
import OperationRowForm from "../../patientOperation/operationForm/OperationRowForm";
import { opRowFields } from "../../patientOperation/opRowFields";
import OperationRowForm from "../../patientOperation/operationForm/OperationRowForm";
import TextField from "../../textField/TextField";
import "./styles.scss";
import { TProps } from "./types";
Expand Down Expand Up @@ -662,6 +662,7 @@ const PatientOPDForm: FunctionComponent<TProps> = ({
content={
<>
<OperationRowForm
opd={true}
fields={operationsRowFields}
onSubmit={handleAddOperationRow}
creationMode={operationCreationMode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { useTranslation } from "react-i18next";
import { number, object, string } from "yup";
import warningIcon from "../../../../assets/warning-icon.png";
import { OperationDTO } from "../../../../generated";
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
import {
formatAllFieldValues,
getFromFields,
} from "../../../../libraries/formDataHandling/functions";
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
import { FIELD_VALIDATION, IState } from "../../../../types";
import AutocompleteField from "../../autocompleteField/AutocompleteField";
import Button from "../../button/Button";
Expand All @@ -32,6 +32,7 @@ const OperationRowForm: FC<OperationRowProps> = ({
shouldResetForm,
resetFormCallback,
hideResultField,
opd,
}) => {
const { t } = useTranslation();

Expand Down Expand Up @@ -82,6 +83,10 @@ const OperationRowForm: FC<OperationRowProps> = ({
(item) => item.code === formattedValues.operation
);

if (opd) {
formattedValues.transUnit = 0;
}

onSubmit(formattedValues);
},
});
Expand Down Expand Up @@ -166,22 +171,6 @@ const OperationRowForm: FC<OperationRowProps> = ({
>
<div className="row start-sm center-xs">
<div className="fullWidth patientOperationForm__item">
<AutocompleteField
fieldName="operation"
fieldValue={formik.values.operation}
label={t("operation.operation")}
isValid={isValid("operation")}
errorText={getErrorText("operation")}
onBlur={onBlurCallback("operation")}
options={renderOptions(operationList)}
loading={operationStatus === "LOADING"}
disabled={isLoading}
/>
</div>
</div>

<div className="row start-sm center-xs">
<div className="patientOperationForm__item">
<DateField
fieldName="opDate"
fieldValue={formik.values.opDate}
Expand All @@ -196,19 +185,37 @@ const OperationRowForm: FC<OperationRowProps> = ({
required={FIELD_VALIDATION.REQUIRED}
/>
</div>
<div className="patientOperationForm__item">
<TextField
field={formik.getFieldProps("transUnit")}
theme="regular"
label={t("operation.transUnit")}
isValid={isValid("transUnit")}
errorText={getErrorText("transUnit")}
onBlur={formik.handleBlur}
type="number"
<div className="fullWidth patientOperationForm__item">
<AutocompleteField
fieldName="operation"
fieldValue={formik.values.operation}
label={t("operation.operation")}
isValid={isValid("operation")}
errorText={getErrorText("operation")}
onBlur={onBlurCallback("operation")}
options={renderOptions(operationList)}
loading={operationStatus === "LOADING"}
disabled={isLoading}
/>
</div>
</div>

<div className="row start-sm center-xs">
{!opd && (
<div className="patientOperationForm__item">
<TextField
field={formik.getFieldProps("transUnit")}
theme="regular"
label={t("operation.transUnit")}
isValid={isValid("transUnit")}
errorText={getErrorText("transUnit")}
onBlur={formik.handleBlur}
type="number"
disabled={isLoading}
/>
</div>
)}
</div>
{!hideResultField && (
<div className="row start-sm center-xs">
<div className="fullWidth patientOperationForm__item">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ interface IOperationRowProps {
resetButtonLabel: string;
isLoading: boolean;
shouldResetForm: boolean;
opdId?: number;
/**
* Set to true if the operation row is in opd context
*/
opd?: boolean;
admissionId?: number;
creationMode: boolean;
resetFormCallback: () => void;
Expand Down