diff --git a/redux/insurance/insurance.actions.js b/redux/insurance/insurance.actions.js index dc6391e3..bf92d4ba 100644 --- a/redux/insurance/insurance.actions.js +++ b/redux/insurance/insurance.actions.js @@ -8,6 +8,7 @@ import InsuranceActions from './insurance.type'; import { createConsultationUrl, + getAmountConsultationUrl, getDrugAndDevicesUrl, getInsuranceListUrl, getInsurancePrimeAmountUrl, @@ -432,3 +433,33 @@ export const fetchCreateConsultation = (data) => { onError: fetchCreateConsultationError, }); }; + +/************************************************************/ +export const fetchGetAmountConsultationPending = () => ({ + type: InsuranceActions.GET_AMOUNT_CONSULTATION_PENDING, +}); + +export const fetchGetAmountConsultationReset = () => ({ + type: InsuranceActions.GET_AMOUNT_CONSULTATION_RESET, +}); + +export const fetchGetAmountConsultationSuccess = (authkey: any) => ({ + type: InsuranceActions.GET_AMOUNT_CONSULTATION_SUCCESS, + payload: authkey, +}); + +export const fetchGetAmountConsultationError = (error: any) => ({ + type: InsuranceActions.GET_AMOUNT_CONSULTATION_ERROR, + payload: error, +}); + +export const fetchGetAmountConsultation = (data) => { + return ApiAction({ + url: `${getAmountConsultationUrl}`, + method: 'POST', + data, + onLoading: fetchGetAmountConsultationPending, + onSuccess: fetchGetAmountConsultationSuccess, + onError: fetchGetAmountConsultationError, + }); +}; diff --git a/redux/insurance/insurance.reducer.js b/redux/insurance/insurance.reducer.js index fdf1447f..0768d315 100644 --- a/redux/insurance/insurance.reducer.js +++ b/redux/insurance/insurance.reducer.js @@ -437,3 +437,33 @@ export const createConsultationReducer = (state = INITIAL_STATE, action: Insuran } }; + +export const getAmountConsultationReducer = (state = INITIAL_STATE, action: InsuranceActions) => { + switch (action.type) { + case InsuranceActions.GET_AMOUNT_CONSULTATION_PENDING: + return { + ...state, + loading: true + } + case InsuranceActions.GET_AMOUNT_CONSULTATION_SUCCESS: + return { + loading: false, + result: action.payload, + error: null + } + case InsuranceActions.GET_AMOUNT_CONSULTATION_ERROR: + return { + ...state, + loading: false, + result: null, + error: action.payload + } + + case InsuranceActions.GET_AMOUNT_CONSULTATION_RESET: + return INITIAL_STATE; + + default: + return state + + } +}; diff --git a/redux/insurance/insurance.selector.js b/redux/insurance/insurance.selector.js index e26a3467..95f6a663 100644 --- a/redux/insurance/insurance.selector.js +++ b/redux/insurance/insurance.selector.js @@ -21,6 +21,7 @@ const selectAddDrugReducer = (state) => state.addDrugReducer; const selectGetProviderClassReducer = (state) => state.getProviderClassReducer; const selectGetNetworkActReducer = (state) => state.getNetworkActReducer; const selectCreateConsultationReducer = (state) => state.createConsultationReducer; +const selectGetAmountConsultationReducer = (state) => state.getAmountConsultationReducer; export const selectInsuranceList = createSelector( [selectInsuranceListReducer], @@ -85,3 +86,7 @@ export const selectGetNetworkAct = createSelector( [selectGetNetworkActReducer], (getNetworkActReducer) => getNetworkActReducer ); +export const selectGetAmountConsultation = createSelector( + [selectGetAmountConsultationReducer], + (getAmountConsultationReducer) => getAmountConsultationReducer +); diff --git a/redux/insurance/insurance.type.js b/redux/insurance/insurance.type.js index 1f0c9b47..e3aed0ab 100644 --- a/redux/insurance/insurance.type.js +++ b/redux/insurance/insurance.type.js @@ -75,5 +75,10 @@ const InsuranceActions = { CREATE_CONSULTATION_SUCCESS: 'CREATE_CONSULTATION_SUCCESS', CREATE_CONSULTATION_ERROR: 'CREATE_CONSULTATION_ERROR', CREATE_CONSULTATION_RESET: 'CREATE_CONSULTATION_RESET', + + GET_AMOUNT_CONSULTATION_PENDING: 'GET_AMOUNT_CONSULTATION_PENDING', + GET_AMOUNT_CONSULTATION_SUCCESS: 'GET_AMOUNT_CONSULTATION_SUCCESS', + GET_AMOUNT_CONSULTATION_ERROR: 'GET_AMOUNT_CONSULTATION_ERROR', + GET_AMOUNT_CONSULTATION_RESET: 'GET_AMOUNT_CONSULTATION_RESET', } export default InsuranceActions; diff --git a/redux/reducers/index.js b/redux/reducers/index.js index 5ec80460..e8e315e4 100755 --- a/redux/reducers/index.js +++ b/redux/reducers/index.js @@ -54,7 +54,7 @@ import { activatePaySubscriptionReducer, addBeneficiaryToSubscriptionReducer, addDrugReducer, - createConsultationReducer, + createConsultationReducer, getAmountConsultationReducer, getDrugAppareilReducer, getInsurancePrimeAmountReducer, getNetworkActReducer, @@ -165,7 +165,8 @@ const rootReducer = persistCombineReducers(persistConfig, { addDrugReducer: addDrugReducer, getProviderClassReducer: getProviderClassReducer, getNetworkActReducer: getNetworkActReducer, - createConsultationReducer: createConsultationReducer + createConsultationReducer: createConsultationReducer, + getAmountConsultationReducer: getAmountConsultationReducer }); export default rootReducer; diff --git a/screens/wallet/agent/SaisirFeuilleSoinScreen.js b/screens/wallet/agent/SaisirFeuilleSoinScreen.js index 892e580e..040e8307 100644 --- a/screens/wallet/agent/SaisirFeuilleSoinScreen.js +++ b/screens/wallet/agent/SaisirFeuilleSoinScreen.js @@ -32,8 +32,11 @@ import { fetchActivePaySubscription, fetchActivePaySubscriptionReset, fetchAddDrug, + fetchAddDrugReset, fetchCreateConsultation, fetchCreateConsultationReset, + fetchGetAmountConsultation, + fetchGetAmountConsultationReset, fetchGetDrugAppareil, fetchGetDrugAppareilReset, fetchGetNetworkActs, @@ -55,6 +58,7 @@ import { selectActivatePaySubscription, selectAddDrug, selectCreateConsultation, + selectGetAmountConsultation, selectGetDrugAppareil, selectGetNetworkAct, selectGetProviderClass, @@ -255,6 +259,7 @@ const SaisirFeuilleSoinScreen = ({ fetchGetProviderClass, fetchGetNetworkActs, fetchCreateConsultation, + fetchGetAmountConsultation, getUserByNameOrNumber, getUserByIdQRCode, getDrugAppareil, @@ -262,10 +267,11 @@ const SaisirFeuilleSoinScreen = ({ addDrug, createConsultation, getNetworkAct, + getAmountConsultation, navigation }) => { - const [datePrestation, setDatePrestation] = useState('' + moment(new Date()).format('YYYY-MM-DD')); + const [datePrestation, setDatePrestation] = useState('' + moment(new Date()).format('YYYY-MM-DD HH:mm')); const [showDatePrestation, setShowDatePrestation] = useState(false); const [dateAccident, setDateAccident] = useState(null); @@ -276,13 +282,13 @@ const SaisirFeuilleSoinScreen = ({ const [wallet] = useState(store.getState().walletDetailReducer.result.response); const [isNumeroAssureSearch, setIsNumeroAssureSearch] = useState(true); - const [isNomAssureSearch, setIsNomAssureSearch] = useState(false); const [dateDebutGrossesse, setDateDebutGrossesse] = useState(null); const [dateFinGrossesse, setDateFinGrossesse] = useState(null); const [isGrossesse, setIsGrossesse] = useState(false); const [showDateDebutGrossessePicker, setShowDateDebutGrossessePicker] = useState(false); const [showDateFinGrossessePicker, setShowDateFinGrossessePicker] = useState(false); + const [careConditon, setCareCondition] = useState(null); const [user, setUser] = useState(null); const [assure, setAssure] = useState(null); @@ -294,6 +300,7 @@ const SaisirFeuilleSoinScreen = ({ const [currentStep, setCurrentStep] = useState(1); const [modalPrestation, setModalPrestation] = useState(false); const [modalMedicament, setModalMedicament] = useState(false); + const [modalAddMedicament, setModalAddMedicament] = useState(false); const [modalExamen, setModalExamen] = useState(false); const [modalListAssure, setModalListAssure] = useState(false); const [modalListMedicament, setModalListMedicament] = useState(false); @@ -333,13 +340,24 @@ const SaisirFeuilleSoinScreen = ({ const [conditionPriseEnChange] = useState([ {label: I18n.t('AFFECTION_COURANTE'), value: "CURRENT_AFFECTION"}, {label: I18n.t('AFFECTION_LONGUE'), value: "LONG_TERM_AFFECTION"}, - {label: I18n.t('EXONERE'), value: "EXONERATION"}, + { + label: + I18n.t('EXONERE'), value: "EXONERATION" + }, + ]); + const [onPrescription] = useState([ + {label: I18n.t('COMPRESSED'), value: "COMPRESSED"}, + {label: I18n.t('SYRUP'), value: "SYRUP"}, + {label: I18n.t('SOLUTION'), value: "SOLUTION"}, + {label: I18n.t('SUPPOSITORY'), value: "SUPPOSITORY"}, + {label: I18n.t('DEVICE'), value: "DEVICE"}, ]); const dispatch = useDispatch(); let dropDownAlertRef: any = null; let classificationRef = null; let codeActeRef = null; + let onPrescriptionRef = null; useEffect(() => { readUser().then((user) => { @@ -355,6 +373,7 @@ const SaisirFeuilleSoinScreen = ({ dispatch(fetchCreateConsultationReset()); dispatch(fetchGetNetworkActsReset()); dispatch(fetchGetProviderClassReset()); + dispatch(fetchAddDrugReset()); fetchGetProviderClass(wallet.id_network); fetchGetNetworkActs(wallet.id_network, ''); @@ -397,6 +416,22 @@ const SaisirFeuilleSoinScreen = ({ if (getDrugAppareil.result !== null) { if (getDrugAppareil.result.response.length > 0) { setModalListMedicament(true); + } else { + Alert.alert( + I18n.t("ERROR_LABEL"), + I18n.t('NO_DRUG_MATCH_YOU_SEARCH'), + [ + { + text: I18n.t("OK"), onPress: () => { + setModalAddMedicament(true); + dispatch(fetchGetDrugAppareilReset()); + dispatch(fetchAddDrugReset()); + } + } + + ], + {cancelable: false} + ) } } @@ -410,6 +445,22 @@ const SaisirFeuilleSoinScreen = ({ } }, [getDrugAppareil]); + useEffect(() => { + if (addDrug.result !== null) { + setModalAddMedicament(false); + setMedicament(addDrug.result.response); + } + + if (addDrug.error) { + dropDownAlertRef.alertWithType( + 'error', + I18n.t('ERROR_LABEL'), + Utils.getErrorMsg(addDrug), + ); + dispatch(fetchAddDrugReset()); + } + }, [addDrug]); + useEffect(() => { if (createConsultation.result !== null) { Alert.alert( @@ -438,8 +489,6 @@ const SaisirFeuilleSoinScreen = ({ } }, [createConsultation]); - - console.log("Date accident", dateAccident); const SaisirFeuilleSoinSchema = Yup.object().shape({ numero_assure: Yup.string() .required(I18n.t('THIS_FIELD_IS_REQUIRED')), @@ -471,6 +520,12 @@ const SaisirFeuilleSoinScreen = ({ drug_posologie: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')), }); + const AddNewMedicamentToDB = Yup.object().shape({ + code: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')), + name: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')), + type: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')) + }); + const onChangeDatePrestation = (event, selectedDate) => { const currentDate = selectedDate || '' + moment(new Date()).format('YYYY-MM-DD'); setShowDatePrestation(Platform.OS === 'ios'); @@ -481,7 +536,7 @@ const SaisirFeuilleSoinScreen = ({ return ( { if (values.code_acte === '') codeActeRef.shake(200) - else + else { setPrestations([{ act_id: values.code_acte, amount: values.amount_prestation, home_visit_fees: values.frais_deplacement }, ...prestations]); - setModalPrestation(false); - Utils.displayToast(I18n.t('PRESTATION_SUCCESSFULLY_ADD')); + setModalPrestation(false); + Utils.displayToast(I18n.t('PRESTATION_SUCCESSFULLY_ADD')); + } + }}> {({ @@ -632,16 +687,8 @@ const SaisirFeuilleSoinScreen = ({ { - Keyboard.dismiss(); - setShowDatePrestation(true); - }} - success={touched.date_prestation && !errors.date_prestation} - touched={touched.date_prestation} - error={errors.date_prestation} + value={'' + moment(datePrestation).format('YYYY-MM-DD HH:mm')} + editable={false} /> { @@ -683,25 +730,27 @@ const SaisirFeuilleSoinScreen = ({ success={touched.amount_prestation && !errors.amount_prestation} touched={touched.amount_prestation} error={errors.amount_prestation} + onKeyPress={() => { + fetchGetAmountConsultation({ + network_id: wallet.id_network, + amount: values.amount_prestation, + care_condition: careConditon + }); + }} /> + value={getAmountConsultation.result !== null ? getAmountConsultation.result.response.insurance_amount : ''}/> ); + const renderAddNewMedicamentToDB = () => ( + { + setMedicament(null); + fetchAddDrug({ + network_id: wallet.id_network, + code: values.code, + name: values.name, + type: values.type, + on_prescription: values.on_prescription + }) + }}> + + {({ + values, + errors, + touched, + handleChange, + handleBlur, + handleSubmit, + setFieldValue, + + isSubmitting, + }) => ( + + + { + setModalAddMedicament(false); + }} + swipeDirection={['down']} + style={styles.bottomModal}> + + + + + + {I18n.t('AJOUTER_NOUVEAU_MEDICAMENT')} + + + + + + { + onPrescriptionRef = comp + }} + style={{ + width: responsiveWidth(90), + height: 60, + alignSelf: 'center', + borderRadius: 10, + paddingLeft: 20, + marginTop: 10, + paddingRight: 20, + backgroundColor: 'white' + }}> + { + setFieldValue('type', value.value); + }} + valueExtractor={(value) => { + return value + }} + labelExtractor={(value) => { + return value.label + }} + /> + + + + {I18n.t('SOUS_ORDONNANCE')} + + { + setFieldValue('on_prescription', value === 'YES'); + console.log("On Prescription", value); + //setGender(value); + }}/> + + + + + + + + + )} + + ); + const renderAddNewExamen = () => ( { console.log("Value", value); + setCareCondition(value); setFieldTouched('care_condition'); setFieldValue('care_condition', value); }} @@ -1582,7 +1772,14 @@ const SaisirFeuilleSoinScreen = ({ }, ]} onPress={e => { - setModalPrestation(true); + dispatch(fetchGetAmountConsultationReset()); + if(careConditon === null) { + dropDownAlertRef.alertWithType( + 'warn', + I18n.t('ERROR_LABEL'), + I18n.t('PLEASE_SELECT_CONDITON_PRISE_CHARGE_FIRST'), + ); + } else setModalPrestation(true); }}> {I18n.t('PRESTATION')} @@ -1785,7 +1983,8 @@ const mapStateToProps = createStructuredSelector({ addDrug: selectAddDrug, getProviderClass: selectGetProviderClass, createConsultation: selectCreateConsultation, - getNetworkAct: selectGetNetworkAct + getNetworkAct: selectGetNetworkAct, + getAmountConsultation: selectGetAmountConsultation }); export default connect(mapStateToProps, { @@ -1797,7 +1996,8 @@ export default connect(mapStateToProps, { fetchAddDrug, fetchGetProviderClass, fetchGetNetworkActs, - fetchCreateConsultation + fetchCreateConsultation, + fetchGetAmountConsultation })( SaisirFeuilleSoinScreen, ); diff --git a/utils/i18n/fr.json b/utils/i18n/fr.json index dad5877e..bc2fe9d0 100755 --- a/utils/i18n/fr.json +++ b/utils/i18n/fr.json @@ -662,5 +662,14 @@ "PRESTATION_SUCCESSFULLY_ADD": "Prestation ajouté avec succès", "EXAMENS_SUCCESSFULLY_ADD": "Examens ajouté avec succès", "PRESCRIPTIONS_SUCCESSFULLY_ADD": "Prescription ajouté avec succès", - "YOU_MUST_ADD_AT_LEAST_ONE_PRESTATION": "Vous devez ajouter au moins une prestation" + "YOU_MUST_ADD_AT_LEAST_ONE_PRESTATION": "Vous devez ajouter au moins une prestation", + "NO_DRUG_MATCH_YOU_SEARCH": "Aucun médicament ne correspond à votre rechercher, voulez-vous en ajouter ?", + "COMPRESSED": "Comprimé", + "SYRUP": "Sirop", + "SOLUTION": "Solution", + "SUPPOSITORY": "Suppositoire", + "DEVICE": "Appareillage", + "AJOUTER_NOUVEAU_MEDICAMENT": "Ajouter un nouveau médicament", + "SOUS_ORDONNANCE": "Sous ordonnance ?", + "PLEASE_SELECT_CONDITON_PRISE_CHARGE_FIRST": "Veuillez d'abord sélectionner la conditon de prise en charge" } diff --git a/webservice/IlinkConstants.js b/webservice/IlinkConstants.js index 72f230d1..6b57d945 100755 --- a/webservice/IlinkConstants.js +++ b/webservice/IlinkConstants.js @@ -89,6 +89,7 @@ export const subscribeInsuranceUrl = testBaseUrl + '/nanoSanteService/insurances export const getProviderClassUrl = testBaseUrl + '/nanoSanteService/provider-classes'; export const getNetworkActsUrl = testBaseUrl + '/nanoSanteService/acts'; export const createConsultationUrl = testBaseUrl + '/nanoSanteService/health-care-sheets/consultation'; +export const getAmountConsultationUrl = testBaseUrl + '/nanoSanteService/health-care-sheets/performances-amount'; export const getInsurancePrimeAmountUrl = testBaseUrl + '/nanoSanteService/insurances/subscriptions/bonus-amount'; export const uploadInsuranceImagetUrl = 'https://test.ilink-app.com:8086/insurances/subscriptions/upload-images';