Ejemplo n.º 1
0
 function actionList()
 {
     $userid = $this->userid;
     //管理员的userid
     $page = $this->get('page', 1);
     $limit = $this->get('limit', 20);
     $exArr = array('page' => $page, 'limit' => $limit);
     if ($projectid = $this->get('projectid')) {
         $whArr = array('piid' => $this->get('piid'), 'projectid' => $projectid, 'hospitalid' => $this->get('hospitalid'), 'username%' => $this->get('username'));
         CFun::removeArrayNull($whArr);
         // print_r($whArr);
         $MProject = $this->LoadApiModelMedical('project');
         $patientArr = $MProject->getAppends('doctor', $whArr, $exArr);
         // print_r($patientArr);
         if (false !== $patientArr) {
             if (!empty($patientArr['data'])) {
                 foreach ($patientArr['data'] as &$r0001) {
                     $r0001['num_patient'] = $MProject->getCounts('patient', array('projectid' => $r0001['projectid'], 'doctorid' => $r0001['doctorid']));
                 }
             }
             $this->response($patientArr);
         }
     }
     $this->error('没有找到任何新医生信息');
 }
Ejemplo n.º 2
0
 protected function runCli($route = 'cli', $paramters = array())
 {
     $indexcli = $this->getLoc() . '/building/indexcli.php';
     $paramters = base64_encode(json_encode($paramters));
     $phpbin = CFun::isWindows() ? 'php' : '/usr/local/php/bin/php';
     $cmd = $phpbin . ' ' . $indexcli . ' ' . $route . ' ' . $paramters;
     CFun::Process($cmd);
 }
Ejemplo n.º 3
0
 function actionAppend()
 {
     $userid = $this->userid;
     //医生的userid
     if ($this->isPost() && ($projectid = $this->post('projectid'))) {
         $postArr = $this->posts('patientid');
         //病人id序列
         $othArr = $this->posts('num_goal');
         $MProject = $this->LoadApiModelMedical('project');
         $MUser = $this->LoadApiModelMedical('user');
         $user = $MUser->getUser($userid);
         $role = intval($user['role']);
         $hospitalid = $user['hospitalid'];
         if ($role >= 10) {
             if ($role >= 20) {
                 $doctorid = $this->post('doctorid');
                 $doctorid = $doctorid ? $doctorid : $userid;
                 //相当于操作帮别人(doctorid)添加
             } else {
                 $doctorid = $userid;
             }
             if (($mobile = $this->post('mobile')) && ($idcard = $this->post('idcard'))) {
                 //直接添加
                 $userinfo = array('mobile' => $mobile, 'idcard' => $idcard, 'doctorid' => $this->post('doctorid', $userid), 'role' => -10, 'hospitalid' => $hospitalid, 'username' => $this->post('username'), 'plain' => substr($mobile, -6));
                 $userinfo = array_merge($userinfo, $this->posts('email,deptid,truename,sex,ethnic,birthplace,address,idcard,age,height,weight,tel,num_ill,date_in,date_out,deptname,avatar'));
                 CFun::removeArrayNull($userinfo, true);
                 // print_r($userinfo);exit;
                 $retArr = $MUser->addUser($userinfo);
                 // print_r($retArr);exit;
                 if (1 != $retArr['status']) {
                     $this->error('添加病人信息时失败:' . $retArr['message']);
                 }
                 $patientid = $retArr['user']['id'];
                 $postArr['patientid'] = array($patientid);
             }
             $ok = $MProject->appendPatient($projectid, $doctorid, $postArr);
         } else {
             $this->error('操作无权限');
         }
         if (false !== $ok) {
             $this->response($postArr);
         } else {
             $this->error('为项目添加病人失败或已添加过');
         }
     }
     $this->error('添加病人失败');
 }
Ejemplo n.º 4
0
 function actionList()
 {
     $userid = $this->userid;
     //管理员的userid
     $page = $this->get('page', 1);
     $limit = $this->get('limit', 20);
     $exArr = array('page' => $page, 'limit' => $limit, 'join_detail' => true);
     if (1) {
         $whArr = array('kindid' => $this->get('kindid'), 'name%' => $this->get('name'));
         CFun::removeArrayNull($whArr);
         $MTpl = $this->LoadApiModelMedical('tpl');
         $tplArr = $MTpl->getTpls(null, $whArr, $exArr);
         if ($tplArr) {
             $this->response($tplArr);
         }
     }
     $this->error('没有找到任何模板');
 }
