diff --git a/App.js b/App.js index f4c16bb8..9c2161fb 100755 --- a/App.js +++ b/App.js @@ -93,6 +93,7 @@ import ExecuterPrescriptionScreen from "./screens/wallet/agent/ExecuterPrescript import ModifierFeuilleSoinScreen from "./screens/wallet/agent/ModifierFeuilleSoinScreen"; import ModifierExecutionPrescriptionScreen from "./screens/wallet/agent/ModifierExecutionPrescriptionScreen"; import HistoriqueNanoSanteUserScreen from "./screens/wallet/user/HistoriqueNanoSanteUserScreen"; +import DemandeAutorisationSoinScreen from "./screens/wallet/user/DemandeAutorisationSoinScreen"; const instructions = Platform.select({ @@ -143,6 +144,7 @@ const AppStack = createDrawerNavigator({ addBeneficiaryScreen: AddBeneficiaryScreen, insuranceSubscriptionScreen: InsuranceSubscriptionScreen, validateConsultationScreen: ValidateConsultationScreen, + demandeAutorisationSoinScreen: DemandeAutorisationSoinScreen, validateConsultationDetailScreen: ValidateConsultationDetailScreen, activateBuySubscriptionScreen: ActivateBuySubscriptionScreen, historiqueNanoSanteUserScreen: HistoriqueNanoSanteUserScreen, diff --git a/components/SpinnerOverlayComponent.js b/components/SpinnerOverlayComponent.js new file mode 100644 index 00000000..687f6b59 --- /dev/null +++ b/components/SpinnerOverlayComponent.js @@ -0,0 +1,68 @@ +/** + * Project iLinkWorld + * File SpinnerOverlayComponent + * Path components + * Created by BRICE ZELE + * Date: 01/02/2022 + */ +import React, {ReactNode} from 'react'; +import {ActivityIndicator, Modal, View} from 'react-native'; +import Text from './Text'; +import I18n from "react-native-i18n"; + +interface SpinnerOverlayProps { + show: boolean; + color?: string; + backgroundColor?: string; + dimLights?: number; + children: ReactNode; + loadingMessage?: string; +} + +const SpinnerOverlay = ({ + show = false, + color = '', + backgroundColor = '', + dimLights = 0.6, + loadingMessage = '', + children = null + }: SpinnerOverlayProps) => { + return ( + + + + {children !== null ? + React.Children.map(children, child => + React.cloneElement(child, {}), + ) + : + + } + + {loadingMessage === '' + ? I18n.t('LOADING_DOTS') + : loadingMessage} + + + + + + ); +}; + +export default SpinnerOverlay; diff --git a/redux/insurance/insurance.actions.js b/redux/insurance/insurance.actions.js index 8bfc2141..697a8865 100644 --- a/redux/insurance/insurance.actions.js +++ b/redux/insurance/insurance.actions.js @@ -7,6 +7,7 @@ */ import InsuranceActions from './insurance.type'; import { + autorisationCareRequestUrl, consultationUrl, createConsultationUrl, executionPrescriptionUrl, @@ -41,9 +42,9 @@ export const fetchGetListInsuranceError = (error: any) => ({ payload: error, }); -export const fetchGetListInsurance = (idCountry) => { +export const fetchGetListInsurance = (idCountry, otherParam = '') => { return ApiAction({ - url: `${getInsuranceListUrl}/networks?country_id=${idCountry}`, + url: `${getInsuranceListUrl}/networks?country_id=${idCountry}${otherParam}`, method: 'GET', onLoading: fetchGetListInsurancePending, onSuccess: fetchGetListInsuranceSuccess, @@ -396,9 +397,9 @@ export const fetchGetNetworkActsError = (error: any) => ({ payload: error, }); -export const fetchGetNetworkActs = (network_id, code = '') => { +export const fetchGetNetworkActs = (network_id, code = '', otherParam = '') => { return ApiAction({ - url: `${getNetworkActsUrl}?network_id=${network_id}&code=${code}`, + url: `${getNetworkActsUrl}?network_id=${network_id}&code=${code}${otherParam}`, method: 'GET', onLoading: fetchGetNetworkActsPending, onSuccess: fetchGetNetworkActsSuccess, @@ -596,3 +597,33 @@ export const fetchModifyPrescription = (id, data) => { onError: fetchModifyPrescriptionError, }); }; + +/************************************************************/ +export const fetchDemaneAutorisationSoinPending = () => ({ + type: InsuranceActions.DEMAND_AUTORISATION_PENDING, +}); + +export const fetchDemaneAutorisationSoinReset = () => ({ + type: InsuranceActions.DEMAND_AUTORISATION_RESET, +}); + +export const fetchDemaneAutorisationSoinSuccess = (authkey: any) => ({ + type: InsuranceActions.DEMAND_AUTORISATION_SUCCESS, + payload: authkey, +}); + +export const fetchDemaneAutorisationSoinError = (error: any) => ({ + type: InsuranceActions.DEMAND_AUTORISATION_ERROR, + payload: error, +}); + +export const fetchDemaneAutorisationSoin = (data) => { + return ApiAction({ + url: `${autorisationCareRequestUrl}`, + method: 'POST', + data, + onLoading: fetchDemaneAutorisationSoinPending, + onSuccess: fetchDemaneAutorisationSoinSuccess, + onError: fetchDemaneAutorisationSoinError, + }); +}; diff --git a/redux/insurance/insurance.reducer.js b/redux/insurance/insurance.reducer.js index b8741562..bedd4f5b 100644 --- a/redux/insurance/insurance.reducer.js +++ b/redux/insurance/insurance.reducer.js @@ -587,3 +587,33 @@ export const modifyPrescriptionReducer = (state = INITIAL_STATE, action: Insuran } }; + +export const demandeAutorisationSoinReducer = (state = INITIAL_STATE, action: InsuranceActions) => { + switch (action.type) { + case InsuranceActions.DEMAND_AUTORISATION_PENDING: + return { + ...state, + loading: true + } + case InsuranceActions.DEMAND_AUTORISATION_SUCCESS: + return { + loading: false, + result: action.payload, + error: null + } + case InsuranceActions.DEMAND_AUTORISATION_ERROR: + return { + ...state, + loading: false, + result: null, + error: action.payload + } + + case InsuranceActions.DEMAND_AUTORISATION_RESET: + return INITIAL_STATE; + + default: + return state + + } +}; diff --git a/redux/insurance/insurance.selector.js b/redux/insurance/insurance.selector.js index cc60aad4..97a433aa 100644 --- a/redux/insurance/insurance.selector.js +++ b/redux/insurance/insurance.selector.js @@ -26,6 +26,7 @@ const selectGetConsultationReducer = (state) => state.getConsultationReducer; const selectAcceptRefuseConsultationReducer = (state) => state.acceptOrRejectConsultationReducer; const selectExecutionPrescriptionReducerReducer = (state) => state.executionPrescriptionReducer; const selectModifyPrescriptionReducer = (state) => state.modifyPrescriptionReducer; +const selectDemandeAutorisationSoinReducer = (state) => state.demandeAutorisationSoinReducer; export const selectInsuranceList = createSelector( [selectInsuranceListReducer], @@ -111,3 +112,8 @@ export const selectModifyPrescription = createSelector( [selectModifyPrescriptionReducer], (modifyPrescriptionReducer) => modifyPrescriptionReducer ); + +export const selectDemandeAutorisationSoin = createSelector( + [selectDemandeAutorisationSoinReducer], + (demandeAutorisationSoin) => demandeAutorisationSoin +); diff --git a/redux/insurance/insurance.type.js b/redux/insurance/insurance.type.js index c96cd4c1..799180de 100644 --- a/redux/insurance/insurance.type.js +++ b/redux/insurance/insurance.type.js @@ -100,5 +100,10 @@ const InsuranceActions = { MODIFY_PRESCRIPTION_SUCCESS: 'MODIFY_PRESCRIPTION_SUCCESS', MODIFY_PRESCRIPTION_ERROR: 'MODIFY_PRESCRIPTION_ERROR', MODIFY_PRESCRIPTION_RESET: 'MODIFY_PRESCRIPTION_RESET', + + DEMAND_AUTORISATION_PENDING: 'DEMAND_AUTORISATION_PENDING', + DEMAND_AUTORISATION_SUCCESS: 'DEMAND_AUTORISATION_SUCCESS', + DEMAND_AUTORISATION_ERROR: 'DEMAND_AUTORISATION_ERROR', + DEMAND_AUTORISATION_RESET: 'DEMAND_AUTORISATION_RESET', } export default InsuranceActions; diff --git a/redux/reducers/index.js b/redux/reducers/index.js index 356be876..a74deb53 100755 --- a/redux/reducers/index.js +++ b/redux/reducers/index.js @@ -55,7 +55,11 @@ import { activatePaySubscriptionReducer, addBeneficiaryToSubscriptionReducer, addDrugReducer, - createConsultationReducer, executionPrescriptionReducer, getAmountConsultationReducer, getConsultationReducer, + createConsultationReducer, + demandeAutorisationSoinReducer, + executionPrescriptionReducer, + getAmountConsultationReducer, + getConsultationReducer, getDrugAppareilReducer, getInsurancePrimeAmountReducer, getNetworkActReducer, @@ -63,7 +67,8 @@ import { getSubscriptionListReducer, getUserByIdQRCodeReducer, getUserByNameOrNumberReducer, - insuranceListReducer, modifyPrescriptionReducer, + insuranceListReducer, + modifyPrescriptionReducer, subscribeInsuranceReducer, uploadInsuranceImagesReducer } from "../insurance/insurance.reducer"; @@ -171,7 +176,8 @@ const rootReducer = persistCombineReducers(persistConfig, { getConsultationReducer: getConsultationReducer, acceptOrRejectConsultationReducer: acceptOrRejectConsultationReducer, executionPrescriptionReducer: executionPrescriptionReducer, - modifyPrescriptionReducer: modifyPrescriptionReducer + modifyPrescriptionReducer: modifyPrescriptionReducer, + demandeAutorisationSoinReducer: demandeAutorisationSoinReducer }); export default rootReducer; diff --git a/screens/optionMenu/OptionsMenu.js b/screens/optionMenu/OptionsMenu.js index 58fd7db3..100424f3 100755 --- a/screens/optionMenu/OptionsMenu.js +++ b/screens/optionMenu/OptionsMenu.js @@ -273,7 +273,8 @@ export default class OptionsMenu extends Component { || item === 'adhererGroupNanoCredit' || item === 'myNanoCreditGroup' || item === 'askNanoCredit' || item === 'refundNanoCreditUser' || item === 'cautionNanoCreditAgent' || item === 'epargnerArgentUser' || item === 'askNanoCredit' || item === 'casserEpargneUser' || item === 'envoieWalletToBankAgent' || item === 'reattachAccountUser' || item === 'insuranceSubscriptionScreen' || item === 'addBeneficiaryScreen' || item === 'activateBuySubscriptionScreen' || item === 'saisirFeuilleSoinScreen' || item === 'validateConsultationScreen' || item === 'validateConsultationDetailScreen' - || item === 'executerPrescriptionScreen' || item === 'modifierFeuilleSoinScreen' || item === 'modifierExecutionPrescriptionScreen' || item === 'historiqueNanoSanteUserScreen') { + || item === 'executerPrescriptionScreen' || item === 'modifierFeuilleSoinScreen' || item === 'modifierExecutionPrescriptionScreen' || item === 'historiqueNanoSanteUserScreen' + || item === 'demandeAutorisationSoinScreen') { return null } else { const color = this.state.currentId === item.id ? theme.accent : "grey" diff --git a/screens/wallet/user/DemandeAutorisationSoinScreen.js b/screens/wallet/user/DemandeAutorisationSoinScreen.js new file mode 100644 index 00000000..b8f24e9f --- /dev/null +++ b/screens/wallet/user/DemandeAutorisationSoinScreen.js @@ -0,0 +1,406 @@ +/** + * Project iLinkWorld + * File DemandeAutorisationSoinScreen + * Path screens/wallet/user + * Created by BRICE ZELE + * Date: 01/02/2022 + */ +import React, {useEffect, useState} from 'react'; +import { + ActivityIndicator, + Alert, + Dimensions, + KeyboardAvoidingView, + Platform, + ProgressBarAndroid, + ScrollView, + StyleSheet, + TouchableOpacity, + View, +} from 'react-native'; +import {connect, useDispatch} from 'react-redux'; +import {Color} from "../../../config/Color"; +import I18n from 'react-native-i18n'; +import {ScreenComponent} from "../../../components/ScreenComponent"; +import { + fetchAcceptRejectConsultation, + fetchAcceptRejectConsultationReset, + fetchActivePaySubscription, fetchDemaneAutorisationSoin, fetchDemaneAutorisationSoinReset, + fetchGetConsultation, + fetchGetConsultationReset, + fetchGetListInsurance, + fetchGetListInsuranceReset, + fetchGetNetworkActs +} from "../../../redux/insurance/insurance.actions"; +import DropdownAlert from "react-native-dropdownalert"; +import {createStructuredSelector} from "reselect"; +import { + selectAcceptRefuseConsultation, + selectActivatePaySubscription, selectDemandeAutorisationSoin, + selectGetConsultation, selectGetNetworkAct, + selectInsuranceList, + selectSubscriptionList +} from "../../../redux/insurance/insurance.selector"; +import {readUser} from "../../../webservice/AuthApi"; +import Text from '../../../components/Text'; +import * as Utils from "../../../utils/UtilsFunction"; +import {uppercaseFirstLetter} from "../../../utils/UtilsFunction"; +import Dialog from "react-native-dialog"; +import {Typography} from "../../../config/typography"; +import {store} from "../../../redux/store"; +import {Formik} from "formik"; +import * as Animatable from "react-native-animatable"; +import {responsiveWidth} from "react-native-responsive-dimensions"; +import {Dropdown} from "react-native-material-dropdown"; +import PasswordInput from "../../../components/PasswordInput"; +import FontAwesome from "react-native-vector-icons/FontAwesome"; +import Button from "../../../components/Button"; +import * as Yup from "yup"; +import SpinnerOverlay from "../../../components/SpinnerOverlayComponent"; + + +let moment = require('moment-timezone'); + +const {width, height} = Dimensions.get('window'); + +const DemandeAutorisationSoinScreen = ({ + navigation, + fetchGetNetworkActs, + fetchAcceptRejectConsultation, + fetchGetListInsurance, + fetchDemaneAutorisationSoin, + getConsultation, + insuranceList, + getNetworkAct, + demandeAutorisationSoin + }) => { + const dispatch = useDispatch(); + const [user, setUser] = useState(null); + const [displayModalHistory, setDisplayModalHistory] = useState(false); + const [historyItemDetail, setHistoryItemDetail] = useState({}); + const [wallet] = useState(store.getState().walletDetailReducer.result.response); + const [insurances, setInsurances] = useState([]); + const [insurance, setInsurance] = useState(null); + + let insurancesRef = null; + let codeActeRef = null; + + let dropDownAlertRef: any = null; + + const RegisterSchema = Yup.object().shape({ + password: Yup.string() + .required(I18n.t('THIS_FIELD_IS_REQUIRED')) + }); + + useEffect(() => { + dispatch(fetchGetConsultationReset()); + dispatch(fetchGetListInsuranceReset()); + dispatch(fetchAcceptRejectConsultationReset()); + readUser().then((user) => { + setUser(user); + console.log("User", user); + fetchGetListInsurance(user.country_id, `&user_id=${user.id}`); + //fetchGetConsultation(user.id, 'ACCEPTED', ''); + }); + //fetchGetNetworkActs(wallet.idNetwork, '', '&authorization_type=PRIOR'); + }, []); + + useEffect(() => { + if (getConsultation.error) { + dropDownAlertRef.alertWithType( + 'error', + I18n.t('ERROR_LABEL'), + Utils.getErrorMsg(getConsultation), + ); + dispatch(fetchGetConsultationReset()); + } + }, [getConsultation]); + + useEffect(() => { + if (insuranceList.result !== null) { + let insuranceListTemp = []; + insuranceList.result.response.map((insuranceItem, index) => { + insuranceListTemp.push(insuranceItem); + }); + setInsurances(insuranceListTemp); + } + + if (insuranceList.error) { + dropDownAlertRef.alertWithType( + 'error', + I18n.t('ERROR_LABEL'), + Utils.getErrorMsg(insuranceList), + ); + dispatch(fetchGetListInsuranceReset()); + } + }, [insuranceList]); + + useEffect(() => { + if (demandeAutorisationSoin.result !== null) { + Alert.alert( + I18n.t("SUCCESS"), + demandeAutorisationSoin.result.response, + [ + { + text: I18n.t("OK"), onPress: () => { + dispatch(fetchDemaneAutorisationSoinReset()); + navigation.goBack(); + } + } + + ], + {cancelable: false} + ); + } + + if (demandeAutorisationSoin.error) { + dropDownAlertRef.alertWithType( + 'error', + I18n.t('ERROR_LABEL'), + Utils.getErrorMsg(demandeAutorisationSoin), + ); + dispatch(fetchDemaneAutorisationSoinReset()); + } + }, [demandeAutorisationSoin]); + + const renderLoader = () => ( + + {Platform.OS === 'android' + ? + ( + <> + + {I18n.t('LOADING_DOTS')} + + + ) : + <> + + {I18n.t('LOADING_DOTS')} + + } + + ); + return ( + + (dropDownAlertRef = ref)}/> + + + + + { + if (user !== null) { + if (insurance === null) { + insurancesRef.shake(800); + } else if (values.code_acte === '') + codeActeRef.shake(200) + else { + + fetchDemaneAutorisationSoin({ + act_id: values.code_acte, + user_id: user.id, + password: values.password + }); + console.log(user); + console.log("insurance", insurance); + } + } + }}> + + {({ + values, + errors, + touched, + handleChange, + handleBlur, + setFieldValue, + setFieldTouched, + handleSubmit, + isSubmitting, + }) => (<> + { + insuranceList.loading + ? renderLoader() + : insuranceList.result ? + + { + insurancesRef = comp + }} + style={{ + width: responsiveWidth(90), + height: 60, + alignSelf: 'center', + borderRadius: 10, + paddingLeft: 20, + paddingRight: 20, + backgroundColor: 'white' + }}> + { + console.log("Value", value); + setInsurance(value); + dispatch(fetchGetConsultationReset()); + fetchGetNetworkActs(value.id, '', '&authorization_type=PRIOR') + }} + valueExtractor={(value) => { + return value + }} + labelExtractor={(value) => { + return value.name + }} + /> + + + { + codeActeRef = comp + }} + style={{ + width: responsiveWidth(90), + height: 60, + alignSelf: 'center', + borderRadius: 10, + paddingLeft: 20, + marginTop: 10, + paddingRight: 20, + backgroundColor: 'white' + }}> + { + setFieldTouched('code_acte'); + setFieldValue('code_acte', value.id); + }} + valueExtractor={(value) => { + return value + }} + labelExtractor={(value) => { + return value.name + }} + /> + + + } + value={values.password} + onBlur={handleBlur('password')} + success={touched.password && !errors.password} + touched={touched.password} + error={errors.password} + /> + + + + : null} + )} + + + + + + {/* {getConsultation.loading + ? renderLoader() + : getConsultation.result !== null ? + ( + { + return ( + {I18n.t('NO_CONSULTATION_DEMAND')} + ) + }} + data={[]} + keyExtractor={(item, index) => item.id} + renderItem={({item, index}) => ( + renderItem(item) + )} + /> + ) + : null}*/} + + ) +}; + +const mapStateToProps = createStructuredSelector({ + subscriptionList: selectSubscriptionList, + insuranceList: selectInsuranceList, + activatePaySubscription: selectActivatePaySubscription, + getConsultation: selectGetConsultation, + getNetworkAct: selectGetNetworkAct, + demandeAutorisationSoin: selectDemandeAutorisationSoin +}); + +export default connect(mapStateToProps, { + fetchActivePaySubscription, + fetchGetNetworkActs, + fetchAcceptRejectConsultation, + fetchGetListInsurance, + fetchDemaneAutorisationSoin +})( + DemandeAutorisationSoinScreen, +); +const styles = StyleSheet.create({ + textInput: { + height: 46, + backgroundColor: Color.fieldColor, + borderRadius: 5, + marginTop: 10, + padding: 10, + width: '100%', + }, + lineRow: { + flexDirection: 'row', + justifyContent: 'space-between', + paddingBottom: 20, + }, + contain: { + marginTop: 20, + paddingBottom: 20, + paddingLeft: 10, + paddingRight: 10, + flex: 1, + }, + content: { + padding: 10, + marginBottom: 10, + borderRadius: 8 + }, + contentTop: { + flexDirection: "row", + paddingBottom: 10, + borderBottomWidth: 1 + }, + + contentBottom: { + flexDirection: "row", + marginTop: 10, + justifyContent: "space-between" + }, + bottomLeft: {flexDirection: "row", alignItems: "center"}, + image: {width: 32, height: 32, marginRight: 10, borderRadius: 16}, + blockView: { + paddingVertical: 10, + borderBottomWidth: 0.5, + }, +}); diff --git a/utils/UtilsFunction.js b/utils/UtilsFunction.js index 31a1f100..3fea8223 100755 --- a/utils/UtilsFunction.js +++ b/utils/UtilsFunction.js @@ -524,7 +524,7 @@ export const optionNanoSanteUserScreen = { { icon: 'account-multiple', title: 'DEMAND_AUTORIZATION_HEALTH', - screen: '' + screen: 'demandeAutorisationSoinScreen' }, { title: 'HISTORIC_HEALTH', diff --git a/webservice/IlinkConstants.js b/webservice/IlinkConstants.js index 30bb92aa..0a7c52e2 100755 --- a/webservice/IlinkConstants.js +++ b/webservice/IlinkConstants.js @@ -93,6 +93,7 @@ export const executionPrescriptionUrl = testBaseUrl + '/nanoSanteService/health- export const consultationUrl = testBaseUrl + '/nanoSanteService/health-care-sheets'; export const getAmountConsultationUrl = testBaseUrl + '/nanoSanteService/health-care-sheets/performances-amount'; export const getInsurancePrimeAmountUrl = testBaseUrl + '/nanoSanteService/insurances/subscriptions/bonus-amount'; +export const autorisationCareRequestUrl = testBaseUrl + '/nanoSanteService/authorizations-care-requests'; export const uploadInsuranceImagetUrl = 'https://test.ilink-app.com:8086/insurances/subscriptions/upload-images'; export const authKeyUrl = testBaseUrl + '/oauth/token';