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 <[email protected]>
SteveGT96 and SteveGT96 authored Sep 10, 2024

Partially verified

This commit is signed with the committer’s verified signature.
cljoly’s contribution has been verified via SSH key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent 8f06d5d commit 68204fc
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
@@ -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";
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",
@@ -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);
@@ -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();
2 changes: 1 addition & 1 deletion src/state/laboratories/thunk.ts
Original file line number Diff line number Diff line change
@@ -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 }
)
)

0 comments on commit 68204fc

Please sign in to comment.