Add endpoint to fetch one health care sheet

This commit is contained in:
Djery-Tom 2021-12-07 09:29:00 +01:00
parent 55f9a42cf7
commit d7ef5fe660
3 changed files with 74 additions and 19 deletions

View File

@ -828,28 +828,57 @@ class HealthCareSheetController extends Controller
$sheets = NhInfosHealthCareSheets::with(['performances.act:id,code,name', 'exams.act:id,code,name', 'prescriptions.drug_or_device:id,name'])->where('user_id', $request->input('user_id'))->get();
foreach ($sheets as $sheet) {
$sheet->state = trans('states.' . $sheet->state);
$sheet->patient_situation = trans('states.' . $sheet->patient_situation);
$sheet->care_condition = trans('states.' . $sheet->care_condition);
foreach ($sheet->performances as $p) {
$p->amount = $this->toMoneyWithCurrencyCode($p->amount, $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->home_visit_fees = isset($p->home_visit_fees) ? $this->toMoneyWithCurrencyCode($p->home_visit_fees, $sheet->currency_code) : null;
}
foreach ($sheet->exams as $e) {
$this->formatExamAndPrescriptionAmounts($e, $sheet);
}
foreach ($sheet->prescriptions as $p) {
$this->formatExamAndPrescriptionAmounts($p, $sheet);
}
$this->formalizeHealthCareSheet($sheet);
}
return $this->successResponse($sheets);
}
/**
* @OA\Get(
* path="/health-care-sheets/{id}",
* summary="Obtenir une feuilles de soins par son id",
* tags={"Feuilles de soins"},
* security={{"api_key":{}}},
* @OA\Parameter(
* parameter="id",
* name="id",
* description="ID de la feuille de soins",
* @OA\Schema(
* type="integer",
* default = 349
* ),
* in="path",
* required=true
* ),
* @OA\Response(
* response=200,
* description="OK",
* @OA\JsonContent(
* ref="#/components/schemas/ApiResponse",
* example = {
* "status" : 200,
* "response" : {"insured_id":"GJKS8ZGBEJTL","network_id":250,"user_id":349,"id":8,"health_care_sheet_id":"XLLLCY75OU8H","insurance_id":4,"network_agent_id":43510,"patient_lastname":"Dietchi",
* "patient_firstname":"Djery","patient_situation":"AYANT DROIT","practitioner_lastname":"Dr Luc","practitioner_firstname":"Boris","practitioner_provider_class_id":"1","care_condition":"AFFECTION COURANTE",
* "accident_date":null,"pregnancy_start_at":null,"pregnancy_end_at":null,"state":"EN COURS DE VALIDATION","created_at":"2021-11-25T04:39:06.000000Z","updated_at":"2021-11-25T04:39:06.000000Z","type":"CONSULTATION",
* "practitioner_provider_class":"Chirugien","institution_name":"Agent 2 cnamgs fond 4","institution_code":"aon8K9BZOn","currency_code":"XAF","performances":{{"id":10,"act_id":5,"amount":"5 000 FCFA","moderator_ticket":"1 000 FCFA",
* "insurance_amount":"4 000 FCFA","home_visit_fees":"2 000 FCFA","created_at":"2021-11-25T05:39:06.000000Z","updated_at":"2021-11-25T05:39:06.000000Z","act":{"id":5,"code":"CODE2","name":"Les actes infirmiers"}}},"exams":{{"id":2,"act_id":7,"description":"Une description de l'examen","quantity":5,"unit_price":null,"insured_paid_amount":null,"insurer_paid_amount":null,"created_at":"2021-11-25T04:39:06.000000Z",
* "updated_at":"2021-11-25T04:39:06.000000Z","laravel_through_key":8,"act":{"id":7,"code":"CODE4","name":"Les analyses de biologie m\u00e9dicale"}}},"prescriptions":{{"id":4,"drug_or_device_id":1,"dosage":"3 fois\/jour","quantity":5,"unit_price":null,"insured_paid_amount":null,"insurer_paid_amount":null,"created_at":"2021-11-25T05:39:06.000000Z","updated_at":"2021-11-25T05:39:06.000000Z",
* "drug_or_device":{"id":1,"name":"Paracetamol"}}}},
* "error":null
* }
* )
* )
* )
*/
public function getOneHealthCareSheets($id)
{
$sheet = NhInfosHealthCareSheets::with(['performances.act:id,code,name', 'exams.act:id,code,name', 'prescriptions.drug_or_device:id,name'])->where('id', $id)->first();
$this->formalizeHealthCareSheet($sheet);
return $this->successResponse($sheet);
}
private function formatExamAndPrescriptionAmounts($e, $sheet): void
{
@ -978,4 +1007,29 @@ class HealthCareSheetController extends Controller
} while ($codeCorrect);
return $code;
}
/**
* @param $sheet
* @return void
*/
private function formalizeHealthCareSheet($sheet): void
{
$sheet->state = trans('states.' . $sheet->state);
$sheet->patient_situation = trans('states.' . $sheet->patient_situation);
$sheet->care_condition = trans('states.' . $sheet->care_condition);
foreach ($sheet->performances as $p) {
$p->amount = $this->toMoneyWithCurrencyCode($p->amount, $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->home_visit_fees = isset($p->home_visit_fees) ? $this->toMoneyWithCurrencyCode($p->home_visit_fees, $sheet->currency_code) : null;
}
foreach ($sheet->exams as $e) {
$this->formatExamAndPrescriptionAmounts($e, $sheet);
}
foreach ($sheet->prescriptions as $p) {
$this->formatExamAndPrescriptionAmounts($p, $sheet);
}
}
}

View File

@ -57,9 +57,9 @@ class InsuredConsultationNotification
$body->date = $event->healthCareSheet->created_at->format('Y-m-d H:i:s') ?? date('Y-m-d H:i:s');
$data = new stdClass();
$data->screen = "notificationview";
$data->screen = "validateConsultationDetailScreen";
$data->data = new stdClass();
$data->data->health_care_sheet_id = $data->data->id = $event->healthCareSheet->id;
$data->data->id = $event->healthCareSheet->id;
$body->data = $data;
$client->request('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers]);

View File

@ -47,6 +47,7 @@ $router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($route
$router->post('health-care-sheets/performances-amount', 'HealthCareSheetController@calculateConsultationPerformancesAmount');
$router->post('health-care-sheets/consultation', 'HealthCareSheetController@storeHealthCareSheetConsultation');
$router->post('health-care-sheets/execution', 'HealthCareSheetController@storeHealthCareSheetExecution');
$router->get('health-care-sheets/{id}', 'HealthCareSheetController@getOneHealthCareSheets');
//QRCode for agents
$router->get('qrcode/generate/{id_user}', 'QRCodeController@generate');