Ejemplo n.º 1
0
 public function passOrdinarySignin($request, $response)
 {
     /*{{{*/
     $signin = DAL::get()->find('PatientSignin', $request->signinId);
     $diseaseRef = DAL::get()->find_by_signinid('PatientSigninDiseaseRef', $signin->id);
     $isTreated = $request->isTreated;
     $inspectGroupName = $request->inspectGroupName;
     if ($signin->isSrcQRcode() && $isTreated && false == $diseaseRef->disease->isNull()) {
         $this->checkDiseaseQuestionSheet($diseaseRef->disease->id, $signin->space->id);
     }
     $ticket = DAL::get()->find('ticket', $request->ticketId);
     if ($ticket->isNull()) {
         $response->setRedirect($response->router->urlfor('nfsaudit/nextOrdinarysignin?inspectGroup=' . $inspectGroupName));
     }
     if ($request->needSaveDiseaseRef == '1') {
         PatientSigninClient::getInstance()->updatePatientSigninDiseaseRef($this->curInspector, $request->signinId, $request->diseaseIds);
     }
     $vars = $request->vars;
     $latestTreatedTime = XDateTime::valueOf($vars['latestTreatedTime']);
     $groupId = $request->groupId;
     if ($isTreated || $signin->isAudited()) {
         $dto = new PatientSigninInspectResultDto($ticket->source, PatientSignin::STATUS_AUDITED, $vars['content'], $vars['diseaseName'], isset($vars['isInHospital']) ? $vars['isInHospital'] : 0, $latestTreatedTime, $vars['hospitalCaseNO'], $vars['treatment'], $vars['helpGuide'], $vars['content'], $vars['treatType'], $vars['medicalCardNo'], $groupId);
         InspectClient::getInstance()->next($ticket->id, $dto, $this->curInspector);
     } else {
         //管理员和医生关联病例的报到拒绝不触发站内信
         if (false == $signin->isSrcPatientBindByInspector() && false == $signin->isSrcPatientBindByDoctor()) {
             $this->sendMsg4SrcQRcode($signin, $vars['refuseReason']);
         }
         if ($signin->isSrcQRcode()) {
             PatientFileClient::getInstance()->setHealthApplyInvalid4QRCode($signin->patient->id);
         }
         $dto = new PatientSigninInspectResultDto($ticket->source, PatientSignin::STATUS_REFUSED, $vars['content'], $vars['diseaseName'], isset($vars['isInHospital']) ? $vars['isInHospital'] : 0, $latestTreatedTime, $vars['hospitalCaseNO'], $vars['treatment'], $vars['helpGuide'], $vars['content'], $vars['treatType'], $vars['medicalCardNo']);
         InspectClient::getInstance()->refuse($ticket->id, $this->curInspector, $dto);
     }
     $response->setRedirect($response->router->urlfor('nfsaudit/nextOrdinarysignin?inspectGroup=' . $inspectGroupName));
 }
 public static function getNewAllQuestionTitleAndAnswerContentArrByPatient($patient, $pageId=1, $pageSize=10)
 {/*{{{*/
     DBC::requireTrue($patient instanceof Patient, '患者不存在');
     $result = PatientFileClient::getInstance()->getRecordListByPatientId($patient->id, $pageId, $pageSize);
     $healthRecordList =  $result['list'];
     $healthRecordInfos = array();
     $healthRecordInfos['pageInfo'] = $result['pageInfo'];
     foreach ($healthRecordList as $healthRecord)
     {
         $healthRecordInfo = array();
         $healthRecordInfo['ctime'] = $healthRecord->ctime->getDateTime();
         $healthRecordInfo['status'] =$healthRecord->status == PatientHealthRecord::STATUS_ABNORMAL ? "异常" : "正常";
         $questionIdArr = $healthRecord->answerSheet->getQuestionId_answerArr();
         foreach($questionIdArr as $questionId => $answer)
         {
             $question = DAL::get()->find('Question', $questionId);
             if ($question->isUpload())
             {
                 $answer = $questionIdArr[$question->id];
                 $ids = explode(',', $answer->getAnswerContent()); 
                 $patientAttachments = DAL::get()->find('PatientAttachment', $ids);
                 list($infos, $datas) = self::getAttachmentListImp($patientAttachments, 0, 100);
                 $infos['question'] = $question->content;
                 $infos['type'] = "UploadQuestion";
                 $healthRecordInfo['recordContent'][] = $infos;
             }
             else
             {
                 $units = $answer->getAnswerUnit();
                 $units = $units == '' ? $units : " ".$units;
                 $answerInfo['type'] = $answer->question->sourceType;
                 $answerInfo['question'] = $answer->question->content;
                 $answerInfo['answer'] = $answer->content.$units;
                 if ($answer->question->isOptionQuestion4Health())
                 {
                     $options = $answer->getOptions();
                     $optionContent = array();
                     foreach ($options as $option)
                     {
                         $optionContent[] = $option->content;
                     }
                     $optionContent = implode(",", $optionContent);
                     $answerInfo['answer'] = $optionContent.$units;
                 }
                 $healthRecordInfo['recordContent'][] = $answerInfo;
             }
         }
         $healthRecordInfos[] = $healthRecordInfo;
     }
     return $healthRecordInfos;
 }/*}}}*/
 public function updateNewQuestionSheet($request, $response)
 {
     $this->initialize($request, $response);
     $wrapperIds = $request->wrappers;
     $patientId = $request->patientid;
     $modelSheetIds = $request->getRequest('modelsheets', array());
     $id = $request->id;
     $questionSheet = PatientFileClient::getInstance()->batchUpdateQuestionWrapper4Patient($patientId, $wrapperIds, $modelSheetIds);
     S3LogClient::getInstance()->add($this->auditor, $this->apply->getLogable()->action(PatientHealthApplyLog::TYPE_UPDATE, '更新问卷'));
     $url = $response->router->urlfor('patientfile/applydetail', array('id' => $id));
     $response->setRedirect($url);
 }
