getCurrentEpisodeByFirm() public static method

wrapper for getCurrentEpisodeBySubspecialtyId($patient_id, $subspecialty_id, $include_closed)
public static getCurrentEpisodeByFirm ( $patient_id, $firm, $include_closed = false )
コード例 #1
0
 /**
  * Caching wrapper for the current episode lookup
  *
  * @return array|mixed|null|void
  * @throws Exception
  */
 public function getOwnerCurrentEpisode()
 {
     if (!$this->current_episode) {
         $this->current_episode = Episode::getCurrentEpisodeByFirm($this->owner->patient->id, $this->owner->firm);
     }
     return $this->current_episode;
 }
コード例 #2
0
 public function run()
 {
     if ($this->element) {
         $this->class = CHTML::modelName($this->element);
     } else {
         $this->class = get_class($this);
     }
     if (empty($_POST) || !array_key_exists($this->class, $_POST)) {
         if (empty($this->element->event_id)) {
             if ($this->default) {
                 // It's a new event so fetch the most recent element_diagnosis
                 $firmId = Yii::app()->session['selected_firm_id'];
                 $firm = Firm::model()->findByPk($firmId);
                 if (isset(Yii::app()->getController()->patient)) {
                     $patientId = Yii::app()->getController()->patient->id;
                     $episode = Episode::getCurrentEpisodeByFirm($patientId, $firm, true);
                     if ($episode && ($disorder = $episode->diagnosis)) {
                         // There is a diagnosis for this episode
                         $this->value = $disorder->id;
                         $this->label = $disorder->term;
                     }
                 }
             }
         } else {
             if (isset($this->element->disorder)) {
                 $this->value = $this->element->disorder->id;
                 $this->label = $this->element->disorder->term;
             }
         }
     } elseif (array_key_exists($this->field, $_POST[$this->class])) {
         if (preg_match('/[^\\d]/', $_POST[$this->class][$this->field])) {
             if ($disorder = Disorder::model()->find('term=? and specialty_id is not null', array($_POST[$this->class][$this->field]))) {
                 $this->value = $disorder->id;
                 $this->label = $disorder->term;
             }
         } else {
             $this->value = $_POST[$this->class][$this->field];
             if ($disorder = Disorder::model()->findByPk($this->value)) {
                 $this->label = $disorder->term;
             }
         }
     }
     parent::run();
 }
コード例 #3
0
echo $subspecialty ? $subspecialty->name : 'Support services';
?>
 episode:</strong>
</div>
<ul class="events">
	<?php 
foreach ($eventTypes as $eventType) {
    if ($subspecialty || $eventType->support_services) {
        if (file_exists(Yii::getPathOfAlias('application.modules.' . $eventType->class_name . '.assets.img'))) {
            $assetpath = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.modules.' . $eventType->class_name . '.assets.img') . '/') . '/';
        } else {
            $assetpath = '/assets/';
        }
        // temporary hack to ensure that we are checking the right operation name for the event.
        $oprn = 'OprnCreate' . ($eventType->class_name == 'OphDrPrescription' ? 'Prescription' : 'Event');
        if ($this->checkAccess($oprn, $this->firm, Episode::getCurrentEpisodeByFirm($this->patient->id, $this->firm), $eventType)) {
            ?>
				<li>
					<?php 
            echo CHtml::link('<img src="' . $assetpath . 'small.png" alt="operation" /> - <strong>' . $eventType->name . '</strong>', Yii::app()->createUrl($eventType->class_name . '/Default/create') . '?patient_id=' . $patient->id);
            ?>
				</li>
			<?php 
        } else {
            ?>
				<li id="<?php 
            echo $eventType->class_name;
            ?>
_disabled" class="add_event_disabled" title="<?php 
            echo $eventType->disabled ? $eventType->disabled_title : 'You do not have permission to add ' . $eventType->name;
            ?>
コード例 #4
0
ファイル: Patient.php プロジェクト: openeyeswales/OpenEyes
 /**
  * Get or create an episode for the patient under the given Firm (Note that an episode will be returned if there
  * is match on Firm Subspecialty rather than on Firm)
  *
  * @param $firm
  * @param bool $include_closed
  * @return CActiveRecord|Episode|null
  */
 public function getOrCreateEpisodeForFirm($firm, $include_closed = false)
 {
     if (!($episode = Episode::getCurrentEpisodeByFirm($this->id, $firm, $include_closed))) {
         $episode = $this->addEpisode($firm);
     }
     return $episode;
 }
コード例 #5
0
 /**
  * Set default values for forms on create.
  */
 public function setDefaultOptions()
 {
     $patient_id = (int) $_REQUEST['patient_id'];
     $firm = Yii::app()->getController()->firm;
     $episode = Episode::getCurrentEpisodeByFirm($patient_id, $firm);
     if ($episode && $episode->diagnosis) {
         $this->eye_id = $episode->eye_id;
     }
     $this->site_id = Yii::app()->session['selected_site_id'];
     $this->senior_fellow_to_do = false;
     if ($patient = Patient::model()->findByPk($patient_id)) {
         $key = $patient->isChild() ? 'ophtroperationbooking_default_anaesthetic_child' : 'ophtroperationbooking_default_anaesthetic';
         if (isset(Yii::app()->params[$key])) {
             if ($at = AnaestheticType::model()->find('code=?', array(Yii::app()->params[$key]))) {
                 $this->anaesthetic_type_id = $at->id;
             }
         }
     }
     $this->fast_track = false;
     $this->special_equipment = false;
     $this->organising_admission_user_id = Yii::app()->user->id;
     if ($priority = OphTrOperationbooking_Operation_Priority::model()->notDeleted()->find('`default`=1')) {
         $this->priority_id = $priority->id;
     }
 }