Element_OphTrOperationbooking_Operation::getDueLetter PHP Méthode

getDueLetter() public méthode

get the code for the letter that is due on this operation, based on the current status will return null if in an unknown state.
public getDueLetter ( ) : integer | null
Résultat integer | null
    public function getDueLetter()
    {
        $lastletter = $this->getLastLetter();
        if (!$this->getWaitingListStatus()) {
            // if getwaitingliststatus returns null, we're white
            return $lastletter;
            // no new letter is due, so we should print the last one
        }
        if ($this->getWaitingListStatus() == self::STATUS_PURPLE) {
            return self::LETTER_INVITE;
        } elseif ($this->getWaitingListStatus() == self::STATUS_GREEN1) {
            return self::LETTER_REMINDER_1;
        } elseif ($this->getWaitingListStatus() == self::STATUS_GREEN2) {
            return self::LETTER_REMINDER_2;
        } elseif ($this->getWaitingListStatus() == self::STATUS_ORANGE) {
            return self::LETTER_GP;
        } elseif ($this->getWaitingListStatus() == self::STATUS_RED) {
            // this used to return null, but now returning GP so that gp letters can be re-printed if necessary
            return self::LETTER_GP;
        } else {
            return;
            // possibly this should return $lastletter ?
        }
    }

Usage Example

 /**
  * Print the next letter for an operation.
  *
  * @param OEPDFPrint                              $pdf_print
  * @param Element_OphTrOperationbooking_Operation $operation
  * @param bool                                    $auto_confirm
  *
  * @throws CException
  */
 protected function printLetter($operation, $auto_confirm = false)
 {
     $patient = $operation->event->episode->patient;
     $letter_status = $operation->getDueLetter();
     if ($letter_status === null && $operation->getLastLetter() == Element_OphTrOperationbooking_Operation::LETTER_GP) {
         $letter_status = Element_OphTrOperationbooking_Operation::LETTER_GP;
     }
     $letter_templates = array(Element_OphTrOperationbooking_Operation::LETTER_INVITE => 'invitation_letter', Element_OphTrOperationbooking_Operation::LETTER_REMINDER_1 => 'reminder_letter', Element_OphTrOperationbooking_Operation::LETTER_REMINDER_2 => 'reminder_letter', Element_OphTrOperationbooking_Operation::LETTER_GP => 'gp_letter', Element_OphTrOperationbooking_Operation::LETTER_REMOVAL => false);
     $letter_template = isset($letter_templates[$letter_status]) ? $letter_templates[$letter_status] : false;
     if ($letter_template) {
         $firm = $operation->event->episode->firm;
         $site = $operation->site;
         $waitingListContact = $operation->waitingListContact;
         // Don't print GP letter if practice address is not defined
         if ($letter_status != Element_OphTrOperationbooking_Operation::LETTER_GP || $patient->practice && $patient->practice->contact->address) {
             Yii::log('Printing letter: ' . $letter_template, 'trace');
             $html = call_user_func(array($this, 'print_' . $letter_template), $operation);
             if ($auto_confirm) {
                 $operation->confirmLetterPrinted();
             }
             return $html;
         } else {
             Yii::log('Patient has no practice address, printing letter supressed: ' . $patient->id, 'trace');
         }
     } elseif ($letter_status === null) {
         Yii::log('No letter is due: ' . $patient->id, 'trace');
     } else {
         throw new CException('Undefined letter status');
     }
 }