Skip to content

Commit

Permalink
#1318 | Fix error on voiding encounters / program encounters
Browse files Browse the repository at this point in the history
  • Loading branch information
1t5j0y committed Aug 27, 2024
1 parent e13a38a commit 22540e2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 deletions src/dataEntryApp/sagas/subjectDashboardSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ export function* voidProgramEncounterWatcher() {

export function* voidProgramEncounterWorker({ uuid }) {
yield put.resolve(setLoad(false));
const [response, error] = yield call(api.voidProgramEncounter, uuid);
if (!response && error) {
yield put(setVoidServerError(error));
const response = yield call(api.voidProgramEncounter, uuid);
if (!response.success) {
yield put(setVoidServerError(response.errorMessage));
} else {
const subject = yield select(selectSubjectProfile);
const subjectProgram = yield call(api.fetchSubjectProgram, subject.uuid);
Expand All @@ -202,9 +202,9 @@ export function* voidGeneralEncounterWatcher() {

export function* voidGeneralEncounterWorker({ uuid }) {
yield put.resolve(setLoad(false));
const [response, error] = yield call(api.voidEncounter, uuid);
if (!response && error) {
yield put(setVoidServerError(error));
const response = yield call(api.voidEncounter, uuid);
if (!response.success) {
yield put(setVoidServerError(response.errorMessage));
} else {
const subject = yield select(selectSubjectProfile);
const subjectGeneral = yield call(api.fetchSubjectGeneral, subject.uuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export default ({
general={general}
subjectTypeUuid={profile.subjectType.uuid}
subjectVoided={profile.voided}
voidError={voidError}
/>
</Paper>
</TabContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import ExpansionPanelSummary from "@material-ui/core/ExpansionPanelSummary";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import Typography from "@material-ui/core/Typography";
import { useTranslation } from "react-i18next";
import { filter, isNil } from "lodash";
import { filter, isEmpty, isNil } from "lodash";
import { connect } from "react-redux";
import SubjectVoided from "../../../components/SubjectVoided";
import PlannedVisitsTable from "../PlannedVisitsTable";
import { voidGeneralEncounter } from "../../../reducers/subjectDashboardReducer";
import { clearVoidServerError, voidGeneralEncounter } from "../../../reducers/subjectDashboardReducer";
import CompletedVisits from "./CompletedVisits";
import { NewGeneralEncounterButton } from "./NewGeneralEncounterButton";
import ConfirmDialog from "../../../components/ConfirmDialog";
import _ from "lodash";
import MessageDialog from "../../../components/MessageDialog";

const useStyles = makeStyles(theme => ({
label: {
Expand All @@ -25,8 +26,7 @@ const useStyles = makeStyles(theme => ({
expansionPanel: {
marginBottom: "11px",
borderRadius: "5px",
boxShadow:
"0px 0px 3px 1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 2px 1px -1px rgba(0,0,0,0.12)"
boxShadow: "0px 0px 3px 1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 2px 1px -1px rgba(0,0,0,0.12)"
},
root: {
flexGrow: 1,
Expand Down Expand Up @@ -70,7 +70,9 @@ const SubjectDashboardGeneralTab = ({
subjectTypeUuid,
subjectVoided,
voidGeneralEncounter,
displayGeneralInfoInProfileTab
displayGeneralInfoInProfileTab,
voidError,
clearVoidServerError
}) => {
const { t } = useTranslation();
const classes = useStyles();
Expand All @@ -79,17 +81,14 @@ const SubjectDashboardGeneralTab = ({

const plannedVisits = filter(
general,
({ voided, encounterDateTime, cancelDateTime }) =>
!voided && isNil(encounterDateTime) && isNil(cancelDateTime)
({ voided, encounterDateTime, cancelDateTime }) => !voided && isNil(encounterDateTime) && isNil(cancelDateTime)
);
const ContainerComponent = displayGeneralInfoInProfileTab ? Box : Paper;

return (
<ContainerComponent className={displayGeneralInfoInProfileTab ? "" : classes.root}>
{subjectVoided && <SubjectVoided showUnVoid={false} />}
{!subjectVoided && !displayGeneralInfoInProfileTab && (
<NewGeneralEncounterButton subjectUuid={subjectUuid} />
)}
{!subjectVoided && !displayGeneralInfoInProfileTab && <NewGeneralEncounterButton subjectUuid={subjectUuid} />}
<ExpansionPanel className={classes.expansionPanel}>
<ExpansionPanelSummary
expandIcon={<ExpandMoreIcon className={classes.expandMoreIcon} />}
Expand Down Expand Up @@ -131,17 +130,17 @@ const SubjectDashboardGeneralTab = ({
</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails style={{ padding: 0, display: "block" }}>
{isExpanded && (
<CompletedVisits entityUuid={subjectUuid} isForProgramEncounters={false} />
)}
{isExpanded && <CompletedVisits entityUuid={subjectUuid} isForProgramEncounters={false} />}
</ExpansionPanelDetails>
</ExpansionPanel>
<MessageDialog title={t("SubjectErrorTitle")} open={!isEmpty(voidError)} message={t(voidError)} onOk={clearVoidServerError} />
</ContainerComponent>
);
};

const mapDispatchToProps = {
voidGeneralEncounter
voidGeneralEncounter,
clearVoidServerError
};

export default connect(
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13611,10 +13611,10 @@ open@^7.1.0:
grunt "^1.0.3"
webpack "^4.13.0"

openchs-models@1.31.81:
version "1.31.81"
resolved "https://registry.yarnpkg.com/openchs-models/-/openchs-models-1.31.81.tgz#8c873420df888aaae5529a7a66055f1dad70f807"
integrity sha512-V+s6vzD9F0kMzExxe09tTo2Q2Fs9fuDjgOArMjvnRPa4GNC1rPk8Eod9Uf61C48Ke1NXIR8oW40s7IUTScZRpA==
openchs-models@1.32.4:
version "1.32.4"
resolved "https://registry.yarnpkg.com/openchs-models/-/openchs-models-1.32.4.tgz#5667beec7f3ddc970bdac5fb6c5c7807f09de9fb"
integrity sha512-bCbABpUzdiWUCqnx9wDgOoi+jnw0nuZvM9YFRZn1gtnVrmoNEPfdfQfcdXAzTTy5OD1hbCbNnJIU3sEukQvLdQ==
dependencies:
uuid "^9.0.1"

Expand Down

0 comments on commit 22540e2

Please sign in to comment.