Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2381 from HospitalRun/redux-cleanup
Browse files Browse the repository at this point in the history
chore(redux): remove unused redux code
  • Loading branch information
matteovivona committed Sep 9, 2020
2 parents 6ace4d6 + d4e5f36 commit bbd4140
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions src/patients/patient-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import validator from 'validator'

import PatientRepository from '../shared/db/PatientRepository'
import Diagnosis from '../shared/model/Diagnosis'
import Note from '../shared/model/Note'
import Patient from '../shared/model/Patient'
import RelatedPerson from '../shared/model/RelatedPerson'
import Visit from '../shared/model/Visit'
Expand All @@ -22,9 +21,7 @@ interface PatientState {
updateError?: Error
allergyError?: AddAllergyError
diagnosisError?: AddDiagnosisError
noteError?: AddNoteError
relatedPersonError?: AddRelatedPersonError
carePlanError?: AddCarePlanError
visitError?: AddVisitError
}

Expand Down Expand Up @@ -58,23 +55,6 @@ interface AddDiagnosisError {
status?: string
}

interface AddNoteError {
message?: string
note?: string
}

interface AddCarePlanError {
message?: string
title?: string
description?: string
status?: string
intent?: string
startDate?: string
endDate?: string
note?: string
condition?: string
}

interface AddVisitError {
message?: string
status?: string
Expand All @@ -90,11 +70,8 @@ const initialState: PatientState = {
relatedPersons: [],
createError: undefined,
updateError: undefined,
allergyError: undefined,
diagnosisError: undefined,
noteError: undefined,
relatedPersonError: undefined,
carePlanError: undefined,
visitError: undefined,
}

Expand Down Expand Up @@ -129,10 +106,6 @@ const patientSlice = createSlice({
state.status = 'error'
state.updateError = payload
},
addAllergyError(state, { payload }: PayloadAction<AddAllergyError>) {
state.status = 'error'
state.allergyError = payload
},
addDiagnosisError(state, { payload }: PayloadAction<AddDiagnosisError>) {
state.status = 'error'
state.diagnosisError = payload
Expand All @@ -141,18 +114,6 @@ const patientSlice = createSlice({
state.status = 'error'
state.relatedPersonError = payload
},
addNoteError(state, { payload }: PayloadAction<AddRelatedPersonError>) {
state.status = 'error'
state.noteError = payload
},
addCarePlanError(state, { payload }: PayloadAction<AddRelatedPersonError>) {
state.status = 'error'
state.carePlanError = payload
},
addVisitError(state, { payload }: PayloadAction<AddVisitError>) {
state.status = 'error'
state.visitError = payload
},
},
})

Expand All @@ -165,12 +126,8 @@ export const {
updatePatientStart,
updatePatientSuccess,
updatePatientError,
addAllergyError,
addDiagnosisError,
addRelatedPersonError,
addNoteError,
addCarePlanError,
addVisitError,
} = patientSlice.actions

export const fetchPatient = (id: string): AppThunk => async (dispatch) => {
Expand Down Expand Up @@ -383,35 +340,6 @@ export const addDiagnosis = (
}
}

function validateNote(note: Note) {
const error: AddNoteError = {}
if (!note.text) {
error.message = 'patient.notes.error.noteRequired'
}

return error
}

export const addNote = (
patientId: string,
note: Note,
onSuccess?: (patient: Patient) => void,
): AppThunk => async (dispatch) => {
const newNoteError = validateNote(note)

if (isEmpty(newNoteError)) {
const patient = await PatientRepository.find(patientId)
const notes = patient.notes || []
notes.push({ id: uuid(), date: new Date().toISOString(), ...note })
patient.notes = notes

await dispatch(updatePatient(patient, onSuccess))
} else {
newNoteError.message = 'patient.notes.error.unableToAdd'
dispatch(addNoteError(newNoteError))
}
}

function validateVisit(visit: Visit): AddVisitError {
const error: AddVisitError = {}

Expand Down

1 comment on commit bbd4140

@vercel
Copy link

@vercel vercel bot commented on bbd4140 Sep 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.