Update authorization requests endpoints
This commit is contained in:
parent
2c0df32542
commit
1314e0219e
|
@ -20,6 +20,7 @@ use App\Models\NhHealthCareSheetsPrescription;
|
||||||
use App\Models\NhInfosAuthorizationOfCareRequest;
|
use App\Models\NhInfosAuthorizationOfCareRequest;
|
||||||
use App\Models\NhInfosHealthCareSheets;
|
use App\Models\NhInfosHealthCareSheets;
|
||||||
use App\Models\NhInsurance;
|
use App\Models\NhInsurance;
|
||||||
|
use App\Models\NhInsurancesHavingRight;
|
||||||
use App\Models\NhMedicalPrescription;
|
use App\Models\NhMedicalPrescription;
|
||||||
use App\Models\NhNetworksConfig;
|
use App\Models\NhNetworksConfig;
|
||||||
use App\Models\NhPerformance;
|
use App\Models\NhPerformance;
|
||||||
|
@ -62,8 +63,14 @@ class AuthorizationCareRequestController extends Controller
|
||||||
* example= 5
|
* example= 5
|
||||||
* ),
|
* ),
|
||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
* property="user_id",
|
* property="beneficiary_id",
|
||||||
* description = "ID de l'utilisateur",
|
* description = "ID du beneficiaire , s'il s'agit d'une feuille de soins pour beneficiaire",
|
||||||
|
* type="integer",
|
||||||
|
* example= 4
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="insurance_id",
|
||||||
|
* description = "ID de l'assurance",
|
||||||
* type="integer",
|
* type="integer",
|
||||||
* example= 301
|
* example= 301
|
||||||
* ),
|
* ),
|
||||||
|
@ -94,16 +101,39 @@ class AuthorizationCareRequestController extends Controller
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'act_id' => 'required|integer|exists:nh_acts,id',
|
'act_id' => 'required|integer|exists:nh_acts,id',
|
||||||
'user_id' => 'required|integer|exists:users,id',
|
'insurance_id' => 'required|integer|exists:nh_insurances,id',
|
||||||
|
'beneficiary_id' => 'nullable|int|exists:nh_having_rights,id',
|
||||||
'password' => 'required|string'
|
'password' => 'required|string'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user = User::find($request->input('user_id'));
|
|
||||||
$act_id = $request->input('act_id');
|
$act_id = $request->input('act_id');
|
||||||
$password = $request->input('password');
|
$password = $request->input('password');
|
||||||
|
$insurance = NhInsurance::find($request->input('insurance_id'));
|
||||||
|
if ($insurance->state != InsuranceState::PAID) {
|
||||||
|
return $this->errorResponse(__('errors.insurance_not_in_order'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $insurance->user;
|
||||||
if (!checkPassword($password, $user->encrypted_password, $user->salt))
|
if (!checkPassword($password, $user->encrypted_password, $user->salt))
|
||||||
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
||||||
|
|
||||||
|
$beneficiary_id = $request->input('beneficiary_id');
|
||||||
|
if (!empty($beneficiary_id)) {
|
||||||
|
$beneficiary = NhInsurancesHavingRight::where('insurance_id', $insurance->id)->where('having_right_id', $beneficiary_id)->first();
|
||||||
|
if (!isset($beneficiary)) {
|
||||||
|
return $this->errorResponse(trans('errors.beneficiary_not_found'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$beneficiary_id = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentRequest = NhAuthorizationOfCareRequest::where('insurance_id', $insurance->id)->where('act_id', $act_id)
|
||||||
|
->where('beneficiary_id', $beneficiary_id)->where('state', InsuranceSubscriptionState::UNDER_VALIDATION)->first();
|
||||||
|
if (isset($currentRequest)) {
|
||||||
|
return $this->errorResponse(__('errors.act_application_already_pending'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$act = NhAct::find($act_id);
|
$act = NhAct::find($act_id);
|
||||||
try {
|
try {
|
||||||
$datetime = $this->getCurrentTimeByCountryCode($user->network->country->code_country);
|
$datetime = $this->getCurrentTimeByCountryCode($user->network->country->code_country);
|
||||||
|
@ -111,7 +141,9 @@ class AuthorizationCareRequestController extends Controller
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
NhAuthorizationOfCareRequest::create([
|
NhAuthorizationOfCareRequest::create([
|
||||||
'request_id' => $this->generateRequestID(),
|
'request_id' => $this->generateRequestID(),
|
||||||
'user_id' => $user->id,
|
'insurance_id' => $insurance->id,
|
||||||
|
'beneficiary_id' => $beneficiary_id,
|
||||||
|
'to' => isset($beneficiary) ? 'HAVING_RIGHT' : 'INSURED',
|
||||||
'act_id' => $act_id,
|
'act_id' => $act_id,
|
||||||
'state' => InsuranceSubscriptionState::UNDER_VALIDATION,
|
'state' => InsuranceSubscriptionState::UNDER_VALIDATION,
|
||||||
'created_at' => $datetime, 'updated_at' => $datetime
|
'created_at' => $datetime, 'updated_at' => $datetime
|
||||||
|
@ -124,7 +156,11 @@ class AuthorizationCareRequestController extends Controller
|
||||||
|
|
||||||
|
|
||||||
$title = __('messages.new_care_authorisation');
|
$title = __('messages.new_care_authorisation');
|
||||||
$message = __('messages.new_care_authorisation_email', ['insured' => $user->lastname . ' ' . $user->firstname, 'act' => $act->name]);
|
$insured = $user->lastname . ' ' . $user->firstname;
|
||||||
|
if (isset($beneficiary)) {
|
||||||
|
$insured = $beneficiary->beneficiary->lastname . ' ' . $beneficiary->beneficiary->firstname;
|
||||||
|
}
|
||||||
|
$message = __('messages.new_care_authorisation_email', ['insured' => $insured, 'act' => $act->name]);
|
||||||
|
|
||||||
Mail::mailer('smtp')->raw($message, function ($message) use ($recipients, $title) {
|
Mail::mailer('smtp')->raw($message, function ($message) use ($recipients, $title) {
|
||||||
$message->subject($title)
|
$message->subject($title)
|
||||||
|
@ -156,7 +192,7 @@ class AuthorizationCareRequestController extends Controller
|
||||||
return $this->errorResponse(trans('errors.care_request_already_been_processed'));
|
return $this->errorResponse(trans('errors.care_request_already_been_processed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$datetime = $this->getCurrentTimeByCountryCode($request->user->network->country->code_country);
|
$datetime = $this->getCurrentTimeByCountryCode($request->insurance->network->country->code_country);
|
||||||
|
|
||||||
if ($action == 'ACCEPT') {
|
if ($action == 'ACCEPT') {
|
||||||
$request->state = InsuranceSubscriptionState::ACCEPTED;
|
$request->state = InsuranceSubscriptionState::ACCEPTED;
|
||||||
|
@ -187,6 +223,7 @@ class AuthorizationCareRequestController extends Controller
|
||||||
$data = new stdClass();
|
$data = new stdClass();
|
||||||
$data->screen = "demandeAutorisationSoinScreen";
|
$data->screen = "demandeAutorisationSoinScreen";
|
||||||
$data->data = new stdClass();
|
$data->data = new stdClass();
|
||||||
|
$data->data->id = $request->id;
|
||||||
$body->data = $data;
|
$body->data = $data;
|
||||||
$client->request('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers]);
|
$client->request('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers]);
|
||||||
} catch (Throwable $t) {
|
} catch (Throwable $t) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ use App\InsuranceState;
|
||||||
use App\InsuranceSubscriptionState;
|
use App\InsuranceSubscriptionState;
|
||||||
use App\Models\AgentPlus;
|
use App\Models\AgentPlus;
|
||||||
use App\Models\NhAct;
|
use App\Models\NhAct;
|
||||||
|
use App\Models\NhAuthorizationOfCareRequest;
|
||||||
use App\Models\NhDrugsAndDevice;
|
use App\Models\NhDrugsAndDevice;
|
||||||
use App\Models\NhExam;
|
use App\Models\NhExam;
|
||||||
use App\Models\NhHealthCareSheet;
|
use App\Models\NhHealthCareSheet;
|
||||||
|
@ -22,8 +23,6 @@ use App\Models\NhMedicalPrescription;
|
||||||
use App\Models\NhNetworksConfig;
|
use App\Models\NhNetworksConfig;
|
||||||
use App\Models\NhPerformance;
|
use App\Models\NhPerformance;
|
||||||
use App\Models\NhProviderClass;
|
use App\Models\NhProviderClass;
|
||||||
use App\Traits\ApiResponser;
|
|
||||||
use App\Traits\Helper;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
|
@ -253,6 +252,26 @@ class HealthCareSheetController extends Controller
|
||||||
* in="query",
|
* in="query",
|
||||||
* required=false
|
* required=false
|
||||||
* ),
|
* ),
|
||||||
|
* @OA\Parameter(
|
||||||
|
* parameter="user_id",
|
||||||
|
* name="user_id",
|
||||||
|
* description="ID de utilisateur de l'assuré principal",
|
||||||
|
* @OA\Schema(
|
||||||
|
* type="integer",
|
||||||
|
* ),
|
||||||
|
* in="query",
|
||||||
|
* required=false
|
||||||
|
* ),
|
||||||
|
* @OA\Parameter(
|
||||||
|
* parameter="beneficiary_id",
|
||||||
|
* name="beneficiary_id",
|
||||||
|
* description="ID du beneficiaire , s'il s'agit d'une feuille de soins pour beneficiaire",
|
||||||
|
* @OA\Schema(
|
||||||
|
* type="integer",
|
||||||
|
* ),
|
||||||
|
* in="query",
|
||||||
|
* required=false
|
||||||
|
* ),
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response=200,
|
* response=200,
|
||||||
* description="OK",
|
* description="OK",
|
||||||
|
@ -271,19 +290,23 @@ class HealthCareSheetController extends Controller
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'network_id' => 'required|integer|exists:networks,id',
|
'network_id' => 'required|integer|exists:networks,id',
|
||||||
|
'user_id' => 'nullable|string|exists:users,id',
|
||||||
|
'beneficiary_id' => 'nullable|string|exists:nh_having_rights,id',
|
||||||
'code' => 'nullable|string',
|
'code' => 'nullable|string',
|
||||||
'authorization_type' => 'nullable|in:FREE,PRIOR'
|
'authorization_type' => 'nullable|in:FREE,PRIOR'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$network_id = $request->input('network_id');
|
$network_id = $request->input('network_id');
|
||||||
$authorization_type = $request->input('authorization_type');
|
$authorization_type = $request->input('authorization_type');
|
||||||
|
$user_id = $request->input('user_id');
|
||||||
|
$beneficiary_id = $request->input('beneficiary_id');
|
||||||
|
$code = $request->input('code');
|
||||||
|
|
||||||
$query = NhAct::whereHas('network_config', function ($query) use ($network_id) {
|
$query = NhAct::whereHas('network_config', function ($query) use ($network_id) {
|
||||||
return $query->where('network_id', $network_id);
|
return $query->where('network_id', $network_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($request->has('code')) {
|
if (!empty($code)) {
|
||||||
$code = $request->input('code');
|
|
||||||
$query = $query->where('code', 'like', '%' . $code . '%');
|
$query = $query->where('code', 'like', '%' . $code . '%');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +314,26 @@ class HealthCareSheetController extends Controller
|
||||||
$query = $query->where('authorization_type', $authorization_type);
|
$query = $query->where('authorization_type', $authorization_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
$classes = $query->get(['id', 'code', 'name']);
|
if (!empty($user_id)) {
|
||||||
|
$query = $query->where('authorization_type', 'FREE');
|
||||||
|
|
||||||
|
// Recuperer les actes autorisés
|
||||||
|
$authorized_ids_query = NhAuthorizationOfCareRequest::whereHas('insurance', function ($q) use ($user_id) {
|
||||||
|
return $q->where('user_id', $user_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!empty($beneficiary_id)) {
|
||||||
|
$authorized_ids_query = $authorized_ids_query->where('beneficiary_id', $beneficiary_id);
|
||||||
|
} else {
|
||||||
|
$authorized_ids_query = $authorized_ids_query->whereNull('beneficiary_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
$authorized_ids = $authorized_ids_query->where('state', InsuranceSubscriptionState::ACCEPTED)->pluck('act_id')->toArray();
|
||||||
|
$query = $query->orWhereIn('id', $authorized_ids);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$classes = $query->select('id', 'code', 'name')->get();
|
||||||
|
|
||||||
return $this->successResponse($classes);
|
return $this->successResponse($classes);
|
||||||
}
|
}
|
||||||
|
@ -402,6 +444,18 @@ class HealthCareSheetController extends Controller
|
||||||
* example= 4
|
* example= 4
|
||||||
* ),
|
* ),
|
||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
|
* property="patient_lastname",
|
||||||
|
* description = "Nom du patient",
|
||||||
|
* type="string",
|
||||||
|
* example= "Tom"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="patient_firstname",
|
||||||
|
* description = "Prenom du patient",
|
||||||
|
* type="string",
|
||||||
|
* example= "BOBOL"
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
* property="practitioner_lastname",
|
* property="practitioner_lastname",
|
||||||
* description = "Nom du pratricien",
|
* description = "Nom du pratricien",
|
||||||
* type="string",
|
* type="string",
|
||||||
|
@ -547,6 +601,8 @@ class HealthCareSheetController extends Controller
|
||||||
'network_agent_id' => 'required|integer|exists:networks_agents,id',
|
'network_agent_id' => 'required|integer|exists:networks_agents,id',
|
||||||
'password' => 'required|string',
|
'password' => 'required|string',
|
||||||
'beneficiary_id' => 'nullable|int|exists:nh_having_rights,id',
|
'beneficiary_id' => 'nullable|int|exists:nh_having_rights,id',
|
||||||
|
'patient_lastname' => 'required|string',
|
||||||
|
'patient_firstname' => 'nullable|string',
|
||||||
'practitioner_lastname' => 'required|string',
|
'practitioner_lastname' => 'required|string',
|
||||||
'practitioner_firstname' => 'nullable|string',
|
'practitioner_firstname' => 'nullable|string',
|
||||||
'practitioner_provider_class_id' => 'required|integer',
|
'practitioner_provider_class_id' => 'required|integer',
|
||||||
|
@ -583,6 +639,8 @@ class HealthCareSheetController extends Controller
|
||||||
if (!isset($beneficiary)) {
|
if (!isset($beneficiary)) {
|
||||||
return $this->errorResponse(trans('errors.beneficiary_not_found'));
|
return $this->errorResponse(trans('errors.beneficiary_not_found'));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$beneficiary_id = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nhConfig = NhNetworksConfig::where('network_id', $insurance->network_id)->first();
|
$nhConfig = NhNetworksConfig::where('network_id', $insurance->network_id)->first();
|
||||||
|
@ -597,13 +655,12 @@ class HealthCareSheetController extends Controller
|
||||||
|
|
||||||
$datetime = $this->getCurrentTimeByCountryCode($insurance->network->country->code_country);
|
$datetime = $this->getCurrentTimeByCountryCode($insurance->network->country->code_country);
|
||||||
|
|
||||||
$beneficiary_id = $request->input('beneficiary_id');
|
|
||||||
$accident_date = $request->input('accident_date');
|
$accident_date = $request->input('accident_date');
|
||||||
$pregnancy_start_at = $request->input('pregnancy_start_at');
|
$pregnancy_start_at = $request->input('pregnancy_start_at');
|
||||||
$pregnancy_end_at = $request->input('pregnancy_end_at');
|
$pregnancy_end_at = $request->input('pregnancy_end_at');
|
||||||
$healthCareSheet = NhHealthCareSheet::create([
|
$healthCareSheet = NhHealthCareSheet::create([
|
||||||
'health_care_sheet_id' => $this->generateSheetID(),
|
'health_care_sheet_id' => $this->generateSheetID(),
|
||||||
'beneficiary_id' => !empty($beneficiary_id) ? $beneficiary_id : null,
|
'beneficiary_id' => $beneficiary_id,
|
||||||
'network_agent_id' => $request->input('network_agent_id'),
|
'network_agent_id' => $request->input('network_agent_id'),
|
||||||
'care_condition' => $request->input('care_condition'),
|
'care_condition' => $request->input('care_condition'),
|
||||||
'practitioner_lastname' => $request->input('practitioner_lastname'),
|
'practitioner_lastname' => $request->input('practitioner_lastname'),
|
||||||
|
@ -637,6 +694,8 @@ class HealthCareSheetController extends Controller
|
||||||
'performance_id' => $performance->id,
|
'performance_id' => $performance->id,
|
||||||
'created_at' => $datetime, 'updated_at' => $datetime,
|
'created_at' => $datetime, 'updated_at' => $datetime,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->useAuthorizationRequest($p['act_id'], $insurance->id, $beneficiary_id, $healthCareSheet->id, $datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($request->input('prescriptions', []) as $p) {
|
foreach ($request->input('prescriptions', []) as $p) {
|
||||||
|
@ -664,6 +723,8 @@ class HealthCareSheetController extends Controller
|
||||||
'exam_id' => $exam->id,
|
'exam_id' => $exam->id,
|
||||||
'created_at' => $datetime, 'updated_at' => $datetime,
|
'created_at' => $datetime, 'updated_at' => $datetime,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->useAuthorizationRequest($e['act_id'], $insurance->id, $beneficiary_id, $healthCareSheet->id, $datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
NhHealthCareSheetsHistory::create([
|
NhHealthCareSheetsHistory::create([
|
||||||
|
@ -691,6 +752,21 @@ class HealthCareSheetController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function useAuthorizationRequest($act_id, $insurance_id, $beneficiary_id, $sheet_id, $datetime): void
|
||||||
|
{
|
||||||
|
$authorization_request = NhAuthorizationOfCareRequest::where('act_id', $act_id)->where('insurance_id', $insurance_id);
|
||||||
|
if (empty($beneficiary_id)) {
|
||||||
|
$authorization_request = $authorization_request->whereNull('beneficiary_id');
|
||||||
|
} else {
|
||||||
|
$authorization_request = $authorization_request->where('beneficiary_id', $beneficiary_id);
|
||||||
|
}
|
||||||
|
$authorization_request->update([
|
||||||
|
'state' => 'USED',
|
||||||
|
'health_care_sheet_id' => $sheet_id,
|
||||||
|
'updated_at' => $datetime
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @OA\Post(
|
* @OA\Post(
|
||||||
* path="/health-care-sheets/execution",
|
* path="/health-care-sheets/execution",
|
||||||
|
@ -1101,7 +1177,6 @@ class HealthCareSheetController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$query = $query->with(['performances.act:id,code,name', 'exams.act:id,code,name', 'prescriptions.drug_or_device:id,name']);
|
$query = $query->with(['performances.act:id,code,name', 'exams.act:id,code,name', 'prescriptions.drug_or_device:id,name']);
|
||||||
|
|
||||||
if (!empty($state) && $state == 'TO_BILL') {
|
if (!empty($state) && $state == 'TO_BILL') {
|
||||||
|
|
|
@ -479,7 +479,6 @@ class InsuranceSubscriptionController extends Controller
|
||||||
'insurance_subscription_state' => $subscription->state,
|
'insurance_subscription_state' => $subscription->state,
|
||||||
'agent_id' => $request->input('agent_id'),
|
'agent_id' => $request->input('agent_id'),
|
||||||
'nh_validating_agent_id' => $request->input('nh_validating_agent_id'),
|
'nh_validating_agent_id' => $request->input('nh_validating_agent_id'),
|
||||||
|
|
||||||
'created_at' => $datetime, 'updated_at' => $datetime,
|
'created_at' => $datetime, 'updated_at' => $datetime,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,16 @@ use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AuthorizationOfCareRequest
|
* Class NhAuthorizationOfCareRequest
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $request_id
|
* @property string $request_id
|
||||||
* @property int $user_id
|
|
||||||
* @property int $act_id
|
* @property int $act_id
|
||||||
|
* @property int $insurance_id
|
||||||
|
* @property int|null $beneficiary_id
|
||||||
|
* @property string $to
|
||||||
* @property string $state
|
* @property string $state
|
||||||
|
* @property int|null $health_care_sheet_id
|
||||||
* @property int|null $validating_agent_id
|
* @property int|null $validating_agent_id
|
||||||
* @property Carbon $created_at
|
* @property Carbon $created_at
|
||||||
* @property Carbon $updated_at
|
* @property Carbon $updated_at
|
||||||
|
@ -28,20 +31,26 @@ class NhAuthorizationOfCareRequest extends Model
|
||||||
protected $table = 'nh_authorization_of_care_requests';
|
protected $table = 'nh_authorization_of_care_requests';
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'user_id' => 'int',
|
'act_id' => 'int',
|
||||||
'act_id' => 'int'
|
'insurance_id' => 'int',
|
||||||
|
'beneficiary_id' => 'int',
|
||||||
|
'health_care_sheet_id' => 'int',
|
||||||
|
'validating_agent_id' => 'int'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'request_id',
|
'request_id',
|
||||||
'user_id',
|
|
||||||
'act_id',
|
'act_id',
|
||||||
|
'insurance_id',
|
||||||
|
'beneficiary_id',
|
||||||
|
'to',
|
||||||
'state',
|
'state',
|
||||||
|
'health_care_sheet_id',
|
||||||
'validating_agent_id'
|
'validating_agent_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function user()
|
public function insurance()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'user_id');
|
return $this->belongsTo(NhInsurance::class, 'insurance_id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,12 @@ class CreateNhAuthorizationOfCareRequestsTable extends Migration
|
||||||
Schema::create('nh_authorization_of_care_requests', function (Blueprint $table) {
|
Schema::create('nh_authorization_of_care_requests', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('request_id')->unique();
|
$table->string('request_id')->unique();
|
||||||
$table->integer('user_id');
|
|
||||||
$table->integer('act_id');
|
$table->integer('act_id');
|
||||||
$table->enum('state', ['UNDER_VALIDATION', 'ACCEPTED', 'REJECTED'])->default('UNDER_VALIDATION');
|
$table->integer('insurance_id');
|
||||||
|
$table->integer('beneficiary_id')->nullable();
|
||||||
|
$table->enum('to', ['INSURED', 'HAVING_RIGHT'])->default('INSURED')->comment('Destiné à assuré ou ayant droit');
|
||||||
|
$table->enum('state', ['UNDER_VALIDATION', 'ACCEPTED', 'REJECTED', 'USED'])->default('UNDER_VALIDATION');
|
||||||
|
$table->integer('health_care_sheet_id')->nullable();
|
||||||
$table->integer('validating_agent_id')->nullable();
|
$table->integer('validating_agent_id')->nullable();
|
||||||
$table->timestamp('created_at')->useCurrent();
|
$table->timestamp('created_at')->useCurrent();
|
||||||
$table->timestamp('updated_at')->useCurrent();
|
$table->timestamp('updated_at')->useCurrent();
|
||||||
|
|
|
@ -15,10 +15,10 @@ class CreaeNhInfosAuthorizationOfCareRequestsView extends Migration
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
DB::statement("CREATE OR REPLACE VIEW nh_infos_authorization_of_care_requests AS
|
DB::statement("CREATE OR REPLACE VIEW nh_infos_authorization_of_care_requests AS
|
||||||
SELECT r.* , na.name as act_name , na.code as act_code, nnc.network_id , u.lastname as user_lastname , u.firstname as user_firstname , u.phone as user_phone, u.email as user_email , nva.lastname as validating_agent_lastname,
|
SELECT r.* , na.name as act_name , na.code as act_code, nnc.network_id , u.lastname as user_lastname , u.firstname as user_firstname , u.phone as user_phone, u.email as user_email , nva.lastname as validating_agent_lastname,
|
||||||
nva.firstname as validating_agent_firstname , nva.phone as validating_agent_phone, nva.email as validating_agent_email
|
nva.firstname as validating_agent_firstname , nva.phone as validating_agent_phone, nva.email as validating_agent_email, nhr.lastname as beneficiary_lastname , nhr.firstname as beneficiary_firstname
|
||||||
FROM nh_authorization_of_care_requests r JOIN users u ON r.user_id = u.id JOIN nh_acts na on na.id = r.act_id JOIN nh_networks_configs nnc on na.nh_network_config_id = nnc.id
|
FROM nh_authorization_of_care_requests r JOIN nh_insurances nhi ON nhi.id = r.insurance_id JOIN users u ON nhi.user_id = u.id JOIN nh_acts na on na.id = r.act_id JOIN nh_networks_configs nnc on na.nh_network_config_id = nnc.id
|
||||||
LEFT JOIN nh_validating_agents nva on r.validating_agent_id = nva.id");
|
LEFT JOIN nh_having_rights nhr on nhr.id = r.beneficiary_id LEFT JOIN nh_validating_agents nva on r.validating_agent_id = nva.id");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue