/** * Project YooLearn * File skills.actions * Path app/redux/skills * Created by BRICE ZELE * Date: 13/09/2021 */ import InsuranceActions from './insurance.type'; import { autorisationCareRequestUrl, consultationUrl, createConsultationUrl, executionPrescriptionUrl, getAmountConsultationUrl, getDrugAndDevicesUrl, getInsuranceListUrl, getInsurancePrimeAmountUrl, getNetworkActsUrl, getProviderClassUrl, getUserByIdQRCodeUrl, getUserByNameOrNumberUrl, subscribeInsuranceUrl, uploadInsuranceImagetUrl } from "../../webservice/IlinkConstants"; import {ApiAction} from "../reducers"; export const fetchGetListInsurancePending = () => ({ type: InsuranceActions.GET_INSURANCE_LIST_PENDING, }); export const fetchGetListInsuranceReset = () => ({ type: InsuranceActions.GET_INSURANCE_LIST_RESET, }); export const fetchGetListInsuranceSuccess = (authkey: any) => ({ type: InsuranceActions.GET_INSURANCE_LIST_SUCCESS, payload: authkey, }); export const fetchGetListInsuranceError = (error: any) => ({ type: InsuranceActions.GET_INSURANCE_LIST_ERROR, payload: error, }); export const fetchGetListInsurance = (idCountry, otherParam = '') => { return ApiAction({ url: `${getInsuranceListUrl}/networks?country_id=${idCountry}${otherParam}`, method: 'GET', onLoading: fetchGetListInsurancePending, onSuccess: fetchGetListInsuranceSuccess, onError: fetchGetListInsuranceError, }); }; /************************************************************/ export const fetchSubscribeInsurancePending = () => ({ type: InsuranceActions.SUBSCRIBE_INSURANCE_PENDING, }); export const fetchSubscribeInsuranceReset = () => ({ type: InsuranceActions.SUBSCRIBE_INSURANCE_RESET, }); export const fetchSubscribeInsuranceSuccess = (authkey: any) => ({ type: InsuranceActions.SUBSCRIBE_INSURANCE_SUCCESS, payload: authkey, }); export const fetchSubscribeInsuranceError = (error: any) => ({ type: InsuranceActions.SUBSCRIBE_INSURANCE_ERROR, payload: error, }); export const fetchSubscribeInsurance = (data) => { return ApiAction({ url: subscribeInsuranceUrl, data, method: 'POST', onLoading: fetchSubscribeInsurancePending, onSuccess: fetchSubscribeInsuranceSuccess, onError: fetchSubscribeInsuranceError, }); }; /************************************************************/ export const fetchGetInsurancePrimeAmountPending = () => ({ type: InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_PENDING, }); export const fetchGetInsurancePrimeAmountReset = () => ({ type: InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_RESET, }); export const fetchGetInsurancePrimeAmountSuccess = (authkey: any) => ({ type: InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_SUCCESS, payload: authkey, }); export const fetchGetInsurancePrimeAmountError = (error: any) => ({ type: InsuranceActions.GET_INSURANCE_PRIME_AMOUNT_ERROR, payload: error, }); export const fetchGetInsurancePrimeAmount = (data) => { return ApiAction({ url: getInsurancePrimeAmountUrl, data, method: 'POST', onLoading: fetchGetInsurancePrimeAmountPending, onSuccess: fetchGetInsurancePrimeAmountSuccess, onError: fetchGetInsurancePrimeAmountError, }); }; /************************************************************/ export const fetchUploadInsurancePending = () => ({ type: InsuranceActions.UPLOAD_INSURANCE_IMAGES_PENDING, }); export const fetchUploadInsuranceReset = () => ({ type: InsuranceActions.UPLOAD_INSURANCE_IMAGES_RESET, }); export const fetchUploadInsuranceSuccess = (authkey: any) => ({ type: InsuranceActions.UPLOAD_INSURANCE_IMAGES_SUCCESS, payload: authkey, }); export const fetchUploadInsuranceError = (error: any) => ({ type: InsuranceActions.UPLOAD_INSURANCE_IMAGES_ERROR, payload: error, }); export const fetchUploadInsurance = (data) => { return ApiAction({ url: uploadInsuranceImagetUrl, data, accessToken: 'gZ7KibrSvFNLxrGz49usnRiKBZ4OlX99', method: 'POST', onLoading: fetchUploadInsurancePending, onSuccess: fetchUploadInsuranceSuccess, onError: fetchUploadInsuranceError, }); }; /************************************************************/ export const fetchGetSubscriptionListPending = () => ({ type: InsuranceActions.GET_SUBSCRIPTION_LIST_PENDING, }); export const fetchGetSubscriptionListReset = () => ({ type: InsuranceActions.GET_SUBSCRIPTION_LIST_RESET, }); export const fetchGetSubscriptionListSuccess = (authkey: any) => ({ type: InsuranceActions.GET_SUBSCRIPTION_LIST_SUCCESS, payload: authkey, }); export const fetchGetSubscriptionListError = (error: any) => ({ type: InsuranceActions.GET_SUBSCRIPTION_LIST_ERROR, payload: error, }); export const fetchGetSubscriptionList = (idUser, type, includeSubscription = true) => { return ApiAction({ url: includeSubscription ? `${getInsuranceListUrl}/subscriptions?user_id=${idUser}&type=${type}` : `${getInsuranceListUrl}?user_id=${idUser}&type=${type}`, method: 'GET', onLoading: fetchGetSubscriptionListPending, onSuccess: fetchGetSubscriptionListSuccess, onError: fetchGetSubscriptionListError, }); }; /************************************************************/ export const fetchActivePaySubscriptionPending = () => ({ type: InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_PENDING, }); export const fetchActivePaySubscriptionReset = () => ({ type: InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_RESET, }); export const fetchActivePaySubscriptionSuccess = (authkey: any) => ({ type: InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_SUCCESS, payload: authkey, }); export const fetchActivePaySubscriptionError = (error: any) => ({ type: InsuranceActions.ACTIVATE_PAY_SUBSCRIPTION_ERROR, payload: error, }); export const fetchActivePaySubscription = (id, data) => { return ApiAction({ url: `${subscribeInsuranceUrl}/${id}/pay`, data, method: 'PUT', onLoading: fetchActivePaySubscriptionPending, onSuccess: fetchActivePaySubscriptionSuccess, onError: fetchActivePaySubscriptionError, }); }; /************************************************************/ export const fetchAddBeneficiaryToSubscriptionPending = () => ({ type: InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_PENDING, }); export const fetchAddBeneficiaryToSubscriptionReset = () => ({ type: InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_RESET, }); export const fetchAddBeneficiaryToSubscriptionSuccess = (authkey: any) => ({ type: InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_SUCCESS, payload: authkey, }); export const fetchAddBeneficiaryToSubscriptionError = (error: any) => ({ type: InsuranceActions.ADD_BENEFICIARY_TO_SUBSCRIPTION_ERROR, payload: error, }); export const fetchAddBeneficiaryToSubscription = (id, data) => { return ApiAction({ url: `${getInsuranceListUrl}/${id}/add-beneficiaries`, data, method: 'PUT', onLoading: fetchAddBeneficiaryToSubscriptionPending, onSuccess: fetchAddBeneficiaryToSubscriptionSuccess, onError: fetchAddBeneficiaryToSubscriptionError, }); }; /************************************************************/ export const fetchGetUserByIdQRCodePending = () => ({ type: InsuranceActions.GET_USER_BY_ID_QR_CODE_PENDING, }); export const fetchGetUserByIdQRCodeReset = () => ({ type: InsuranceActions.GET_USER_BY_ID_QR_CODE_RESET, }); export const fetchGetUserByIdQRCodeSuccess = (authkey: any) => ({ type: InsuranceActions.GET_USER_BY_ID_QR_CODE_SUCCESS, payload: authkey, }); export const fetchGetUserByIdQRCodeError = (error: any) => ({ type: InsuranceActions.GET_USER_BY_ID_QR_CODE_ERROR, payload: error, }); export const fetchGetUserByIdQRCode = (network_id, id) => { return ApiAction({ url: `${getUserByIdQRCodeUrl}?network_id=${network_id}&${id}`, method: 'GET', onLoading: fetchGetUserByIdQRCodePending, onSuccess: fetchGetUserByIdQRCodeSuccess, onError: fetchGetUserByIdQRCodeError, }); }; /************************************************************/ export const fetchGetUserByNameOrNumberPending = () => ({ type: InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_PENDING, }); export const fetchGetUserByNameOrNumberReset = () => ({ type: InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_RESET, }); export const fetchGetUserByNameOrNumberSuccess = (authkey: any) => ({ type: InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_SUCCESS, payload: authkey, }); export const fetchGetUserByNameOrNumberError = (error: any) => ({ type: InsuranceActions.GET_USER_BY_NAME_OR_NUMBER_ERROR, payload: error, }); export const fetchGetUserByNameOrNumber = (network_id, id) => { return ApiAction({ url: `${getUserByNameOrNumberUrl}?network_id=${network_id}${id}`, method: 'GET', onLoading: fetchGetUserByNameOrNumberPending, onSuccess: fetchGetUserByNameOrNumberSuccess, onError: fetchGetUserByNameOrNumberError, }); }; /************************************************************/ export const fetchGetDrugAppareilPending = () => ({ type: InsuranceActions.GET_DRUG_APPAREIL_PENDING, }); export const fetchGetDrugAppareilReset = () => ({ type: InsuranceActions.GET_DRUG_APPAREIL_RESET, }); export const fetchGetDrugAppareilSuccess = (authkey: any) => ({ type: InsuranceActions.GET_DRUG_APPAREIL_SUCCESS, payload: authkey, }); export const fetchGetDrugAppareilError = (error: any) => ({ type: InsuranceActions.GET_DRUG_APPAREIL_ERROR, payload: error, }); export const fetchGetDrugAppareil = (network_id, name) => { return ApiAction({ url: `${getDrugAndDevicesUrl}?network_id=${network_id}&name=${name}`, method: 'GET', onLoading: fetchGetDrugAppareilPending, onSuccess: fetchGetDrugAppareilSuccess, onError: fetchGetDrugAppareilError, }); }; /************************************************************/ export const fetchAddDrugPending = () => ({ type: InsuranceActions.ADD_DRUG_PENDING, }); export const fetchAddDrugReset = () => ({ type: InsuranceActions.ADD_DRUG_RESET, }); export const fetchAddDrugSuccess = (authkey: any) => ({ type: InsuranceActions.ADD_DRUG_SUCCESS, payload: authkey, }); export const fetchAddDrugError = (error: any) => ({ type: InsuranceActions.ADD_DRUG_ERROR, payload: error, }); export const fetchAddDrug = (data) => { return ApiAction({ url: `${getDrugAndDevicesUrl}`, method: 'POST', data, onLoading: fetchAddDrugPending, onSuccess: fetchAddDrugSuccess, onError: fetchAddDrugError, }); }; /************************************************************/ export const fetchGetProviderClassPending = () => ({ type: InsuranceActions.GET_PROVIDER_CLASS_PENDING, }); export const fetchGetProviderClassReset = () => ({ type: InsuranceActions.GET_PROVIDER_CLASS_RESET, }); export const fetchGetProviderClassSuccess = (authkey: any) => ({ type: InsuranceActions.GET_PROVIDER_CLASS_SUCCESS, payload: authkey, }); export const fetchGetProviderClassError = (error: any) => ({ type: InsuranceActions.GET_PROVIDER_CLASS_ERROR, payload: error, }); export const fetchGetProviderClass = (network_id) => { return ApiAction({ url: `${getProviderClassUrl}?network_id=${network_id}`, method: 'GET', onLoading: fetchGetProviderClassPending, onSuccess: fetchGetProviderClassSuccess, onError: fetchGetProviderClassError, }); }; /************************************************************/ export const fetchGetNetworkActsPending = () => ({ type: InsuranceActions.GET_NETWORK_ACT_PENDING, }); export const fetchGetNetworkActsReset = () => ({ type: InsuranceActions.GET_NETWORK_ACT_RESET, }); export const fetchGetNetworkActsSuccess = (authkey: any) => ({ type: InsuranceActions.GET_NETWORK_ACT_SUCCESS, payload: authkey, }); export const fetchGetNetworkActsError = (error: any) => ({ type: InsuranceActions.GET_NETWORK_ACT_ERROR, payload: error, }); export const fetchGetNetworkActs = (network_id, code = '', otherParam = '') => { return ApiAction({ url: `${getNetworkActsUrl}?network_id=${network_id}&code=${code}${otherParam}`, method: 'GET', onLoading: fetchGetNetworkActsPending, onSuccess: fetchGetNetworkActsSuccess, onError: fetchGetNetworkActsError, }); }; /************************************************************/ export const fetchCreateConsultationPending = () => ({ type: InsuranceActions.CREATE_CONSULTATION_PENDING, }); export const fetchCreateConsultationReset = () => ({ type: InsuranceActions.CREATE_CONSULTATION_RESET, }); export const fetchCreateConsultationSuccess = (authkey: any) => ({ type: InsuranceActions.CREATE_CONSULTATION_SUCCESS, payload: authkey, }); export const fetchCreateConsultationError = (error: any) => ({ type: InsuranceActions.CREATE_CONSULTATION_ERROR, payload: error, }); export const fetchCreateConsultation = (data) => { return ApiAction({ url: `${createConsultationUrl}`, method: 'POST', data, onLoading: fetchCreateConsultationPending, onSuccess: fetchCreateConsultationSuccess, 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, }); }; /************************************************************/ export const fetchGetConsultationPending = () => ({ type: InsuranceActions.GET_USER_CONSULTATION_PENDING, }); export const fetchGetConsultationReset = () => ({ type: InsuranceActions.GET_USER_CONSULTATION_RESET, }); export const fetchGetConsultationSuccess = (authkey: any) => ({ type: InsuranceActions.GET_USER_CONSULTATION_SUCCESS, payload: authkey, }); export const fetchGetConsultationError = (error: any) => ({ type: InsuranceActions.GET_USER_CONSULTATION_ERROR, payload: error, }); export const fetchGetConsultation = (user_id, state = 'UNTREATED', typeParam = 'CONSULTATION', otherParam = '') => { console.log("user_id", user_id); return ApiAction({ url: `${consultationUrl}?user_id=${user_id}&state=${state}${otherParam}`, method: 'GET', onLoading: fetchGetConsultationPending, onSuccess: fetchGetConsultationSuccess, onError: fetchGetConsultationError, }); }; export const fetchGetSubscription = (user_id, typeParam = 'ALL', otherParam = '') => { console.log("user_id", user_id); return ApiAction({ url: `${subscribeInsuranceUrl}?user_id=${user_id}&type=${typeParam}${otherParam}`, method: 'GET', onLoading: fetchGetConsultationPending, onSuccess: fetchGetConsultationSuccess, onError: fetchGetConsultationError, }); }; /************************************************************/ export const fetchAcceptRejectConsultationPending = () => ({ type: InsuranceActions.ACCEPT_REJECT_CONSULTATION_PENDING, }); export const fetchAcceptRejectConsultationReset = () => ({ type: InsuranceActions.ACCEPT_REJECT_CONSULTATION_RESET, }); export const fetchAcceptRejectConsultationSuccess = (authkey: any) => ({ type: InsuranceActions.ACCEPT_REJECT_CONSULTATION_SUCCESS, payload: authkey, }); export const fetchAcceptRejectConsultationError = (error: any) => ({ type: InsuranceActions.ACCEPT_REJECT_CONSULTATION_ERROR, payload: error, }); export const fetchAcceptRejectConsultation = (data) => { return ApiAction({ url: `${consultationUrl}`, method: 'PUT', data, onLoading: fetchAcceptRejectConsultationPending, onSuccess: fetchAcceptRejectConsultationSuccess, onError: fetchAcceptRejectConsultationError, }); }; /************************************************************/ export const fetchExecutionPrescriptionPending = () => ({ type: InsuranceActions.EXECUTION_PRESCRIPTION_PENDING, }); export const fetchExecutionPrescriptionReset = () => ({ type: InsuranceActions.EXECUTION_PRESCRIPTION_RESET, }); export const fetchExecutionPrescriptionSuccess = (authkey: any) => ({ type: InsuranceActions.EXECUTION_PRESCRIPTION_SUCCESS, payload: authkey, }); export const fetchExecutionPrescriptionError = (error: any) => ({ type: InsuranceActions.EXECUTION_PRESCRIPTION_ERROR, payload: error, }); export const fetchExecutionPrescription = (data) => { return ApiAction({ url: `${executionPrescriptionUrl}`, method: 'POST', data, onLoading: fetchExecutionPrescriptionPending, onSuccess: fetchExecutionPrescriptionSuccess, onError: fetchExecutionPrescriptionError, }); }; /************************************************************/ export const fetchModifyPrescriptionPending = () => ({ type: InsuranceActions.MODIFY_PRESCRIPTION_PENDING, }); export const fetchModifyPrescriptionReset = () => ({ type: InsuranceActions.MODIFY_PRESCRIPTION_RESET, }); export const fetchModifyPrescriptionSuccess = (authkey: any) => ({ type: InsuranceActions.MODIFY_PRESCRIPTION_SUCCESS, payload: authkey, }); export const fetchModifyPrescriptionError = (error: any) => ({ type: InsuranceActions.MODIFY_PRESCRIPTION_ERROR, payload: error, }); export const fetchModifyPrescription = (id, data) => { return ApiAction({ url: `${consultationUrl}/${id}`, method: 'PUT', data, onLoading: fetchModifyPrescriptionPending, onSuccess: fetchModifyPrescriptionSuccess, onError: fetchModifyPrescriptionError, }); }; /************************************************************/ export const fetchDemaneAutorisationSoinPending = () => ({ type: InsuranceActions.DEMAND_AUTORISATION_PENDING, }); export const fetchDemaneAutorisationSoinReset = () => ({ type: InsuranceActions.DEMAND_AUTORISATION_RESET, }); export const fetchDemaneAutorisationSoinSuccess = (authkey: any) => ({ type: InsuranceActions.DEMAND_AUTORISATION_SUCCESS, payload: authkey, }); export const fetchDemaneAutorisationSoinError = (error: any) => ({ type: InsuranceActions.DEMAND_AUTORISATION_ERROR, payload: error, }); export const fetchDemaneAutorisationSoin = (data) => { return ApiAction({ url: `${autorisationCareRequestUrl}`, method: 'POST', data, onLoading: fetchDemaneAutorisationSoinPending, onSuccess: fetchDemaneAutorisationSoinSuccess, onError: fetchDemaneAutorisationSoinError, }); };