Ejemplo n.º 4
0
 public function showHealthRecordList($request, $response)
 {
     $userId = $this->user->id;
     $patientId = $request->getRequest('patientId', "");
     $patientInfos = $this->getHealthApplyPatientList($userId);
     if(empty($patientId)) 
     {
         $patientId = isset($_COOKIE["_patientid"])?$_COOKIE["_patientid"]:'';
     }
     if(empty($patientId)) 
     {
         $patientId = $this->getCurrentUserStatus($userId);
     }
     DBC::requireFalse(empty($patientId),'该患者没有开通');
     $cookie = new HdfCookie();
     $cookie->set("_patientid", $patientId);
     $response->patientId = $patientId;
     $response->patientInfos = $patientInfos;
     $patient = DAL::get()->find("patient", $patientId);
     $response->patient = $patient;
     $nowPage = $request->getRequest('page', 1);
     $res = PatientFileClient::getInstance()->getUnWaitRecordListByPatientId($patient->id, $nowPage, 3);
         $response->pageLink = PageNav::getNavLink(
             PageNav::getPageNavTemplate("/myhealth/showhealthrecordlist?patientId=".$patient->id."&page="),
             $res['pageInfo']['nowpage'], $res['pageInfo']['pagesize'],
             $res['pageInfo']['total']);
     $response->records =  $res['list'];
 }
