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-374 | Fix wrong feedback on patient exams and lab request table loading indefinitely #655

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
2 changes: 1 addition & 1 deletion src/components/accessories/patientExams/PatientExams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import ConfirmationDialog from "../confirmationDialog/ConfirmationDialog";
import InfoBox from "../infoBox/InfoBox";
import { initialRequestFields } from "../laboratory/consts";
import ExamRequestForm from "../laboratory/examRequestForm/ExamRequestForm";
import { initialFields } from "./consts";
import ExamForm from "./ExamForm/ExamForm";
import { initialFields } from "./consts";
import PatientExamRequestsTable from "./patientExamRequestsTable/PatientExamRequestsTable";
import PatientExamsTable from "./patientExamsTable/PatientExamsTable";
import "./styles.scss";
Expand Down
20 changes: 16 additions & 4 deletions src/state/laboratories/slice.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createSlice } from "@reduxjs/toolkit";
import { isEmpty } from "lodash";
import { ApiResponse } from "state/types";
import { initial } from "./initial";
import * as thunks from "./thunk";
import { ApiResponse } from "state/types";
import { isEmpty } from "lodash";

export const laboratorySlice = createSlice({
name: "laboratories",
Expand Down Expand Up @@ -46,8 +46,7 @@ export const laboratorySlice = createSlice({
state.searchLabs = ApiResponse.loading();
})
.addCase(thunks.searchLabs.fulfilled, (state, action) => {
state.searchLabs =
ApiResponse.value(action.payload);
state.searchLabs = ApiResponse.value(action.payload);
})
.addCase(thunks.searchLabs.rejected, (state, action) => {
state.searchLabs = ApiResponse.error(action.payload);
Expand All @@ -65,6 +64,19 @@ export const laboratorySlice = createSlice({
.addCase(thunks.getLabsByPatientId.rejected, (state, action) => {
state.labsByPatientId = ApiResponse.error(action.payload);
})
// Get Lab Requests By Patient ID
.addCase(thunks.getLabsRequestByPatientId.pending, (state) => {
state.labsRequestByPatientId = ApiResponse.loading();
})
.addCase(thunks.getLabsRequestByPatientId.fulfilled, (state, action) => {
state.labsRequestByPatientId.status = isEmpty(action.payload)
? "SUCCESS_EMPTY"
: "SUCCESS";
state.labsRequestByPatientId.data = action.payload as any;
})
.addCase(thunks.getLabsRequestByPatientId.rejected, (state, action) => {
state.labsRequestByPatientId = ApiResponse.error(action.payload);
})
// Get Lab By Code
.addCase(thunks.getLabByCode.pending, (state) => {
state.getLabByCode = ApiResponse.loading();
Expand Down
2 changes: 1 addition & 1 deletion src/state/laboratories/thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const getLabsByPatientId = createAsyncThunk(
.getLaboratory1({ patId: patId ?? -1 })
.toPromise()
.then((result) =>
result.map((item) =>
(result ?? []).map((item) =>
item.laboratoryDTO ? item : { laboratoryDTO: item }
)
)
Expand Down