Consultation OK

This commit is contained in:
Brice Zele 2021-11-30 16:33:51 +01:00
parent 26c6de01a6
commit c90a4f3ad6
8 changed files with 317 additions and 35 deletions

View File

@ -8,6 +8,7 @@
import InsuranceActions from './insurance.type';
import {
createConsultationUrl,
getAmountConsultationUrl,
getDrugAndDevicesUrl,
getInsuranceListUrl,
getInsurancePrimeAmountUrl,
@ -432,3 +433,33 @@ export const fetchCreateConsultation = (data) => {
onError: fetchCreateConsultationError,
});
};
/************************************************************/
export const fetchGetAmountConsultationPending = () => ({
type: InsuranceActions.GET_AMOUNT_CONSULTATION_PENDING,
});
export const fetchGetAmountConsultationReset = () => ({
type: InsuranceActions.GET_AMOUNT_CONSULTATION_RESET,
});
export const fetchGetAmountConsultationSuccess = (authkey: any) => ({
type: InsuranceActions.GET_AMOUNT_CONSULTATION_SUCCESS,
payload: authkey,
});
export const fetchGetAmountConsultationError = (error: any) => ({
type: InsuranceActions.GET_AMOUNT_CONSULTATION_ERROR,
payload: error,
});
export const fetchGetAmountConsultation = (data) => {
return ApiAction({
url: `${getAmountConsultationUrl}`,
method: 'POST',
data,
onLoading: fetchGetAmountConsultationPending,
onSuccess: fetchGetAmountConsultationSuccess,
onError: fetchGetAmountConsultationError,
});
};

View File

@ -437,3 +437,33 @@ export const createConsultationReducer = (state = INITIAL_STATE, action: Insuran
}
};
export const getAmountConsultationReducer = (state = INITIAL_STATE, action: InsuranceActions) => {
switch (action.type) {
case InsuranceActions.GET_AMOUNT_CONSULTATION_PENDING:
return {
...state,
loading: true
}
case InsuranceActions.GET_AMOUNT_CONSULTATION_SUCCESS:
return {
loading: false,
result: action.payload,
error: null
}
case InsuranceActions.GET_AMOUNT_CONSULTATION_ERROR:
return {
...state,
loading: false,
result: null,
error: action.payload
}
case InsuranceActions.GET_AMOUNT_CONSULTATION_RESET:
return INITIAL_STATE;
default:
return state
}
};

View File