Ejemplo n.º 5
0
    public function addPatientSignin($request, $response)
    {/*{{{*/
        $space = DAL::get()->find('space', $request->spaceId);
        $patient = DAL::get()->find('patient', $request->patientId);
        DBC::requireFalse($patient->isNull(), '无效的patientId');
        DBC::requireFalse($space->isNull(), '无效的spaceId');
        $diseaseName = $request->diseaseName;
        $diseaseId = $request->diseaseId;

        $signinId = PatientSigninClient::getInstance()->addQRCODEPatientSignin($space, $patient, '', $diseaseName, $diseaseId, '');
        $newQRCodePatientSignin = DAL::get()->find('patientsignin', $signinId);
        if ($newQRCodePatientSignin->isNull())
        {
            $this->_exit404();
            return;
        }
        PatientFileClient::getInstance()->createPatientHealthApply4QRCode($patient->id, $diseaseId, $diseaseName);
        $url = $response->router->urlfor('user/addition4patientreport', array('spaceId'=>$space->id, 'patientId'=>$patient->id, 'signinId'=>$signinId));
        $response->setRedirect($url);
        return ;
    }/*}}}*/
    /**
        * @brief 提交二维码诊后报到申请
        * @author zjj 
        * @exampleUrl http://dev.mobile-api.haodf.com/patientapi/patientsignin_patientSignin4QRCode?name=TestDay&sex=0&relation=0&birthday=2014-01-18&city=北京&province=北京&xdebug=1
        *
        * @param $name
        * @param $sex
        * @param $birthday
        * @param $province
        * @param $city
        * @param $diseaseName
        * @param $hospitalCaseNO
        * @param $idcard
        * @param $spaceId
        * @param $diseaseId
        *
        * @return array('msg')
     */
    public function patientSignin4QRCode($name, $sex, $birthday, $province, $city, $diseaseName, $hospitalCaseNO, $idcard, $spaceId, $diseaseId, $patientId) 
    {/*{{{*/
        if ($diseaseName == '')
        {
            $this->setErrorCode(802);
            return 0;
        }

        if ($hospitalCaseNO == '')
        {
            $this->setErrorCode(803);
            return 0;
        }

        $disease = DAL::get()->find('Disease', $diseaseId);
        if ($disease->isNull())
        {
            $this->setErrorCode(804);
            return 0;
        }

        $user = DAL::get()->find('user', $this->currentUserId);
        if ($user->isNull())
        {
            $this->setErrorCode(178);
            return 0;
        }

        if($idcard != '')
        {
            if(15 == strlen($idcard))
            {
                $idcard = IdCard::idcard_15to18($idcard);
            }

            if(false == IdCard::idcard_checksum18($idcard))
            {
                $this->setErrorCode(312);
                return 0;
            }
        }


        if ($patientId != '')
        {
            $patient = DAL::get()->find('Patient', $patientId);
            if ($patient->isNull())
            {
                $this->setErrorCode(309);
                return 0;
            }
        }else{
            $params = array();
            $params['name'] = $name;
            $params['sex'] = $sex;
            $params['relation'] = Patient::RELATION_SELF;
            $params['province'] = $province;
            $params['city'] = $city;
            $params['birthday'] = $birthday;
            $params['mobile'] = $user->mobile;
            $params['idcard'] = $idcard;
            $patient = PatientClient::getInstance()->add($user, $params);
        }


        $spaceId = $this->filterHttpUrlString($spaceId);
        $space = DAL::get()->find('Space', $spaceId);
        if ($space->isNull())
        {
            $this->setErrorCode(144);
            return 0;
        }

        $QRcodePatientSignin = DAL::get()->find_by_QRpatientSign('patientsignin', $space->id, $patient->id);
        $res = array();
        if(false == $QRcodePatientSignin->isNull())
        {
            if($QRcodePatientSignin->isUnaudited())
            {
                $res['msg'] = self::PATIENT_SIGNIN_RES_AUDIT;
            }
        }

        if (empty($res))
        {
            $signinId = PatientSigninClient::getInstance()->addQRCODEPatientSignin($space, $patient, $hospitalCaseNO, $diseaseName, $diseaseId);
            $newQRCodePatientSignin = DAL::get()->find('patientsignin', $signinId);
            if ($newQRCodePatientSignin->isNull())
            {
                $this->setErrorCode(801);
                return 0;
            }
            $disease = DAL::get()->find('disease', $diseaseId);
            PatientFileClient::getInstance()->createPatientHealthApply4QRCode($patient->id, $diseaseId, $disease->name);
            $res['msg'] = self::PATIENT_SIGNIN_RES_SUC;
        }
        $this->content = $res;
    }/*}}}*/
 /**
     * @brief 将患者名下未读健康记录设为已读
     * @author zjj 
     *
     * @param $patientId 患者ID
     *
     * @return void
  */
 public function setHealthRecordRead4Patient($patientId)
 {/*{{{*/
     $unReadRecordIds = $this->getUnReadHealthRecordIds4Patient($patientId); 
     if(is_array($unReadRecordIds))
     {
         PatientFileClient::getInstance()->bindSetRecordRead($unReadRecordIds);
     }
 }/*}}}*/
 public function patientHealthRecordDetail($request, $response)
 {
     /*{{{*/
     $patientId = $request->patientId;
     $patient = DAL::get()->find('Patient', $patientId);
     $patientCaseId = $request->patientCaseId;
     $response->patientId = $patientId;
     $response->patientCaseId = $patientCaseId;
     $p = $request->getRequest("p", 1);
     $abNormal = $request->abNormal;
     $doctorPatientRefs = DAL::get()->find_all_by_spaceid_and_userid('DoctorPatientRef', $this->space->id, $patient->user->id);
     $proposals = DAL::get()->find_all_by_spaceid_and_userid_and_servicedef('Proposal', $this->space->id, $patient->user->id, 'FLOW');
     if (empty($doctorPatientRefs) && empty($proposals)) {
         throw new BizException('您没有权限查看此患者健康日记');
     }
     if ($abNormal) {
         $res = PatientFileClient::getInstance()->getAbnormalRecordListByPatientId($patientId, $p, 10);
     } else {
         $res = PatientFileClient::getInstance()->getRecordListByPatientId($patientId, $p, 10);
     }
     $response->healthRecordList = $healthRecordList = $res['list'];
     if (empty($res['pageInfo']) == false) {
         $url = "/adminpatient/patienthealthrecorddetail?patientId=" . $patientId;
         $pageLink = PageNav::getNavLink(PageNav::getPageNavTemplateForSpace($url . "&abNormal={$abNormal}&p="), $res['pageInfo']['nowpage'], $res['pageInfo']['pagesize'], $res['pageInfo']['total']);
     }
     $answerArrs = $wrapperCntArr = $wrapperArrs = $uploadArr = array();
     foreach ($healthRecordList as $record) {
         $wrapperCntArr[$record->id] = array();
         foreach ($record->answerSheet->answers as $answer) {
             if ($answer->getAnswerContent() == '' || $answer->getAnswerContent() instanceof NullEntity) {
                 continue;
             }
             if ($answer->question->isUpload()) {
                 $uploadArr[$record->id][] = $answer->getAnswerContent();
             }
             $answerArrs[$record->id][$answer->question->id] = $answer;
             $question = $answer->question;
             if (array_key_exists($question->wrapperid, $wrapperCntArr[$record->id])) {
                 $wrapperCntArr[$record->id][$question->wrapperid]++;
             } else {
                 $wrapperCntArr[$record->id][$question->wrapperid] = 1;
             }
         }
         $questionIdAnswerArr = $record->answerSheet->getQuestionId_answerArr();
         $answerSheetQuestionIds = array_keys($questionIdAnswerArr);
         $questionSheetQuestionIds = array_keys($record->answerSheet->questionSheet->questions);
         $deleteQuestionIds = array_diff($answerSheetQuestionIds, $questionSheetQuestionIds);
         $questionIds = array_merge($questionSheetQuestionIds, $deleteQuestionIds);
         $questions = DAL::get()->find('question', $questionIds);
         foreach ($questions as $question) {
             $wrapperArrs[$record->id][$question->wrapperid][] = $question;
         }
     }
     $response->answerArrs = $answerArrs;
     $response->wrapperArrs = $wrapperArrs;
     $response->wrapperCntArr = $wrapperCntArr;
     $response->uploadArr = $uploadArr;
     $response->pageLink = $pageLink;
     $response->abNormal = $abNormal = $abNormal == 1 ? 1 : 0;
     $response->patient = DAL::get()->find('Patient', $patientId);
 }
