public function save() { if ($this->input->is_ajax_request()) { $data = $this->input->post('data'); if (!empty($data)) { //check exist $is_exist = $this->patient->check_e0_exist($this->hospcode, $data['hn'], to_mysql_date($data['date_serv']), $data['diagcode']); if (!$is_exist) { $data['e0_hosp'] = $this->get_e0_hosp($this->hospcode) + 1; $data['e1_hosp'] = $this->get_e1_hosp($this->hospcode, $data['code506']) + 1; $data['amp_code'] = $this->amp_code; $data['addrcode'] = $data['changwat'] . $data['ampur'] . $data['tambon'] . $data['moo']; $age = get_current_age(to_mysql_date($data['birth'])); $data['agey'] = $age['year']; $data['agem'] = $age['month']; $data['aged'] = $age['day']; $data['hserv'] = $this->hserv; $rs = $this->patient->save($data); if ($rs) { //update status $this->patient->updat_waiting_status($data['id'], '2'); $json = '{"success": true}'; } else { $json = '{"success": false, "msg": "ไม่สามารถบันทึกรายการได้"}'; } } else { $json = '{"success": false, "msg": "รายการซ้ำ"}'; } } else { $json = '{"success": false, "msg": "ไม่พบข้อมูลที่ต้องการบันทึก"}'; } render_json($json); } else { show_error('No ajax.', 404); } }
public function save($data) { $rs = $this->db->set('year', substr($data['date_serv'], 6, 4) - 543)->set('hospcode', $this->hospcode)->set('e0_hosp', $data['e0_hosp'])->set('e1_hosp', $data['e1_hosp'])->set('cid', $data['cid'])->set('amp_code', $data['amp_code'])->set('disease', $data['code506'])->set('birth', to_mysql_date($data['birth']))->set('name', $data['name'] . ' ' . $data['lname'])->set('hn', $data['hn'])->set('nation', $data['nation'])->set('nmepate', $data['nmepate'])->set('sex', $data['sex'])->set('agey', $data['agey'])->set('agem', $data['agem'])->set('aged', $data['aged'])->set('marietal', $data['mstatus'])->set('occupat', $data['occupation'])->set('address', $data['address'])->set('soi', $data['soi'])->set('road', $data['road'])->set('addrcode', $data['addrcode'])->set('metropol', $data['address_type'])->set('hospital', $data['service_place'])->set('type', $data['patient_type'])->set('result', $data['ptstatus'])->set('hserv', $data['hserv'])->set('class', $data['school_class'])->set('school', $data['school'])->set('datesick', to_mysql_date($data['illdate']))->set('datefine', to_mysql_date($data['date_serv']))->set('datedeath', to_mysql_date($data['date_death']))->set('daterecord', to_mysql_date($data['date_record']))->set('datereach', to_mysql_date($data['date_report']))->set('organism', $data['ogranism'])->set('complica', $data['complication'])->set('icd10', $data['diagcode'])->set('last_update', date('Y-m-d H:i:s'))->insert('epe0'); return $rs; }