123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?php
- namespace app\manage\controller;
- use think\Controller;
- use think\Db;
- use think\Session;
- use think\Config;
- use think\Cookie;
- use think\Request;
- use app\common\library\SysLogs;
- use app\common\library\UUIDs;
- class Exam extends Base {
- public function index() {
- return $this->fetch('index');
- }
- public function datas() {
- $request = Request::instance();
- $params = $request->param();
- $insid = isset($params["insid"]) ? $params["insid"] : null;
- $deptid = isset($params["deptid"]) ? $params["deptid"] : null;
- $patient_num = isset($params["patient_num"]) ? $params["patient_num"] : null;
- $accession_num = isset($params["accession_num"]) ? $params["accession_num"] : null;
- $insMap = array();
- $insArr = Db::table("institution")->field("id, name")->select();
- if (!empty($insArr)) {
- foreach ($insArr as $key => $val) {
- $insMap[$val["id"]] = $val["name"];
- }
- }
- $deptMap = array();
- $deptArr = Db::table("department")->field("id, department_name")->select();
- if (!empty($deptArr)) {
- foreach ($deptArr as $key => $val) {
- $deptMap[$val["id"]] = $val["department_name"];
- }
- }
- $doctMap = array();
- $doctArr = Db::table("doctors")->field("id, username")->select();
- if (!empty($doctArr)) {
- foreach ($doctArr as $key => $val) {
- $doctMap[$val["id"]] = $val["username"];
- }
- }
- $wheres = array();
- if (!empty($insid)) {
- $wheres["institution_id"] = $insid;
- }
- if (!empty($deptid)) {
- $wheres["dept_id"] = $deptid;
- }
- if (!empty($patient_num)) {
- $wheres["patient_num"] = $patient_num;
- }
- if (!empty($accession_num)) {
- $wheres["accession_num"] = $accession_num;
- }
- // 处理分页
- $page = empty($_GET["page"]) ? 1 : $_GET["page"];
- $pagesize = empty($_GET["rows"]) ? 1 : $_GET["rows"];
- if (empty($page) || $page < 1) {
- $page = 1;
- }
- if (empty($pagesize) || $pagesize < 1) {
- $pagesize = 30;
- }
- $resultArr = array();
-
- $sortArr=array();
- $sortArr["register_datetime"]="desc";
-
- $rs = Db::table("exams")->where($wheres)->order($sortArr)->page($page, $pagesize)->select();
- if (!empty($rs)) {
- foreach ($rs as $key => $val) {
- if (isset($insMap[$val["institution_id"]])) {
- $val["institution_name"] = $insMap[$val["institution_id"]];
- } else {
- $val["institution_name"] = $val["institution_id"];
- }
- if (isset($deptMap[$val["dept_id"]])) {
- $val["dept_name"] = $deptMap[$val["dept_id"]];
- } else {
- $val["dept_name"] = $val["dept_id"];
- }
- // 技师
- if (isset($doctMap[$val["technician"]])) {
- $val["technician_name"] = $doctMap[$val["technician"]];
- } else {
- $val["technician_name"] = $val["technician"];
- }
- // 送诊医生
- if (isset($doctMap[$val["clin_doctors"]])) {
- $val["clin_doctors_name"] = $doctMap[$val["clin_doctors"]];
- } else {
- $val["clin_doctors_name"] = $val["clin_doctors"];
- }
- // 申请医生
- if (isset($doctMap[$val["req_doctor"]])) {
- $val["req_doctor_name"] = $doctMap[$val["req_doctor"]];
- } else {
- $val["req_doctor_name"] = $val["req_doctor"];
- }
- // 登记人员
- if (isset($doctMap[$val["register"]])) {
- $val["register_name"] = $doctMap[$val["register"]];
- } else {
- $val["register_name"] = $val["register"];
- }
-
-
- array_push($resultArr, $val);
- }
- }
- $count = Db::table("exams")->where($wheres)->count();
- $data = array();
- $data["total"] = $count;
- $data["rows"] = $resultArr;
- echo json_encode($data);
- }
- /**
- * 编辑页面
- * @return type
- */
- public function edit() {
- $id = is_string($_GET["id"]) ? $_GET["id"] : null;
- if ($id != null) {
- // 查询检查表
- $exam = Db::table("exams")->where("id", $id)->find();
- // 以下追加名称字段
- $exam = self::appendName($exam, "technician", "doctors", "username"); // 技师
- $exam = self::appendName($exam, "clin_doctors", "doctors", "username"); // 送诊医生
- $exam = self::appendName($exam, "req_doctor", "doctors", "username"); // 申请医生
- $exam = self::appendName($exam, "register", "doctors", "username"); // 登记人员
- $exam = self::appendName($exam, "institution_id", "institution", "name"); // 机构名称
- $exam = self::appendName($exam, "clin_dept_id", "department", "department_name"); // 科室
- $exam = self::appendName($exam, "body_part", "bodypart", "name"); // 检查部位
- $exam = self::appendName($exam, "device", "bodypart", "name"); // 检查设备
- $exam = self::appendName($exam, "exam_project", "exam_project", "name"); // 检查设备
- $exam = self::appendName($exam, "exam_sub_class", "exam_subclass", "name"); // 检查设备
- $exam = self::appendName($exam, "exam_class", "exam_class", "name"); // 检查类型
- $exam = self::appendName($exam, "patient_id", "patient_info", "name"); // 患者
- $exam = self::appendName($exam, "dept_id", "department", "department_name"); // 患者
- $this->assign("exam", $exam);
- // 查询报告表
- $report = Db::table("report")->where("exam_id", $id)->find();
- if (!empty($report)) {
- $report = self::appendName($report, "report_doctor_id", "doctors", "username"); // 报告医生
- $report = self::appendName($report, "review_doctor_id", "doctors", "username"); // 审核医生
- $report = self::appendName($report, "confirm_doctor_id", "doctors", "username"); // 确认医生
- }
- $this->assign("report", $report);
- // 查询报告流程历史记录表
- if (!empty($report)) {
- $report_record = Db::table("report_record")->where("report_id", $id)->order("createdAt", "asc")->select();
- $errlist = array();
- if (count($report_record) > 0) {
- foreach ($report_record as $key => $val) {
- $val = self::appendName($val, "doctor_id", "doctors", "username"); // 操作医生
- array_push($errlist, $val);
- }
- }
- $this->assign("report_record", $errlist);
- }
- // 查询影像表
- // TODO 待处理
- }
- return $this->fetch('edit');
- }
- /**
- * 信息保存<br />
- * 暂时只有修改状态
- */
- public function save() {
- $id = is_string($_GET["id"]) ? $_GET["id"] : null;
- $status = is_numeric($_GET["status"]) ? $_GET["status"] : null;
- if ($id != "" && $status != null) {
- $data = array();
- $data["status"] = $status;
- Db::table("exams")->where("id", $id)->update($data);
- $exam = Db::table("exams")->where("id", $id)->find();
- SysLogs::log("exam", "U", "id = " . $id . " " . json_encode($data));
- }
- $id = is_string($_GET["id"]) ? $_GET["id"] : "";
- }
- }
|