public function newimportantEventSubmit($request, $response)
 {
     /*{{{*/
     $sheets = $request->sheets;
     $customer = DAL::get()->find('followupCustomer', $request->customerid);
     $answerSheetId = $request->answersheetid;
     if (false == empty($sheets)) {
         $answerSheetArr = WenDaClient::getInstance()->processAnswerSheets($sheets, $customer, $this->auditor->user->id);
         $answerSheet = reset($answerSheetArr['add']);
         if ($answerSheet instanceof AnswerSheet) {
             $answerSheetId = $answerSheet->id;
         }
     }
     $response->setRedirect($response->router->urlfor('followup/newimportantEvent', array('customerid' => $request->customerid, 'answersheetid' => $answerSheetId)));
 }
 /**
  * @brief 当前流所对应随访患者的健康日记
  * @author lhl
  * @version branches/v2.14.23
  * @date 2013-07-25
  */
 public function patientDiaryList($request, $response)
 {
     /*{{{*/
     $doctorPatientRefId = Codec::getInstance()->decodeId($request->refid);
     $ref = DAL::get()->find('DoctorPatientRef', $doctorPatientRefId);
     $p = $request->getRequest('p', 1);
     $pageSize = 10;
     $res = WenDaClient::getInstance()->getMixedAllPatientRecord($ref->patient, $p, $pageSize);
     $pageInfo = $res['pageInfo'];
     $pagelink = PageNav::getNavLink(PageNav::getPageNavTemplateForSpace("/flow/patientdiarylist?refid=" . $ref->id . '&p='), $pageInfo['nowpage'], $pageInfo['pagesize'], $pageInfo['total']);
     $diaryList = $res['diaries'];
     $response->diaryList = $this->getHealthRecordAdapterList($diaryList);
     // 查询异常
     $diaryIds = array_keys($diaryList);
     $abnormalStatus = array();
     //todo diaryIds is mixed
     if (false == empty($diaryIds)) {
         $abnormalStatus = PatientCaseHistoryClient::getInstance()->getAbnormalStatusByEntityIds($diaryIds);
     }
     $response->abnormalStatus = $abnormalStatus;
     $patientSignin = DAL::get()->find_by_patientid_and_spaceid('FollowupOwner', $ref->patient->id, $this->space->id);
     $signinProblems = array();
     if (false == $patientSignin->isNull()) {
         $response->leaveHospitalDate = $patientSignin->leaveHospitalDate;
         $signinProblems = $patientSignin->getNfsDisease()->getSigninHealthProblems();
     } else {
         $response->leaveHospitalDate = '';
     }
     $response->signinProblems = $signinProblems;
     $response->pagelink = $pagelink;
     $response->ref = $ref;
     $res = FlowClient::getInstance()->getFlowInfos($ref->id, $p, $pageSize, array('curUserId' => $this->user->id));
     list($hasBooking, $hasTel, $bookingOrder, $telCase) = $this->getUnFinishedService($res['objects']);
     $response->hasBooking = $hasBooking;
     $response->hasTel = $hasTel;
     $out = MedicineClient::getInstance()->getMedicineEventLog($ref->user->id, 1, 2);
     $response->medicineEventLogList = $out['eventList'];
     $medicineSchemeList = MedicineClient::getInstance()->getUserCurrentMedicineScheme($ref->user->id);
     $response->medicineSchemeList = $medicineSchemeList;
     $groups = ForumClient::getInstance()->getGroupListByPatientIdAndSpaceId($ref->patient->id, $this->space->id);
     $response->groupList = $groups;
 }
 public function returnTo400FenZhen($request, $response)
 {
     /*{{{*/
     $curGroup = $this->getBuGroup($request->groupid);
     $patient = DAL::get()->mustFind('patient', $request->patientid);
     $comment = $request->comment;
     $tickets = $this->getTickets($patient, $curGroup);
     foreach ($tickets as $ticket) {
         if ($ticket->source instanceof Intention && $ticket->source->isSrcInspector()) {
             $intention = DAL::get()->find('intention', $ticket->source->id);
             $labelName = LabelCategory::getCategoryName(LabelCategory::TYPE_FENZHEN_400_INTENTION);
             $label = DAL::get()->find_by_name('Label', $labelName);
             $labelRef = WenDaClient::getInstance()->addLabelRef($ticket->source, $label->id);
             if ($labelRef->isNull() == false) {
                 $logContent = "IntentionId:" . $intention->id . ", " . $comment;
                 S3LogClient::getInstance()->add($this->curInspector, $patient->getLogable()->action(PatientLog::ACTION_BU_PASS_FENZHEN_400, $logContent));
             }
         }
     }
     $this->buComplete($request, $response);
     $this->redirectToNext($curGroup, $response);
 }
 public function saveMessageTmplate($request, $response)
 {
     /*{{{*/
     $tplKey = '';
     $description = '';
     $title = $request->name;
     $content = $request->content;
     $templateId = '';
     $categoryId = $request->msgtmpcategories;
     if ('edit' == $request->savetype) {
         $category = DAL::get()->find('label', $categoryId);
         $oldCategoryId = $request->oldcategoryid;
         $templateId = $request->id;
         StationLetterClient::getInstance()->modifyTemplate($templateId, $title, $title, $title, $content);
         $template = DAL::get()->find('messagetpl', $templateId);
         $labelRefIdArr = DAL::get()->find_id_by_sourceid_and_labelid('labelref', $templateId, $oldCategoryId);
         $labelRefId = $labelRefIdArr[0];
         WenDaClient::getInstance()->modifyLabelRef($labelRefId, $category, $template);
     } else {
         $templateId = StationLetterClient::getInstance()->addTemplate($title, $title, $title, $content);
         $template = DAL::get()->find('messagetpl', $templateId);
         WenDaClient::getInstance()->addLabelRef($template, $categoryId);
     }
     $url = $response->router->urlfor('message/showMessageManageDetail', array('id' => $templateId, 'categoryid' => $categoryId));
     $response->setRedirect($url);
 }
    private function modifyAnswerSheet4Patient($patientId, $answerSheetInfos)
    {/*{{{*/
        $patient = DAL::get()->find('Patient', $patientId);
        DBC::requireFalse($patient->isNull(), '患者不存在!');
        $patientQuestionSheetRef = DAL::get()->find_by_patientid_and_status('PatientQuestionSheetRef', $patientId, PatientQuestionSheetRef::STATUS_VALID);
        DBC::requireFalse(($patientQuestionSheetRef->isNull() || $patientQuestionSheetRef->questionSheet->isNull()), '问卷不存在!');
        $questionSheet = $patientQuestionSheetRef->questionSheet;
        $answerSheetInfos = $this->filterAnswerInfos($answerSheetInfos);
        $isExist = $this->checkLastSubmitedHealthRecord($patient->id);
        DBC::requireFalse($isExist,'今天日记已经填写完');
        $patientQuestionSheetRef = DAL::get()->find_by_patientid_and_status('PatientQuestionSheetRef', $patientId, PatientQuestionSheetRef::STATUS_VALID);
        if ($patientQuestionSheetRef->isNull() || $patientQuestionSheetRef->questionSheet->isNull())
        {
            echo "患者问卷不存在";
            return parent::DIRECT_OUTPUT;
        }

        $questionSheet = $patientQuestionSheetRef->questionSheet;

        //获取答卷
        $answerSheet = WenDaClient::getInstance()->getAnswerSheetOfWaitStatusRecord4PatientFile($questionSheet->id, $patient->id); 
        if ($answerSheet->isNull())
        {
            echo "患者答卷不存在";
            return parent::DIRECT_OUTPUT;
        }

        //修改答卷
        $answerSheet = WenDaClient::getInstance()->modifyAnswerSheet($answerSheet->id, $answerSheetInfos, $patientId);
        return $answerSheet;
    }/*}}}*/
 /**
  * ajax4DeleteModelLabel 
  * 删除 
  * @param mixed $request 
  * @param mixed $response 
  * @access public
  * @return void
  * todo::psq
  */
 public function ajax4DeleteModelLabel($request, $response)
 {
     $id = $request->id;
     WenDaClient::getInstance()->deleteLabel($id);
     return self::DIRECT_OUTPUT;
 }
    /**
        * @brief 保存健康日记草稿
        * @author zjj
        *
        * @param $patientId 患者ID
        * @param $answerSheetInfos 问题答案信息(keyValue格式,key为问题ID)
        *
        * @return $answerSheet 问卷
     */
    public function modifyAnswerSheet4Patient($patientId, $answerSheetInfos)
    {/*{{{*/
        $patient = DAL::get()->find('Patient', $patientId);
        if ($patient->isNull())
        {
            $this->setErrorCode(316);
            return 0;
        }
        if ($this->currentUserId != $patient->user->id)
        {
            $this->setErrorCode(370);
            return 0;
        }

        $lastSubmintHealthRecord = $this->checkLastSubmitedHealthRecord($patient->id);
        if (false == $lastSubmintHealthRecord->isNull() && $lastSubmintHealthRecord->isCreateInCurrentDay())
        {
            $this->setErrorCode(368);
            return 0;
        }

        $patientQuestionSheetRef = DAL::get()->find_by_patientid_and_status('PatientQuestionSheetRef', $patientId, PatientQuestionSheetRef::STATUS_VALID);
        if ($patientQuestionSheetRef->isNull() || $patientQuestionSheetRef->questionSheet->isNull())
        {
            $this->setErrorCode(363);
            return 0;
        }

        $questionSheet = $patientQuestionSheetRef->questionSheet;
        $answerSheetInfos = $this->filterAnswerInfos($answerSheetInfos);

        //获取答卷
        $answerSheet = WenDaClient::getInstance()->getAnswerSheetOfWaitStatusRecord4PatientFile($questionSheet->id, $patient->id); 
        if ($answerSheet->isNull())
        {
            $this->setErrorCode(364);
            return 0;
        }


        //修改答卷
        $answerSheet = WenDaClient::getInstance()->modifyAnswerSheet($answerSheet->id, $answerSheetInfos, $patientId);
        $res['res'] = self::RECORD_SAVE_SUC;
        if ($answerSheet->isNull())
        {
            $res['res'] = self::RECORD_SAVE_FAL;
        }
        $this->content = $res;
        return $answerSheet;
    }/*}}}*/
 public function saveInitialInfo($request, $response)
 {
     /*{{{*/
     $signinId = $request->signinId;
     $this->doSavePatientInfo($request, $response);
     $this->doSaveSigninInfo($request, $response);
     $this->doSaveInitialInfoProblems($request, $response);
     $response->signinId = $signinId;
     //$response->setRedirect($response->router->urlfor('patientcasehistory/followupinitialinfo',array('c' =>'patientcasehistory','signinId'=>$signinId)));
     //$diseaseInfo = $request->diseaseinfo;
     $sheets = $request->sheets;
     $followupOwner = DAL::get()->find('FollowupOwner', $signinId);
     WenDaClient::getInstance()->processAnswerSheets($sheets, $followupOwner->user, $this->auditor->user->id);
 }
 public function simpleBingshiOfCustomerPost($request, $response)
 {
     /*{{{*/
     DBC::requireNotEmptyString($request->followupcustomerid, "FollowupCustomerID 不能为空!");
     // wenda
     $sheets = $request->sheets;
     $customer = DAL::get()->find("FollowupCustomer", $request->followupcustomerid);
     WenDaClient::getInstance()->processAnswerSheets($sheets, $customer->getBindUser(), $this->auditor->user->id);
     // healthrecordproblem 吸烟, 身高体重,
     $values = $request->pbs;
     HealthRecordClient::getInstance()->batchAddAnswer4Initial($customer->userId, $values);
     echo "修改成功";
     return parent::DIRECT_OUTPUT;
 }
 public function addLabelQuestionRefs($request, $response)
 {
     /*{{{*/
     $this->checkAuditor();
     DBC::requireNotEmpty($request->labelid, 'labelid不能为空');
     $questionIds = DAL::get()->find_id_labelidAndSourceType('question', $request->labelid, 'question');
     $currentQuestionIds = $request->getRequest('currentQuestionIds', array());
     $deleteQuestionIds = array_diff($questionIds, $currentQuestionIds);
     WenDaClient::getInstance()->batchDeleteLabelFromSourceEntities($request->labelid, $deleteQuestionIds);
     $addQuestionIds = $request->getRequest('addQuestionIds', array());
     $addQuestions = DAL::get()->find('question', $addQuestionIds);
     WenDaClient::getInstance()->batchAddLabel2sourceEntity($request->labelid, $addQuestions);
     $response->setRedirect($response->router->urlfor('checkup/checkupquestionlabelrefmanage', array('labelid' => $request->labelid)));
 }