/**
        * @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;
    }/*}}}*/
예제 #2
0
    public function newSetPatient($userId, $patientId, $name, $sex, $province, $city, $idcard, $paperstype, $birthday, $mobile, $relation)
    {/*{{{*/
        $user = DAL::get()->find('user', $userId);
        error_log('birthday:'.$birthday."\n",3,'/tmp/wap123.log');

		$request = new Request();
		if($request->os == 'ios' && $request->v == '2.1.0' && $paperstype == '0')
        {
            $birthday = substr($birthday, 0, 4)."-".substr($birthday, 4, 2)."-".substr($birthday, 6, 2);
        }
        else
        {
            $birthday = date('Y-m-d',$birthday);
        }
        if ($user->isNull())
        {
            $this->setErrorCode(107);
            return 0;
        }
        if(0 == $paperstype)
        {
            if(15 == strlen($idcard))
            {
                $idcard = IdCard::idcard_15to18($idcard);
            }

            if(false == IdCard::idcard_checksum18($idcard))
            {
                $this->setErrorCode(312);
                return 0;
            }
        }
        $patientNew = DAL::get()->find('patient', $patientId);
        if("" == trim($name))
        {
            $this->setErrorCode(176);
            return 0;
        }
        if("" == trim($birthday))
        {
            $this->setErrorCode(171);
            return 0;
        }
        if("" == trim($sex))
        {
            $this->setErrorCode(172);
            return 0;
        }
        if("" == trim($province))
        {
            $this->setErrorCode(173);
            return 0;
        }
        if("" == trim($city))
        {
            $this->setErrorCode(174);
            return 0;
        }
        if("" == trim($relation))
        {
            $this->setErrorCode(175);
            return 0;
        }
        if(false == XString::isMobile($mobile))
        {
            $this->setErrorCode(110);
            return 0;
        }
        /** 患者不存在,写入一条患者信息 */
        if ($patientNew->isNull()) {
            $birthday = $birthday;
            $params = array(
                'name' => trim($name),
                'sex' => trim($sex),
                'province' => trim($province),
                'city' => trim($city),
                'idcard' => trim($idcard),
                'paperstype'=> trim($paperstype),
                'birthday' => trim($birthday),
                'mobile' => trim($mobile),
                'relation' => trim($relation),
            );
            $theSame = PatientClient::getInstance()->theSame($user, $params, 'jiahao');
            if(false == $theSame)
            {
                $patientInfo = PatientClient::getInstance()->add($user, $params, 0, '', '', 'jiahao');
            }
            else
            {
                $patientInfo = DAL::get()->find('patient', $theSame);
            }
        } 
        else 
        {
            $info = array();
            $info['paperstype'] = trim($paperstype);
            $info['idcard'] = trim($idcard);
            $info['name'] = trim($name);
            $info['mobile'] = trim($mobile);
            //svc方法中会对info中有的字段会被重新赋值。我们不会更改省和市的字段(客户端获取信息时省市拼接一个字段返回,所以无法区别省市回传)
          //  $info['province'] = trim($province);
          //  $info['city'] = trim($city);
            $info['birthday'] = trim($birthday);
            if (false == empty($info))
            {
                PatientClient::getInstance()->modifyInfo($patientNew->id , $info);
            }
            $patientInfo = $patientNew;
        }
        $patient = array();
        $patient['patientId'] = $patientInfo->id;
        $this->content = $patient;
    }/*}}}*/