예제 #1
0
 public function finishSignin($request, $response)
 {/*{{{*/
     $patientId = $request->patientid;
     $spaceId = $request->spaceid;
     $disease = $request->disease;
     $type = PatientSignin::TYPE_WEIXIN;
     $patientSignin = DAL::get()->find_by_ForWeiXinSignin('PatientSignin', $spaceId, $patientId);
     $url = $response->router->urlfor('attach/weixinconfirmattach',  array('patientId'=>$patientId, 'spaceId'=>$spaceId));
     if($patientSignin->isNull())
     {
         $signinId = PatientSigninClient::getInstance()->addPatientSigninFromWeixin($spaceId,$patientId,array('diseaseName'=>$disease));
         $weixUserId = $this->getWeixUserIdFromRequest();
         $weixUser = DAL::get()->find("WeixUser", $weixUserId, true);
         if(false == $weixUser->isNull())
         {
             WeixClient::getInstance()->updateScanStatus($weixUser->openid, $spaceId);
         }
     }
     else
     {
         $attachmentIds = $patientSignin->attachmentIds;
         $hasPatientSigninContent = (false == empty($attachmentIds)) || ('' != trim($patientSignin->treatment));
         if(false == $hasPatientSigninContent)
         {
             $url = $response->router->urlfor('weixin/wxflowdetail',  array('patientid'=>$patientId, 'spaceid'=>$spaceId));
         }
     }
     $response->setRedirect($url);
 }/*}}}*/
예제 #2
0
    public function patientSignin($doctorId, $userId, $patientId, $diseaseName, $isInHospital, $latestTreatedTime, $treatDescription, 
        $checkItems, $treatment, $hospitalCaseNO, $attachmentIds,  $name='', $birthday='', $sex='', $province='', $city='', $relation='', $mobile='')
    {/*{{{*/
        if($patientId)
        {
            $patient = DAL::get()->find('patient', $patientId);
        }
        else
        {
            $patient = $this->addPatient($userId, $name, $birthday, $sex, $province, $city, $relation, $mobile);
        }
        if($patient instanceof Patient == false)
        {
            $this->setErrorCode(316);
            return 0;
        }
        $doctor = DAL::get()->find('doctor', $doctorId);
        if($doctor->isNull() || $doctor->space->isNull())
        {
            $this->setErrorCode(328);
            return 0;
        }
        $params = array();
        $params['diseaseName'] = $diseaseName;
        $params['isInHospital'] = $isInHospital;
        $params['latestTreatedTime'] = $latestTreatedTime;
        $params['treatDescription'] = $treatDescription;
        $params['checkItems'] = $checkItems;
        $params['treatment'] = $treatment;
        $params['hospitalCaseNO'] = $hospitalCaseNO;
        $params['attachmentIds'] = (empty($attachmentIds) == false) ? explode(',', $attachmentIds) : '';

        $patientSignin = FlowClient::getInstance()->getOrdinaryPatientSignin($doctor->space->id, $patient->id); 
        if($patientSignin->isNull() == false && $patientSignin->isUnaudited())
        {
            $this->setErrorCode(345);
            return 0;
        }
        $signinId = PatientSigninClient::getInstance()->addOrdinaryPatientSignin($doctor->space->id, $patient->id, $params);
        $this->content = array('signinId'=>$signinId);
    }/*}}}*/
 /**
  * addPatientNotice 备注设置 
  * 
  * @param mixed $request 
  * @param mixed $response 
  * @access public
  * @return void
  */
 public function addPatientNotice($request, $response)
 {
     /*{{{*/
     $noticeContent = $request->noticecontent;
     $ticketId = $request->ticketid;
     $refId = $request->refid;
     $ref = DAL::get()->find('doctorPatientRef', $refId);
     if ($ref instanceof DoctorPatientRef) {
         PatientSigninClient::getInstance()->addPatientNotice($this->curInspector, $ref, $noticeContent);
     }
     if (false == $ticketId && $refId) {
         $response->setRedirect($response->router->urlfor('nfsaudit/notalk', array('refId' => $refId)));
     } else {
         $response->setRedirect($response->router->urlfor('nfsaudit/nexttask', array('c' => 'nfsaudit', 'a' => 'nexttask', 'ticketId' => $ticketId)));
     }
 }
 public function saveSignin($request, $response)
 {
     /*{{{*/
     $signinId = $request->signinId;
     $patientSignin = DAL::get()->find('FollowupOwner', $signinId);
     $savedAuditLog = false;
     //是否保存默认审核记录
     $curFollowupStatus = $patientSignin->followupStatus;
     $this->doSaveSignin($request, $response, $patientSignin);
     $followupStatus = $request->followupStatus;
     if ($followupStatus == FollowupOwner::FOLLOWUP_STATUS_OPENED) {
         $assistantGroupIds = $request->assistantGroupIds;
         $followupOwner = DAL::get()->find('FollowupOwner', $signinId);
         $spaceId = $request->bindspaceid;
         $space = DAL::get()->find('space', $spaceId);
         $this->bindGroup4Owner($assistantGroupIds, $followupOwner, $space);
     }
     if ($followupStatus != $curFollowupStatus) {
         $savedAuditLog = true;
         if ($followupStatus == FollowupOwner::FOLLOWUP_STATUS_OPENED) {
             $this->doPassSignin($request, $response);
         } else {
             if ($followupStatus == FollowupOwner::FOLLOWUP_STATUS_CLOSED) {
                 $this->doRefuseSignin($request, $response);
             } else {
                 $ticket = DAL::get()->find('NfsTaskTicket', $request->ticketId);
                 if ($ticket->isNull() == false && $ticket->isPassed() == false) {
                     NfsAuditClient::getInstance()->onlyPassTicket($this->auditor, $ticket->id);
                 }
             }
         }
     }
     if ($savedAuditLog == false) {
         //增加管理员操作日志
         $logContent = '管理员更新随访老患者报到信息';
         PatientSigninClient::getInstance()->writeAuditLog4PatientSignin($this->auditor, $signinId, $logContent);
     }
     $statusClosedReason = $request->followupstatusclosedreason;
     if (false == empty($statusClosedReason)) {
         NfsAuditClient::getInstance()->addAuditLog($patientSignin, $patientSignin, $this->auditor, NfsAuditLog::TypeFollowupOwner, $statusClosedReason);
     }
     $response->setRedirect($response->router->urlfor('followup/nextsignin', array('signinId' => $signinId)));
 }
