/** * Project iLinkWorld * File SaisirFeuilleSoinScreen * Path screens/wallet/agent * Created by BRICE ZELE * Date: 11/11/2021 */ import React, {useEffect, useRef, useState} from 'react'; import { ActivityIndicator, Alert, Dimensions, FlatList, Keyboard, KeyboardAvoidingView, Platform, ScrollView, StyleSheet, TouchableOpacity, View, } from 'react-native'; import {connect, useDispatch} from 'react-redux'; import Dialog from "react-native-dialog"; import {Formik, useFormik} from 'formik'; import * as Yup from 'yup'; import {Color} from "../../../config/Color"; import I18n from 'react-native-i18n'; import {ScreenComponent} from "../../../components/ScreenComponent"; import Button from "../../../components/Button"; import {responsiveWidth} from "react-native-responsive-dimensions"; import { fetchActivePaySubscription, fetchActivePaySubscriptionReset, fetchAddDrug, fetchAddDrugReset, fetchCheckInsuranceCoverageAmount, fetchCheckInsuranceCoverageAmountReset, fetchCreateConsultation, fetchCreateConsultationReset, fetchGetAmountConsultation, fetchGetAmountConsultationReset, fetchGetDrugAppareil, fetchGetDrugAppareilReset, fetchGetNetworkActs, fetchGetNetworkActsReset, fetchGetProviderClass, fetchGetProviderClassReset, fetchGetSubscriptionList, fetchGetSubscriptionListReset, fetchGetUserByIdQRCode, fetchGetUserByIdQRCodeReset, fetchGetUserByNameOrNumber, fetchGetUserByNameOrNumberReset } from "../../../redux/insurance/insurance.actions"; import DropdownAlert from "react-native-dropdownalert"; import {readUser} from "../../../webservice/AuthApi"; import TextInput from "../../../components/TextInput"; import {createStructuredSelector} from "reselect"; import { selectActivatePaySubscription, selectAddDrug, selectCheckInsuranceCoverageAmount, selectCreateConsultation, selectGetAmountConsultation, selectGetDrugAppareil, selectGetNetworkAct, selectGetProviderClass, selectGetUserByIdQRCode, selectGetUserByIdQRCodeReducer, selectGetUserByNameOrNumber, selectGetUserByNameOrNumberReducer, selectSubscriptionList } from "../../../redux/insurance/insurance.selector"; import StepHeader from "../../../components/StepHeaderComponent"; import Wizard from "react-native-wizard"; import Icon from "react-native-vector-icons/FontAwesome5"; import FontAwesome5 from "react-native-vector-icons/FontAwesome5"; import FontAwesome from "react-native-vector-icons/FontAwesome"; import Text from "../../../components/Text"; import SwitchSelector from "react-native-switch-selector"; import * as Animatable from "react-native-animatable"; import {Dropdown} from "react-native-material-dropdown"; import Modal from "react-native-modal"; import DateTimePicker from "@react-native-community/datetimepicker"; import QRCodeScanner from "react-native-qrcode-scanner"; import {RNCamera} from "react-native-camera"; import * as Utils from "../../../utils/UtilsFunction"; import {store} from "../../../redux/store"; import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons"; import Fontisto from "react-native-vector-icons/Fontisto"; let moment = require('moment-timezone'); const {width, height} = Dimensions.get('window'); const CIRCLE_SIZE = width * 0.5; 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: { alignItems: 'center', marginTop: 40, paddingBottom: 20, paddingLeft: 20, paddingRight: 20, flex: 1, }, circle: { width: CIRCLE_SIZE, height: CIRCLE_SIZE, borderRadius: CIRCLE_SIZE / 2, position: 'absolute', top: '15%', }, circleContainer: { alignItems: 'flex-end', right: -(CIRCLE_SIZE / 3), top: -(CIRCLE_SIZE / 1.5), }, lineSeparator: { borderWidth: 1, width: '40%', height: 1, alignSelf: 'center', }, line: { width: 1, height: 14, backgroundColor: Color.grayColor, marginLeft: 10, }, contentModeView: { width: 30, height: '100%', alignItems: 'flex-end', justifyContent: 'center', }, contentFilter: { flexDirection: 'row', alignItems: 'center', marginLeft: 10, }, bottomModal: { justifyContent: 'flex-end', margin: 0, }, contentFilterBottom: { width: "100%", borderTopLeftRadius: 8, borderTopRightRadius: 8, paddingHorizontal: 20 }, contentSwipeDown: { paddingTop: 10, alignItems: 'center', }, lineSwipeDown: { width: 30, height: 2.5, backgroundColor: Color.dividerColor, }, contentActionModalBottom: { flexDirection: 'row', paddingVertical: 15, justifyContent: 'space-between', borderBottomWidth: 1, }, containModal: { paddingVertical: 10, paddingHorizontal: 20, flexDirection: 'row', justifyContent: 'space-between', }, floatingButtonAdd: { backgroundColor: Color.accentColor, position: "absolute", width: 25, bottom: 0, zIndex: 1000, right: 20, top: 35, height: 25, borderRadius: 12.5, alignItems: 'center', justifyContent: 'center', }, contentSwitch: { width: responsiveWidth(40), }, switch: {}, choosePhotoBtn: { marginTop: 10, marginBottom: 10, width: "auto", height: "auto", padding: 5, alignItems: 'center', borderColor: Color.borderColor, marginRight: 10, elevation: 2, }, checkbox: { alignSelf: "center", color: "white" }, itemAmountPerMonth: { paddingLeft: 10, marginTop: 10, flexDirection: 'row', }, dot: { width: 12, height: 12, borderRadius: 6 }, blockView: { paddingVertical: 10, borderBottomWidth: 0.5, }, iconNavigation: { width: '100%', flexDirection: 'row', marginTop: 20, justifyContent: 'space-between', alignItems: 'center', }, iconNavigationButton: { borderWidth: 1, borderRadius: 25, width: 50, height: 50, alignItems: 'center', justifyContent: 'center' }, beneficiarySubSection: { marginTop: 10, flexDirection: 'row', width: '100%', } }); const SaisirFeuilleSoinScreen = ({ activatePaySubscription, fetchGetSubscriptionList, subscriptionList, fetchActivePaySubscription, fetchGetUserByIdQRCode, fetchGetUserByNameOrNumber, fetchGetDrugAppareil, fetchAddDrug, fetchGetProviderClass, fetchGetNetworkActs, fetchCreateConsultation, fetchGetAmountConsultation, fetchCheckInsuranceCoverageAmount, getUserByNameOrNumber, getUserByIdQRCode, getDrugAppareil, getProviderClass, addDrug, checkInsuranceCoverageAmount, createConsultation, getNetworkAct, getAmountConsultation, navigation }) => { const [datePrestation, setDatePrestation] = useState('' + moment(new Date()).format('YYYY-MM-DD HH:mm')); const [showDatePrestation, setShowDatePrestation] = useState(false); const [dateAccident, setDateAccident] = useState(null); const [isAccident, setIsAccident] = useState(false); const [showQRCodeScanner, setShowQRCodeScanner] = useState(false); const [showDateAccidentPicker, setShowDateAccidentPicker] = useState(false); const [wallet] = useState(store.getState().walletDetailReducer.result.response); const [isNumeroAssureSearch, setIsNumeroAssureSearch] = useState(false); const [isPhoneAssureSearch, setIsPhoneAssureSearch] = 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 [tmpSheetId, setTmpSheetId] = useState('' + Date.now()); const [user, setUser] = useState(null); const [assure, setAssure] = useState(null); const [beneficiary, setBeneficiary] = useState(null); const [medicament, setMedicament] = useState(null); const wizard = useRef(); const [isFirstStep, setIsFirstStep] = useState(true); const [isLastStep, setIsLastStep] = useState(false); 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); const [networkAct, setNetworkAct] = useState(null); const [prestations, setPrestations] = useState([]); const [examens, setExamens] = useState([]); const [prescriptions, setPrescriptions] = useState([]); console.log("Prestations", prestations); console.log("examens", examens); console.log("prescriptions", prescriptions); const [statutPatientOption] = useState([ {label: I18n.t('AYANT_DROITS'), value: "M"}, {label: I18n.t('ASSURE'), value: "F"}, ]); const [statutPatient, setStatutPatient] = useState(1); const [accident] = useState([ {label: I18n.t('YES'), value: "YES"}, {label: I18n.t('NO'), value: "NO"}, ]); const [grossesse] = useState([ {label: I18n.t('YES'), value: "YES"}, {label: I18n.t('NO'), value: "NO"}, ]); const [visiteDomicile] = useState([ {label: I18n.t('YES'), value: "YES"}, {label: I18n.t('NO'), value: "NO"}, ]); const [isVisiteDomicile, setIsVisiteDomicile] = useState(false); 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" }, ]); 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) => { setFieldValue('agrement_praticien', user.code_membre); console.log("User", user); setUser(user) }); dispatch(fetchGetSubscriptionListReset()); dispatch(fetchActivePaySubscriptionReset()); dispatch(fetchGetUserByNameOrNumberReset()); dispatch(fetchGetUserByIdQRCodeReset()); dispatch(fetchGetDrugAppareilReset()); dispatch(fetchCreateConsultationReset()); dispatch(fetchGetNetworkActsReset()); dispatch(fetchGetProviderClassReset()); dispatch(fetchAddDrugReset()); dispatch(fetchCheckInsuranceCoverageAmountReset()); fetchGetProviderClass(wallet.id_network); }, []); useEffect(() => { if (user !== null) { console.log("user", user); } }, [user]); useEffect(() => { console.log("getUserByNameOrNumber.result", getUserByNameOrNumber); if (getUserByNameOrNumber.result !== null) { if (getUserByNameOrNumber.result.response.length > 0) { setModalListAssure(true); //wizard.current.next(); } else { dropDownAlertRef.alertWithType( 'warn', I18n.t('EMPTY_LIST'), I18n.t('NO_ASSURE_MATCH_SEARCH'), ); dispatch(fetchGetUserByNameOrNumberReset()); } } if (getUserByNameOrNumber.error) { Alert.alert( I18n.t("ERROR_LABLE"), Utils.getErrorMsg(getUserByNameOrNumber), [ { text: I18n.t("OK"), onPress: () => { dispatch(fetchGetUserByNameOrNumberReset()); } } ], {cancelable: false} ); /* dropDownAlertRef.alertWithType( 'error', I18n.t('ERROR_LABEL'), Utils.getErrorMsg(getUserByNameOrNumber), ); dispatch(fetchGetUserByNameOrNumberReset());*/ } }, [getUserByNameOrNumber]); useEffect(() => { console.log("getUserByNameOrNumber.result", getUserByNameOrNumber); if (getUserByNameOrNumber.result !== null) { if (getUserByNameOrNumber.result.response.length > 0) { setModalListAssure(true); //wizard.current.next(); } else { dropDownAlertRef.alertWithType( 'warn', I18n.t('EMPTY_LIST'), I18n.t('NO_ASSURE_MATCH_SEARCH'), ); dispatch(fetchGetUserByNameOrNumberReset()); } } if (getUserByNameOrNumber.error) { Alert.alert( I18n.t("ERROR_LABLE"), Utils.getErrorMsg(getUserByNameOrNumber), [ { text: I18n.t("OK"), onPress: () => { dispatch(fetchGetUserByNameOrNumberReset()); } } ], {cancelable: false} ); /* dropDownAlertRef.alertWithType( 'error', I18n.t('ERROR_LABEL'), Utils.getErrorMsg(getUserByNameOrNumber), ); dispatch(fetchGetUserByNameOrNumberReset());*/ } }, [getUserByNameOrNumber]); useEffect(() => { console.log("checkInsuranceCoverageAmount.result", checkInsuranceCoverageAmount); console.log("Prestations", prestations); if (checkInsuranceCoverageAmount.result !== null) { if (checkInsuranceCoverageAmount.result.response !== null) { if (prestations !== null) { setModalPrestation(false); Utils.displayToast(I18n.t('PRESTATION_SUCCESSFULLY_ADD')); } /* if(examens !== null) { setModalExamen(false); Utils.displayToast(I18n.t('EXAMENS_SUCCESSFULLY_ADD')); } if(prescriptions !== null) { setModalMedicament(false); Utils.displayToast(I18n.t('PRESCRIPTIONS_SUCCESSFULLY_ADD')); }*/ dispatch(fetchCheckInsuranceCoverageAmountReset()); } } if (checkInsuranceCoverageAmount.error) { Alert.alert( I18n.t("INFORMATION_MESSAGE"), Utils.getErrorMsg(checkInsuranceCoverageAmount), [ { text: I18n.t("OK"), onPress: () => { if (prestations !== null) { let newPrestation = [...prestations]; newPrestation.shift(); setPrestations(newPrestation); setModalPrestation(false); } /* if(examens !== null) { setModalExamen(false); } if(prescriptions !== null) { setModalMedicament(false); }*/ dispatch(fetchCheckInsuranceCoverageAmountReset()); } } ], {cancelable: false} ); /* dropDownAlertRef.alertWithType( 'error', I18n.t('ERROR_LABEL'), Utils.getErrorMsg(getUserByNameOrNumber), ); dispatch(fetchGetUserByNameOrNumberReset());*/ } }, [checkInsuranceCoverageAmount]); useEffect(() => { 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} ) } } if (getDrugAppareil.error) { Alert.alert( I18n.t("ERROR_LABLE"), Utils.getErrorMsg(getDrugAppareil), [ { text: I18n.t("OK"), onPress: () => { dispatch(fetchGetDrugAppareilReset()); } } ], {cancelable: false} ); /* dropDownAlertRef.alertWithType( 'error', I18n.t('ERROR_LABEL'), Utils.getErrorMsg(getDrugAppareil), ); dispatch(fetchGetDrugAppareilReset());*/ } }, [getDrugAppareil]); useEffect(() => { if (addDrug.result !== null) { setModalAddMedicament(false); setMedicament(addDrug.result.response); } if (addDrug.error) { Alert.alert( I18n.t("ERROR_LABLE"), Utils.getErrorMsg(addDrug), [ { text: I18n.t("OK"), onPress: () => { dispatch(fetchAddDrugReset()); } } ], {cancelable: false} ); /* dropDownAlertRef.alertWithType( 'error', I18n.t('ERROR_LABEL'), Utils.getErrorMsg(addDrug), ); dispatch(fetchAddDrugReset());*/ } }, [addDrug]); useEffect(() => { if (createConsultation.result !== null) { Alert.alert( I18n.t("SUCCESS"), createConsultation.result.response, [ { text: I18n.t("OK"), onPress: () => { dispatch(fetchCreateConsultationReset()); navigation.goBack(); } } ], {cancelable: false} ) } if (createConsultation.error) { Alert.alert( I18n.t("ERROR_LABLE"), Utils.getErrorMsg(createConsultation), [ { text: I18n.t("OK"), onPress: () => { dispatch(fetchCreateConsultationReset()); } } ], {cancelable: false} ); /* dropDownAlertRef.alertWithType( 'error', I18n.t('ERROR_LABEL'), Utils.getErrorMsg(createConsultation), ); dispatch(fetchCreateConsultationReset());*/ } }, [createConsultation]); useEffect(() => { console.log("getUserByNameOrNumber.result", getUserByIdQRCode); if (getUserByIdQRCode.result !== null) { setIsNumeroAssureSearch(false); setIsPhoneAssureSearch(true); setFieldValue('numero_assure', getUserByIdQRCode.result.response.phone); fetchGetUserByNameOrNumber(wallet.id_network, `&phone=${getUserByIdQRCode.result.response.phone}`); } if (getUserByIdQRCode.error) { Alert.alert( I18n.t("ERROR_LABLE"), Utils.getErrorMsg(getUserByIdQRCode), [ { text: I18n.t("OK"), onPress: () => { dispatch(fetchGetUserByIdQRCodeReset()); } } ], {cancelable: false} ); } }, [getUserByIdQRCode]); const SaisirFeuilleSoinSchema = Yup.object().shape({ numero_assure: Yup.string() .required(I18n.t('THIS_FIELD_IS_REQUIRED')), password: Yup.string() .required(I18n.t('THIS_FIELD_IS_REQUIRED')), practitioner_lastname: Yup.string() .required(I18n.t('THIS_FIELD_IS_REQUIRED')), practitioner_firstname: Yup.string() .required(I18n.t('THIS_FIELD_IS_REQUIRED')), }); const AddNewPrestation = Yup.object().shape({ amount_prestation: Yup.number().required(I18n.t('THIS_FIELD_IS_REQUIRED')), code_acte: Yup.object().required(I18n.t('THIS_FIELD_IS_REQUIRED')), frais_deplacement: Yup.number(), date_prestation: Yup.date(), ticker_moderateur: Yup.number(), }); const AddNewExamen = Yup.object().shape({ examen_name: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')), code_acte: Yup.object().required(I18n.t('THIS_FIELD_IS_REQUIRED')), amount: Yup.number(), }); const AddNewMedicament = Yup.object().shape({ drug_name: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')), drug_quantity: Yup.number().required(I18n.t('THIS_FIELD_IS_REQUIRED')), 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'); setDatePrestation(currentDate); }; const renderDatePrestationPicker = () => { return ( ); } const onChangeDateAccident = (event, selectedDate) => { const currentDate = selectedDate || new Date(); setShowDateAccidentPicker(Platform.OS === 'ios'); setDateAccident(moment(currentDate).format('YYYY-MM-DD')); setFieldValue('accident_date', moment(currentDate).format('YYYY-MM-DD')); }; const renderDateAccidentPicker = () => { return ( ); } const onChangeDateDebutGrossesse = (event, selectedDate) => { const currentDate = selectedDate || new Date(); setShowDateDebutGrossessePicker(Platform.OS === 'ios'); setDateDebutGrossesse(moment(currentDate).format('YYYY-MM-DD')); setFieldValue('pregnancy_start_at', moment(currentDate).format('YYYY-MM-DD')); }; const renderDateDebutGrossessePicker = () => { return ( ); } const onChangeDateFinGrossesse = (event, selectedDate) => { const currentDate = selectedDate || new Date(); setShowDateFinGrossessePicker(Platform.OS === 'ios'); setDateFinGrossesse(moment(currentDate).format('YYYY-MM-DD')); setFieldValue('pregnancy_end_at', moment(currentDate).format('YYYY-MM-DD')); }; const renderDateFinGrossessePicker = () => { return ( ); } const renderDialogQRCodeScanner = () => { return ( {I18n.t('SCAN')} {I18n.t('BRING_YOUR_CAMERA_CLOSER_TO_SCAN_QR_CODE')} { setShowQRCodeScanner(false); fetchGetUserByIdQRCode(result.data); }} flashMode={RNCamera.Constants.FlashMode.off} /> { setShowQRCodeScanner(false); }}/> ) } const renderAddNewPrestation = () => ( { if (values.code_acte === '') codeActeRef.shake(200) else { setPrestations([{ act_id: values.code_acte.id, amount: values.amount_prestation, home_visit_fees: values.frais_deplacement }, ...prestations]); fetchCheckInsuranceCoverageAmount({ insurance_id: assure.id, beneficiary_id: beneficiary !== null ? beneficiary.id : null, care_condition: careConditon, act_action: "INSERT", act_type: "PERFORMANCE", tmp_sheet_id: tmpSheetId, performances: [ { amount: values.amount_prestation, home_visit_fees: values.frais_deplacement } ], }); } }}> {({ values, errors, touched, handleChange, handleBlur, setFieldValue, setFieldTouched, handleSubmit, isSubmitting, }) => ( {console.log("Errors", errors)} { setModalPrestation(false); }} swipeDirection={['down']} style={styles.bottomModal}> {I18n.t('ADD_PRESTATION')} { codeActeRef = comp }} style={{ width: responsiveWidth(90), height: 60, alignSelf: 'center', borderRadius: 10, paddingLeft: 20, marginTop: 10, paddingRight: 20, backgroundColor: 'white' }}> act.type === 'CONSULTATION') : []} useNativeDriver={true} onChangeText={(value, index, data) => { setFieldTouched('code_acte'); console.log("Value", value); setFieldValue('code_acte', value); if (value.billing_type !== 'FREE') { setFieldValue('amount_prestation', value.amount); fetchGetAmountConsultation({ network_id: wallet.id_network, amount: '' + value.amount, care_condition: careConditon }); } }} valueExtractor={(value) => { return value }} labelExtractor={(value) => { return value.name }} /> { setFieldValue('amount_prestation', text); fetchGetAmountConsultation({ network_id: wallet.id_network, amount: '' + text, care_condition: careConditon }); }} onBlur={handleBlur('amount_prestation')} success={touched.amount_prestation && !errors.amount_prestation} touched={touched.amount_prestation} error={errors.amount_prestation} /> {I18n.t('VISITE_DOMICILE')} { setIsVisiteDomicile(value === 'YES') }}/> {isVisiteDomicile && ( ) } )} ); const renderAddNewMedicament = () => ( { setPrescriptions([{ drug_or_device_id: medicament.id, dosage: values.drug_posologie, quantity: values.drug_quantity }, ...prescriptions]); Utils.displayToast(I18n.t('PRESCRIPTIONS_SUCCESSFULLY_ADD')); setModalMedicament(false); }}> {({ values, errors, touched, handleChange, handleBlur, handleSubmit, isSubmitting, }) => ( { setModalMedicament(false); }} swipeDirection={['down']} style={styles.bottomModal}> {I18n.t('AJOUTER_MEDICAMENT')} { fetchGetDrugAppareil(wallet.id_network, values.drug_name); }}> {(getDrugAppareil.loading) ? : } )} ); 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", values); setExamens([{ act_id: values.code_acte.id, description: values.examen_name, quantity: null }, ...examens]); setModalExamen(false); Utils.displayToast(I18n.t('EXAMENS_SUCCESSFULLY_ADD')); }}> {({ values, errors, touched, handleChange, setFieldValue, setFieldTouched, handleBlur, handleSubmit, isSubmitting, }) => ( { setModalExamen(false); }} swipeDirection={['down']} style={styles.bottomModal}> {I18n.t('AJOUTER_EXAMEN')} { codeActeRef = comp }} style={{ width: responsiveWidth(90), height: 60, alignSelf: 'center', borderRadius: 10, paddingLeft: 20, marginTop: 10, paddingRight: 20, backgroundColor: 'white' }}> (act.type === "EXAM_OR_OTHER")) : []} useNativeDriver={true} onChangeText={(value, index, data) => { console.log("Value", value); setFieldTouched('code_acte'); setFieldValue('code_acte', value); }} valueExtractor={(value) => { return value }} labelExtractor={(value) => { return value.name }} /> )} ); const renderListAssure = () => ( { setModalListAssure(false); }} swipeDirection={['down']} style={styles.bottomModal}> {I18n.t('LIST_ASSURE')} index} ListEmptyComponent={{I18n.t('NO_ASSURE_MATCH_SEARCH')}} renderItem={({item, index}) => { return ( { if (item.state === 'SUSPENDED') { Alert.alert(I18n.t('ERROR_LABEL'), I18n.t('ASSURE_SUSPENDU'), [{ text: I18n.t('OK'), onPress: () => { } }]); } else if (item.state !== 'PAID') { Alert.alert(I18n.t('ERROR_LABEL'), I18n.t('ASSURE_NON_EN_REGLE'), [{ text: I18n.t('OK'), onPress: () => { } }]); } else { setAssure(item); setBeneficiary(null); setStatutPatient(1); setModalListAssure(false); setFieldValue( 'lastname_patient', item.user.lastname, ); setFieldValue( 'firstname_patient', item.user.firstname, ); fetchGetNetworkActs(wallet.id_network, '', `&user_id=${item.user.id}`); dispatch(fetchGetUserByNameOrNumberReset()); wizard.current.next(); } }}> {`${item.user.firstname !== null ? item.user.firstname : ''} ${item.user.lastname !== null ? item.user.lastname : ''}`} {`${I18n.t('MONTANT_ASSURANCE_CONSOMME')}: ${item.insurance_consumed_amount}`} {`${I18n.t('MONTANT_ASSURANCE_RESTANTE')}: ${item.insurance_remaining_amount}`} {item.beneficiaries.map((beneficiary) => ( { if (item.state === 'SUSPENDED') { Alert.alert(I18n.t('ERROR_LABEL'), I18n.t('ASSURE_PRINCIPAL_SUSPENDU'), [{ text: I18n.t('OK'), onPress: () => { } }]); } else { setAssure(item); setBeneficiary(beneficiary); setStatutPatient(0); setModalListAssure(false); setFieldValue( 'lastname_patient', beneficiary.lastname, ); setFieldValue( 'firstname_patient', beneficiary.firstname, ); fetchGetNetworkActs(wallet.id_network, '', `&user_id=${item.user.id}&beneficiary_id=${beneficiary.id}`); dispatch(fetchGetUserByNameOrNumberReset()); wizard.current.next(); } }}> {`${beneficiary.firstname !== null ? beneficiary.firstname : ''} ${beneficiary.lastname !== null ? beneficiary.lastname : ''} (${I18n.t('AYANT_DROITS')})`} {`${I18n.t('MONTANT_ASSURANCE_CONSOMME')}: ${beneficiary.insurance_consumed_amount}`} {`${I18n.t('MONTANT_ASSURANCE_RESTANTE')}: ${beneficiary.insurance_remaining_amount}`} ))} ) }}/> ) const renderListMedicament = () => ( { setModalListMedicament(false); }} swipeDirection={['down']} style={styles.bottomModal}> {I18n.t('LISTE_MEDICAMENT')} index} renderItem={({item, index}) => { return ( { setMedicament(item); setModalListMedicament(false); }}> {`${item.name} | ${item.type}`} ) }}/> ) const { handleChange, handleSubmit, handleBlur, values, errors, touched, setFieldValue, setFieldTouched, isValid, } = useFormik({ validationSchema: SaisirFeuilleSoinSchema, initialValues: { numero_assure: '', password: '', firstname_patient: '', lastname_patient: '', practitioner_firstname: '', practitioner_lastname: '', agrement_praticien: user?.code_membre, accident_date: null, pregnancy_start_at: null, pregnancy_end_at: null, }, onSubmit: values => { if (prestations.length === 0) { Alert.alert( I18n.t("ERROR_LABLE"), I18n.t('YOU_MUST_ADD_AT_LEAST_ONE_PRESTATION'), [ { text: I18n.t("OK"), onPress: () => { } } ], {cancelable: false} ); /* dropDownAlertRef.alertWithType( 'error', I18n.t('ERROR_LABEL'), I18n.t('YOU_MUST_ADD_AT_LEAST_ONE_PRESTATION'), );*/ } else { fetchCreateConsultation({ insured_id: assure.insured_id, network_agent_id: wallet.network_agent_id, password: values.password, beneficiary_id: beneficiary !== null ? beneficiary.id : null, practitioner_lastname: values.practitioner_lastname, practitioner_firstname: values.practitioner_firstname, practitioner_provider_class_id: values.practitioner_provider_class_id, care_condition: values.care_condition, accident_date: values.accident_date, pregnancy_start_at: values.pregnancy_start_at, pregnancy_end_at: values.pregnancy_end_at, performances: prestations, prescriptions: prescriptions, exams: examens }) } }, }); const onNext = () => { console.log("currentStep", currentStep); switch (currentStep) { case 0: console.log("values", values); dispatch(fetchGetUserByNameOrNumberReset()); if (values.numero_assure !== '' && getUserByNameOrNumber.result === null) { if (isNumeroAssureSearch) fetchGetUserByNameOrNumber(wallet.id_network, `&insured_id=${values.numero_assure}`); else if (isPhoneAssureSearch) fetchGetUserByNameOrNumber(wallet.id_network, `&phone=${values.numero_assure}`); else fetchGetUserByNameOrNumber(wallet.id_network, `&name=${values.numero_assure}`) console.log("errors", errors); } return false; break; default: return true; } }; const stepList = [ { title: I18n.t('ASSURE'), content: ( } /> { setIsNumeroAssureSearch(true); setIsPhoneAssureSearch(false); }} /> { setIsNumeroAssureSearch(false); setIsPhoneAssureSearch(true); }} /> { setIsNumeroAssureSearch(false); setIsPhoneAssureSearch(false); }} /> { setShowQRCodeScanner(true); }} /> ), }, { title: I18n.t('PATIENT'), content: ( {I18n.t('SITUATION')} { //setGender(value); }}/> ), }, { title: I18n.t('PRATICIEN'), content: ( { classificationRef = comp }} style={{ width: responsiveWidth(90), height: 60, alignSelf: 'center', borderRadius: 10, paddingLeft: 20, marginTop: 10, paddingRight: 20, backgroundColor: 'white' }}> { setFieldTouched('practitioner_provider_class_id'); setFieldValue('practitioner_provider_class_id', value.id); console.log("Value", value); }} valueExtractor={(value) => { return value }} labelExtractor={(value) => { return value.name }} /> { classificationRef = comp }} style={{ width: responsiveWidth(90), height: 60, alignSelf: 'center', borderRadius: 10, paddingLeft: 20, marginTop: 10, paddingRight: 20, backgroundColor: 'white' }}> { console.log("Value", value); setCareCondition(value); setFieldTouched('care_condition'); setFieldValue('care_condition', value); }} valueExtractor={(value) => { return value.value }} labelExtractor={(value) => { return value.label }} /> {I18n.t('ACCIDENT')} { console.log(value); setIsAccident(value === 'YES'); }}/> { isAccident && ( { Keyboard.dismiss(); //setDateAccident('' + moment(new Date()).format('YYYY-MM-DD')); setShowDateAccidentPicker(true); }} success={touched.date_accident && !errors.date_accident} touched={touched.date_accident} error={errors.date_accident} /> ) } {I18n.t('GROSSESSE')} { setIsGrossesse(value === 'YES'); }}/> { isGrossesse && ( <> { Keyboard.dismiss(); //setDateAccident('' + moment(new Date()).format('YYYY-MM-DD')); setShowDateDebutGrossessePicker(true); }} success={touched.date_debut_grossesse && !errors.date_debut_grossesse} touched={touched.date_debut_grossesse} error={errors.date_debut_grossesse} /> { Keyboard.dismiss(); //setDateAccident('' + moment(new Date()).format('YYYY-MM-DD')); setShowDateFinGrossessePicker(true); }} success={touched.date_fin_grossesse && !errors.date_fin_grossesse} touched={touched.date_fin_grossesse} error={errors.date_fin_grossesse} /> ) } { dispatch(fetchGetAmountConsultationReset()); setIsVisiteDomicile(false); if (careConditon === null) { dropDownAlertRef.alertWithType( 'warn', I18n.t('ERROR_LABEL'), I18n.t('PLEASE_SELECT_CONDITON_PRISE_CHARGE_FIRST'), ); } else setModalPrestation(true); }}> {I18n.t('CONSULTATION')} { setModalExamen(true); }}> {I18n.t('ACTE_EXAMEN')} { setModalMedicament(true); setMedicament(null); }}> {I18n.t('MEDICAMENT')} ), }, ]; return ( (dropDownAlertRef = ref)}/> setIsFirstStep(val) } isLastStep={val => setIsLastStep(val) } onNext={() => { onNext(); }} onPrev={() => { }} currentStep={({ currentStep, isLastStep, isFirstStep, }) => { setCurrentStep(currentStep); setIsFirstStep(isFirstStep); setIsLastStep(isLastStep); }} /> {!isFirstStep ? ( wizard.current.prev() }> ) : ( )} {currentStep === 2 ? ( ) : ( { handleSubmit(e); if (onNext()) wizard.current.next(); }}> {(subscriptionList.loading || getUserByNameOrNumber.loading || getUserByIdQRCode.loading) ? : } )} {modalPrestation && renderAddNewPrestation()} {modalMedicament && renderAddNewMedicament()} {modalExamen && renderAddNewExamen()} {showDatePrestation && renderDatePrestationPicker()} {showDateAccidentPicker && renderDateAccidentPicker()} {showDateDebutGrossessePicker && renderDateDebutGrossessePicker()} {showDateFinGrossessePicker && renderDateFinGrossessePicker()} {showQRCodeScanner && renderDialogQRCodeScanner()} {modalListAssure && renderListAssure()} {modalListMedicament && renderListMedicament()} {modalAddMedicament && renderAddNewMedicamentToDB()} ); }; const mapStateToProps = createStructuredSelector({ subscriptionList: selectSubscriptionList, activatePaySubscription: selectActivatePaySubscription, getUserByNameOrNumber: selectGetUserByNameOrNumber, getUserByIdQRCode: selectGetUserByIdQRCode, getDrugAppareil: selectGetDrugAppareil, addDrug: selectAddDrug, getProviderClass: selectGetProviderClass, createConsultation: selectCreateConsultation, getNetworkAct: selectGetNetworkAct, getAmountConsultation: selectGetAmountConsultation, checkInsuranceCoverageAmount: selectCheckInsuranceCoverageAmount }); export default connect(mapStateToProps, { fetchActivePaySubscription, fetchGetSubscriptionList, fetchGetUserByIdQRCode, fetchGetUserByNameOrNumber, fetchGetDrugAppareil, fetchAddDrug, fetchGetProviderClass, fetchGetNetworkActs, fetchCreateConsultation, fetchGetAmountConsultation, fetchCheckInsuranceCoverageAmount })( SaisirFeuilleSoinScreen, );