ilink-world/screens/wallet/agent/SaisirFeuilleSoinScreen.js

1343 lines
57 KiB
JavaScript

/**
* 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,
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,
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 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";
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',
},
});
const SaisirFeuilleSoinScreen = ({
activatePaySubscription,
fetchGetSubscriptionList,
subscriptionList,
fetchActivePaySubscription,
fetchGetUserByIdQRCode,
fetchGetUserByNameOrNumber,
getUserByNameOrNumber,
getUserByIdQRCode,
navigation
}) => {
const [datePrestation, setDatePrestation] = useState('' + moment(new Date()).format('YYYY-MM-DD'));
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(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 [user, setUser] = useState(null);
const [assure, setAssure] = 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 [modalPrescription, setModalPrescription] = useState(false);
const [modalListAssure, setModalListAssure] = useState(false);
const [statutPatientOption] = useState([
{label: I18n.t('AYANT_DROITS'), value: "M"},
{label: I18n.t('ASSURE'), value: "F"},
]);
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 [conditionPriseEnChange] = useState([
{label: I18n.t('AFFECTION_COURANTE'), value: "AFFECTION_COURANTE"},
{label: I18n.t('AFFECTION_LONGUE'), value: "AFFECTION_LONGUE"},
{label: I18n.t('EXONERE'), value: "EXONERE"},
]);
const dispatch = useDispatch();
let dropDownAlertRef: any = null;
let classificationRef = null;
let codeActeRef = null;
useEffect(() => {
readUser().then((user) => {
setUser(user)
});
dispatch(fetchGetSubscriptionListReset());
dispatch(fetchActivePaySubscriptionReset());
dispatch(fetchGetUserByNameOrNumberReset());
dispatch(fetchGetUserByIdQRCodeReset());
}, []);
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) {
dropDownAlertRef.alertWithType(
'error',
I18n.t('ERROR_LABEL'),
Utils.getErrorMsg(getUserByNameOrNumber),
);
dispatch(fetchGetUserByNameOrNumberReset());
}
}, [getUserByNameOrNumber]);
console.log("Date accident", dateAccident);
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'))
});
const AddBeneficiarySchema = Yup.object().shape({
lastname: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')),
firstname: Yup.string(),
});
const onChangeDatePrestation = (event, selectedDate) => {
const currentDate = selectedDate || '' + moment(new Date()).format('YYYY-MM-DD');
setShowDatePrestation(Platform.OS === 'ios');
setDatePrestation(currentDate);
};
const renderDatePrestationPicker = () => {
return (<DateTimePicker
timeZoneOffsetInMinutes={0}
is24Hour={true}
value={new Date(dateNaissance)}
mode='date'
display="spinner"
onChange={onChangeDatePrestation}
/>
);
}
const onChangeDateAccident = (event, selectedDate) => {
const currentDate = selectedDate || new Date();
setShowDateAccidentPicker(Platform.OS === 'ios');
setDateAccident(moment(currentDate).format('YYYY-MM-DD'));
};
const renderDateAccidentPicker = () => {
return (<DateTimePicker
timeZoneOffsetInMinutes={0}
is24Hour={true}
value={new Date()}
mode='date'
display="spinner"
onChange={onChangeDateAccident}
/>
);
}
const onChangeDateDebutGrossesse = (event, selectedDate) => {
const currentDate = selectedDate || new Date();
setShowDateDebutGrossessePicker(Platform.OS === 'ios');
setDateDebutGrossesse(moment(currentDate).format('YYYY-MM-DD'));
};
const renderDateDebutGrossessePicker = () => {
return (<DateTimePicker
timeZoneOffsetInMinutes={0}
is24Hour={true}
value={new Date()}
mode='date'
display="spinner"
onChange={onChangeDateDebutGrossesse}
/>
);
}
const onChangeDateFinGrossesse = (event, selectedDate) => {
const currentDate = selectedDate || new Date();
setShowDateFinGrossessePicker(Platform.OS === 'ios');
setDateFinGrossesse(moment(currentDate).format('YYYY-MM-DD'));
};
const renderDateFinGrossessePicker = () => {
return (<DateTimePicker
timeZoneOffsetInMinutes={0}
is24Hour={true}
value={new Date()}
mode='date'
display="spinner"
onChange={onChangeDateFinGrossesse}
/>
);
}
const renderDialogQRCodeScanner = () => {
return (
<Dialog.Container contentStyle={{width: responsiveWidth(80)}} useNativeDriver={true}
visible={showQRCodeScanner}>
<Dialog.Title>{I18n.t('SCAN')}</Dialog.Title>
<ScrollView style={[styles.blockView, {borderBottomColor: Color.borderColor, maxHeight: 300}]}>
<Text>
{I18n.t('BRING_YOUR_CAMERA_CLOSER_TO_SCAN_QR_CODE')}
</Text>
<QRCodeScanner
onRead={(result) => {
setShowQRCodeScanner(false);
console.log("result", result.data);
}}
flashMode={RNCamera.Constants.FlashMode.off}
/>
</ScrollView>
<Dialog.Button bold={true} label={I18n.t('CLOSE')} onPress={() => {
setShowQRCodeScanner(false);
}}/>
</Dialog.Container>
)
}
const renderAddNewPrestation = () => (
<Formik validationSchema={AddBeneficiarySchema}
initialValues={{
amount_prestation: '',
lastname: '',
}}
onSubmit={(values) => {
}}>
{({
values,
errors,
touched,
handleChange,
handleBlur,
handleSubmit,
isSubmitting,
}) => (
<ScrollView style={{flex: 1}}>
<View style={[styles.containModal, {backgroundColor: Color.containerBackgroundColor}]}>
<Modal
isVisible={modalPrestation}
onSwipeComplete={() => {
setModalPrestation(false);
}}
swipeDirection={['down']}
style={styles.bottomModal}>
<View
style={[
styles.contentFilterBottom,
{backgroundColor: Color.containerBackgroundColor},
]}>
<View style={styles.contentSwipeDown}>
<View style={styles.lineSwipeDown}/>
</View>
<Text body2 style={{marginTop: 10}}>{I18n.t('ADD_PRESTATION')}</Text>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('DATE_NAISSANCE')}
value={'' + moment(datePrestation).format('YYYY-MM-DD')}
onChangeText={handleChange('birthdate')}
onBlur={handleBlur('birthdate')}
onFocus={() => {
Keyboard.dismiss();
setShowDatePrestation(true);
}}
success={touched.birthdate && !errors.birthdate}
touched={touched.birthdate}
error={errors.birthdate}
/>
<Animatable.View ref={(comp) => {
codeActeRef = comp
}}
style={{
width: responsiveWidth(90),
height: 60,
alignSelf: 'center',
borderRadius: 10,
paddingLeft: 20,
marginTop: 10,
paddingRight: 20,
backgroundColor: 'white'
}}>
<Dropdown
label={I18n.t('CODE_ACTE')}
data={[]}
useNativeDriver={true}
onChangeText={(value, index, data) => {
console.log("Value", value);
}}
valueExtractor={(value) => {
return value
}}
labelExtractor={(value) => {
return value.name
}}
/>
</Animatable.View>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('AMOUNT')}
value={values.amount_prestation}
onChangeText={handleChange('amount_prestation')}
onBlur={handleBlur('amount_prestation')}
success={touched.amount_prestation && !errors.amount_prestation}
touched={touched.amount_prestation}
error={errors.amount_prestation}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('TICKET_MONDERATEUR')}
value={values.amount_prestation}
onChangeText={handleChange('amount_prestation')}
onBlur={handleBlur('amount_prestation')}
success={touched.amount_prestation && !errors.amount_prestation}
touched={touched.amount_prestation}
error={errors.amount_prestation}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('AMOUNT_PER_INSURANCE')}
value={values.amount_prestation}
onChangeText={handleChange('amount_prestation')}
onBlur={handleBlur('amount_prestation')}
success={touched.amount_prestation && !errors.amount_prestation}
touched={touched.amount_prestation}
error={errors.amount_prestation}
/>
<View style={{
marginTop: 10,
width: "100%",
flexDirection: 'row',
justifyContent: "space-between"
}}>
<Text body2>{I18n.t('VISITE_DOMICILE')}</Text>
<View style={styles.contentSwitch}>
<SwitchSelector options={visiteDomicile}
initial={0}
buttonColor={Color.accentColor}
backgroundColor={Color.primaryDarkColor}
textColor='white'
bold={true}
hasPadding
height={32}
onPress={(value) => {
//setGender(value);
}}/>
</View>
</View>
<Button
style={{marginTop: 20, marginBottom: 20}}
full
onPress={handleSubmit}>
{I18n.t('SUBMIT_LABEL')}
</Button>
</View>
</Modal>
</View>
</ScrollView>
)}
</Formik>
);
const renderAddNewPrescription = () => (
<Formik validationSchema={AddBeneficiarySchema}
initialValues={{
amount_prestation: '',
lastname: '',
}}
onSubmit={(values) => {
}}>
{({
values,
errors,
touched,
handleChange,
handleBlur,
handleSubmit,
isSubmitting,
}) => (
<ScrollView style={{flex: 1}}>
<View style={[styles.containModal, {backgroundColor: Color.containerBackgroundColor}]}>
<Modal
isVisible={modalPrescription}
onSwipeComplete={() => {
setModalPrescription(false);
}}
swipeDirection={['down']}
style={styles.bottomModal}>
<View
style={[
styles.contentFilterBottom,
{backgroundColor: Color.containerBackgroundColor},
]}>
<View style={styles.contentSwipeDown}>
<View style={styles.lineSwipeDown}/>
</View>
<Text body2 style={{marginTop: 10}}>{I18n.t('ADD_PRESCRIPTION')}</Text>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('DATE_PRESTATION')}
value={'' + moment(dateAccident).format('YYYY-MM-DD')}
onChangeText={handleChange('birthdate')}
onBlur={handleBlur('birthdate')}
onFocus={() => {
Keyboard.dismiss();
setShowDatePrestation(true);
}}
success={touched.birthdate && !errors.birthdate}
touched={touched.birthdate}
error={errors.birthdate}
/>
<Animatable.View ref={(comp) => {
codeActeRef = comp
}}
style={{
width: responsiveWidth(90),
height: 60,
alignSelf: 'center',
borderRadius: 10,
paddingLeft: 20,
marginTop: 10,
paddingRight: 20,
backgroundColor: 'white'
}}>
<Dropdown
label={I18n.t('CODE_ACTE')}
data={[]}
useNativeDriver={true}
onChangeText={(value, index, data) => {
console.log("Value", value);
}}
valueExtractor={(value) => {
return value
}}
labelExtractor={(value) => {
return value.name
}}
/>
</Animatable.View>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('AMOUNT')}
value={values.amount_prestation}
onChangeText={handleChange('amount_prestation')}
onBlur={handleBlur('amount_prestation')}
success={touched.amount_prestation && !errors.amount_prestation}
touched={touched.amount_prestation}
error={errors.amount_prestation}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('TICKET_MONDERATEUR')}
value={values.amount_prestation}
onChangeText={handleChange('amount_prestation')}
onBlur={handleBlur('amount_prestation')}
success={touched.amount_prestation && !errors.amount_prestation}
touched={touched.amount_prestation}
error={errors.amount_prestation}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('AMOUNT_PER_INSURANCE')}
value={values.amount_prestation}
onChangeText={handleChange('amount_prestation')}
onBlur={handleBlur('amount_prestation')}
success={touched.amount_prestation && !errors.amount_prestation}
touched={touched.amount_prestation}
error={errors.amount_prestation}
/>
<View style={{
marginTop: 10,
width: "100%",
flexDirection: 'row',
justifyContent: "space-between"
}}>
<Text body2>{I18n.t('VISITE_DOMICILE')}</Text>
<View style={styles.contentSwitch}>
<SwitchSelector options={visiteDomicile}
initial={0}
buttonColor={Color.accentColor}
backgroundColor={Color.primaryDarkColor}
textColor='white'
bold={true}
hasPadding
height={32}
onPress={(value) => {
//setGender(value);
}}/>
</View>
</View>
<Button
style={{marginTop: 20, marginBottom: 20}}
full
onPress={handleSubmit}>
{I18n.t('SUBMIT_LABEL')}
</Button>
</View>
</Modal>
</View>
</ScrollView>
)}
</Formik>
);
const renderListAssure = () => (
<ScrollView style={{flex: 1}}>
<View style={[styles.containModal, {backgroundColor: Color.containerBackgroundColor}]}>
<Modal
isVisible={modalListAssure}
onSwipeComplete={() => {
setModalListAssure(false);
}}
swipeDirection={['down']}
style={styles.bottomModal}>
<View
style={[
styles.contentFilterBottom,
{backgroundColor: Color.containerBackgroundColor},
]}>
<View style={styles.contentSwipeDown}>
<View style={styles.lineSwipeDown}/>
</View>
<Text body2 style={{marginTop: 10}}>{I18n.t('LIST_ASSURE')}</Text>
<FlatList data={getUserByNameOrNumber.result?.response}
extraData={getUserByNameOrNumber.result?.response}
keyExtractor={(item, index) => index}
renderItem={({item, index}) => {
return (
<TouchableOpacity
style={[
styles.contentActionModalBottom,
{borderBottomColor: Color.borderColor},
]}
key={item.id}
onPress={() => {
if (item.state !== 'PAID') {
Alert.alert(I18n.t('ERROR_LABEL'), I18n.t('ASSURE_NON_EN_REGLE'),
[{
text: I18n.t('OK'), onPress: () => {
}
}]);
} else {
setAssure(item);
setModalListAssure(false);
setFieldValue(
'lastname_patient',
item.user.lastname,
);
setFieldValue(
'firstname_patient',
item.user.firstname,
);
dispatch(fetchGetUserByNameOrNumberReset());
wizard.current.next();
}
}}>
<Text body2 semibold>
{`${item.user.firstname} ${item.user.lastname}`}
</Text>
</TouchableOpacity>
)
}}/>
<Button
full
style={{marginTop: 10, marginBottom: 20}}
onPress={() => setModalListAssure(false)}>
{I18n.t('OK')}
</Button>
</View>
</Modal>
</View>
</ScrollView>
)
const {
handleChange,
handleSubmit,
handleBlur,
values,
errors,
touched,
setFieldValue,
setFieldTouched,
isValid,
} = useFormik({
validationSchema: SaisirFeuilleSoinSchema,
initialValues: {
numero_assure: '',
password: '',
firstname_patient: '',
lastname_patient: '',
firstname_praticien: '',
lastname_praticien: '',
agrement_praticien: ''
},
onSubmit: values => {
},
});
const onNext = () => {
console.log("currentStep", currentStep);
console.log("values", values);
switch (currentStep) {
case 0:
if (values.numero_assure !== '') {
if (getUserByNameOrNumber.result === null) {
if (isNumeroAssureSearch)
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: (
<View>
<TextInput
style={{marginTop: 10}}
placeholder={isNumeroAssureSearch ? I18n.t('NUMERO_ASSURE') : I18n.t('NOM_ASSURE')}
value={values.numero_assure}
onChangeText={handleChange('numero_assure')}
onBlur={handleBlur('numero_assure')}
success={touched.numero_assure && !errors.numero_assure}
touched={touched.numero_assure}
error={errors.numero_assure}
icon={
<FontAwesome
style={{zIndex: 10}}
name={isNumeroAssureSearch ? 'lock' : 'user'}
size={20}
/>
}
/>
<View style={{
flexDirection: 'row',
position: 'absolute',
top: 22,
right: 10,
justifyContent: 'space-between',
width: 50
}}>
<Icon
style={{paddingRight: 5}}
name={isNumeroAssureSearch ? 'user' : 'lock'}
size={20}
color={Color.primaryColor}
onPress={() => {
setIsNumeroAssureSearch(!isNumeroAssureSearch);
}}
/>
<Icon
style={{paddingRight: 5}}
name="qrcode"
size={20}
color={Color.primaryColor}
onPress={() => {
setShowQRCodeScanner(true);
}}
/>
</View>
</View>
),
},
{
title: I18n.t('PATIENT'),
content: (
<View>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('NOM_CLIENT')}
value={values.lastname_patient}
onChangeText={handleChange('lastname_patient')}
onBlur={handleBlur('lastname_patient')}
success={touched.lastname_patient && !errors.lastname_patient}
touched={touched.lastname_patient}
error={errors.lastname_patient}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('PRENOM_CLIENT')}
value={values.firstname_patient}
onChangeText={handleChange('firstname_patient')}
onBlur={handleBlur('firstname_patient')}
success={touched.firstname_patient && !errors.firstname_patient}
touched={touched.firstname_patient}
error={errors.firstname_patient}
/>
<View style={{
marginTop: 10,
flexDirection: 'row',
justifyContent: "space-between"
}}>
<Text body2>{I18n.t('SITUATION')}</Text>
<View style={{width: responsiveWidth(60)}}>
<SwitchSelector options={statutPatientOption}
initial={0}
buttonColor={Color.accentColor}
backgroundColor={Color.primaryDarkColor}
textColor='white'
bold={true}
hasPadding
height={32}
onPress={(value) => {
//setGender(value);
}}/>
</View>
</View>
</View>
),
},
{
title: I18n.t('PRATICIEN'),
content: (
<View>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('CODE_AGREMENT')}
value={values.agrement_praticien}
onChangeText={handleChange('agrement_praticien')}
onBlur={handleBlur('agrement_praticien')}
success={touched.agrement_praticien && !errors.agrement_praticien}
touched={touched.agrement_praticien}
error={errors.agrement_praticien}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('NOM_PRATICIEN')}
value={values.lastname_praticien}
onChangeText={handleChange('lastname_praticien')}
onBlur={handleBlur('lastname_praticien')}
success={touched.lastname_praticien && !errors.lastname_praticien}
touched={touched.lastname_praticien}
error={errors.lastname_praticien}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('PRENOM_PRATICIEN')}
value={values.firstname_praticien}
onChangeText={handleChange('firstname_praticien')}
onBlur={handleBlur('firstname_praticien')}
success={touched.firstname_praticien && !errors.firstname_praticien}
touched={touched.firstname_praticien}
error={errors.firstname_praticien}
/>
<Animatable.View ref={(comp) => {
classificationRef = comp
}}
style={{
width: responsiveWidth(90),
height: 60,
alignSelf: 'center',
borderRadius: 10,
paddingLeft: 20,
marginTop: 10,
paddingRight: 20,
backgroundColor: 'white'
}}>
<Dropdown
label={I18n.t('CLASSIFICATION')}
data={[]}
useNativeDriver={true}
onChangeText={(value, index, data) => {
console.log("Value", value);
}}
valueExtractor={(value) => {
return value
}}
labelExtractor={(value) => {
return value.name
}}
/>
</Animatable.View>
<Animatable.View ref={(comp) => {
classificationRef = comp
}}
style={{
width: responsiveWidth(90),
height: 60,
alignSelf: 'center',
borderRadius: 10,
paddingLeft: 20,
marginTop: 10,
paddingRight: 20,
backgroundColor: 'white'
}}>
<Dropdown
label={I18n.t('CONDITION_PRISE_CHARGE')}
data={conditionPriseEnChange}
useNativeDriver={true}
onChangeText={(value, index, data) => {
console.log("Value", value);
}}
valueExtractor={(value) => {
return value
}}
labelExtractor={(value) => {
return value.label
}}
/>
</Animatable.View>
<View style={{
marginTop: 10,
flexDirection: 'row',
justifyContent: "space-between"
}}>
<Text body2>{I18n.t('ACCIDENT')}</Text>
<View style={{width: responsiveWidth(40)}}>
<SwitchSelector options={accident}
initial={1}
buttonColor={Color.accentColor}
backgroundColor={Color.primaryDarkColor}
textColor='white'
bold={true}
hasPadding
height={32}
onPress={(value) => {
console.log(value);
setIsAccident(value === 'YES');
}}/>
</View>
</View>
{
isAccident && (
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('DATE_ACCIDENT')}
value={dateAccident !== null ? dateAccident : ''}
onChangeText={handleChange('date_accident')}
onBlur={handleBlur('date_accident')}
onFocus={() => {
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}
/>
)
}
<View style={{
marginTop: 10,
flexDirection: 'row',
justifyContent: "space-between"
}}>
<Text body2>{I18n.t('GROSSESSE')}</Text>
<View style={styles.contentSwitch}>
<SwitchSelector options={grossesse}
initial={1}
buttonColor={Color.accentColor}
backgroundColor={Color.primaryDarkColor}
textColor='white'
bold={true}
hasPadding
height={32}
onPress={(value) => {
setIsGrossesse(value === 'YES');
}}/>
</View>
</View>
{
isGrossesse && (
<>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('DATE_DEBUT_GROSSESSE')}
value={dateDebutGrossesse !== null ? dateDebutGrossesse : ''}
onChangeText={handleChange('date_debut_grossesse')}
onBlur={handleBlur('date_debut_grossesse')}
onFocus={() => {
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}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('DATE_FIN_GROSSESSE')}
value={dateFinGrossesse !== null ? dateFinGrossesse : ''}
onChangeText={handleChange('date_fin_grossesse')}
onBlur={handleBlur('date_fin_grossesse')}
onFocus={() => {
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}
/>
</>
)
}
<View
style={{
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'space-between',
marginTop: 25,
}}>
<TouchableOpacity
onPress={() => {
setModalPrestation(true);
}}>
<Text body1 primaryColor bold>
{I18n.t('ADD_PRESTATION')}
</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
setModalPrescription(true);
}}>
<Text body1 primaryColor bold>
{I18n.t('ADD_PRESCRIPTION')}
</Text>
</TouchableOpacity>
</View>
</View>
),
},
];
return (
<ScreenComponent>
<DropdownAlert ref={ref => (dropDownAlertRef = ref)}/>
<KeyboardAvoidingView
behavior={Platform.OS === 'android' ? 'height' : 'padding'}
style={{flex: 1}}>
<ScrollView style={{flex: 1}}>
<View style={styles.contain}>
<StepHeader
steps={stepList}
currentStepIndex={currentStep + 1}
/>
<View
style={{
flexDirection: 'column',
alignItems: 'center',
}}>
<Wizard
ref={wizard}
activeStep={0}
steps={stepList}
useNativeDriver
nextStepAnimation="slideLeft"
prevStepAnimation="slideRight"
isFirstStep={val =>
setIsFirstStep(val)
}
isLastStep={val =>
setIsLastStep(val)
}
onNext={() => {
onNext();
}}
onPrev={() => {
}}
currentStep={({
currentStep,
isLastStep,
isFirstStep,
}) => {
setCurrentStep(currentStep);
setIsFirstStep(isFirstStep);
setIsLastStep(isLastStep);
}}
/>
</View>
<View style={styles.iconNavigation}>
{!isFirstStep ? (
<TouchableOpacity
style={[
styles.iconNavigationButton,
{
backgroundColor:
Color.primaryColor,
borderColor:
Color.primaryColor,
},
]}
onPress={() =>
wizard.current.prev()
}>
<Icon
name="arrow-left"
size={20}
color={Color.whiteColor}
/>
</TouchableOpacity>
) : (
<View/>
)}
{currentStep === 3 ? (
<Button
onPress={() => {
}}>
{I18n.t('SUBMIT_LABEL')}
</Button>
) : (
<TouchableOpacity
style={[
styles.iconNavigationButton,
{
backgroundColor:
Color.primaryColor,
borderColor:
Color.primaryColor,
},
]}
onPress={e => {
handleSubmit(e);
if (onNext())
wizard.current.next();
}}>
{(subscriptionList.loading || getUserByNameOrNumber.loading || getUserByIdQRCode.loading) ?
<ActivityIndicator
size="small"
color="#fff"
/>
: <Icon
name="arrow-right"
size={24}
color={Color.whiteColor}
/>}
</TouchableOpacity>
)}
</View>
{modalPrestation && renderAddNewPrestation()}
{modalPrescription && renderAddNewPrescription()}
{showDatePrestation && renderDatePrestationPicker()}
{showDateAccidentPicker && renderDateAccidentPicker()}
{showDateDebutGrossessePicker && renderDateDebutGrossessePicker()}
{showDateFinGrossessePicker && renderDateFinGrossessePicker()}
{showQRCodeScanner && renderDialogQRCodeScanner()}
{modalListAssure && renderListAssure()}
</View>
</ScrollView>
</KeyboardAvoidingView>
</ScreenComponent>
);
};
const mapStateToProps = createStructuredSelector({
subscriptionList: selectSubscriptionList,
activatePaySubscription: selectActivatePaySubscription,
getUserByNameOrNumber: selectGetUserByNameOrNumber,
getUserByIdQRCode: selectGetUserByIdQRCode,
});
export default connect(mapStateToProps, {
fetchActivePaySubscription,
fetchGetSubscriptionList,
fetchGetUserByIdQRCode,
fetchGetUserByNameOrNumber
})(
SaisirFeuilleSoinScreen,
);