/**
  * newPatientCase 
  * 创建病历头 
  * @param mixed $doctorOwnerId 必填 
  * @param mixed $name 
  * @param mixed $age 
  * @param mixed $sex 
  * @param mixed $address 
  * @param mixed $phone 
  * @param mixed $$province 
  * @param mixed $city 
  * @param mixed $src 
  * @param mixed $medicalCard 
  * @param mixed $personIdCard 
  * @param mixed $patientIdCard 
  * @param mixed $mark 
  * @param mixed $attachmentids 
  * @param mixed $groupId 
  * @param mixed $isAttention 0 未关注 1 重点关注 
  * @access public
  * @return void
  */
 public function newPatientCase($userId, $caseSummary, $clientCreateTime, $clientUpdateTime, $clientId, $name, $age, $sex, $address, $phone, $province, $city, $src, $medicalCard, $personIdCard, $patientIdCard, $mark, $diagnose, $attachmentIds, $groupId, $isAttention, $patientCaseId)
 {/*{{{*/
     if(empty($clientId))
     {
         return 0;
     }
     $doctorOwner = DAL::get()->find_by_userid('DoctorOwner',$userId);
     if($doctorOwner->isNull())
     {
         return 0;
     }
     if (false == empty($patientCaseId)) 
     {
         $oldPatientCase = DAL::get()->find('PatientCase', $patientCaseId);
     }
     $oldPatientCase = (false == isset($oldPatientCase) || $oldPatientCase->isNull()) ? PatientCase::getCaseByOwnerAndCaseSummary($doctorOwner->id, $caseSummary) : $oldPatientCase;
     if($oldPatientCase->isNull())
     {
         $patientCaseId = PatientCourseClient::getInstance()->createPatientCaseWithAttach($doctorOwner, $caseSummary, $clientCreateTime, $clientUpdateTime, $name, $age, $sex, $address, $phone, $province, $city, $src, $medicalCard, $personIdCard, $patientIdCard, $mark, $diagnose, $attachmentIds);  
         if($this->isOldVersion($_REQUEST['os'], $_REQUEST['v']))
         {
             $this->newPatientCourseWithAllDetail($userId, $patientCaseId, 1, PatientCourse::TYPE_FIRST_MEDICAL,  md5($patientCaseId.XDateTime::now()->toString()), XDateTime::now(), '', array());
         }
     }
     else 
     {
         $patientCaseId = $oldPatientCase->id;
         PatientCourseClient::getInstance()->modifyPatientCaseClientUpdateTime($patientCaseId, $clientUpdateTime);
     }
     $patientCase = DAL::get()->find('patientCase', $patientCaseId);
     $group = DAL::get()->find('regroup', $groupId);
     if($group->isNull())
     {
         $unGroup = DAL::get()->find_by_doctorownerid_and_type('regroup', $doctorOwner->id, ReGroup::TYPE_2);
         $groupId = $unGroup->id;
     }
     if ($groupId > 0) 
     {
         PatientClubClient::getInstance()->updateMember($doctorOwner->user->id, $patientCaseId, $groupId, ReGroupMember::MEMBER_PATIENT_TYPE_MYINPUT, $isAttention);
     }
     $this->content = array('clientId'=>$clientId, 'patientCaseId'=>$patientCase->id, 'ver'=>$patientCase->ver);
 }/*}}}*/