2022-01-17 02:02:01 +00:00
/ * *
* Project iLinkWorld
* File ExecuterPrescriptionScreen
* Path screens / wallet / agent
* Created by BRICE ZELE
* Date : 11 / 11 / 2021
* /
import React , { useEffect , useRef , useState } from 'react' ;
import {
ActivityIndicator ,
Alert ,
Dimensions ,
FlatList ,
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 {
2022-04-04 17:47:36 +00:00
fetchActivePaySubscription ,
fetchCheckInsuranceCoverageAmount ,
fetchCheckInsuranceCoverageAmountReset ,
2022-01-17 02:02:01 +00:00
fetchCreateConsultation ,
fetchCreateConsultationReset ,
fetchExecutionPrescription ,
fetchExecutionPrescriptionReset ,
fetchGetAmountConsultation ,
fetchGetConsultation ,
fetchGetConsultationReset ,
fetchGetProviderClass ,
fetchGetProviderClassReset ,
fetchGetSubscriptionListReset ,
fetchGetUserByIdQRCode ,
fetchGetUserByIdQRCodeReset ,
fetchGetUserByNameOrNumber ,
fetchGetUserByNameOrNumberReset ,
fetchModifyPrescription ,
fetchModifyPrescriptionReset
} 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 {
2022-04-04 17:47:36 +00:00
selectActivatePaySubscription ,
selectCheckInsuranceCoverageAmount ,
2022-01-17 02:02:01 +00:00
selectExecutionPrescription ,
selectGetAmountConsultation ,
selectGetConsultation ,
selectGetProviderClass ,
selectGetUserByIdQRCode ,
selectGetUserByIdQRCodeReducer ,
selectGetUserByNameOrNumber ,
selectGetUserByNameOrNumberReducer ,
selectModifyPrescription
} 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 QRCodeScanner from "react-native-qrcode-scanner" ;
import { RNCamera } from "react-native-camera" ;
import * as Utils from "../../../utils/UtilsFunction" ;
import { displayToast , uppercaseFirstLetter } from "../../../utils/UtilsFunction" ;
import { store } from "../../../redux/store" ;
import Fontisto from "react-native-vector-icons/Fontisto" ;
import { Typography } from "../../../config/typography" ;
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 : 10 ,
marginBottom : 10 ,
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 ModifierExecutionPrescriptionScreen = ( {
subscriptionList ,
fetchGetUserByIdQRCode ,
fetchGetUserByNameOrNumber ,
fetchGetProviderClass ,
fetchGetConsultation ,
fetchExecutionPrescription ,
fetchModifyPrescription ,
2022-02-28 09:41:54 +00:00
fetchCheckInsuranceCoverageAmount ,
checkInsuranceCoverageAmount ,
2022-01-17 02:02:01 +00:00
modifyPrescription ,
getConsultation ,
getUserByNameOrNumber ,
getUserByIdQRCode ,
getProviderClass ,
createConsultation ,
getAmountConsultation ,
executionPrescription ,
navigation
} ) => {
const [ showQRCodeScanner , setShowQRCodeScanner ] = useState ( false ) ;
const [ wallet ] = useState ( store . getState ( ) . walletDetailReducer . result . response ) ;
console . log ( "Wallet" , wallet ) ;
2022-01-20 03:51:20 +00:00
const [ isNumeroAssureSearch , setIsNumeroAssureSearch ] = useState ( false ) ;
const [ isPhoneAssureSearch , setIsPhoneAssureSearch ] = useState ( false ) ;
2022-01-17 02:02:01 +00:00
const [ user , setUser ] = useState ( null ) ;
const [ assure , setAssure ] = useState ( null ) ;
const [ beneficiary , setBeneficiary ] = useState ( null ) ;
const [ medicament , setMedicament ] = useState ( null ) ;
const [ elementToSetPrice , setElementToSetPrice ] = useState ( null ) ;
2022-04-04 17:47:36 +00:00
const [ tmpSheetId , setTmpSheetId ] = useState ( '' + Date . now ( ) ) ;
2022-01-17 02:02:01 +00:00
const wizard = useRef ( ) ;
const [ isFirstStep , setIsFirstStep ] = useState ( true ) ;
const [ isLastStep , setIsLastStep ] = useState ( false ) ;
const [ currentStep , setCurrentStep ] = useState ( 1 ) ;
const [ modalConsultation , setModalConsultation ] = useState ( false ) ;
const [ consultation , setConsultation ] = useState ( null ) ;
2022-02-28 09:41:54 +00:00
const [ consultationClone , setConsultationClone ] = useState ( null ) ;
2022-01-17 02:02:01 +00:00
const [ displayModalHistory , setDisplayModalHistory ] = useState ( false ) ;
const [ historyItemDetail , setHistoryItemDetail ] = useState ( { } ) ;
const [ modalExamen , setModalExamen ] = useState ( false ) ;
const [ modalPrice , setModalPrice ] = useState ( false ) ;
const [ modalListAssure , setModalListAssure ] = useState ( false ) ;
const [ modalListMedicament , setModalListMedicament ] = useState ( false ) ;
const [ prestations , setPrestations ] = useState ( [ ] ) ;
const [ examens , setExamens ] = useState ( [ ] ) ;
const [ prescriptions , setPrescriptions ] = useState ( [ ] ) ;
const [ statutPatientOption ] = useState ( [
{ label : I18n . t ( 'AYANT_DROITS' ) , value : "M" } ,
{ label : I18n . t ( 'ASSURE' ) , value : "F" } ,
] ) ;
const [ statutPatient , setStatutPatient ] = useState ( 1 ) ;
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 ;
console . log ( "Health sheet" , consultation ) ;
console . log ( "executionPrescription" , executionPrescription ) ;
useEffect ( ( ) => {
readUser ( ) . then ( ( user ) => {
setFieldValue ( 'agrement_praticien' , user . code _membre ) ;
console . log ( "User" , user ) ;
setUser ( user )
} ) ;
dispatch ( fetchGetSubscriptionListReset ( ) ) ;
dispatch ( fetchGetUserByNameOrNumberReset ( ) ) ;
dispatch ( fetchGetUserByIdQRCodeReset ( ) ) ;
dispatch ( fetchCreateConsultationReset ( ) ) ;
dispatch ( fetchGetProviderClassReset ( ) ) ;
dispatch ( fetchGetConsultationReset ( ) ) ;
dispatch ( fetchExecutionPrescriptionReset ( ) ) ;
fetchGetProviderClass ( wallet . id _network ) ;
} , [ ] ) ;
useEffect ( ( ) => {
if ( user !== null ) {
console . log ( "user" , user ) ;
}
} , [ user ] ) ;
2022-03-18 10:58:47 +00:00
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 ] ) ;
2022-01-17 02:02:01 +00:00
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 ) {
2022-02-09 17:43:48 +00:00
Alert . alert (
I18n . t ( "ERROR_LABLE" ) ,
Utils . getErrorMsg ( getUserByNameOrNumber ) ,
[
{
text : I18n . t ( "OK" ) , onPress : ( ) => {
dispatch ( fetchGetUserByNameOrNumberReset ( ) ) ;
}
}
] ,
2022-04-04 17:47:36 +00:00
{ cancelable : false }
2022-01-17 02:02:01 +00:00
) ;
2022-04-04 17:47:36 +00:00
/ * d r o p D o w n A l e r t R e f . a l e r t W i t h T y p e (
'error' ,
I18n . t ( 'ERROR_LABEL' ) ,
Utils . getErrorMsg ( getUserByNameOrNumber ) ,
) ;
dispatch ( fetchGetUserByNameOrNumberReset ( ) ) ; * /
2022-01-17 02:02:01 +00:00
}
} , [ getUserByNameOrNumber ] ) ;
useEffect ( ( ) => {
if ( getConsultation . result !== null )
setModalConsultation ( true ) ;
if ( getConsultation . error ) {
2022-02-09 17:43:48 +00:00
Alert . alert (
I18n . t ( "ERROR_LABLE" ) ,
Utils . getErrorMsg ( getConsultation ) ,
[
{
text : I18n . t ( "OK" ) , onPress : ( ) => {
dispatch ( fetchGetConsultationReset ( ) ) ;
}
}
] ,
2022-04-04 17:47:36 +00:00
{ cancelable : false }
2022-01-17 02:02:01 +00:00
) ;
2022-04-04 17:47:36 +00:00
/ * d r o p D o w n A l e r t R e f . a l e r t W i t h T y p e (
'error' ,
I18n . t ( 'ERROR_LABEL' ) ,
Utils . getErrorMsg ( getConsultation ) ,
) ;
dispatch ( fetchGetConsultationReset ( ) ) ; * /
2022-01-17 02:02:01 +00:00
}
} , [ getConsultation ] ) ;
useEffect ( ( ) => {
if ( modifyPrescription . result !== null ) {
Alert . alert (
I18n . t ( "SUCCESS" ) ,
modifyPrescription . result . response ,
[
{
text : I18n . t ( "OK" ) , onPress : ( ) => {
dispatch ( fetchModifyPrescriptionReset ( ) ) ;
navigation . goBack ( ) ;
}
}
] ,
{ cancelable : false }
)
}
if ( modifyPrescription . error ) {
2022-02-09 17:43:48 +00:00
Alert . alert (
I18n . t ( "ERROR_LABLE" ) ,
Utils . getErrorMsg ( modifyPrescription ) ,
[
{
text : I18n . t ( "OK" ) , onPress : ( ) => {
dispatch ( fetchModifyPrescriptionReset ( ) ) ;
}
}
] ,
2022-04-04 17:47:36 +00:00
{ cancelable : false }
2022-01-17 02:02:01 +00:00
) ;
2022-04-04 17:47:36 +00:00
/ * d r o p D o w n A l e r t R e f . a l e r t W i t h T y p e (
'error' ,
I18n . t ( 'ERROR_LABEL' ) ,
Utils . getErrorMsg ( modifyPrescription ) ,
) ;
dispatch ( fetchModifyPrescriptionReset ( ) ) ; * /
2022-01-17 02:02:01 +00:00
}
} , [ modifyPrescription ] ) ;
2022-02-28 09:41:54 +00:00
useEffect ( ( ) => {
setModalPrice ( false ) ;
if ( checkInsuranceCoverageAmount . result !== null ) {
if ( checkInsuranceCoverageAmount . result . response !== null ) {
dispatch ( fetchCheckInsuranceCoverageAmountReset ( ) ) ;
}
}
if ( checkInsuranceCoverageAmount . error ) {
Alert . alert (
I18n . t ( "INFORMATION_MESSAGE" ) ,
Utils . getErrorMsg ( checkInsuranceCoverageAmount ) ,
[
{
text : I18n . t ( "OK" ) , onPress : ( ) => {
2022-04-04 17:47:36 +00:00
if ( elementToSetPrice . examen ) {
2022-02-28 09:41:54 +00:00
setConsultation ( {
... consultation ,
exams : consultation . exams . map ( exam => {
return elementToSetPrice . id === exam . id ? {
... exam ,
unit _price : consultationClone . exams . filter ( examen => examen . id === elementToSetPrice . id ) [ 0 ] . unit _price
} : exam ;
} )
} ) ;
} else {
setConsultation ( {
... consultation ,
prestations : consultation . prestations . map ( presta => {
return elementToSetPrice . id === presta . id ? {
... presta ,
2022-04-13 10:30:36 +00:00
quantity : consultationClone . exams . filter ( prestation => prestation . id === elementToSetPrice . id ) [ 0 ] . quantity ,
2022-02-28 09:41:54 +00:00
unit _price : consultationClone . exams . filter ( prestation => prestation . id === elementToSetPrice . id ) [ 0 ] . unit _price
} : presta ;
} )
} ) ;
}
dispatch ( fetchCheckInsuranceCoverageAmountReset ( ) ) ;
}
}
] ,
2022-04-04 17:47:36 +00:00
{ cancelable : false }
2022-02-28 09:41:54 +00:00
) ;
}
} , [ checkInsuranceCoverageAmount ] ) ;
2022-01-17 02:02:01 +00:00
const ExecuterPrescriptionSchema = 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 PriceModal = Yup . object ( ) . shape ( {
price : Yup . number ( ) . required ( I18n . t ( 'THIS_FIELD_IS_REQUIRED' ) ) ,
2022-04-07 13:48:10 +00:00
examen _quantite : Yup . number ( ) ,
2022-04-07 17:27:54 +00:00
unit _quantity _condition : Yup . boolean ( ) ,
unit _quantity : Yup . number ( ) . when ( 'unit_quantity_condition' , {
is : true ,
then : Yup . number ( ) . required ( I18n . t ( 'THIS_FIELD_IS_REQUIRED' ) ) ,
otherwise : Yup . number ( )
} ) ,
2022-01-17 02:02:01 +00:00
} ) ;
const renderDialogQRCodeScanner = ( ) => {
return (
< Dialog . Container contentStyle = { { width : responsiveWidth ( 80 ) } } useNativeDriver = { true }
visible = { showQRCodeScanner } >
< Dialog . Title > { I18n . t ( 'SCAN' ) } < / D i a l o g . T i t l e >
< ScrollView style = { [ styles . blockView , { borderBottomColor : Color . borderColor , maxHeight : 300 } ] } >
< Text >
{ I18n . t ( 'BRING_YOUR_CAMERA_CLOSER_TO_SCAN_QR_CODE' ) }
< / T e x t >
< QRCodeScanner
onRead = { ( result ) => {
setShowQRCodeScanner ( false ) ;
2022-03-18 10:58:47 +00:00
fetchGetUserByIdQRCode ( result . data ) ;
2022-01-17 02:02:01 +00:00
console . log ( "result" , result . data ) ;
} }
flashMode = { RNCamera . Constants . FlashMode . off }
/ >
< / S c r o l l V i e w >
< Dialog . Button bold = { true } label = { I18n . t ( 'CLOSE' ) } onPress = { ( ) => {
setShowQRCodeScanner ( false ) ;
} } / >
< / D i a l o g . C o n t a i n e r >
)
}
const renderPriceModal = ( ) => (
< Formik validationSchema = { PriceModal }
initialValues = { {
2022-04-13 10:30:36 +00:00
examen _quantity : elementToSetPrice !== null ? elementToSetPrice . drugs ? parseInt ( elementToSetPrice . quantity ) - parseInt ( elementToSetPrice . billed _quantity !== null ? elementToSetPrice . billed _quantity : 0 ) : '' : '' ,
2022-01-17 02:02:01 +00:00
price : elementToSetPrice . unit _price ,
2022-04-07 17:27:54 +00:00
unit _quantity : elementToSetPrice . unit _quantity !== null ? elementToSetPrice . unit _quantity : '' ,
2022-04-13 10:30:36 +00:00
unit _quantity _condition : elementToSetPrice !== null ? elementToSetPrice . hasOwnProperty ( 'act' ) ? elementToSetPrice . act . billing _type === "UNIT_PRICE" : false : false ,
2022-04-07 17:27:54 +00:00
code _acte : '' + elementToSetPrice !== null ? ! elementToSetPrice . drugs ? elementToSetPrice . act : '' : '' ,
2022-01-17 02:02:01 +00:00
} }
onSubmit = { ( values ) => {
console . log ( "Value" , elementToSetPrice ) ;
if ( elementToSetPrice . examen ) {
setConsultation ( {
... consultation ,
exams : consultation . exams . map ( exam => {
return elementToSetPrice . id === exam . id ? {
... exam ,
2022-04-07 17:27:54 +00:00
unit _price : values . price ,
quantity : values . examen _quantity ,
unit _quantity : values . unit _quantity === '' ? null : values . unit _quantity
2022-01-17 02:02:01 +00:00
} : exam ;
} )
} ) ;
2022-02-28 09:41:54 +00:00
fetchCheckInsuranceCoverageAmount ( {
insurance _id : assure . id ,
beneficiary _id : beneficiary !== null ? beneficiary . id : null ,
care _condition : consultation . _care _condition ,
2022-04-04 17:47:36 +00:00
act _id : consultation . exams . filter ( exam => elementToSetPrice . id === exam . id ) [ 0 ] . act _id ,
2022-02-28 09:41:54 +00:00
act _action : "UPDATE" ,
act _type : "EXAM" ,
exams : [
{
unit _price : values . price ,
2022-04-07 17:27:54 +00:00
quantity : values . examen _quantity
2022-02-28 09:41:54 +00:00
}
] ,
2022-04-04 17:47:36 +00:00
tmp _sheet _id : tmpSheetId ,
2022-02-28 09:41:54 +00:00
} ) ;
2022-01-17 02:02:01 +00:00
} else {
2022-04-13 10:30:36 +00:00
let quantityValue = historyItemDetail . prescriptions . filter ( prescription => prescription . id = elementToSetPrice . id ) [ 0 ] . quantity ;
if ( parseInt ( values . examen _quantity ) > parseInt ( quantityValue - parseInt ( elementToSetPrice . billed _quantity !== null ? elementToSetPrice . billed _quantity : 0 ) ) ) {
Alert . alert ( I18n . t ( 'ERROR_LABEL' ) , I18n . t ( 'QUANTITY_CANNOT_BE_SUPERIOR' ) + " " + quantityValue ,
[ {
text : I18n . t ( 'OK' ) , onPress : ( ) => {
}
} ] ) ;
} else {
setConsultation ( {
... consultation ,
prescriptions : consultation . prescriptions . map ( exam => {
return elementToSetPrice . id === exam . id ? {
... exam ,
unit _price : values . price ,
quantity : values . examen _quantity ,
} : exam ;
} )
} ) ;
fetchCheckInsuranceCoverageAmount ( {
insurance _id : assure . id ,
beneficiary _id : beneficiary !== null ? beneficiary . id : null ,
care _condition : consultation . _care _condition ,
act _id : elementToSetPrice . id ,
act _action : "UPDATE" ,
act _type : "PRESCRIPTION" ,
prescriptions : [
{
unit _price : values . price ,
quantity : values . examen _quantity
}
] ,
tmp _sheet _id : tmpSheetId ,
} ) ;
}
2022-01-17 02:02:01 +00:00
}
} } >
{ ( {
values ,
errors ,
touched ,
handleChange ,
setFieldValue ,
setFieldTouched ,
handleBlur ,
handleSubmit ,
isSubmitting ,
} ) => (
< ScrollView style = { { flex : 1 } } >
2022-04-07 17:27:54 +00:00
{ console . log ( "Errors" , errors ) }
2022-01-17 02:02:01 +00:00
< View style = { [ styles . containModal , { backgroundColor : Color . containerBackgroundColor } ] } >
< Modal
isVisible = { modalPrice }
onSwipeComplete = { ( ) => {
setModalPrice ( false ) ;
} }
swipeDirection = { [ 'down' ] }
style = { styles . bottomModal } >
< View
style = { [
styles . contentFilterBottom ,
{ backgroundColor : Color . containerBackgroundColor } ,
] } >
< View style = { styles . contentSwipeDown } >
< View style = { styles . lineSwipeDown } / >
< / V i e w >
2022-04-07 17:27:54 +00:00
{ elementToSetPrice . examen ?
< >
< Text body2 style = { { marginTop : 10 } } > { I18n . t ( 'MODIFY_EXECUTION' ) } < / T e x t >
< TextInput
style = { { marginTop : 10 } }
placeholder = { I18n . t ( 'QUANTITE' ) }
value = { '' + values . examen _quantity }
onChangeText = { handleChange ( 'examen_quantity' ) }
onBlur = { handleBlur ( 'examen_quantity' ) }
success = { touched . examen _quantity && ! errors . examen _quantity }
touched = { touched . examen _quantity }
error = { errors . examen _quantity }
keyboardType = 'numeric'
/ >
{
elementToSetPrice . act . billing _type === "UNIT_PRICE" ?
< View style = { { flexDirection : 'row' } } >
< Text
style = { {
marginTop : 20 ,
width : 40 ,
height : 40 ,
} } > { ` ${ elementToSetPrice . act . unit _value } = ` } < / T e x t >
< View style = { {
flexDirection : 'row' ,
width : '90%' ,
justifyContent : 'space-between'
} } >
< TextInput
style = { { marginTop : 10 , width : 180 } }
editable = { elementToSetPrice . act . billing _type === "FREE" }
placeholder = { I18n . t ( 'AMOUNT_LABEL_DESCRIPTION' ) }
value = { values . price }
onChangeText = { handleChange ( 'price' ) }
onBlur = { handleBlur ( 'price' ) }
success = { touched . price && ! errors . price }
touched = { touched . price }
error = { errors . price }
keyboardType = 'numeric'
/ >
< Text style = { {
marginTop : 20 ,
marginLeft : 5 ,
width : 40 ,
height : 40
} } > X < / T e x t >
< TextInput
style = { { marginTop : 10 , width : 180 } }
placeholder = { I18n . t ( 'UNIT_QUANTITE' ) }
value = { '' + values . unit _quantity }
onChangeText = { handleChange ( 'unit_quantity' ) }
onBlur = { handleBlur ( 'unit_quantity' ) }
success = { touched . unit _quantity && ! errors . unit _quantity }
touched = { touched . unit _quantity }
error = { errors . unit _quantity }
keyboardType = 'numeric'
/ >
< / V i e w >
< / V i e w > :
< TextInput
style = { { marginTop : 10 } }
2022-04-13 10:30:36 +00:00
editable = { elementToSetPrice . hasOwnProperty ( 'act' ) ? elementToSetPrice . act . billing _type === "FREE" : true }
2022-04-07 17:27:54 +00:00
placeholder = { I18n . t ( 'AMOUNT_LABEL_DESCRIPTION' ) }
value = { values . price }
onChangeText = { handleChange ( 'price' ) }
onBlur = { handleBlur ( 'price' ) }
success = { touched . price && ! errors . price }
touched = { touched . price }
error = { errors . price }
keyboardType = 'numeric'
/ >
}
< / > :
< >
2022-04-13 10:30:36 +00:00
< Text body2 style = { { marginTop : 10 } } > { I18n . t ( 'EXECUTION' ) } < / T e x t >
2022-04-07 17:27:54 +00:00
2022-04-13 10:30:36 +00:00
< TextInput
style = { { marginTop : 10 } }
placeholder = { I18n . t ( 'QUANTITE' ) }
value = { '' + values . examen _quantity }
onChangeText = { handleChange ( 'examen_quantity' ) }
onBlur = { handleBlur ( 'examen_quantity' ) }
success = { touched . examen _quantity && ! errors . examen _quantity }
touched = { touched . examen _quantity }
error = { errors . examen _quantity }
keyboardType = 'numeric'
/ >
2022-04-07 17:27:54 +00:00
< TextInput
style = { { marginTop : 10 } }
placeholder = { I18n . t ( 'AMOUNT_LABEL_DESCRIPTION' ) }
value = { values . price }
onChangeText = { handleChange ( 'price' ) }
onBlur = { handleBlur ( 'price' ) }
success = { touched . price && ! errors . price }
touched = { touched . price }
error = { errors . price }
keyboardType = 'numeric'
/ >
< / >
}
2022-01-17 02:02:01 +00:00
< Button
2022-02-28 09:41:54 +00:00
loading = { checkInsuranceCoverageAmount . loading }
2022-01-17 02:02:01 +00:00
full
style = { { marginTop : 10 , marginBottom : 20 } }
onPress = { handleSubmit } >
{ I18n . t ( 'OK' ) }
< / B u t t o n >
< / V i e w >
< / M o d a l >
< / V i e w >
< / S c r o l l V i e w >
) }
< / F o r m i k >
) ;
const renderExamList = ( ) => (
< ScrollView style = { { flex : 1 } } >
< View style = { [ styles . containModal , { backgroundColor : Color . containerBackgroundColor } ] } >
< Modal
isVisible = { modalExamen }
onSwipeComplete = { ( ) => {
setModalExamen ( false ) ;
} }
swipeDirection = { [ 'down' ] }
style = { styles . bottomModal } >
< View
style = { [
styles . contentFilterBottom ,
{ backgroundColor : Color . containerBackgroundColor } ,
] } >
< View style = { styles . contentSwipeDown } >
< View style = { styles . lineSwipeDown } / >
< / V i e w >
< Text body2 style = { { marginTop : 10 } } > { I18n . t ( 'EXAMEN' ) } < / T e x t >
< FlatList data = { consultation . exams }
extraData = { consultation . exams }
keyExtractor = { ( item , index ) => index }
renderItem = { ( { item , index } ) => {
return (
< TouchableOpacity
style = { [
styles . contentActionModalBottom ,
{ borderBottomColor : Color . borderColor , width : "100%" } ,
] }
key = { item . id }
onPress = { ( ) => {
setElementToSetPrice ( {
... item ,
examen : true
} ) ;
setConsultation ( {
... consultation ,
exams : consultation . exams . map ( exam => {
return item . id === exam . id ? {
... exam ,
checked : ! item . checked
} : exam ;
} )
} ) ;
if ( ! item . checked )
setModalPrice ( true ) ;
} } >
< Text body2 semibold numberOfLines = { 2 } >
2022-04-07 17:27:54 +00:00
{ ` ${ item . quantity } ${ item . description } ${ item . unit _price ? ' - ' + ( item . unit _price + '' + ( item . unit _quantity !== null ? ' X ' + item . unit _quantity : '' ) ) : '' } \n ${ item . act . name } ` }
2022-01-17 02:02:01 +00:00
< / T e x t >
{ item . checked && (
< Icon name = "check" size = { 14 } color = { Color . primaryColor } / >
) }
< / T o u c h a b l e O p a c i t y >
)
} } / >
< Button
full
style = { { marginTop : 10 , marginBottom : 20 } }
onPress = { ( ) => setModalExamen ( false ) } >
{ I18n . t ( 'OK' ) }
< / B u t t o n >
< / V i e w >
< / M o d a l >
< / V i e w >
< / S c r o l l V i e w >
) ;
console . log ( "consultaiton" , consultation ) ;
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 } / >
< / V i e w >
< Text body2 style = { { marginTop : 10 } } > { I18n . t ( 'LIST_ASSURE' ) } < / T e x t >
< FlatList data = { getUserByNameOrNumber . result ? . response }
extraData = { getUserByNameOrNumber . result ? . response }
ListEmptyComponent = { < Text body2 > { I18n . t ( 'NO_ASSURE_MATCH_SEARCH' ) } < / T e x t > }
keyExtractor = { ( item , index ) => index }
renderItem = { ( { item , index } ) => {
return (
< View style = { {
paddingVertical : 15 ,
alignItems : 'flex-start' ,
} } >
< TouchableOpacity
style = { [
styles . contentActionModalBottom ,
2022-04-04 17:47:36 +00:00
{
borderBottomColor : Color . borderColor ,
width : "100%" ,
flexDirection : 'column' ,
} ,
2022-01-17 02:02:01 +00:00
] }
key = { item . id }
onPress = { ( ) => {
2022-04-04 17:47:36 +00:00
if ( item . state === 'SUSPENDED' ) {
Alert . alert ( I18n . t ( 'ERROR_LABEL' ) , I18n . t ( 'ASSURE_SUSPENDU' ) ,
[ {
text : I18n . t ( 'OK' ) , onPress : ( ) => {
}
} ] ) ;
} else if ( item . state !== 'PAID' ) {
2022-01-17 02:02:01 +00:00
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 ,
) ;
//dispatch(fetchGetUserByNameOrNumberReset());
2022-01-20 03:51:20 +00:00
fetchGetConsultation ( item . user . id , 'UNTREATED' , 'EXECUTION' , ` &network_agent_id= ${ wallet . network _agent _id } ` ) ;
2022-01-17 02:02:01 +00:00
}
} } >
< Text body2 semibold >
2022-02-09 17:43:48 +00:00
{ ` ${ item . user . firstname !== null ? item . user . firstname : '' } ${ item . user . lastname !== null ? item . user . lastname : '' } ` }
2022-01-17 02:02:01 +00:00
< / T e x t >
2022-03-02 06:20:17 +00:00
< Text footnote >
{ ` ${ I18n . t ( 'MONTANT_ASSURANCE_CONSOMME' ) } : ${ item . insurance _consumed _amount } ` }
< / T e x t >
< Text footnote >
{ ` ${ I18n . t ( 'MONTANT_ASSURANCE_RESTANTE' ) } : ${ item . insurance _remaining _amount } ` }
< / T e x t >
2022-01-17 02:02:01 +00:00
< / T o u c h a b l e O p a c i t y >
{ item . beneficiaries . map ( ( beneficiary ) => (
< TouchableOpacity style = { styles . beneficiarySubSection }
onPress = { ( ) => {
2022-04-04 17:47:36 +00:00
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 ,
) ;
fetchGetConsultation ( item . user . id , 'UNTREATED' , 'EXECUTION' , ` &beneficiary_id= ${ beneficiary . id } &network_agent_id= ${ wallet . network _agent _id } ` ) ;
}
2022-01-17 02:02:01 +00:00
} } >
< View style = { { width : 10 } } / >
< View style = { { paddingHorizontal : 10 , alignItems : 'flex-start' } } >
2022-03-02 06:20:17 +00:00
< Text subhead semibold textAlign = "left" >
2022-02-09 17:43:48 +00:00
{ ` ${ beneficiary . firstname !== null ? beneficiary . firstname : '' } ${ beneficiary . lastname !== null ? beneficiary . lastname : '' } ( ${ I18n . t ( 'AYANT_DROITS' ) } ) ` }
2022-01-17 02:02:01 +00:00
< / T e x t >
2022-03-02 06:20:17 +00:00
< Text footnote >
{ ` ${ I18n . t ( 'MONTANT_ASSURANCE_CONSOMME' ) } : ${ beneficiary . insurance _consumed _amount } ` }
< / T e x t >
< Text footnote >
{ ` ${ I18n . t ( 'MONTANT_ASSURANCE_RESTANTE' ) } : ${ beneficiary . insurance _remaining _amount } ` }
< / T e x t >
2022-01-17 02:02:01 +00:00
< / V i e w >
< / T o u c h a b l e O p a c i t y >
) ) }
< / V i e w >
)
} } / >
< Button
full
style = { { marginTop : 10 , marginBottom : 20 } }
onPress = { ( ) => setModalListAssure ( false ) } >
{ I18n . t ( 'OK' ) }
< / B u t t o n >
< / V i e w >
< / M o d a l >
< / V i e w >
< / S c r o l l V i e w >
) ;
const renderListConsultation = ( ) => (
< ScrollView style = { { flex : 1 } } >
< View style = { [ styles . containModal , { backgroundColor : Color . containerBackgroundColor } ] } >
< Modal
isVisible = { modalConsultation }
onSwipeComplete = { ( ) => {
setModalConsultation ( false ) ;
} }
swipeDirection = { [ 'down' ] }
style = { styles . bottomModal } >
< View
style = { [
styles . contentFilterBottom ,
{ backgroundColor : Color . containerBackgroundColor } ,
] } >
< View style = { styles . contentSwipeDown } >
< View style = { styles . lineSwipeDown } / >
< / V i e w >
< Text body2 style = { { marginTop : 10 } } > { I18n . t ( 'LIST_EXECUTION' ) } < / T e x t >
< FlatList data = { getConsultation . result ? . response }
extraData = { getConsultation . result ? . response }
ListEmptyComponent = { < Text body2 > { I18n . t ( 'NO_EXECUTION' ) } < / T e x t > }
keyExtractor = { ( item , index ) => index }
renderItem = { ( { item , index } ) => {
return (
< TouchableOpacity
style = { [
styles . contentActionModalBottom ,
{ borderBottomColor : Color . borderColor , width : "100%" } ,
] }
key = { item . id }
onPress = { ( ) => {
setHistoryItemDetail ( item ) ;
setDisplayModalHistory ( true ) ;
} } >
< Text body2 semibold >
{ ` ${ item . type } # ${ item . health _care _sheet _id } - ${ moment ( item . created _at ) . format ( 'YYYY-MM-DD' ) } ` }
< / T e x t >
< / T o u c h a b l e O p a c i t y >
)
} } / >
< Button
full
style = { { marginTop : 10 , marginBottom : 20 } }
onPress = { ( ) => setModalConsultation ( false ) } >
{ I18n . t ( 'OK' ) }
< / B u t t o n >
< / V i e w >
< / M o d a l >
< / V i e w >
< / S c r o l l V i e w >
) ;
const renderModalHistoryDetail = ( ) => (
< Dialog . Container useNativeDriver = { true } visible = { displayModalHistory } >
< Dialog . Title > { I18n . t ( 'DETAIL' ) } < / D i a l o g . T i t l e >
< ScrollView persistentScrollbar = { true } >
< View style = { [ styles . blockView , { borderBottomColor : Color . borderColor } ] } >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > { I18n . t ( 'PATIENT' ) } < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { ` ${ historyItemDetail . patient _lastname } ${ historyItemDetail . patient _firstname } ` } < / T e x t >
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > Situation < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { historyItemDetail . patient _situation . toLowerCase ( ) } < / T e x t >
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > { I18n . t ( 'PRATICIEN' ) } < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { ` ${ historyItemDetail . practitioner _lastname } ${ historyItemDetail . practitioner _firstname } ` } < / T e x t >
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > { I18n . t ( 'CLASSE_PRESTATAIRE' ) } < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { uppercaseFirstLetter ( historyItemDetail . practitioner _provider _class . toLowerCase ( ) ) } < / T e x t >
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > { I18n . t ( 'STATE' ) } < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { uppercaseFirstLetter ( historyItemDetail . state . toLowerCase ( ) ) } < / T e x t >
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > Type < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { uppercaseFirstLetter ( historyItemDetail . type . toLowerCase ( ) ) } < / T e x t >
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > { I18n . t ( 'CONDITION_PRISE_CHARGE' ) } < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { uppercaseFirstLetter ( historyItemDetail . care _condition . toLowerCase ( ) ) } < / T e x t >
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > { I18n . t ( 'INSTITUTE_NAME' ) } < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { uppercaseFirstLetter ( historyItemDetail . institution _name . toLowerCase ( ) ) } < / T e x t >
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > Date < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { moment ( historyItemDetail . created _at ) . format ( 'YYYY-MM-DD' ) } < / T e x t >
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > { I18n . t ( 'PRESTATION' ) } < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
{ historyItemDetail . performances . map ( performance => (
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { ` ${ performance . act . name } \n ${ performance . amount } \n ` } < / T e x t >
) ) }
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > { I18n . t ( 'EXAMEN' ) } < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
{ historyItemDetail . exams . map ( exam => (
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { ` ${ exam . description } \n ${ exam . act . name } \n ` } < / T e x t >
) ) }
< / V i e w >
< / V i e w >
< View style = { { flexDirection : 'row' , marginTop : 10 } } >
< View style = { { flex : 1 } } >
< Text style = { [ styles . body2 ] } > { I18n . t ( 'MEDICAMENT' ) } < / T e x t >
< / V i e w >
< View style = { { flex : 1 , alignItems : 'flex-end' } } >
{ historyItemDetail . prescriptions . map ( prescription => (
< Text
style = { [ Typography . caption1 , Color . grayColor ] } > { ` ${ prescription . drug _or _device . name } \n ${ prescription . dosage } \n ` } < / T e x t >
) ) }
< / V i e w >
< / V i e w >
< / V i e w >
< / S c r o l l V i e w >
< Dialog . Button bold = { true } label = { I18n . t ( 'CANCEL_LABEL' ) } onPress = { ( ) => {
setDisplayModalHistory ( false ) ;
} } / >
< Dialog . Button bold = { true } label = { I18n . t ( 'OK' ) } onPress = { ( ) => {
setDisplayModalHistory ( false ) ;
setModalListAssure ( false ) ;
setModalConsultation ( false ) ;
setConsultation ( historyItemDetail ) ;
2022-02-28 09:41:54 +00:00
setConsultationClone ( historyItemDetail ) ;
2022-01-17 02:02:01 +00:00
setFieldValue (
'practitioner_firstname' ,
historyItemDetail . practitioner _firstname ,
) ;
setFieldValue (
'practitioner_lastname' ,
historyItemDetail . practitioner _lastname ,
) ;
//dispatch(fetchGetUserByNameOrNumberReset());
wizard . current . next ( ) ;
} } / >
< / D i a l o g . C o n t a i n e r >
)
const renderListMedicament = ( ) => (
< ScrollView style = { { flex : 1 } } >
< View style = { [ styles . containModal , { backgroundColor : Color . containerBackgroundColor } ] } >
< Modal
isVisible = { modalListMedicament }
onSwipeComplete = { ( ) => {
setModalListMedicament ( false ) ;
} }
swipeDirection = { [ 'down' ] }
style = { styles . bottomModal } >
< View
style = { [
styles . contentFilterBottom ,
{ backgroundColor : Color . containerBackgroundColor } ,
] } >
< View style = { styles . contentSwipeDown } >
< View style = { styles . lineSwipeDown } / >
< / V i e w >
< Text body2 style = { { marginTop : 10 } } > { I18n . t ( 'MEDICAMENTS' ) } < / T e x t >
< FlatList data = { consultation . prescriptions }
extraData = { consultation . prescriptions }
keyExtractor = { ( item , index ) => index }
renderItem = { ( { item , index } ) => {
return (
< TouchableOpacity
style = { [
styles . contentActionModalBottom ,
{ borderBottomColor : Color . borderColor , width : "100%" } ,
] }
key = { item . id }
onPress = { ( ) => {
setElementToSetPrice ( {
... item ,
drugs : true
} ) ;
setConsultation ( {
... consultation ,
prescriptions : consultation . prescriptions . map ( drug => {
return item . id === drug . id ? {
... drug ,
checked : ! item . checked
} : drug ;
} )
} ) ;
if ( ! item . checked )
setModalPrice ( true ) ;
} } >
< Text body2 semibold numberOfLines = { 2 } >
{ ` ${ item . quantity } ${ item . drug _or _device . name } ${ item . unit _price ? ' - ' + item . unit _price : '' } \n ${ item . dosage } ` }
< / T e x t >
{ item . checked && (
< Icon name = "check" size = { 14 } color = { Color . primaryColor } / >
) }
< / T o u c h a b l e O p a c i t y >
)
} } / >
< Button
full
style = { { marginTop : 10 , marginBottom : 20 } }
onPress = { ( ) => setModalListMedicament ( false ) } >
{ I18n . t ( 'OK' ) }
< / B u t t o n >
< / V i e w >
< / M o d a l >
< / V i e w >
< / S c r o l l V i e w >
)
const {
handleChange ,
handleSubmit ,
handleBlur ,
values ,
errors ,
touched ,
setFieldValue ,
setFieldTouched ,
isValid ,
} = useFormik ( {
validationSchema : ExecuterPrescriptionSchema ,
initialValues : {
numero _assure : '' ,
password : '' ,
firstname _patient : '' ,
lastname _patient : '' ,
practitioner _firstname : '' ,
practitioner _lastname : '' ,
agrement _praticien : user ? . code _membre ,
pregnancy _start _at : null ,
pregnancy _end _at : null ,
} ,
onSubmit : values => {
fetchModifyPrescription ( consultation . id , {
network _agent _id : wallet . network _agent _id ,
password : values . password ,
practitioner _lastname : values . practitioner _lastname ,
practitioner _firstname : values . practitioner _firstname ,
practitioner _provider _class _id : values . practitioner _provider _class _id ,
performances : consultation . performances ,
prescriptions : consultation . prescriptions ,
} ) ;
} ,
} ) ;
const onNext = ( ) => {
console . log ( "currentStep" , currentStep ) ;
switch ( currentStep ) {
case 0 :
2022-01-20 03:51:20 +00:00
console . log ( "values" , values ) ;
2022-04-04 17:47:36 +00:00
if ( values . numero _assure !== '' && getUserByNameOrNumber . result === null ) {
2022-01-20 03:51:20 +00:00
dispatch ( fetchGetUserByNameOrNumberReset ( ) ) ;
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 ) ;
2022-01-17 02:02:01 +00:00
}
return false ;
break ;
default :
return true ;
}
} ;
const renderBtnExamen = ( ) => (
< TouchableOpacity
style = { [
styles . iconNavigationButton ,
{
borderRadius : 5 ,
width : 100 ,
height : 30 ,
flexDirection : "row" ,
backgroundColor :
Color . primaryColor ,
borderColor :
Color . primaryColor ,
} ,
] }
onPress = { e => {
if ( consultation . prescriptions . filter ( exam => exam . checked ) . length > 0 )
displayToast ( "Vous avez deja renseigner les médicaments" ) ;
else
setModalExamen ( true ) ;
} } >
< Text whiteColor > { I18n . t ( 'EXAMEN' ) } < / T e x t >
< FontAwesome5
name = "file-medical"
size = { 20 }
color = { Color . whiteColor }
/ >
< / T o u c h a b l e O p a c i t y >
) ;
const renderBtnMedicament = ( ) => (
< TouchableOpacity
style = { [
styles . iconNavigationButton ,
{
borderRadius : 5 ,
width : 110 ,
height : 30 ,
flexDirection : "row" ,
backgroundColor :
Color . primaryColor ,
borderColor :
Color . primaryColor ,
} ,
] }
onPress = { e => {
if ( consultation . exams . filter ( exam => exam . checked ) . length > 0 )
displayToast ( "Vous avez deja renseigner les examens" ) ;
else
setModalListMedicament ( true ) ;
} } >
< Text whiteColor > { I18n . t ( 'MEDICAMENT' ) } < / T e x t >
< Fontisto
name = "drug-pack"
size = { 20 }
color = { Color . whiteColor }
/ >
< / T o u c h a b l e O p a c i t y >
) ;
const stepList = [
{
title : I18n . t ( 'ASSURE' ) ,
content : (
< View >
< TextInput
2022-04-12 07:24:31 +00:00
style = { { marginTop : 10 , width : responsiveWidth ( 90 ) } }
2022-01-20 03:51:20 +00:00
placeholder = { isNumeroAssureSearch ? I18n . t ( 'NUMERO_ASSURE' ) : isPhoneAssureSearch ? I18n . t ( 'PHONE_NUMBER' ) : I18n . t ( 'NOM_ASSURE' ) }
2022-01-17 02:02:01 +00:00
value = { values . numero _assure }
2022-01-20 03:51:20 +00:00
keyboardType = { isPhoneAssureSearch ? 'numeric' : 'default' }
2022-01-17 02:02:01 +00:00
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 } }
2022-01-20 03:51:20 +00:00
name = { isNumeroAssureSearch ? 'lock' : isPhoneAssureSearch ? 'phone' : 'user' }
2022-01-17 02:02:01 +00:00
size = { 20 }
/ >
}
/ >
< View style = { {
flexDirection : 'row' ,
position : 'absolute' ,
top : 22 ,
2022-04-12 07:24:31 +00:00
right : 70 ,
2022-01-17 02:02:01 +00:00
justifyContent : 'space-between' ,
width : 50
} } >
< Icon
2022-04-12 07:24:31 +00:00
style = { { paddingRight : 10 } }
2022-01-20 03:51:20 +00:00
name = 'lock'
size = { 20 }
color = { Color . primaryColor }
onPress = { ( ) => {
setIsNumeroAssureSearch ( true ) ;
setIsPhoneAssureSearch ( false ) ;
} }
/ >
< Icon
2022-04-12 07:24:31 +00:00
style = { { paddingRight : 10 } }
2022-01-20 03:51:20 +00:00
name = 'phone'
size = { 20 }
color = { Color . primaryColor }
onPress = { ( ) => {
setIsNumeroAssureSearch ( false ) ;
setIsPhoneAssureSearch ( true ) ;
} }
/ >
< Icon
2022-04-12 07:24:31 +00:00
style = { { paddingRight : 10 } }
2022-01-20 03:51:20 +00:00
name = 'user'
2022-01-17 02:02:01 +00:00
size = { 20 }
color = { Color . primaryColor }
onPress = { ( ) => {
2022-01-20 03:51:20 +00:00
setIsNumeroAssureSearch ( false ) ;
setIsPhoneAssureSearch ( false ) ;
2022-01-17 02:02:01 +00:00
} }
/ >
< Icon
2022-04-12 07:24:31 +00:00
style = { { paddingRight : 10 } }
2022-01-17 02:02:01 +00:00
name = "qrcode"
size = { 20 }
color = { Color . primaryColor }
onPress = { ( ) => {
setShowQRCodeScanner ( true ) ;
} }
/ >
< / V i e w >
2022-04-12 07:24:31 +00:00
< / V i e w > ) ,
2022-01-17 02:02:01 +00:00
} ,
{
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 }
editable = { false }
error = { errors . lastname _patient }
/ >
< TextInput
style = { { marginTop : 10 } }
placeholder = { I18n . t ( 'PRENOM_CLIENT' ) }
value = { values . firstname _patient }
editable = { false }
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' ) } < / T e x t >
< View style = { { width : responsiveWidth ( 60 ) } } >
< SwitchSelector options = { statutPatientOption }
disabled = { true }
value = { statutPatient }
initial = { statutPatient }
buttonColor = { Color . accentColor }
backgroundColor = { Color . primaryDarkColor }
textColor = 'white'
bold = { true }
hasPadding
height = { 32 }
onPress = { ( value ) => {
//setGender(value);
} } / >
< / V i e w >
< / V i e w >
< / V i e w >
) ,
} ,
{
title : I18n . t ( 'PRATICIEN' ) ,
content : (
< View >
< TextInput
style = { { marginTop : 10 } }
placeholder = { I18n . t ( 'CODE_AGREMENT' ) }
value = { values . agrement _praticien }
editable = { false }
/ >
< TextInput
style = { { marginTop : 10 } }
placeholder = { I18n . t ( 'NOM_PRATICIEN' ) }
value = { values . practitioner _lastname }
onChangeText = { handleChange ( 'practitioner_lastname' ) }
onBlur = { handleBlur ( 'practitioner_lastname' ) }
success = { touched . practitioner _lastname && ! errors . practitioner _lastname }
touched = { touched . practitioner _lastname }
error = { errors . practitioner _lastname }
/ >
< TextInput
style = { { marginTop : 10 } }
placeholder = { I18n . t ( 'PRENOM_PRATICIEN' ) }
value = { values . practitioner _firstname }
onChangeText = { handleChange ( 'practitioner_firstname' ) }
onBlur = { handleBlur ( 'practitioner_firstname' ) }
success = { touched . practitioner _firstname && ! errors . practitioner _firstname }
touched = { touched . practitioner _firstname }
error = { errors . practitioner _firstname }
/ >
< 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' ) }
value = { historyItemDetail !== null ? historyItemDetail . practitioner _provider _class : '' }
data = { getProviderClass . result !== null ? getProviderClass . result ? . response : [ ] }
useNativeDriver = { true }
onChangeText = { ( value , index , data ) => {
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
} }
/ >
< / A n i m a t a b l e . V i e w >
< TextInput
style = { { marginTop : 10 } }
placeholder = { I18n . t ( 'PASSWORD' ) }
value = { values . password }
onChangeText = { handleChange ( 'password' ) }
onBlur = { handleBlur ( 'password' ) }
success = { touched . password && ! errors . password }
touched = { touched . password }
error = { errors . password }
secureTextEntry
/ >
< View
style = { {
marginTop : 25 ,
} } >
< View style = { {
flexDirection : 'row' ,
alignItems : 'center' ,
justifyContent : 'space-between' ,
} } >
{ consultation !== null ?
2022-01-20 03:51:20 +00:00
! consultation . prescriptions . length > 0 ?
2022-01-17 02:02:01 +00:00
renderBtnExamen ( ) : < View / > : null }
{ consultation !== null ?
2022-01-20 03:51:20 +00:00
! consultation . exams . length > 0 ?
2022-01-17 02:02:01 +00:00
renderBtnMedicament ( ) : < View / > : null }
< / V i e w >
< / V i e w >
< / V i e w >
) ,
} ,
] ;
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 = { ( ) => {
if ( currentStep === 0 )
dispatch ( fetchGetUserByNameOrNumberReset ( ) ) ;
} }
currentStep = { ( {
currentStep ,
isLastStep ,
isFirstStep ,
} ) => {
setCurrentStep ( currentStep ) ;
setIsFirstStep ( isFirstStep ) ;
setIsLastStep ( isLastStep ) ;
} }
/ >
< / V i e w >
< 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 }
/ >
< / T o u c h a b l e O p a c i t y >
) : (
< View / >
) }
{ currentStep === 2 ? (
< Button
loading = { modifyPrescription . loading }
onPress = { handleSubmit } >
{ I18n . t ( 'SUBMIT_LABEL' ) }
< / B u t t o n >
) : (
< TouchableOpacity
style = { [
styles . iconNavigationButton ,
{
backgroundColor :
Color . primaryColor ,
borderColor :
Color . primaryColor ,
} ,
] }
onPress = { e => {
handleSubmit ( e ) ;
if ( onNext ( ) )
wizard . current . next ( ) ;
} } >
{ ( getUserByNameOrNumber . loading || getUserByIdQRCode . loading || getConsultation . loading ) ?
< ActivityIndicator
size = "small"
color = "#fff"
/ >
: < Icon
name = "arrow-right"
size = { 24 }
color = { Color . whiteColor }
/ > }
< / T o u c h a b l e O p a c i t y >
) }
< / V i e w >
{ modalExamen && renderExamList ( ) }
{ showQRCodeScanner && renderDialogQRCodeScanner ( ) }
{ modalListAssure && renderListAssure ( ) }
{ modalListMedicament && renderListMedicament ( ) }
{ modalConsultation && renderListConsultation ( ) }
{ displayModalHistory && renderModalHistoryDetail ( ) }
{ modalPrice && renderPriceModal ( ) }
< / V i e w >
< / S c r o l l V i e w >
< / K e y b o a r d A v o i d i n g V i e w >
< / S c r e e n C o m p o n e n t >
) ;
} ;
const mapStateToProps = createStructuredSelector ( {
activatePaySubscription : selectActivatePaySubscription ,
getUserByNameOrNumber : selectGetUserByNameOrNumber ,
getUserByIdQRCode : selectGetUserByIdQRCode ,
getProviderClass : selectGetProviderClass ,
getAmountConsultation : selectGetAmountConsultation ,
executionPrescription : selectExecutionPrescription ,
getConsultation : selectGetConsultation ,
2022-02-28 09:41:54 +00:00
modifyPrescription : selectModifyPrescription ,
checkInsuranceCoverageAmount : selectCheckInsuranceCoverageAmount
2022-01-17 02:02:01 +00:00
} ) ;
export default connect ( mapStateToProps , {
fetchActivePaySubscription ,
fetchGetUserByIdQRCode ,
fetchGetUserByNameOrNumber ,
fetchGetProviderClass ,
fetchCreateConsultation ,
fetchGetAmountConsultation ,
fetchGetConsultation ,
fetchExecutionPrescription ,
2022-02-28 09:41:54 +00:00
fetchModifyPrescription ,
fetchCheckInsuranceCoverageAmount
2022-01-17 02:02:01 +00:00
} ) (
ModifierExecutionPrescriptionScreen ,
) ;