Execution et modification des prestations

This commit is contained in:
Brice Zele 2022-04-07 18:27:54 +01:00
parent 6b053091a3
commit a95dfc6d01
3 changed files with 232 additions and 70 deletions

View File

@ -78,7 +78,7 @@ 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 {FontWeight, Typography} from "../../../config/typography";
import {Typography} from "../../../config/typography";
let moment = require('moment-timezone');
@ -531,6 +531,12 @@ const ExecuterPrescriptionScreen = ({
const PriceModal = Yup.object().shape({
price: Yup.number().required(I18n.t('THIS_FIELD_IS_REQUIRED')),
examen_quantite: Yup.number(),
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()
}),
code_acte: Yup.object()
});
@ -566,7 +572,9 @@ const ExecuterPrescriptionScreen = ({
const renderPriceModal = () => (
<Formik validationSchema={PriceModal}
initialValues={{
examen_quantite: '' + elementToSetPrice !== null ? !elementToSetPrice.drugs ? elementToSetPrice.quantity : '' : '',
examen_quantity: '',
unit_quantity: '',
unit_quantity_condition: elementToSetPrice !== null ? !elementToSetPrice.drugs ? elementToSetPrice.act.billing_type === 'UNIT_PRICE' : false : false,
code_acte: '' + elementToSetPrice !== null ? !elementToSetPrice.drugs ? elementToSetPrice.act : '' : '',
price: elementToSetPrice !== null ? !elementToSetPrice.drugs ? elementToSetPrice.act.amount : '' : ''
}}
@ -579,7 +587,9 @@ const ExecuterPrescriptionScreen = ({
exams: consultation.exams.map(exam => {
return elementToSetPrice.id === exam.id ? {
...exam,
unit_price: values.price
unit_price: values.price,
quantity: values.examen_quantity,
unit_quantity: values.unit_quantity === '' ? null : values.unit_quantity
} : exam;
})
});
@ -592,7 +602,7 @@ const ExecuterPrescriptionScreen = ({
exams: [
{
unit_price: values.price,
quantity: consultation.exams.filter(exam => elementToSetPrice.id === exam.id)[0].quantity
quantity: values.examen_quantity
}
],
tmp_sheet_id: tmpSheetId,
@ -617,7 +627,7 @@ const ExecuterPrescriptionScreen = ({
prescriptions: [
{
unit_price: values.price,
quantity: consultation.prescriptions.filter(prescription => elementToSetPrice.id === prescription.id)[0].quantity
quantity: values.examen_quantity
}
],
});
@ -654,22 +664,104 @@ const ExecuterPrescriptionScreen = ({
<View style={styles.lineSwipeDown}/>
</View>
<Text body2 style={{marginTop: 10}}>{I18n.t('AMOUNT_LABEL')}</Text>
{elementToSetPrice.examen ?
<>
<Text body2 style={{marginTop: 10}}>{I18n.t('EXECUTION')}</Text>
<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'
/>
<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} = `}</Text>
<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 </Text>
<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'
/>
</View>
</View> :
<TextInput
style={{marginTop: 10}}
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 body2 style={{marginTop: 10}}>{I18n.t('AMOUNT_LABEL')}</Text>
<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'
/>
</>
}
{values.code_acte !== '' ?
{/* {values.code_acte !== '' ?
values.code_acte.billing_type === 'UNIT_PRICE' && (<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('QUANTITE')}
@ -680,40 +772,8 @@ const ExecuterPrescriptionScreen = ({
touched={touched.examen_quantite}
error={errors.examen_quantite}
keyboardType='numeric'
/>) : null}
/>) : null}*/}
<View>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('AMOUNT')}
value={'' + ((values.code_acte.amount !== null) ? parseFloat(values.examen_quantite) * parseFloat(values.price) : values.price)}
editable={values.code_acte.amount === null}
onChangeText={handleChange('price')}
onBlur={handleBlur('price')}
success={touched.price && !errors.price}
touched={touched.price}
error={errors.price}
keyboardType='numeric'
/>
<View style={{
position: 'absolute',
left: responsiveWidth(82),
top: 20,
flexDirection: 'row'
}}>
<View
style={{
width: 1,
borderLeftColor: '#f0f0f0',
height: 40,
left: -8,
borderLeftWidth: 1,
}}
/>
<Text style={[Typography.body1, FontWeight.bold]}>{values.code_acte.code}</Text>
</View>
</View>
<Button
loading={checkInsuranceCoverageAmount.loading}
@ -783,7 +843,7 @@ const ExecuterPrescriptionScreen = ({
}}>
<Text body2 semibold numberOfLines={2}>
{`${item.quantity} ${item.description} ${item.unit_price ? ' - ' + item.unit_price : ''} \n ${item.act.name}`}
{`${item.quantity === null ? '' : item.quantity} ${item.description} ${item.unit_price ? ' - ' + item.unit_price : ''} \n ${item.act.name}`}
</Text>
{item.checked && (
<Icon name="check" size={14} color={Color.primaryColor}/>
@ -1256,7 +1316,12 @@ const ExecuterPrescriptionScreen = ({
}),
exams: consultation.exams.filter(exam => exam.checked)
.map(exam => {
return {id: exam.id, unit_price: exam.unit_price}
return {
id: exam.id,
unit_price: exam.unit_price,
quantity: exam.quantity,
unit_quantity: parseInt(exam.unit_quantity)
}
})
});
},

View File

@ -541,6 +541,12 @@ const ModifierExecutionPrescriptionScreen = ({
const PriceModal = Yup.object().shape({
price: Yup.number().required(I18n.t('THIS_FIELD_IS_REQUIRED')),
examen_quantite: Yup.number(),
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()
}),
});
const renderDialogQRCodeScanner = () => {
@ -577,6 +583,10 @@ const ModifierExecutionPrescriptionScreen = ({
<Formik validationSchema={PriceModal}
initialValues={{
price: elementToSetPrice.unit_price,
examen_quantity: elementToSetPrice.quantity,
unit_quantity: elementToSetPrice.unit_quantity !== null ? elementToSetPrice.unit_quantity : '',
unit_quantity_condition: elementToSetPrice !== null ? elementToSetPrice.act.billing_type === 'UNIT_PRICE' : false,
code_acte: '' + elementToSetPrice !== null ? !elementToSetPrice.drugs ? elementToSetPrice.act : '' : '',
}}
onSubmit={(values) => {
console.log("Value", elementToSetPrice);
@ -586,7 +596,9 @@ const ModifierExecutionPrescriptionScreen = ({
exams: consultation.exams.map(exam => {
return elementToSetPrice.id === exam.id ? {
...exam,
unit_price: values.price
unit_price: values.price,
quantity: values.examen_quantity,
unit_quantity: values.unit_quantity === '' ? null : values.unit_quantity
} : exam;
})
});
@ -600,7 +612,7 @@ const ModifierExecutionPrescriptionScreen = ({
exams: [
{
unit_price: values.price,
quantity: consultation.exams.filter(exam => elementToSetPrice.id === exam.id)[0].quantity
quantity: values.examen_quantity
}
],
tmp_sheet_id: tmpSheetId,
@ -625,7 +637,7 @@ const ModifierExecutionPrescriptionScreen = ({
prescriptions: [
{
unit_price: values.price,
quantity: consultation.prescriptions.filter(prescription => elementToSetPrice.id === prescription.id)[0].quantity
quantity: values.examen_quantity
}
],
tmp_sheet_id: tmpSheetId,
@ -645,6 +657,7 @@ const ModifierExecutionPrescriptionScreen = ({
isSubmitting,
}) => (
<ScrollView style={{flex: 1}}>
{console.log("Errors", errors)}
<View style={[styles.containModal, {backgroundColor: Color.containerBackgroundColor}]}>
<Modal
isVisible={modalPrice}
@ -662,19 +675,101 @@ const ModifierExecutionPrescriptionScreen = ({
<View style={styles.lineSwipeDown}/>
</View>
<Text body2 style={{marginTop: 10}}>{I18n.t('AMOUNT_LABEL')}</Text>
{elementToSetPrice.examen ?
<>
<Text body2 style={{marginTop: 10}}>{I18n.t('MODIFY_EXECUTION')}</Text>
<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'
/>
<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} = `}</Text>
<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 </Text>
<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'
/>
</View>
</View> :
<TextInput
style={{marginTop: 10}}
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 body2 style={{marginTop: 10}}>{I18n.t('AMOUNT_LABEL')}</Text>
<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'
/>
</>
}
<Button
loading={checkInsuranceCoverageAmount.loading}
@ -744,7 +839,7 @@ const ModifierExecutionPrescriptionScreen = ({
}}>
<Text body2 semibold numberOfLines={2}>
{`${item.quantity} ${item.description} ${item.unit_price ? ' - ' + item.unit_price : ''} \n ${item.act.name}`}
{`${item.quantity} ${item.description} ${item.unit_price ? ' - ' + (item.unit_price + '' + (item.unit_quantity !== null ? ' X ' + item.unit_quantity : '')) : ''} \n ${item.act.name}`}
</Text>
{item.checked && (
<Icon name="check" size={14} color={Color.primaryColor}/>

View File

@ -729,5 +729,7 @@
"CONSULTATION": "Consultation",
"ACTE_EXAMEN": "Autre acte et examen",
"AMOUNT_FREE": "Montant libre",
"DESCRIPTION": "Description"
"DESCRIPTION": "Description",
"EXECUTION": "Execution",
"UNIT_QUANTITE": "Qté unitaire"
}