Ejemplo n.º 9
0
 public function getPatientDetailStatus($patientId, $userId = '')
 {/*{{{*/
     $patient = DAL::get()->find('patient', $patientId);
     $userId = empty($userId) ? '' : $userId;
     $ids = DAL::get()->find_id_BypatientId('patientattachment',$patientId);
     $isHaveAttachment = $isHaveFlow = $isHaveSpaceFlow = $isHaveHealthDiary = 0;
     if(false == empty($ids))
     {
         $isHaveAttachment = 1;
     }
     $flowIds = DAL::get()->find_all_by_patient_otherSpace('DoctorPatientRef', array($patientId), '', 1, '', true);
     if(false == empty($flowIds))
     {
         $isHaveFlow = 1;
     }
     if($userId)
     {
         $ref = DAL::get()->find_by_spaceid_and_patientid('doctorPatientRef', $userId, $patientId);
         if(false == $ref->isNull())
         {
             $isHaveSpaceFlow = 1;
             $isHaveFlow = 1;
         }
     }
     $out= PatientFileClient::getInstance()->getRecordListByPatientId($patientId, 1, 10);
     if(false == empty($out['list']))
     {
         $isHaveHealthDiary = 1;
     }
     $this->content = array('patientId'=>$patientId, 'isHaveAttachment'=>$isHaveAttachment, 'isHaveFlow'=>$isHaveFlow, 
         'isHaveSpaceFlow'=>$isHaveSpaceFlow, 'isHaveHealthDiary'=>$isHaveHealthDiary);
     return $this->content;
 }/*}}}*/