app/Http/Controllers/VitalsController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        if (empty($request->input('rdt'))){
            $vital = Vital::where('registration_id',$request->input('registration_id'))
                ->where('patient_id',$request->input('patient_id'))->first();
            $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 = "Consultation";
            $vital->user_id=Auth::user()->id;
            $vital->save();
            $registration = Registration::find($request->input('registration_id'));
            $registration->vitals = 1;
            $registration->save();
            toastr()->success('Vitals Updated Successfully');
            return redirect()->route('vitals.index');
        }else{
            $registration = Registration::find($request->input('registration_id'));
            $vital = Vital::where('registration_id',$request->input('registration_id'))
                ->where('patient_id',$request->input('patient_id'))->first();
            if ($vital->RDT == ""){
                $bill = new Bill();
                $bill->registration_id = $request->input('registration_id');
                $bill->patient_id =$registration->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();
            }
            $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 = "Consultation";
            $vital->user_id=Auth::user()->id;
            $vital->save();
            $registration->vitals = 1;
            $registration->save();
            toastr()->success('Vitals Updated');
            return back();
        }
    }
public function update ( Request $ request , $ id ) { if ( empty ( $ request -> input ( 'rdt' ) ) ) { $ vital = Vital :: where ( 'registration_id' , $ request -> input ( 'registration_id' ) ) -> where ( 'patient_id' , $ request -> input ( 'patient_id' ) ) -> first ( ) ; $ 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 = " Consultation " ; $ vital -> user_id = Auth :: user ( ) -> id ; $ vital -> save ( ) ; $ registration = Registration :: find ( $ request -> input ( 'registration_id' ) ) ; $ registration -> vitals = 1 ; $ registration -> save ( ) ; toastr ( ) -> success ( 'Vitals Updated Successfully' ) ; return redirect ( ) -> route ( 'vitals.index' ) ; } else { $ registration = Registration :: find ( $ request -> input ( 'registration_id' ) ) ; $ vital = Vital :: where ( 'registration_id' , $ request -> input ( 'registration_id' ) ) -> where ( 'patient_id' , $ request -> input ( 'patient_id' ) ) -> first ( ) ; if ( $ vital -> RDT == " " ) { $ bill = new Bill ( ) ; $ bill -> registration_id = $ request -> input ( 'registration_id' ) ; $ bill -> patient_id = $ registration -> 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 ( ) ; } $ 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 = " Consultation " ; $ vital -> user_id = Auth :: user ( ) -> id ; $ vital -> save ( ) ; $ registration -> vitals = 1 ; $ registration -> save ( ) ; toastr ( ) -> success ( 'Vitals Updated' ) ; return back ( ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
//check if patient doesn't need rdt(malaria) test //add a new bill for rdt (malaria Test)