Ejemplo n.º 5
0
 function actionList()
 {
     $userid = $this->userid;
     //管理员的userid
     $page = $this->get('page', 1);
     $limit = $this->get('limit', 20);
     $exArr = array('page' => $page, 'limit' => $limit);
     if (1) {
         $whArr = array('hospitalid' => $this->get('hospitalid'), 'userid' => $this->get('userid'), 'status' => $this->get('status'));
         CFun::removeArrayNull($whArr);
         $MProject = $this->LoadApiModelMedical('project');
         $projectArr = $MProject->getProjects(null, $whArr, $exArr);
         // $this->dump($project);
         if ($projectArr) {
             $this->response($projectArr);
         }
     }
     $this->error('没有找到任何项目');
 }
Ejemplo n.º 6
0
 function actionList()
 {
     $userid = $this->userid;
     //管理员的userid
     $page = $this->get('page', 1);
     $limit = $this->get('limit', 10);
     $exArr = array('page' => $page, 'limit' => $limit);
     if ($tplid = $this->get('tplid')) {
         $whArr = array('userid' => $userid, 'patientid' => $this->get('patientid'));
         CFun::removeArrayNull($whArr);
         $MTpl = $this->LoadApiModelMedical('tpl');
         $reportArr = $MTpl->getTplReports($tplid, $whArr, $exArr);
         // $this->dump($reportArr);
         if (false !== $reportArr) {
             $this->response($reportArr);
         }
     }
     $this->error('尚未填写报告');
 }
Ejemplo n.º 7
0
 function actionList()
 {
     $userid = $this->userid;
     //管理员的userid
     $page = $this->get('page', 1);
     $limit = $this->get('limit', 20);
     $exArr = array('page' => $page, 'limit' => $limit);
     if ($projectid = $this->get('projectid')) {
         $whArr = array('projectid' => $projectid, 'hospitalid' => $this->get('hospitalid'), 'username%' => $this->get('username'));
         CFun::removeArrayNull($whArr);
         // print_r($whArr);
         $MProject = $this->LoadApiModelMedical('project');
         $patientArr = $MProject->getAppends('pi', $whArr, $exArr);
         // print_r($patientArr);
         if ($patientArr) {
             $this->response($patientArr);
         }
     }
     $this->error('没有找到任何新PI信息');
 }
Ejemplo n.º 8
0
 function actionChat()
 {
     $userid = $this->userid;
     //管理员的userid
     $page = $this->get('page', 1);
     $limit = $this->get('limit', 20);
     $exArr = array('page' => $page, 'limit' => $limit, 'order' => 'id desc', 'fields' => 'id,userid,targetid friendid,content msg,ctime');
     //lastime
     if (1) {
         $MMessage = $this->LoadApiModel('message');
         $date = $this->get('date');
         list($date_start, $date_end) = CTime::DeltaMonths(-1);
         // echo "$date_start, $date_end";
         $date = $date ? $date : $date_start;
         $friendid = $this->get('id');
         if ($friendid) {
             //我与指定好友的消息(也就是我发给别人的)
             $whArr = array('type' => 0, 'targetid in' => array($friendid, $userid), 'removed>' => -1);
             $messArr = $MMessage->getMessages(null, $whArr, $exArr);
         } else {
             //别人发给我的
             $whArr = array('type' => 0, 'or' => array('userid' => $userid, 'targetid' => $userid), 'removed>' => -1);
             // $exArr['fields'] .= ',max(ctime) lastime';
             // $exArr['group']   = 'userid,targetid';
             $messArr = $MMessage->getLastMessages($userid, $page);
             // print_r($messArr);
             $messArr = array('data' => $messArr, 'total' => count($messArr));
         }
         CFun::removeArrayNull($whArr);
         // print_r($whArr);
         // print_r($messArr);
         if (false !== $messArr) {
             if (isset($messArr['data'])) {
                 $MUser = $this->LoadApiModelMedical('user');
                 $uid_fild = $friendid ? 'userid' : 'friendid';
                 $fid_arr = $this->getArrayColumn($messArr['data'], $uid_fild);
                 $userArr = $MUser->getUsers($fid_arr, null, array('limit' => count($fid_arr), 'only_data' => true, 'fields' => 'id,username,idcard,mobile'));
                 if ($friendid) {
                     $messArr['data'] = $this->joinToArray($messArr['data'], $userArr, 'userid:id', 'user');
                 } else {
                     $messArr['data'] = $this->joinToArray($messArr['data'], $userArr, 'friendid:id', 'user');
                 }
             }
             $this->response($messArr);
         }
     }
     $this->error('没有任何消息');
 }
