Skip to content

Commit ba07f60

Browse files
committed
Only set the latest follow up or dianosis if there is currently an active patient.
1 parent 24dc1d0 commit ba07f60

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/redux/modules/patient.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,19 @@ export default handleActions({
493493
return patient;
494494
},
495495
[UPDATE_DIAGNOSIS]: (state, action) => {
496-
let activePatient = {...state.activePatient};
497-
activePatient.diagnosis = action.payload.diagnosis;
498-
let patient = {
499-
...state,
500-
activePatient: activePatient,
501-
};
502-
return patient;
496+
if (state.activePatient) {
497+
let activePatient = {...state.activePatient};
498+
activePatient.diagnosis = action.payload.diagnosis;
499+
let patient = {
500+
...state,
501+
activePatient: activePatient,
502+
};
503+
return patient;
504+
} else {
505+
return {
506+
...state
507+
};
508+
}
503509
},
504510
[REMOVE_ACTIVE_PATIENT]: (state, action) => {
505511
let newState = {
@@ -702,13 +708,19 @@ export default handleActions({
702708
};
703709
},
704710
[FOLLOW_UP_FETCH_LATEST]: (state, action) => {
705-
return {
706-
...state,
707-
activePatient: {
708-
...state.activePatient,
709-
activeFollowUp: state.activePatient.followUps[0]
710-
}
711-
};
711+
if (state.activePatient && state.activePatient.followUps) {
712+
return {
713+
...state,
714+
activePatient: {
715+
...state.activePatient,
716+
activeFollowUp: state.activePatient.followUps[0]
717+
}
718+
};
719+
} else {
720+
return {
721+
...state
722+
};
723+
}
712724
},
713725
[FOLLOW_UP_CREATE_NEW]: (state, action) => {
714726
const now = new Date();

0 commit comments

Comments
 (0)