app/Http/Controllers/PatientController.php
//upload labs or scan REsult for consultation or detention
upload labs or scan REsult for consultation or detention
upload labs or scan REsult for consultation or detention
public function uploadLabScanResult(Request $request,$patient_id){
        if ($request->has('labs')) {
            $this->validate($request,[
                'lab_registration_id' => ['required'],
            ]);
            $consultation = Consultation::where('registration_id',$request->input('lab_registration_id'))->first();
            for ($i = 0; $i < count($request->file('labs')); $i++) {
                $file = $request->file('labs')[$i];
                $extension = $file->getClientOriginalExtension();
                $files = substr($file->getClientOriginalName(), 0, strpos($file->getClientOriginalName(), '.'));
                $fileName = $files . '_' . time() . '.' . $extension;
                $file->move('public/labs', $fileName);
                $record = new LabResult();
                $record->patient_id = $patient_id;
                $record->registration_id = $request->input('lab_registration_id');
                $record->consultation_id = $consultation->id;
                $record->file_name =$fileName;
                if ($request->has('lab_review')){
                    $record->type="Review";
                }else{
                    $record->type="Consultation";
                }
                $record->user_id = Auth::user()->id;
                $record->save();
            }
        }
        if ($request->has('scan')){
            $this->validate($request,[
                'scan_registration_id' => ['required'],
            ]);
            $consultation = Consultation::where('lab_registration_id',$request->input('scan_registration_id'))->first();
            for ($i = 0; $i < count($request->file('scan')); $i++) {
                $scannedFile = $request->file('scan')[$i];
                $scannedExtension = $scannedFile->getClientOriginalExtension();
                $scannedFiles = substr($scannedFile->getClientOriginalName(), 0, strpos($scannedFile->getClientOriginalName(), '.'));
                $scannedFileName = $scannedFiles . '_' . time() . '.' . $scannedExtension;
                $scannedFile->move('public/scan', $scannedFileName);
                $record = new ScannedResult();
                $record->patient_id = $patient_id;
                $record->registration_id = $request->input('scan_registration_id');
                $record->consultation_id = $consultation->id;
                $record->file_name =$scannedFileName;
                if ($request->has('scan_review')){
                    $record->type="Review";
                }else{
                    $record->type="Consultation";
                }
                $record->user_id = Auth::user()->id;
                $record->save();
            }
        }
        toastr()->success('Upload Successful');
        return back();
    }
public function uploadLabScanResult ( Request $ request , $ patient_id ) { if ( $ request -> has ( 'labs' ) ) { $ this -> validate ( $ request , [ 'lab_registration_id' => [ 'required' ] , ] ) ; $ consultation = Consultation :: where ( 'registration_id' , $ request -> input ( 'lab_registration_id' ) ) -> first ( ) ; for ( $ i = 0 ; $ i < count ( $ request -> file ( 'labs' ) ) ; $ i ++ ) { $ file = $ request -> file ( 'labs' ) [ $ i ] ; $ extension = $ file -> getClientOriginalExtension ( ) ; $ files = substr ( $ file -> getClientOriginalName ( ) , 0 , strpos ( $ file -> getClientOriginalName ( ) , '.' ) ) ; $ fileName = $ files . '_' . time ( ) . '.' . $ extension ; $ file -> move ( 'public/labs' , $ fileName ) ; $ record = new LabResult ( ) ; $ record -> patient_id = $ patient_id ; $ record -> registration_id = $ request -> input ( 'lab_registration_id' ) ; $ record -> consultation_id = $ consultation -> id ; $ record -> file_name = $ fileName ; if ( $ request -> has ( 'lab_review' ) ) { $ record -> type = " Review " ; } else { $ record -> type = " Consultation " ; } $ record -> user_id = Auth :: user ( ) -> id ; $ record -> save ( ) ; } } if ( $ request -> has ( 'scan' ) ) { $ this -> validate ( $ request , [ 'scan_registration_id' => [ 'required' ] , ] ) ; $ consultation = Consultation :: where ( 'lab_registration_id' , $ request -> input ( 'scan_registration_id' ) ) -> first ( ) ; for ( $ i = 0 ; $ i < count ( $ request -> file ( 'scan' ) ) ; $ i ++ ) { $ scannedFile = $ request -> file ( 'scan' ) [ $ i ] ; $ scannedExtension = $ scannedFile -> getClientOriginalExtension ( ) ; $ scannedFiles = substr ( $ scannedFile -> getClientOriginalName ( ) , 0 , strpos ( $ scannedFile -> getClientOriginalName ( ) , '.' ) ) ; $ scannedFileName = $ scannedFiles . '_' . time ( ) . '.' . $ scannedExtension ; $ scannedFile -> move ( 'public/scan' , $ scannedFileName ) ; $ record = new ScannedResult ( ) ; $ record -> patient_id = $ patient_id ; $ record -> registration_id = $ request -> input ( 'scan_registration_id' ) ; $ record -> consultation_id = $ consultation -> id ; $ record -> file_name = $ scannedFileName ; if ( $ request -> has ( 'scan_review' ) ) { $ record -> type = " Review " ; } else { $ record -> type = " Consultation " ; } $ record -> user_id = Auth :: user ( ) -> id ; $ record -> save ( ) ; } } toastr ( ) -> success ( 'Upload Successful' ) ; return back ( ) ; }
upload labs or scan REsult for consultation or detention
upload labs or scan REsult for consultation or detention
//        return $consultation; //Upload Scans