예제 #5
0
 public function success4Signin($request, $response)
 {
     $response->title = "提交申请成功";
     $attachIds = explode(',', $request->attachIds);
     $space = DAL::get()->find('space', $request->spaceId);
     $patient = DAL::get()->find('patient', $request->patientId);
     DBC::requireFalse($patient->isNull(), '无效的patientId');
     DBC::requireFalse($space->isNull(), '无效的spaceId');
     $mobile = isset($_SESSION['newSignin']['mobile']) ? ($_SESSION['newSignin']['mobile']) : '';
     $diseaseName = isset($_SESSION['newSignin']['diseaseName']) ? ($_SESSION['newSignin']['diseaseName']) : '';
     PatientClient::getInstance()->modifyPatientMobile($patient->id, $mobile);
     $canSignin = 0;
     $oldSignins = DAL::get()->find_all_by_spaceid_and_patientid_and_status('patientsignin', $space->id, $patient->id, PatientSignin::STATUS_UNAUDITED);
     if(empty($oldSignins))
     {
         $signinId = PatientSigninClient::getInstance()->addOrdinaryPatientSignin($space->id, $patient->id, array('diseaseName' => $diseaseName));
         $newQRCodePatientSignin = DAL::get()->find('patientsignin', $signinId);
         if ($newQRCodePatientSignin->isNull())
         {
             $this->_exit404();
             return;
         }
         PatientSigninClient::getInstance()->addPatientSigninHelpInfo($signinId, "", $attachIds, PatientSigninHelpInfo::TYPE_ATTACH);
         $canSignin = 1;
     }
     $response->space = $space;
     $response->canSignin = $canSignin;
     if (!session_id())
     {
         session_start();
     }
     session_unset();
     session_destroy();
 }