Ejemplo n.º 9
0
 function actionDetail()
 {
     //判断是否登入
     $userid = $this->userid;
     $termid = $this->get('id');
     $MTerm = $this->LoadApiModelMedical('term');
     if ($this->isPost() && $termid) {
         //更新profile
         $postArr = $this->posts('hospitalid,name,itype,vtype,editbypat');
         $values = $this->posts('id,val');
         // $termid  = $this->post('termid');
         CFun::removeArrayNull($values);
         $retArr = $MTerm->updateTerm($termid, $postArr, $values);
         if (!$retArr['status']) {
             $this->error('设置资料失败');
         }
     }
     $term = $MTerm->getTerm($termid, null, array('join_val' => true, 'join_cate' => true));
     // print_r($term);
     if ($term) {
         $this->response($term);
     }
     $this->error('获取资料失败');
 }
Ejemplo n.º 10
0
 public function actionJoined()
 {
     $userid = $this->userid;
     //管理员的userid
     $page = $this->get('page', 1);
     $limit = $this->get('limit', 20);
     $exArr = array('page' => $page, 'limit' => $limit, 'fields' => '^ctime', 'order' => 'id desc', 'join' => array('project' => 'projectid:id'));
     $role = $this->get('role');
     $q = $this->get('q');
     $whArr = array('patientid' => $userid);
     CFun::removeArrayNull($whArr);
     // print_r($whArr);
     $MProject = $this->LoadApiModelMedical('project');
     $dataArr = $MProject->getAppends('patient', $whArr, $exArr);
     // print_r($dataArr);
     if (is_array($dataArr)) {
         $this->response($dataArr);
     }
     $this->error('没有找到用户');
 }
Ejemplo n.º 11
0
 public function compressImage($src)
 {
     $cmd = $this->getConfig('sh_compress');
     CFun::Process($cmd);
 }
Ejemplo n.º 12
0
 function actionEntry()
 {
     $userid = $this->userid;
     //管理员的userid
     $page = $this->get('page', 1);
     $limit = $this->get('limit', 1000);
     $exArr = array('page' => $page, 'limit' => $limit, 'no_hospital' => 1, 'only_data' => true, 'fields' => '^ctime,hospitalid');
     if (!function_exists('__append_role')) {
         function __append_role(&$rowArr, $role, $uidfield)
         {
             if (!$rowArr) {
                 return $rowArr;
             }
             foreach ($rowArr as &$r0001) {
                 $r0001['role'] = $role;
                 $r0001['uid'] = $r0001[$uidfield];
             }
         }
     }
     $type = $this->rest(0);
     $typeArr = array('pi' => 20, 'doctor' => 10, 'patient' => -10);
     $flipArr = array_flip($typeArr);
     if (1) {
         $MUser = $this->LoadApiModelMedical('user');
         $user = $MUser->getUser($userid);
         $roleU = $user['role'];
         $hospitalid = $user['hospitalid'];
         $hospitalid = $this->get('hospitalid', $hospitalid, true);
         //获取所有项目
         $MProject = $this->LoadApiModelMedical('project');
         $projectidP = $projectid = $this->get('projectid');
         if (isset($typeArr[$type])) {
             $role = $typeArr[$type];
             $uidfield = $flipArr[$role] . 'id';
             $wh_app = array();
             if ($projectid) {
                 //获取指定项目的相关人员
                 // $pid_arr = array($projectid);
                 $project = $MProject->getProject($projectid);
                 if (!$project) {
                     $this->error('项目不存在');
                 }
                 $makerid = $project['userid'];
                 if ($roleU >= 80 || $makerid == $userid) {
                     $wh_app = array('projectid' => $projectid);
                 } else {
                     $wh_app = array('projectid' => $projectid, 'hospitalid' => $hospitalid);
                     if ($roleU <= 10 && $roleU > $role) {
                         $wh_app[$flipArr[$roleU] . 'id'] = $userid;
                     }
                 }
             } else {
                 //获取hospitalid下所有项目的相关人员
                 if (!isset($typeArr[$type])) {
                     $this->error('错误的请求');
                 }
                 $projArr = $MProject->getProjects(null, array('hospitalid' => $hospitalid, 'status' => 0), array('fields' => 'distinct id', 'keyas' => 'id', 'only_data' => true));
                 if (!$projArr) {
                     $this->error('没有活动项目存在');
                 }
                 $pid_arr = array_keys($projArr);
                 $wh_app = array('hospitalid' => $hospitalid, 'projectid in' => $pid_arr);
             }
             $wh_app['username%'] = $this->get('q');
             CFun::removeArrayNull($wh_app, true);
             // print_r($wh_app);
             $appendArr = $MProject->getAppends($type, $wh_app, $exArr);
             $uid_arr = $this->getArrayColumn($appendArr, $uidfield);
             __append_role($appendArr, $typeArr[$type], $uidfield);
         } else {
             if ($roleU >= 80) {
                 $wh_app = array('projectid' => $projectid);
             } else {
                 $wh_app = array('projectid' => $projectid, 'hospitalid' => $hospitalid);
             }
             $wh_app['username%'] = $this->get('q');
             CFun::removeArrayNull($wh_app, true);
             // print_r($wh_app);
             $appendArr1 = $MProject->getAppends('pi', $wh_app, $exArr);
             $appendArr2 = $MProject->getAppends('doctor', $wh_app, $exArr);
             $appendArr3 = $MProject->getAppends('patient', $wh_app, $exArr);
             __append_role($appendArr1, 20, 'piid');
             __append_role($appendArr2, 10, 'doctorid');
             __append_role($appendArr3, -10, 'patientid');
             $appendArr = array_merge($appendArr1, $appendArr2, $appendArr3);
             $uid_arr1 = $this->getArrayColumn($appendArr, 'piid');
             $uid_arr2 = $this->getArrayColumn($appendArr, 'doctorid');
             $uid_arr3 = $this->getArrayColumn($appendArr, 'patientid');
             $uid_arr = array_merge($uid_arr1, $uid_arr2, $uid_arr3);
             $uid_arr = array_unique($uid_arr);
         }
         if (false !== $appendArr) {
             if ($appendArr) {
                 $pid_arr = $this->getArrayColumn($appendArr, 'projectid');
                 $projectArr = $MProject->getProjects($pid_arr, null, array('only_data' => true, 'fields' => '^notice,remark,status,hospitalid,fullname,opendate,closedate'));
                 // print_r($projectArr);
                 $appendArr = $this->joinToArray($appendArr, $projectArr, 'projectid:id', 'project');
                 $userArr = $MUser->getUsers($uid_arr, null, array('only_data' => true, 'limit' => count($uid_arr), 'fields' => 'id,idcard,mobile,tel,age,username,height,weight,ethnic,avatar'));
                 $appendArr = $this->joinToArray($appendArr, $userArr, 'uid:id', 'user');
             }
             $this->response($appendArr);
         }
     }
     $this->error('没有找到用户信息');
 }
