Skip to content

Commit

Permalink
Merge pull request #35 from purplepotion/dev
Browse files Browse the repository at this point in the history
🚀 Final Deployment
  • Loading branch information
ankitkumarsamota121 authored May 28, 2021
2 parents 0355cf0 + 1ec67de commit 3c6147a
Show file tree
Hide file tree
Showing 17 changed files with 879 additions and 74 deletions.
4 changes: 4 additions & 0 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import ProfileScreen from './screens/ProfileScreen';
import DoctorScreen from './screens/DoctorScreen';
import RecordDetailsScreen from './screens/RecordDetailsScreen';
import RecordScreen from './screens/RecordScreen';
import AddConsultationScreen from './screens/AddConsultationScreen';
import ConsultationDetailsScreen from './screens/ConsultationDetailsScreen';

const App = () => {
return (
Expand All @@ -26,6 +28,8 @@ const App = () => {
<Route path='/profile' exact component={ProfileScreen} />
<Route path='/profile/doctor' exact component={DoctorScreen} />
<Route path='/records/add' exact component={AddRecordScreen} />
<Route path='/consultations/add/:hid' exact component={AddConsultationScreen} />
<Route path='/consultations/details/:id' exact component={ConsultationDetailsScreen} />
<Route path='/records/details/:id' exact component={RecordScreen} />
<Route path='/patients/add' exact component={AddPatientScreen} />
<Route path='/patients/details/:id' exact component={PatientDetailsScreen} />
Expand Down
101 changes: 101 additions & 0 deletions client/src/actions/doctor.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ import {
PATIENT_LIST_FAIL,
PATIENT_LIST_REQUEST,
PATIENT_LIST_SUCCESS,
CONSULTATIONS_REQUEST,
CONSULTATIONS_SUCCESS,
CONSULTATIONS_FAIL,
CONSULTATION_DETAILS_FAIL,
CONSULTATION_DETAILS_SUCCESS,
CONSULTATION_DETAILS_REQUEST,
CONSULTATION_APPROVAL_REQUEST,
CONSULTATION_APPROVAL_SUCCESS,
CONSULTATION_APPROVAL_FAIL,
} from '../constants/doctor.constants';

export const listPatients = () => async (dispatch, getState) => {
Expand Down Expand Up @@ -170,3 +179,95 @@ export const createPatientNotification = (patientId, recordId) => async (dispatc
});
}
};

export const getConsultations = () => async (dispatch, getState) => {
try {
dispatch({ type: CONSULTATIONS_REQUEST });

const {
userLogin: { userInfo },
} = getState();

const config = {
headers: {
'Content-Type': 'application/json',
Authorization: userInfo.token,
},
params: {
req_id: undefined,
},
};

const { data } = await axios.get(BASE_URL + `/api/healthOfficial/consultations/get`, config);

dispatch({ type: CONSULTATIONS_SUCCESS, payload: data });
} catch (error) {
dispatch({
type: CONSULTATIONS_FAIL,
payload:
error.response && error.response.data.message ? error.response.data.message : error.message,
});
}
};

export const getConsultationDetails = (req_id) => async (dispatch, getState) => {
try {
dispatch({ type: CONSULTATION_DETAILS_REQUEST });

const {
userLogin: { userInfo },
} = getState();

const config = {
headers: {
'Content-Type': 'application/json',
Authorization: userInfo.token,
},
params: {
req_id,
},
};

const { data } = await axios.get(BASE_URL + `/api/healthOfficial/consultations/get`, config);

dispatch({ type: CONSULTATION_DETAILS_SUCCESS, payload: data });
} catch (error) {
dispatch({
type: CONSULTATION_DETAILS_FAIL,
payload:
error.response && error.response.data.message ? error.response.data.message : error.message,
});
}
};

export const approveConsultation = (req_id, p_id, isApproved) => async (dispatch, getState) => {
try {
dispatch({ type: CONSULTATION_APPROVAL_REQUEST });

const {
userLogin: { userInfo },
} = getState();

const config = {
headers: {
'Content-Type': 'application/json',
Authorization: userInfo.token,
},
};

const approved = isApproved ? 'True' : 'False';
const { data } = await axios.post(
BASE_URL + `/api/healthOfficial/consultations/delete`,
{ req_id, p_id, approved },
config
);

dispatch({ type: CONSULTATION_APPROVAL_SUCCESS, payload: data });
} catch (error) {
dispatch({
type: CONSULTATION_APPROVAL_FAIL,
payload:
error.response && error.response.data.message ? error.response.data.message : error.message,
});
}
};
50 changes: 48 additions & 2 deletions client/src/actions/user.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import {
USER_SEARCH_FAIL,
USER_SEARCH_REQUEST,
USER_SEARCH_SUCCESS,
USER_CREATE_CONSULTATION_REQUEST,
USER_CREATE_CONSULTATION_SUCCESS,
USER_CREATE_CONSULTATION_FAIL,
} from '../constants/user.constants';

export const login = (email, password, userType) => async (dispatch) => {
Expand Down Expand Up @@ -151,21 +154,30 @@ export const getNotifications = () => async (dispatch, getState) => {
}
};

export const doctorsSearch = () => async (dispatch, getState) => {
export const doctorsSearch = (name) => async (dispatch, getState) => {
try {
dispatch({ type: USER_SEARCH_REQUEST });

const {
userLogin: { userInfo },
} = getState();

const config = {
let config = {
headers: {
'Content-Type': 'application/json',
Authorization: userInfo.token,
},
};

if (name.trim().length > 0) {
config = {
...config,
params: {
name,
},
};
}

const { data } = await axios.get(BASE_URL + `/api/users/search`, config);

dispatch({ type: USER_SEARCH_SUCCESS, payload: data });
Expand Down Expand Up @@ -239,3 +251,37 @@ export const removeAccess = (recordId, healthOfficialId) => async (dispatch, get
});
}
};

export const createConsultation =
(doctorId, symptoms, age, gender, description) => async (dispatch, getState) => {
try {
dispatch({ type: USER_CREATE_CONSULTATION_REQUEST });

const {
userLogin: { userInfo },
} = getState();

const config = {
headers: {
'Content-Type': 'application/json',
Authorization: userInfo.token,
},
};

const { data } = await axios.post(
BASE_URL + `/api/users/consultations`,
{ hid: doctorId, symptoms, age, sex: gender, description },
config
);

dispatch({ type: USER_CREATE_CONSULTATION_SUCCESS, payload: data });
} catch (error) {
dispatch({
type: USER_CREATE_CONSULTATION_FAIL,
payload:
error.response && error.response.data.message
? error.response.data.message
: error.message,
});
}
};
15 changes: 15 additions & 0 deletions client/src/constants/doctor.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ export const PATIENT_DETAILS_REQUEST = 'PATIENT_DETAILS_REQUEST';
export const PATIENT_DETAILS_SUCCESS = 'PATIENT_DETAILS_SUCCESS';
export const PATIENT_DETAILS_FAIL = 'PATIENT_DETAILS_FAIL';
export const PATIENT_DETAILS_RESET = 'PATIENT_DETAILS_RESET';

export const CONSULTATIONS_REQUEST = 'CONSULTATIONS_REQUEST';
export const CONSULTATIONS_SUCCESS = 'CONSULTATIONS_SUCCESS';
export const CONSULTATIONS_FAIL = 'CONSULTATIONS_FAIL';
export const CONSULTATIONS_RESET = 'CONSULTATIONS_RESET';

export const CONSULTATION_APPROVAL_REQUEST = 'CONSULTATION_APPROVAL_REQUEST';
export const CONSULTATION_APPROVAL_SUCCESS = 'CONSULTATION_APPROVAL_SUCCESS';
export const CONSULTATION_APPROVAL_FAIL = 'CONSULTATION_APPROVAL_FAIL';
export const CONSULTATION_APPROVAL_RESET = 'CONSULTATION_APPROVAL_RESET';

export const CONSULTATION_DETAILS_REQUEST = 'CONSULTATION_DETAILS_REQUEST';
export const CONSULTATION_DETAILS_SUCCESS = 'CONSULTATION_DETAILS_SUCCESS';
export const CONSULTATION_DETAILS_FAIL = 'CONSULTATION_DETAILS_FAIL';
export const CONSULTATION_DETAILS_RESET = 'CONSULTATION_DETAILS_RESET';
5 changes: 5 additions & 0 deletions client/src/constants/user.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ export const USER_DETAILS_RESET = 'USER_DETAILS_RESET';
export const USER_SEARCH_REQUEST = 'USER_SEARCH_REQUEST';
export const USER_SEARCH_SUCCESS = 'USER_SEARCH_SUCCESS';
export const USER_SEARCH_FAIL = 'USER_SEARCH_FAIL';

export const USER_CREATE_CONSULTATION_REQUEST = 'USER_CREATE_CONSULTATION_REQUEST';
export const USER_CREATE_CONSULTATION_SUCCESS = 'USER_CREATE_CONSULTATION_SUCCESS';
export const USER_CREATE_CONSULTATION_FAIL = 'USER_CREATE_CONSULTATION_FAIL';
export const USER_CREATE_CONSULTATION_RESET = 'USER_CREATE_CONSULTATION_RESET';
57 changes: 57 additions & 0 deletions client/src/reducers/doctor.reducers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import {
CONSULTATIONS_FAIL,
CONSULTATIONS_REQUEST,
CONSULTATIONS_SUCCESS,
CONSULTATION_APPROVAL_FAIL,
CONSULTATION_APPROVAL_REQUEST,
CONSULTATION_APPROVAL_RESET,
CONSULTATION_APPROVAL_SUCCESS,
CONSULTATION_DETAILS_FAIL,
CONSULTATION_DETAILS_REQUEST,
CONSULTATION_DETAILS_RESET,
CONSULTATION_DETAILS_SUCCESS,
PATIENT_ADD_FAIL,
PATIENT_ADD_REQUEST,
PATIENT_ADD_RESET,
Expand Down Expand Up @@ -92,3 +103,49 @@ export const patientConsentReducer = (state = { patient: {} }, action) => {
return state;
}
};

export const doctorConsultationsReducer = (
state = { consultations: [], loading: false },
action
) => {
switch (action.type) {
case CONSULTATIONS_REQUEST:
return { ...state, loading: true };
case CONSULTATIONS_SUCCESS:
return { ...state, loading: false, consultations: action.payload };
case CONSULTATIONS_FAIL:
return { ...state, loading: false, error: action.payload };
default:
return state;
}
};

export const consultationDetailsReducer = (state = {}, action) => {
switch (action.type) {
case CONSULTATION_DETAILS_REQUEST:
return { ...state, loading: true };
case CONSULTATION_DETAILS_SUCCESS:
return { ...state, loading: false, consultation: action.payload };
case CONSULTATION_DETAILS_FAIL:
return { ...state, loading: false, error: action.payload };
case CONSULTATION_DETAILS_RESET:
return {};
default:
return state;
}
};

export const consultationApprovalReducer = (state = {}, action) => {
switch (action.type) {
case CONSULTATION_APPROVAL_REQUEST:
return { loading: true };
case CONSULTATION_APPROVAL_SUCCESS:
return { loading: false, success: true };
case CONSULTATION_APPROVAL_FAIL:
return { loading: false, error: action.payload };
case CONSULTATION_APPROVAL_RESET:
return { loading: false, success: false };
default:
return state;
}
};
8 changes: 8 additions & 0 deletions client/src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { combineReducers } from 'redux';
import {
consultationApprovalReducer,
consultationDetailsReducer,
doctorConsultationsReducer,
patientAddReducer,
patientConsentReducer,
patientCreateRecordReducer,
Expand All @@ -22,6 +25,7 @@ import {
userConsentReducer,
userSearchDoctorsReducer,
userRemoveAccessReducer,
userConsultationReducer,
} from './user.reducers';

export default combineReducers({
Expand All @@ -42,4 +46,8 @@ export default combineReducers({
userConsent: userConsentReducer,
searchDoctors: userSearchDoctorsReducer,
userRemoveAccess: userRemoveAccessReducer,
userConsultation: userConsultationReducer,
doctorConsultations: doctorConsultationsReducer,
consultationApproval: consultationApprovalReducer,
consultationDetails: consultationDetailsReducer,
});
19 changes: 19 additions & 0 deletions client/src/reducers/user.reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {
USER_CONSENT_FAIL,
USER_CONSENT_REQUEST,
USER_CONSENT_SUCCESS,
USER_CREATE_CONSULTATION_FAIL,
USER_CREATE_CONSULTATION_SUCCESS,
USER_CREATE_CONSULTATION_REQUEST,
USER_DETAILS_FAIL,
USER_DETAILS_REQUEST,
USER_DETAILS_RESET,
Expand All @@ -24,6 +27,7 @@ import {
USER_SEARCH_FAIL,
USER_SEARCH_REQUEST,
USER_SEARCH_SUCCESS,
USER_CREATE_CONSULTATION_RESET,
} from '../constants/user.constants';

export const userLoginReducer = (state = {}, action) => {
Expand Down Expand Up @@ -122,3 +126,18 @@ export const userRemoveAccessReducer = (state = {}, action) => {
return state;
}
};

export const userConsultationReducer = (state = {}, action) => {
switch (action.type) {
case USER_CREATE_CONSULTATION_REQUEST:
return { state, loading: true };
case USER_CREATE_CONSULTATION_SUCCESS:
return { loading: false, success: true };
case USER_CREATE_CONSULTATION_FAIL:
return { loading: false, error: action.payload };
case USER_CREATE_CONSULTATION_RESET:
return { loading: false, success: false };
default:
return state;
}
};
Loading

0 comments on commit 3c6147a

Please sign in to comment.