예제 #6
0
 /**
  * @brief 编辑最后一条post
  * @author lhl
  * @version branches/v2.14.23
  * @date 2013-07-25
  */
 public function updatePost($request, $response)
 {
     /*{{{*/
     $ref = DAL::get()->find('DoctorPatientRef', $request->refid);
     $editPostType = $request->editposttype;
     if ('Post' == $editPostType) {
         $editPost = DAL::get()->find('Post', $request->editpostid);
     } else {
         $editPost = DAL::get()->find('DoctorPatientPost', $request->editpostid);
     }
     $relateEntity = $ref;
     if ($ref->isNull() || false == in_array($this->user->id, array($ref->user->id, $ref->space->user->id))) {
         header('Location: ' . $this->space->url);
         return;
     }
     // 如果还有继续能回复post的就打开post回复开关
     if ($ref->isClosePost()) {
         DoctorPatientPostClient::getInstance()->switchPatientPostCan($this->user->id, $ref->id);
     }
     $option = array();
     $attachmentIds = $request->attachmentIds != null ? $request->attachmentIds : '';
     $attachmentArr = explode(',', $attachmentIds);
     $option['attachmentIds'] = $attachmentArr;
     if ($ref->space->user->id == $this->user->id) {
         $content = $ref->space->name . "大夫和您有新对话<a href='" . $ref->url . "' target='_blank'>点击查看详情</a>";
         $title = $ref->space->name . "大夫和您有新对话";
         StationLetterClient::getInstance()->sendMsg(Message::AdminUserId, $ref->user->id, $title, $content);
     }
     if ($editPost->isSpaceReply()) {
         $postContent = $request->getUnSafeData('content');
     } else {
         $postContent = $request->content;
     }
     if (($postContent == '请填写咨询内容...' || $postContent == '') && $attachmentIds != '') {
         $postContent = '有新资料上传';
     }
     $post = DoctorPatientPostClient::getInstance()->updateDoctorPatientPost($editPost->id, array('content' => $postContent, 'attachmentIds' => $attachmentArr));
     if (false == $post->isNull() && $ref->user->id == $this->user->id) {
         //管理员给患者的提示信息失效
         PatientSigninClient::getInstance()->disablePatientNotice($ref->id);
     }
     DBC::requireFalse($post->isNull(), '系统繁忙,请稍后重试');
     $response->setRedirect($ref->url . "#reply");
 }
예제 #7
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 ;
    }/*}}}*/