Ejemplo n.º 13
0
 public function dropPatient($userid, $patientid)
 {
     $uniqueid = CFun::touniqueidArgs($userid, $patientid);
     return $this->dropBuddy($uniqueid);
 }
Ejemplo n.º 14
0
 /**
  * desc: 文件上传(图片)
  * 文件命名规则:年(4).月(2).日(2).唯一ID(12),年.月.日又是目录名(8位),共20位
  *
  * call: curl "http://api.medical.me/upload/web?token=0f5e4d24328d2a3a7cd7d5610985cc56" -F "Filedata=@d:/error.png"
  *
  */
 function actionEntry()
 {
     // $uploadLoc = $this->getLoc('_uploads');
     // $uploadUrl = $this->getUrl('_uploads');
     $uploadLoc = $this->getStaticLocation('upload');
     // $uploadUrl = $this->getUrl('_upload');
     $uploadUrl = '/static/upload';
     $php_path = dirname(__FILE__) . '/';
     $php_url = dirname($_SERVER['PHP_SELF']) . '/';
     //文件保存目录路径
     $save_path = $uploadLoc . '/';
     //文件保存目录URL
     $save_url = $uploadUrl . '/';
     //定义允许上传的文件扩展名
     if ($prefix = $this->get('prefix')) {
         $save_path .= 'ad/';
         $save_url .= 'ad/';
         if (!file_exists($save_path)) {
             mkdir($save_path);
         }
     }
     $ext_arr = array('image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico'), 'flash' => array('swf', 'flv'), 'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'), 'file' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2', 'pdf'));
     //最大文件大小
     $max_size = 5000000;
     $save_path = realpath($save_path) . '/';
     //PHP上传失败
     if (!empty($_FILES['Filedata']['error'])) {
         switch ($_FILES['Filedata']['error']) {
             case '1':
                 $error = '超过php.ini允许的大小。';
                 break;
             case '2':
                 $error = '超过表单允许的大小。';
                 break;
             case '3':
                 $error = '图片只有部分被上传。';
                 break;
             case '4':
                 $error = '请选择图片。';
                 break;
             case '6':
                 $error = '找不到临时目录。';
                 break;
             case '7':
                 $error = '写文件到硬盘出错。';
                 break;
             case '8':
                 $error = 'File upload stopped by extension。';
                 break;
             case '999':
             default:
                 $error = '未知错误。';
         }
         $this->error($error);
     }
     //有上传文件时
     if (empty($_FILES) === false) {
         //原文件名
         $file_name = $_FILES['Filedata']['name'];
         //服务器上临时文件名
         $tmp_name = $_FILES['Filedata']['tmp_name'];
         //文件大小
         $file_size = $_FILES['Filedata']['size'];
         //检查文件名
         if (!$file_name) {
             $this->error("请选择文件。");
         }
         //检查目录
         if (@is_dir($save_path) === false) {
             $this->error("上传目录不存在。");
         }
         //检查目录写权限
         if (@is_writable($save_path) === false) {
             $this->error("上传目录没有写权限。");
         }
         //检查是否已上传
         if (@is_uploaded_file($tmp_name) === false) {
             $this->error("上传失败。");
         }
         //检查文件大小
         if ($file_size > $max_size) {
             $this->error("上传文件大小超过限制。");
         }
         //获得文件扩展名
         $temp_arr = explode(".", $file_name);
         $file_ext = array_pop($temp_arr);
         $file_ext = trim($file_ext);
         $file_ext = strtolower($file_ext);
         //检查目录名
         $dir_name = empty($_GET['dir']) ? 'image' : trim($_GET['dir']);
         if (in_array($file_ext, $ext_arr['file'])) {
             $dir_name = 'file';
         }
         if (empty($ext_arr[$dir_name])) {
             $this->error("目录名不正确。");
         }
         //检查扩展名
         if (in_array($file_ext, $ext_arr[$dir_name]) === false) {
             $this->error("上传文件扩展名是不允许的扩展名。\n只允许" . implode(",", $ext_arr[$dir_name]) . "格式。");
         }
         //创建文件夹
         if ($dir_name !== '') {
             $save_path .= $dir_name . "/";
             $save_url .= $dir_name . "/";
             if (!file_exists($save_path)) {
                 mkdir($save_path);
             }
         }
         $ymd = date("Ymd");
         $year = date("Y");
         $month = date("m");
         $day = date("d");
         // $save_path .= $ymd . "/";
         // $save_url .= $ymd . "/";
         if ('image' == $dir_name) {
             //图片才分年月日
             $save_url .= "{$year}/{$month}/{$day}/";
             $save_path .= "{$year}/";
             if (!file_exists($save_path)) {
                 mkdir($save_path);
             }
             $save_path .= "{$month}/";
             if (!file_exists($save_path)) {
                 mkdir($save_path);
             }
             $save_path .= "{$day}/";
             if (!file_exists($save_path)) {
                 mkdir($save_path);
             }
         }
         //新文件名
         // $new_file_name = date("Ymd") . '' . CTool::getRid() . '.' . $file_ext;
         if (isset($_GET['fixedname'])) {
             $fixedname = strlen($_GET['fixedname']) > 1 ? $_GET['fixedname'] : 'tmp';
             $new_file_name = $fixedname . '.' . $file_ext;
         } else {
             // $new_file_name = date("Ymd") . '' . md5_file($tmp_name) . '.' . $file_ext;
             $new_file_name = CFun::crcU32($tmp_name) . '.' . $file_ext;
         }
         //移动文件
         $file_path = $save_path . $new_file_name;
         if (false === move_uploaded_file($tmp_name, $file_path)) {
             $this->error("上传文件失败。");
         }
         //是否裁剪
         $cut = isset($_GET['x']) ? $_GET['x'] : (isset($_POST['x']) ? $_POST['x'] : null);
         if ($cut && strpos($cut, 'x') && 'image' == $dir_name) {
             if (strpos($cut, 'x')) {
                 $cutArr = explode('i', $cut);
                 foreach ($cutArr as $_cut) {
                     if (strpos($cut, 'x')) {
                         list($cut_w, $cut_h) = explode('x', $_cut);
                         $file_cuted = CImg::cutImg($file_path, $cut_w, $cut_h);
                     }
                 }
             } else {
                 list($cut_w, $cut_h) = explode('x', $cut);
                 $file_cuted = CImg::cutImg($file_path, $cut_w, $cut_h);
             }
         }
         if (isset($file_cuted) && $file_cuted) {
             $file_url = $save_url . basename($file_cuted);
         } else {
             @chmod($file_path, 0644);
             $file_url = $save_url . $new_file_name;
         }
         // header('Content-type: text/html; charset=UTF-8');
         // $json = new Services_JSON();
         // ob_clean();
         // echo json_encode(array('error' => 0, 'url' => $file_url));
         $this->response($file_url);
         exit;
     }
     $this->error('非法操作');
 }