Skip to content

Commit

Permalink
fix(OH2-374): Fix exams state (#655)
Browse files Browse the repository at this point in the history
Co-authored-by: SteveGT96 <steve.tsala@intesys.it>
  • Loading branch information
SteveGT96 and SteveGT96 committed Sep 10, 2024
1 parent 8f06d5d commit 68204fc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
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

0 comments on commit 68204fc

Please sign in to comment.