예제 #8
0
    public function ajaxBuyPresent($request, $response)
    {/*{{{*/
        $patientId = $request->patientid;
        $presentId = $request->presentid;

        list($canSend, $errorMsg) = $this->canSendPresent($patientId, $presentId);
        $response->canSend= $canSend;
        $response->errorMsg = $errorMsg;
        if(false == $canSend)
        {
            return 'ajaxfailsent';
        }
        $isAllowSend = $this->isAllowSendPresent($request, $response);
        if(false == $isAllowSend)
        {
            return 'notsend';
        }

        //处理老订单还是新订单
        $present = DAL::get()->find('Present', $presentId);
        $patient = DAL::get()->find('patient', $patientId);
        $presentOrder = PresentClient::getInstance()->createOrder($this->_newUser, $patient
            , $this->_newSpace, $present, $request->wish, $request->old);
        $response->presentOrder = $presentOrder;
        $response->space = $this->_newSpace;

        $result = 4;
        $url = '';
        $couponId = 0;
        if(false == $presentOrder->isNull())
        {
            $result =  ScoreClient::getInstance()->payForPresent($this->_newUser->id, $this->_newSpace->id, $presentOrder->id);
            $url = Account::resultUrl($result, 'present', $presentOrder->id);
        }
        else
        {
            $result = 4;
        }
        $errorMsg = '';
        if(4 == $result)
        {
            $errorMsg = '订单提交失败';
        }
        else if(Account::PAY_RESULT_FAIL_COUPON == $result)
        {
            $errorMsg = '代金券支付失败!';
        }
        else if(Account::PAY_RESULT_NEED_RECHARGE != $result
            && Account::PAY_RESULT_NEED_EXCHANGE != $result
            && Account::PAY_RESULT_SUCC != $result)
        {
            $errorMsg = '积分处理流程失败!';
        }
        else
        {
            $isUsedCashCoupon = false;
            if ($cashCouponId)
            {
                $usedCoupon = DAL::get()->find('cashcoupon', $cashCouponId);
                $isUsedCashCoupon = $usedCoupon->price;
            }
            $response->isUsedCashCoupon = $isUsedCashCoupon;
            $ref = DAL::get()->find_by_spaceid_and_patientid_and_status('doctorpatientref'
                , $this->_newSpace->id, $patientId, DoctorPatientRef::STATUS_INIT);
            $response->ref = $ref;

            $response->url = $url;
            $response->score = $present->price;
            $response->heartValue = $present->heartValue;
            if(Account::PAY_RESULT_SUCC == $result)
            {
                AsyncSendMessage::regAsyncMessage($presentOrder);//发送站内信

                if($ref instanceof DoctorPatientRef)
                {
                    //管理员给患者的提示信息失效
                    PatientSigninClient::getInstance()->disablePatientNotice($ref->id);
                }
            }
            if($presentOrder->isAudited())
            {
                return 'ajaxsuccesssent';
            }
            else
            {
                return 'ajaxsuccesscustom';
            }
        }
        $response->errorMsg = $errorMsg;
        $response->result = $result;
        return 'ajaxfailsent';
    }/*}}}*/
    /**
        * @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;
    }/*}}}*/
예제 #10
0
 private function saveOrdinarySignin($spaceId, $patientId, $signinParams)
 {/*{{{*/
     /*
     $patientSignin = FlowClient::getInstance()->getOrdinaryPatientSignin($spaceId, $patientId); 
     $signinId = '';
     if(true == $patientSignin->isNull()) {
         $signinId = PatientSigninClient::getInstance()->addOrdinaryPatientSignin($spaceId, $patientId, $signinParams);
     } else {
         $params = $signinParams;
         $params['status'] = PatientSignin::STATUS_UNAUDITED;
         $signinId = PatientSigninClient::getInstance()->updateOrdinaryPatientSignin($patientSignin->id, $params, $patientSignin->userid);
     }
     */
     
     $signinId = PatientSigninClient::getInstance()->addOrdinaryPatientSignin($spaceId, $patientId, $signinParams);
     
     // 病历多患者
     if(isset($signinParams['attachmentIds']) && $patientId)
     {
         BingliClient::getInstance()->bindPatient4Attachment(implode(',', $signinParams['attachmentIds']), $patientId);
     }
     return $signinId;
 }/*}}}*/
예제 #11
0
    private function getCounts($ref, $response)
    {/*{{{*/
        $presentOrders = DAL::get()->find_all_by_spaceid_and_patientid_and_status('presentorder', $ref->space->id, $ref->patient->id, PresentOrder::STATUS_PAID_YES);
        $response->presentOrderCnt = count($presentOrders);

        $response->spacePostCnt = $ref->spacePostCount;

        $telOrders = PaymentClient::getInstance()->getPatientSuccessServiceList($ref->patient->id, $ref->space->id);
        $response->telOrderCnt = count($telOrders);

        $bookingOrders = BookingClient::getInstance()->getList4Flow($ref->space->id, $ref->patient->id);
        $response->bookingOrderCnt = count($bookingOrders);

        $patientApply = PatientSigninClient::getInstance()->getList4Flow($ref->space->id, $ref->patient->id);
        $patientSignin = PatientSigninClient::getInstance()->getList4Flow($ref->space->id, $ref->patient->id);
        $response->oldPatientCnt = count($patientApply) + count($patientSignin);
    }/*}}}*/