Improve method to update health care sheet and get healh care sheet

This commit is contained in:
Djery-Tom 2022-01-03 17:36:06 +01:00
parent 8a5e1d9863
commit edf205a374
2 changed files with 36 additions and 8 deletions

View File

@ -584,15 +584,27 @@ class HealthCareSheetController extends Controller
$datetime = $this->getCurrentTimeByCountryCode($insurance->network->country->code_country); $datetime = $this->getCurrentTimeByCountryCode($insurance->network->country->code_country);
$healthCareSheet = NhHealthCareSheet::create(array_merge($request->all(), [ $accident_date = $request->input('accident_date');
$pregnancy_start_at = $request->input('pregnancy_start_at');
$pregnancy_end_at = $request->input('pregnancy_end_at');
$healthCareSheet = NhHealthCareSheet::create([
'health_care_sheet_id' => $this->generateSheetID(), 'health_care_sheet_id' => $this->generateSheetID(),
'beneficiary_id' => $request->input('beneficiary_id'),
'network_agent_id' => $request->input('network_agent_id'),
'care_condition' => $request->input('care_condition'),
'practitioner_lastname' => $request->input('practitioner_lastname'),
'practitioner_firstname' => $request->input('practitioner_firstname'),
'practitioner_provider_class_id' => $request->input('practitioner_provider_class_id'),
'insurance_id' => $insurance->id, 'insurance_id' => $insurance->id,
'patient_lastname' => isset($beneficiary) ? $beneficiary->lastname : $insurance->user->lastname, 'patient_lastname' => $request->input('patient_lastname'),
'patient_firstname' => isset($beneficiary) ? $beneficiary->firstname : $insurance->user->firstname, 'patient_firstname' => $request->input('patient_firstname'),
'patient_situation' => isset($beneficiary) ? 'HAVING_RIGHT' : 'INSURED', 'patient_situation' => isset($beneficiary) ? 'HAVING_RIGHT' : 'INSURED',
'type' => HealthCareSheetType::CONSULTATION, 'type' => HealthCareSheetType::CONSULTATION,
'state' => InsuranceSubscriptionState::UNDER_VALIDATION 'state' => InsuranceSubscriptionState::UNDER_VALIDATION,
])); 'accident_date' => (!empty($accident_date)) ? $accident_date : null,
'pregnancy_start_at' => (!empty($pregnancy_start_at)) ? $pregnancy_start_at : null,
'pregnancy_end_at' => (!empty($pregnancy_end_at)) ? $pregnancy_end_at : null,
]);
foreach ($request->input('performances', []) as $p) { foreach ($request->input('performances', []) as $p) {
$performance = NhPerformance::create([ $performance = NhPerformance::create([
@ -1109,6 +1121,9 @@ class HealthCareSheetController extends Controller
private function formatExamAndPrescriptionAmounts($e, $sheet): void private function formatExamAndPrescriptionAmounts($e, $sheet): void
{ {
$e->unit_price_non_formatted = $e->unit_price;
$e->insured_paid_amount_non_formatted = $e->insured_paid_amount;
$e->insurer_paid_amount_non_formatted = $e->insurer_paid_amount;
$e->unit_price = isset($e->unit_price) ? $this->toMoneyWithCurrencyCode($e->unit_price, $sheet->currency_code) : null; $e->unit_price = isset($e->unit_price) ? $this->toMoneyWithCurrencyCode($e->unit_price, $sheet->currency_code) : null;
$e->insured_paid_amount = isset($e->insured_paid_amount) ? $this->toMoneyWithCurrencyCode($e->insured_paid_amount, $sheet->currency_code) : null; $e->insured_paid_amount = isset($e->insured_paid_amount) ? $this->toMoneyWithCurrencyCode($e->insured_paid_amount, $sheet->currency_code) : null;
$e->insurer_paid_amount = isset($e->insurer_paid_amount) ? $this->toMoneyWithCurrencyCode($e->insurer_paid_amount, $sheet->currency_code) : null; $e->insurer_paid_amount = isset($e->insurer_paid_amount) ? $this->toMoneyWithCurrencyCode($e->insurer_paid_amount, $sheet->currency_code) : null;
@ -1684,9 +1699,11 @@ class HealthCareSheetController extends Controller
$sheet->patient_situation = trans('states.' . $sheet->patient_situation); $sheet->patient_situation = trans('states.' . $sheet->patient_situation);
$sheet->care_condition = trans('states.' . $sheet->care_condition); $sheet->care_condition = trans('states.' . $sheet->care_condition);
foreach ($sheet->performances as $p) { foreach ($sheet->performances as $p) {
$p->amount_non_formatted = $p->amount;
$p->amount = $this->toMoneyWithCurrencyCode($p->amount, $sheet->currency_code); $p->amount = $this->toMoneyWithCurrencyCode($p->amount, $sheet->currency_code);
$p->moderator_ticket = $this->toMoneyWithCurrencyCode($p->moderator_ticket, $sheet->currency_code); $p->moderator_ticket = $this->toMoneyWithCurrencyCode($p->moderator_ticket, $sheet->currency_code);
$p->insurance_amount = $this->toMoneyWithCurrencyCode($p->insurance_amount, $sheet->currency_code); $p->insurance_amount = $this->toMoneyWithCurrencyCode($p->insurance_amount, $sheet->currency_code);
$p->home_visit_fees_non_formatted = $p->home_visit_fees;
$p->home_visit_fees = isset($p->home_visit_fees) ? $this->toMoneyWithCurrencyCode($p->home_visit_fees, $sheet->currency_code) : null; $p->home_visit_fees = isset($p->home_visit_fees) ? $this->toMoneyWithCurrencyCode($p->home_visit_fees, $sheet->currency_code) : null;
} }

View File

@ -80,10 +80,21 @@ class InsuredController extends Controller
$phone = $request->input('phone'); $phone = $request->input('phone');
$network_id = $request->input('network_id'); $network_id = $request->input('network_id');
$insured = NhInsurance::with(['user:id,firstname,lastname,phone,email', 'network:id,name', 'beneficiaries'])->whereHas('user', function ($query) use ($name, $phone) { $q = NhInsurance::with(['user:id,firstname,lastname,phone,email', 'network:id,name', 'beneficiaries'])->where('network_id', $network_id);
$query->where('lastname', 'like', '%' . $name . '%')->orWhere('phone', 'like', '%' . $phone . '%');
})->where('network_id', $network_id)->get();
if (!empty($name)) {
$q = $q->whereHas('user', function ($query) use ($name) {
return $query->where('lastname', 'like', '%' . $name . '%')->orWhere('firstname', 'like', '%' . $name . '%');
});
}
if (!empty($phone)) {
$q = $q->whereHas('user', function ($query) use ($phone) {
return $query->where('phone', 'like', '%' . $phone . '%');
});
}
$insured = $q->get();
return $this->successResponse($insured); return $this->successResponse($insured);
} }
} }