コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     DB::table('bsm')->truncate();
     BSM::create(['bm_name' => '艾科灵睿', 'bm_model' => '艾科灵睿', 'bm_order' => 1]);
     BSM::create(['bm_name' => '鱼跃', 'bm_model' => '鱼跃', 'bm_order' => 2]);
     BSM::create(['bm_name' => '滕爱', 'bm_model' => '滕爱', 'bm_order' => 3]);
     BSM::create(['bm_name' => '康迅360', 'bm_model' => '康迅360', 'bm_order' => 4]);
     BSM::create(['bm_name' => '泰尔茂', 'bm_model' => '泰尔茂', 'bm_order' => 5]);
     BSM::create(['bm_name' => '艾科益优', 'bm_model' => '艾科益优', 'bm_order' => 6]);
     BSM::create(['bm_name' => 'POP', 'bm_model' => 'POP', 'bm_order' => 7]);
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
コード例 #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @param Request $request
  * @return Response
  */
 public function update(Request $request, $id)
 {
     // validate
     $this->validate($request, Patientprofile::updaterules());
     DB::beginTransaction();
     try {
         // patientprofile1
         $patientprofile = Patientprofile::findOrFail($id);
         $patientprofile->pp_birthday = $request->pp_birthday;
         $patientprofile->pp_age = $request->pp_age;
         $patientprofile->pp_sex = $request->pp_sex;
         $patientprofile->pp_height = $request->pp_height;
         $patientprofile->pp_weight = $request->pp_weight;
         $patientprofile->pp_tel1 = $request->pp_tel1;
         $patientprofile->pp_tel2 = $request->pp_tel2;
         $patientprofile->pp_mobile1 = $request->pp_mobile1;
         $patientprofile->pp_mobile2 = $request->pp_mobile2;
         $patientprofile->pp_area = $request->pp_area;
         $patientprofile->pp_area_other = $request->pp_area_other;
         $patientprofile->pp_doctor = $request->pp_doctor;
         $patientprofile->pp_remark = $request->pp_remark;
         $patientprofile->pp_source = $request->pp_source;
         $patientprofile->pp_source_other = $request->pp_source_other;
         $patientprofile->pp_occupation = $request->pp_occupation;
         $patientprofile->pp_occupation_other = $request->pp_occupation_other;
         $patientprofile->pp_address = $request->pp_address;
         $patientprofile->pp_email = $request->pp_email;
         $patientprofile->educator = Auth::user()->id;
         $patientprofile->save();
         $user = User::find($patientprofile->user_id);
         if ($user) {
             $user->name = $request->pp_name;
             $user->position = '患者';
             $user->save();
         }
         // casecare
         $casecare = CaseCare::where('patientprofile1_id', '=', $id)->firstOrFail();
         // $casecare->patientprofile1_id = $patientprofile->id;
         // $casecare->cc_patientid = trim($request->pp_patientid);
         $casecare->cc_contactor = $request->cc_contactor;
         $casecare->cc_contactor = $request->cc_contactor;
         $casecare->cc_contactor_tel = $request->cc_contactor_tel;
         $casecare->cc_language = $request->cc_language;
         $casecare->cc_mdate = $request->cc_mdate;
         $casecare->cc_mdatem = $request->cc_mdatem;
         $casecare->cc_type = $request->cc_type;
         $casecare->cc_type_other = $request->cc_type_other;
         $casecare->cc_ibw = $request->cc_ibw;
         $casecare->cc_bmi = $request->cc_bmi;
         $casecare->cc_waist = $request->cc_waist;
         $casecare->cc_butt = $request->cc_butt;
         if ($request->cc_status) {
             $casecare->cc_status = ($request->cc_status_c1 ? "1" : "0") . ($request->cc_status_c2 ? "1" : "0") . ($request->cc_status_c3 ? "1" : "0") . ($request->cc_status_c4 ? "1" : "0") . ($request->cc_status_c5 ? "1" : "0");
             $casecare->cc_status_other = $request->cc_status_other;
         } else {
             $casecare->cc_status = "";
             $casecare->cc_status_other = "";
         }
         $casecare->cc_drink = $request->cc_drink;
         $casecare->cc_wine = $request->cc_wine;
         $casecare->cc_wineq = $request->cc_wineq;
         $casecare->cc_smoke = $request->cc_smoke == 1 && $request->cc_smoke_time > 0 ? $request->cc_smoke_time : $request->cc_smoke;
         $casecare->cc_mh = $request->cc_mh;
         $casecare->cc_fh = $request->cc_fh;
         $casecare->cc_fh_desc = $request->cc_fh_desc;
         $casecare->cc_drug_allergy = $request->cc_drug_allergy;
         $casecare->cc_drug_allergy_name = $request->cc_drug_allergy_name;
         $casecare->cc_activity = $request->cc_activity;
         $casecare->cc_medicaretype = $request->cc_medicaretype;
         $casecare->cc_jobtime = $request->cc_jobtime;
         if ($request->cc_current_use) {
             $casecare->cc_current_use = ($request->cc_current_use1 ? "1" : "0") . ($request->cc_current_use2 ? "1" : "0") . ($request->cc_current_use3 ? "1" : "0") . ($request->cc_current_use4 ? "1" : "0") . ($request->cc_current_use5 ? "1" : "0");
             $casecare->cc_starty = $request->cc_starty;
             $casecare->cc_startm = $request->cc_startm;
         } else {
             $casecare->cc_current_use = "";
             $casecare->cc_starty = -1;
             $casecare->cc_startm = -1;
         }
         if ($request->cc_hinder) {
             $casecare->cc_hinder = ($request->cc_hinder_1 ? "1" : "0") . ($request->cc_hinder_2 ? "1" : "0") . ($request->cc_hinder_3 ? "1" : "0") . ($request->cc_hinder_4 ? "1" : "0") . ($request->cc_hinder_5 ? "1" : "0") . ($request->cc_hinder_6 ? "1" : "0") . ($request->cc_hinder_7 ? "1" : "0") . ($request->cc_hinder_8 ? "1" : "0") . ($request->cc_hinder_9 ? "1" : "0");
             $casecare->cc_hinder_desc = $request->cc_hinder_desc;
         } else {
             $casecare->cc_hinder = "";
             $casecare->cc_hinder_desc = "";
         }
         $casecare->cc_act_time = $request->cc_act_time;
         $casecare->cc_act_times = $request->cc_act_times;
         $casecare->cc_act_kind = $request->cc_act_kind;
         $casecare->cc_act_other = $request->cc_act_other;
         $casecare->cc_edu = $request->cc_edu;
         $casecare->cc_careself = $request->cc_careself;
         $casecare->cc_careself_name = $request->cc_careself_name;
         $casecare->cc_careman = $request->cc_careman;
         $casecare->cc_careman_tel = $request->cc_careman_tel;
         if ($request->cc_usebsm) {
             $casecare->cc_usebsm = $request->cc_usebsm_name;
         }
         $casecare->cc_usebsm_frq = $request->cc_usebsm_frq;
         if ($request->cc_usebsm_frq) {
             // by month
             $casecare->cc_usebsm_unit = $request->cc_usebsm_frq_month;
         } else {
             // by week
             $casecare->cc_usebsm_unit = $request->cc_usebsm_frq_week;
         }
         $casecare->cc_g6pd = $request->cc_g6pd;
         $casecare->cc_deathdate = $request->cc_deathdate;
         $casecare->cc_deathdatem = $request->cc_deathdatem;
         $casecare->cc_smartphone = $request->cc_smartphone;
         $casecare->cc_wifi3g = $request->cc_wifi3g;
         $casecare->cc_smartphone_family = $request->cc_smartphone_family;
         $casecare->cc_familyupload = $request->cc_familyupload;
         $casecare->cc_uploadtodm = $request->cc_uploadtodm;
         $casecare->cc_appexp = $request->cc_appexp;
         $casecare->cc_lastexam = $request->cc_lastexam;
         $casecare->save();
         // bsm
         if ($request->cc_usebsm && $request->cc_usebsm_name == 0 && $request->cc_otherbsm) {
             $bsm = new BSM();
             $bsm->bm_name = $request->cc_otherbsm;
             $bsm->bm_model = $request->cc_otherbsm;
             $bsm->save();
             $casecare = CaseCare::where('patientprofile1_id', '=', $patientprofile->id)->firstOrFail();
             $casecare->cc_usebsm = $bsm->id;
             $casecare->save();
         }
         $msg = '项目成功更新。';
         DB::commit();
         EventController::SaveEvent('patientprofile', 'update(更新)');
     } catch (\Exception $e) {
         $msg = '项目更新失败。';
         DB::rollback();
     }
     return redirect()->route('patient.index')->with('message', $msg);
 }