public function create($id) { $inquiry_id = $id; $inquiry = Inquiry::find($inquiry_id); if (is_null($inquiry)) { return redirect()->back()->with('status', 'Missing Inquiry Reference'); } return view('demographic.create')->with('inquiry', $inquiry); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $inquiry = Inquiry::find($id); $inquiry->delete(); // return redirect()->back(); return response()->json(array('status' => 200, 'monolog' => array('title' => 'delete success', 'message' => 'Inquiry has been deleted'), 'id' => $id)); }
public function store(Request $request) { $datedoc = Carbon::now(-6); $yr = $datedoc->year; $mo = $datedoc->month; $dom = $datedoc->day; $doy = $datedoc->dayOfYear; $dateadmission = $request->input('dateadmission'); if (!empty($dateadmission) || $dateadmission == '0000-00-00') { $dateparts = explode('-', $dateadmission); $partyear = $dateparts[0]; $partmonth = $dateparts[1]; $partdom = $dateparts[2]; $dateadmission = Carbon::createFromDate($partyear, $partmonth, $partdom, -6); //return redirect()->back()->with('status',"Date Admission is $dateadmission"); } else { //uh oh, we dont have an admission date. return redirect()->back()->with('status', 'You must specifcy an admission date!'); } if (Auth::check()) { $staff_id = Auth::user()->id; $sfname = Auth::user()->fname; $slname = Auth::user()->lname; } else { return redirect('auth/login'); } $program_id = $request->input('program_id'); $inquiry_id = $request->input('inquiry_id'); $inquiry = Inquiry::find($inquiry_id); if (is_null($inquiry)) { return redirect()->back()->with('status', 'You must have a valid Inquiry'); } //$existingmrn = $inquiry->mrn; $episode_id = $inquiry->episode_id; $client_id = $inquiry->client_id; if (is_null($client_id)) { $client_id = 0; } $currentmrn = $inquiry->mrn; $fname = $inquiry->fname; $lname = $inquiry->lname; $mi = $inquiry->mi; $dob = $inquiry->dob; //=========close previous admissions since you cant have more than one at a time $clearresult = DB::table('admissions')->where('inquiry_id', '=', $inquiry_id)->update(['status_id' => '13', 'status' => 'Discharged', 'dctype_id' => '19', 'dctype' => 'Pending Review', 'datedischarge' => $datedoc]); //=================================== $status = "Admitted"; $status_id = 12; $dctype_id = 18; $dctype = "Not Applicable"; $program_id = $request->input('program_id'); if (is_null($program_id)) { return redirect()->back()->with('status', 'You are missing a valid program id'); } $serviceref = Service::find($program_id); $program = $serviceref->service; $admission = new Admission(); $looper = 0; $vals = array($inquiry_id, $client_id, $episode_id); $flds = array('inquiry_id', 'client_id', 'episode_id'); foreach ($flds as $fld) { $admission->setAttribute($fld, Input::has($fld) ? $vals[$looper] : '0'); $looper++; } //======================= $morechks = array('eie', 'dss'); foreach ($morechks as $morechk) { $admission->setAttribute($morechk, Input::has($morechk) ? true : false); } $admission->mo = $mo; $admission->doy = $doy; $admission->dom = $dom; $admission->yr = $yr; $admission->fname = $fname; //$request->input('fname'); $admission->lname = $lname; //$request->input('lname'); $admission->mi = $mi; $admission->sfname = $sfname; $admission->sfname = $sfname; $admission->slname = $slname; $admission->staff_id = $staff_id; $admission->datedoc = $dateadmission; $admission->dateadmission = $dateadmission; //$request->input('dateadmission'); $admission->datedischarge = $request->input('datedischarge'); $admission->program_id = $request->input('program_id'); $admission->program = $program; $admission->status_id = $status_id; //$request->input('status_id'); $admission->status = $status; $admission->dctype_id = $dctype_id; //$request->input('dctype_id'); $admission->dctype = $dctype; $admission->save(); $admission_id = $admission->id; //====== assign mrn ======/ //$mymsg = "yr: $yr mo: $mo dom: $dom "; //return redirect()->back()->with('status',$mymsg); //first we need to check for previous admissions - not including this one. $numadmissions = DB::table('admissions')->where('eie', '!=', '1')->whereNotIn('id', [$admission_id])->where('inquiry_id', '=', $inquiry_id)->count(); //get the current number of admissions so far this month. $admissionsmtd = DB::table('admissions')->where('eie', '!=', '1')->whereNotIn('id', [$admission_id])->where('mo', '=', $mo)->where('yr', '=', $yr)->count(); $admissionsmtd = $admissionsmtd + 1; //$admissionsmtd = 777; $totlength = 7; //======= heres the split where former clients get one set of things and new clients another. //============================================================ if ($numadmissions < 1) { //then its a brand spanking new admission and we need to generate an mrn and a new client_id //====== $molength = strlen($mo); //check to see if its a two digit or one digit if ($molength == 1) { //if it has only one digit then pad it by one zero. $newmo = str_pad($mo, 2, "0", STR_PAD_LEFT); } //next we get the maxadmission id $admissionsmtdlength = strlen($admissionsmtd); $padlength = $totlength - $admissionsmtdlength; $padlength = abs($padlength); //make sure it isnt a negative number $newnum = str_pad($admissionsmtd, $padlength, "0", STR_PAD_LEFT); $yrend = substr("{$yr}", -2); //get the last two numbers $newmrn = $yrend . "-" . $newmo . $newnum; //$mymsg = "mrn: $newmrn "; //return redirect()->back()->with('status',$mymsg); $client = new Client(); $client->fname = $fname; $client->lname = $lname; $client->datedoc = $dateadmission; //$client->dob = $dob; $client->isalias = 0; $client->eie = 0; $client->dss = 0; $client->sfname = $sfname; $client->slname = $slname; $client->staff_id = $staff_id; $client->inquiry_id = $inquiry_id; $client->episode_id = $episode_id; $client->mrn = $newmrn; $client->save(); $client_id = $client->id; //we probably need the dob in here somewhere too. $updateresult = DB::table('admissions')->where('inquiry_id', '=', $inquiry_id)->where('id', '=', $admission_id)->update(['mrn' => $newmrn, 'client_id' => $client_id]); $updateresult2 = DB::table('inquiries')->where('id', '=', $inquiry_id)->update(['mrn' => $newmrn, 'client_id' => $client_id]); $mrn = new Mrn(); $mrn->mrn = $newmrn; $mrn->datedoc = $dateadmission; $mrn->eie = 0; $mrn->fname = $fname; $mrn->lname = $lname; $mrn->client_id = $client_id; $mrn->inquiry_id = $inquiry_id; $mrn->episode_id = $episode_id; $mrn->save(); $mrnumber = $newmrn; //=================== } else { $inquiry = Inquiry::find($inquiry_id); if (is_null($inquiry)) { return redirect()->back()->with('status', 'You must have a valid Inquiry'); } $existingmrn = $inquiry->mrn; $episode_id = $inquiry->episode_id; $client_id = $inquiry->client_id; $mrnumber = $inquiry->mrn; //we need to update the client table with the last admission information //$updateresult = DB::table('admissions')->where('inquiry_id','=',$inquiry_id) // ->where('id','=',$admission_id) // ->update(['mrn' => $newmrn,'client_id'=>$client_id]); } //this is where we update all existing records with the client_id. //ideally we would get the names of the tables that need to be updated //from those identified through the mfl. that way we don't have to hope //to keep track of what will be completed during inquiry and updated later. // for our purposes right now, we are just going to list them. $tables = array("assessments", "admissions", "demographics", "ice", "payors"); foreach ($tables as $table) { $updatedone = DB::table($table)->where('inquiry_id', '=', $inquiry_id)->update(['mrn' => $mrnumber, 'client_id' => $client_id]); } //if($client_id > 0) // { // //return redirect()->route('clientview', $client_id); // } else { return redirect()->route('inquiryview', $inquiry_id); // } }
public function show($id) { $inquiry = Inquiry::find($id); $user = User::find($inquiry->user_id); return view('contacts.inquiry_show', ['title' => $inquiry->type . " Inquiry"]); }
public function update(Request $request, $id) { $datedoc = Carbon::now(-6); $inquiry_id = $id; $inquiry = Inquiry::find($inquiry_id); $inquiry->fname = $request->input('fname'); $inquiry->lname = $request->input('lname'); $inquiry->callerfname = $request->input('callerfname'); $inquiry->callerlname = $request->input('callerlname'); $inquiry->staff_id = $staff_id; $inquiry->sfname = $sfname; $inquiry->slname = $slname; $inquiry->isalias = 0; //$inquiry->aliasfname = ""; // $inquiry->aliaslname = ""; $inquiry->poc = $request->input('poc'); $inquiry->precipevent = $request->input('precipevent'); $inquiry->dob = $request->input('dob'); $inquiry->callerhphone = $request->input('callerhphone'); $inquiry->callercphone = $request->input('callercphone'); $inquiry->hphone = $request->input('hphone'); $inquiry->cphone = $request->input('cphone'); $morechks = array('eie', 'dss'); foreach ($morechks as $morechk) { $inquiry->setAttribute($morechk, Input::has($morechk) ? true : false); } $inquiry->client_id = 0; $inquiry->episode_id = 0; $inquiry->datedoc = $datedoc; $inquiry->mrn = 0; $inquiry->recordstatus_id = 1; //we'll say that one means active. $inquiry->save(); $inquiry_id = $inquiry->id; return redirect()->route('inquiryview', $inquiry_id); }