app/Http/Controllers/VitalsController.php
//if patient is detained, you can check vitals
if patient is detained, you can check vitals
if patient is detained you can check vitals
public function addVital(Request $request){
       DB::beginTransaction();
       try{
           if ($request->has('rdt')){
               $check_bill = Bill::where('patient_id',$request->input('patient_id'))
                   ->where('registration_id',$request->input('registration_id'))
                   ->where('item','Malaria Test')->first();
               if (empty($check_bill)) {
                   $bill = new Bill();
                   $bill->registration_id = $request->input('registration_id');
                   $bill->patient_id = $request->input('patient_id');
                   $bill->item = "Malaria Test";
                   $bill->amount = 10;
                   $bill->insurance_amount = 0;
                   $bill->total_amount_to_pay = 10;
                   $bill->billed_by = Auth::user()->first_name . " " . Auth::user()->last_name;
                   $bill->save();
               }else{
                   $check_bill->amount=$check_bill->amount+10;
                   $check_bill->total_amount_to_pay=$check_bill->total_amount_to_pay+10;
                   $check_bill->save();
               }
               $payment = Payment::where('registration_id',$request->input('registration_id'))
                   ->where('patient_id',$request->input('patient_id'))
                   ->first();
               $payment->grand_total = $payment->grand_total+10;
               $payment->arrears = str_replace('-','',$payment->arrears)+10;
               $payment->save();
           }
           $vital = new Vital();
           $vital->registration_id = $request->input('registration_id');
           $vital->patient_id = $request->input('patient_id');
           $vital->blood_pressure = $request->input('systolic')."/".$request->input('diastolic');
           $vital->weight = $request->input('weight');
           $vital->temperature = $request->input('temperature');
           $vital->pulse = $request->input('pulse');
           $vital->RDT = $request->input('rdt');
           $vital->glucose = $request->input('glucose');
           $vital->type= "Detention";
           $vital->user_id=Auth::user()->id;
           $vital->save();
           DB::commit();
           toastr()->success('Vitals Updated');
           return back();
       }catch (\Exception $exception){
           DB::rollBack();
           toastr()->warning('Something Went Wrong!1 Try Again');
           return back();
       }
    }
public function addVital ( Request $ request ) { DB :: beginTransaction ( ) ; try { if ( $ request -> has ( 'rdt' ) ) { $ check_bill = Bill :: where ( 'patient_id' , $ request -> input ( 'patient_id' ) ) -> where ( 'registration_id' , $ request -> input ( 'registration_id' ) ) -> where ( 'item' , 'Malaria Test' ) -> first ( ) ; if ( empty ( $ check_bill ) ) { $ bill = new Bill ( ) ; $ bill -> registration_id = $ request -> input ( 'registration_id' ) ; $ bill -> patient_id = $ request -> input ( 'patient_id' ) ; $ bill -> item = " Malaria Test " ; $ bill -> amount = 10 ; $ bill -> insurance_amount = 0 ; $ bill -> total_amount_to_pay = 10 ; $ bill -> billed_by = Auth :: user ( ) -> first_name . " " . Auth :: user ( ) -> last_name ; $ bill -> save ( ) ; } else { $ check_bill -> amount = $ check_bill -> amount + 10 ; $ check_bill -> total_amount_to_pay = $ check_bill -> total_amount_to_pay + 10 ; $ check_bill -> save ( ) ; } $ payment = Payment :: where ( 'registration_id' , $ request -> input ( 'registration_id' ) ) -> where ( 'patient_id' , $ request -> input ( 'patient_id' ) ) -> first ( ) ; $ payment -> grand_total = $ payment -> grand_total + 10 ; $ payment -> arrears = str_replace ( '-' , '' , $ payment -> arrears ) + 10 ; $ payment -> save ( ) ; } $ vital = new Vital ( ) ; $ vital -> registration_id = $ request -> input ( 'registration_id' ) ; $ vital -> patient_id = $ request -> input ( 'patient_id' ) ; $ vital -> blood_pressure = $ request -> input ( 'systolic' ) . " / " . $ request -> input ( 'diastolic' ) ; $ vital -> weight = $ request -> input ( 'weight' ) ; $ vital -> temperature = $ request -> input ( 'temperature' ) ; $ vital -> pulse = $ request -> input ( 'pulse' ) ; $ vital -> RDT = $ request -> input ( 'rdt' ) ; $ vital -> glucose = $ request -> input ( 'glucose' ) ; $ vital -> type = " Detention " ; $ vital -> user_id = Auth :: user ( ) -> id ; $ vital -> save ( ) ; DB :: commit ( ) ; toastr ( ) -> success ( 'Vitals Updated' ) ; return back ( ) ; } catch ( \ Exception $ exception ) { DB :: rollBack ( ) ; toastr ( ) -> warning ( 'Something Went Wrong!1 Try Again' ) ; return back ( ) ; } }
if patient is detained, you can check vitals
if patient is detained you can check vitals