@ -21,6 +21,7 @@ const selectAddDrugReducer = (state) => state.addDrugReducer;
const selectGetProviderClassReducer = (state) => state.getProviderClassReducer;
const selectGetNetworkActReducer = (state) => state.getNetworkActReducer;
const selectCreateConsultationReducer = (state) => state.createConsultationReducer;
const selectGetAmountConsultationReducer = (state) => state.getAmountConsultationReducer;
export const selectInsuranceList = createSelector(
[selectInsuranceListReducer],
@ -85,3 +86,7 @@ export const selectGetNetworkAct = createSelector(
[selectGetNetworkActReducer],
(getNetworkActReducer) => getNetworkActReducer
);
export const selectGetAmountConsultation = createSelector(
[selectGetAmountConsultationReducer],
(getAmountConsultationReducer) => getAmountConsultationReducer
);

View File

@ -75,5 +75,10 @@ const InsuranceActions = {
CREATE_CONSULTATION_SUCCESS: 'CREATE_CONSULTATION_SUCCESS',
CREATE_CONSULTATION_ERROR: 'CREATE_CONSULTATION_ERROR',
CREATE_CONSULTATION_RESET: 'CREATE_CONSULTATION_RESET',
GET_AMOUNT_CONSULTATION_PENDING: 'GET_AMOUNT_CONSULTATION_PENDING',
GET_AMOUNT_CONSULTATION_SUCCESS: 'GET_AMOUNT_CONSULTATION_SUCCESS',
GET_AMOUNT_CONSULTATION_ERROR: 'GET_AMOUNT_CONSULTATION_ERROR',
GET_AMOUNT_CONSULTATION_RESET: 'GET_AMOUNT_CONSULTATION_RESET',
}
export default InsuranceActions;

View File

@ -54,7 +54,7 @@ import {
activatePaySubscriptionReducer,
addBeneficiaryToSubscriptionReducer,
addDrugReducer,
createConsultationReducer,
createConsultationReducer, getAmountConsultationReducer,
getDrugAppareilReducer,
getInsurancePrimeAmountReducer,
getNetworkActReducer,
@ -165,7 +165,8 @@ const rootReducer = persistCombineReducers(persistConfig, {
addDrugReducer: addDrugReducer,
getProviderClassReducer: getProviderClassReducer,
getNetworkActReducer: getNetworkActReducer,
createConsultationReducer: createConsultationReducer
createConsultationReducer: createConsultationReducer,
getAmountConsultationReducer: getAmountConsultationReducer
});
export default rootReducer;

View File

@ -32,8 +32,11 @@ import {
fetchActivePaySubscription,
fetchActivePaySubscriptionReset,
fetchAddDrug,
fetchAddDrugReset,
fetchCreateConsultation,
fetchCreateConsultationReset,
fetchGetAmountConsultation,
fetchGetAmountConsultationReset,
fetchGetDrugAppareil,
fetchGetDrugAppareilReset,
fetchGetNetworkActs,
@ -55,6 +58,7 @@ import {
selectActivatePaySubscription,
selectAddDrug,
selectCreateConsultation,
selectGetAmountConsultation,
selectGetDrugAppareil,
selectGetNetworkAct,
selectGetProviderClass,
@ -255,6 +259,7 @@ const SaisirFeuilleSoinScreen = ({
fetchGetProviderClass,
fetchGetNetworkActs,
fetchCreateConsultation,
fetchGetAmountConsultation,
getUserByNameOrNumber,
getUserByIdQRCode,
getDrugAppareil,
@ -262,10 +267,11 @@ const SaisirFeuilleSoinScreen = ({
addDrug,
createConsultation,
getNetworkAct,
getAmountConsultation,
navigation
}) => {
const [datePrestation, setDatePrestation] = useState('' + moment(new Date()).format('YYYY-MM-DD'));
const [datePrestation, setDatePrestation] = useState('' + moment(new Date()).format('YYYY-MM-DD HH:mm'));
const [showDatePrestation, setShowDatePrestation] = useState(false);
const [dateAccident, setDateAccident] = useState(null);
@ -276,13 +282,13 @@ const SaisirFeuilleSoinScreen = ({
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 [careConditon, setCareCondition] = useState(null);
const [user, setUser] = useState(null);
const [assure, setAssure] = useState(null);
@ -294,6 +300,7 @@ const SaisirFeuilleSoinScreen = ({
const [currentStep, setCurrentStep] = useState(1);
const [modalPrestation, setModalPrestation] = useState(false);
const [modalMedicament, setModalMedicament] = useState(false);
const [modalAddMedicament, setModalAddMedicament] = useState(false);
const [modalExamen, setModalExamen] = useState(false);
const [modalListAssure, setModalListAssure] = useState(false);
const [modalListMedicament, setModalListMedicament] = useState(false);
@ -333,13 +340,24 @@ const SaisirFeuilleSoinScreen = ({
const [conditionPriseEnChange] = useState([
{label: I18n.t('AFFECTION_COURANTE'), value: "CURRENT_AFFECTION"},
{label: I18n.t('AFFECTION_LONGUE'), value: "LONG_TERM_AFFECTION"},
{label: I18n.t('EXONERE'), value: "EXONERATION"},
{
label:
I18n.t('EXONERE'), value: "EXONERATION"
},
]);
const [onPrescription] = useState([
{label: I18n.t('COMPRESSED'), value: "COMPRESSED"},
{label: I18n.t('SYRUP'), value: "SYRUP"},
{label: I18n.t('SOLUTION'), value: "SOLUTION"},
{label: I18n.t('SUPPOSITORY'), value: "SUPPOSITORY"},
{label: I18n.t('DEVICE'), value: "DEVICE"},
]);
const dispatch = useDispatch();
let dropDownAlertRef: any = null;
let classificationRef = null;
let codeActeRef = null;
let onPrescriptionRef = null;
useEffect(() => {
readUser().then((user) => {
@ -355,6 +373,7 @@ const SaisirFeuilleSoinScreen = ({
dispatch(fetchCreateConsultationReset());
dispatch(fetchGetNetworkActsReset());
dispatch(fetchGetProviderClassReset());
dispatch(fetchAddDrugReset());
fetchGetProviderClass(wallet.id_network);
fetchGetNetworkActs(wallet.id_network, '');
@ -397,6 +416,22 @@ const SaisirFeuilleSoinScreen = ({
if (getDrugAppareil.result !== null) {
if (getDrugAppareil.result.response.length > 0) {
setModalListMedicament(true);
} else {
Alert.alert(
I18n.t("ERROR_LABEL"),
I18n.t('NO_DRUG_MATCH_YOU_SEARCH'),
[
{
text: I18n.t("OK"), onPress: () => {
setModalAddMedicament(true);
dispatch(fetchGetDrugAppareilReset());
dispatch(fetchAddDrugReset());
}
}
],
{cancelable: false}
)
}
}
@ -410,6 +445,22 @@ const SaisirFeuilleSoinScreen = ({
}
}, [getDrugAppareil]);
useEffect(() => {
if (addDrug.result !== null) {
setModalAddMedicament(false);
setMedicament(addDrug.result.response);
}
if (addDrug.error) {
dropDownAlertRef.alertWithType(
'error',
I18n.t('ERROR_LABEL'),
Utils.getErrorMsg(addDrug),
);
dispatch(fetchAddDrugReset());
}
}, [addDrug]);
useEffect(() => {
if (createConsultation.result !== null) {
Alert.alert(
@ -438,8 +489,6 @@ const SaisirFeuilleSoinScreen = ({
}
}, [createConsultation]);
console.log("Date accident", dateAccident);
const SaisirFeuilleSoinSchema = Yup.object().shape({
numero_assure: Yup.string()
.required(I18n.t('THIS_FIELD_IS_REQUIRED')),
@ -471,6 +520,12 @@ const SaisirFeuilleSoinScreen = ({
drug_posologie: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')),
});
const AddNewMedicamentToDB = Yup.object().shape({
code: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')),
name: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED')),
type: Yup.string().required(I18n.t('THIS_FIELD_IS_REQUIRED'))
});
const onChangeDatePrestation = (event, selectedDate) => {
const currentDate = selectedDate || '' + moment(new Date()).format('YYYY-MM-DD');
setShowDatePrestation(Platform.OS === 'ios');
@ -481,7 +536,7 @@ const SaisirFeuilleSoinScreen = ({
return (<DateTimePicker
timeZoneOffsetInMinutes={0}
is24Hour={true}
value={new Date(dateNaissance)}
value={new Date(datePrestation)}
mode='date'
display="spinner"
onChange={onChangeDatePrestation}
@ -581,14 +636,12 @@ const SaisirFeuilleSoinScreen = ({
initialValues={{
amount_prestation: '',
frais_deplacement: '',
ticker_moderateur: '',
date_prestation: '',
code_acte: ''
}}
onSubmit={(values) => {
if (values.code_acte === '')
codeActeRef.shake(200)
else
else {
setPrestations([{
act_id: values.code_acte,
amount: values.amount_prestation,
@ -596,6 +649,8 @@ const SaisirFeuilleSoinScreen = ({
}, ...prestations]);
setModalPrestation(false);
Utils.displayToast(I18n.t('PRESTATION_SUCCESSFULLY_ADD'));
}
}}>
{({
@ -632,16 +687,8 @@ const SaisirFeuilleSoinScreen = ({
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('DATE')}
value={'' + moment(datePrestation).format('YYYY-MM-DD')}
onChangeText={handleChange('date_prestation')}
onBlur={handleBlur('date_prestation')}
onFocus={() => {
Keyboard.dismiss();
setShowDatePrestation(true);
}}
success={touched.date_prestation && !errors.date_prestation}
touched={touched.date_prestation}
error={errors.date_prestation}
value={'' + moment(datePrestation).format('YYYY-MM-DD HH:mm')}
editable={false}
/>
<Animatable.View ref={(comp) => {
@ -683,25 +730,27 @@ const SaisirFeuilleSoinScreen = ({
success={touched.amount_prestation && !errors.amount_prestation}
touched={touched.amount_prestation}
error={errors.amount_prestation}
onKeyPress={() => {
fetchGetAmountConsultation({
network_id: wallet.id_network,
amount: values.amount_prestation,
care_condition: careConditon
});
}}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('TICKET_MONDERATEUR')}
value={values.ticker_moderateur}
onChangeText={handleChange('ticker_moderateur')}
onBlur={handleBlur('ticker_moderateur')}
success={touched.ticker_moderateur && !errors.ticker_moderateur}
touched={touched.ticker_moderateur}
error={errors.ticker_moderateur}
editable={false}
value={getAmountConsultation.result !== null ? getAmountConsultation.result.response.moderator_ticket : ''}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('AMOUNT_PER_INSURANCE')}
editable={false}
/>
value={getAmountConsultation.result !== null ? getAmountConsultation.result.response.insurance_amount : ''}/>
<View style={{
marginTop: 10,
@ -811,6 +860,7 @@ const SaisirFeuilleSoinScreen = ({
success={touched.drug_name && !errors.drug_name}
touched={touched.drug_name}
error={errors.drug_name}
editable={medicament === null}
/>
<TouchableOpacity
style={[
@ -879,6 +929,145 @@ const SaisirFeuilleSoinScreen = ({
</Formik>
);
const renderAddNewMedicamentToDB = () => (
<Formik validationSchema={AddNewMedicamentToDB}
initialValues={{
code: '',
name: '',
type: '',
on_prescription: false
}}
onSubmit={(values) => {
setMedicament(null);
fetchAddDrug({
network_id: wallet.id_network,
code: values.code,
name: values.name,
type: values.type,
on_prescription: values.on_prescription
})
}}>
{({
values,
errors,
touched,
handleChange,
handleBlur,
handleSubmit,
setFieldValue,
isSubmitting,
}) => (
<ScrollView style={{flex: 1}}>
<View style={[styles.containModal, {backgroundColor: Color.containerBackgroundColor}]}>
<Modal
isVisible={modalAddMedicament}
onSwipeComplete={() => {
setModalAddMedicament(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('AJOUTER_NOUVEAU_MEDICAMENT')}</Text>
<TextInput
style={{marginTop: 10}}
placeholder='Code'
value={values.code}
onChangeText={handleChange('code')}
onBlur={handleBlur('code')}
success={touched.code && !errors.code}
touched={touched.code}
error={errors.code}
/>
<TextInput
style={{marginTop: 10}}
placeholder={I18n.t('NAME')}
value={values.name}
onChangeText={handleChange('name')}
onBlur={handleBlur('name')}
success={touched.name && !errors.name}
touched={touched.name}
error={errors.name}
/>
<Animatable.View ref={(comp) => {
onPrescriptionRef = comp
}}
style={{
width: responsiveWidth(90),
height: 60,
alignSelf: 'center',
borderRadius: 10,
paddingLeft: 20,
marginTop: 10,
paddingRight: 20,
backgroundColor: 'white'
}}>
<Dropdown
label='Type'
data={onPrescription}
useNativeDriver={true}
onChangeText={(value, index, data) => {
setFieldValue('type', 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('SOUS_ORDONNANCE')}</Text>
<View style={{width: responsiveWidth(60)}}>
<SwitchSelector options={grossesse}
initial={1}
buttonColor={Color.accentColor}
backgroundColor={Color.primaryDarkColor}
textColor='white'
bold={true}
hasPadding
height={32}
onPress={(value) => {
setFieldValue('on_prescription', value === 'YES');
console.log("On Prescription", value);
//setGender(value);
}}/>
</View>
</View>
<Button
style={{marginTop: 20, marginBottom: 20}}
full
loading={addDrug.loading}
onPress={handleSubmit}>
{I18n.t('SUBMIT_LABEL')}
</Button>
</View>
</Modal>
</View>
</ScrollView>
)}
</Formik>
);
const renderAddNewExamen = () => (
<Formik validationSchema={AddNewExamen}
initialValues={{
@ -1431,6 +1620,7 @@ const SaisirFeuilleSoinScreen = ({
useNativeDriver={true}
onChangeText={(value, index, data) => {
console.log("Value", value);
setCareCondition(value);
setFieldTouched('care_condition');
setFieldValue('care_condition', value);
}}
@ -1582,7 +1772,14 @@ const SaisirFeuilleSoinScreen = ({
},
]}
onPress={e => {
setModalPrestation(true);
dispatch(fetchGetAmountConsultationReset());
if(careConditon === null) {
dropDownAlertRef.alertWithType(
'warn',
I18n.t('ERROR_LABEL'),
I18n.t('PLEASE_SELECT_CONDITON_PRISE_CHARGE_FIRST'),
);
} else setModalPrestation(true);
}}>
<Text whiteColor>{I18n.t('PRESTATION')}</Text>
<MaterialCommunityIcons
@ -1769,6 +1966,7 @@ const SaisirFeuilleSoinScreen = ({
{showQRCodeScanner && renderDialogQRCodeScanner()}
{modalListAssure && renderListAssure()}
{modalListMedicament && renderListMedicament()}
{modalAddMedicament && renderAddNewMedicamentToDB()}
</View>
</ScrollView>
</KeyboardAvoidingView>
@ -1785,7 +1983,8 @@ const mapStateToProps = createStructuredSelector({
addDrug: selectAddDrug,
getProviderClass: selectGetProviderClass,
createConsultation: selectCreateConsultation,
getNetworkAct: selectGetNetworkAct
getNetworkAct: selectGetNetworkAct,
getAmountConsultation: selectGetAmountConsultation
});
export default connect(mapStateToProps, {
@ -1797,7 +1996,8 @@ export default connect(mapStateToProps, {
fetchAddDrug,
fetchGetProviderClass,
fetchGetNetworkActs,
fetchCreateConsultation
fetchCreateConsultation,
fetchGetAmountConsultation
})(
SaisirFeuilleSoinScreen,
);

View File

@ -662,5 +662,14 @@
"PRESTATION_SUCCESSFULLY_ADD": "Prestation ajouté avec succès",
"EXAMENS_SUCCESSFULLY_ADD": "Examens ajouté avec succès",
"PRESCRIPTIONS_SUCCESSFULLY_ADD": "Prescription ajouté avec succès",
"YOU_MUST_ADD_AT_LEAST_ONE_PRESTATION": "Vous devez ajouter au moins une prestation"
"YOU_MUST_ADD_AT_LEAST_ONE_PRESTATION": "Vous devez ajouter au moins une prestation",
"NO_DRUG_MATCH_YOU_SEARCH": "Aucun médicament ne correspond à votre rechercher, voulez-vous en ajouter ?",
"COMPRESSED": "Comprimé",
"SYRUP": "Sirop",
"SOLUTION": "Solution",
"SUPPOSITORY": "Suppositoire",
"DEVICE": "Appareillage",
"AJOUTER_NOUVEAU_MEDICAMENT": "Ajouter un nouveau médicament",
"SOUS_ORDONNANCE": "Sous ordonnance ?",
"PLEASE_SELECT_CONDITON_PRISE_CHARGE_FIRST": "Veuillez d'abord sélectionner la conditon de prise en charge"
}

View File

@ -89,6 +89,7 @@ export const subscribeInsuranceUrl = testBaseUrl + '/nanoSanteService/insurances
export const getProviderClassUrl = testBaseUrl + '/nanoSanteService/provider-classes';
export const getNetworkActsUrl = testBaseUrl + '/nanoSanteService/acts';
export const createConsultationUrl = testBaseUrl + '/nanoSanteService/health-care-sheets/consultation';
export const getAmountConsultationUrl = testBaseUrl + '/nanoSanteService/health-care-sheets/performances-amount';
export const getInsurancePrimeAmountUrl = testBaseUrl + '/nanoSanteService/insurances/subscriptions/bonus-amount';
export const uploadInsuranceImagetUrl = 'https://test.ilink-app.com:8086/insurances/subscriptions/upload-images';