ElementLetter::populate_from_macro PHP Метод

populate_from_macro() публичный Метод

public populate_from_macro ( $patient )
    public function populate_from_macro($patient)
    {
        if ($this->macro->use_nickname) {
            $this->use_nickname = 1;
        }
        $address_contact = null;
        if ($this->macro->recipient && $this->macro->recipient->name == 'Patient') {
            $address_contact = $patient;
            $this->address_target = 'patient';
            $this->introduction = $patient->getLetterIntroduction(array('nickname' => $this->use_nickname));
        } elseif ($this->macro->recipient && $this->macro->recipient->name == 'GP') {
            $this->address_target = 'gp';
            if ($patient->gp) {
                $this->introduction = $patient->gp->getLetterIntroduction(array('nickname' => $this->use_nickname));
                $address_contact = $patient->gp;
            } else {
                $this->introduction = 'Dear ' . Gp::UNKNOWN_SALUTATION . ',';
                $address_contact = @$patient->practice;
            }
        }
        if ($address_contact) {
            $this->address = $address_contact->getLetterAddress(array('patient' => $patient, 'include_name' => true, 'include_label' => true, 'delimiter' => "\n"));
        }
        $this->macro->substitute($patient);
        $this->body = $this->macro->body;
        if ($this->macro->cc_patient && $patient->contact->address) {
            $this->cc = $patient->getLetterAddress(array('include_name' => true, 'include_prefix' => true, 'delimiter' => '| '));
            $this->cc = str_replace(',', ';', $this->cc);
            $this->cc = str_replace('|', ',', $this->cc);
            $this->cc_targets[] = 'patient';
        }
        if ($this->macro->cc_doctor && $patient->gp && @$patient->practice->contact->address) {
            $this->cc = $patient->gp->getLetterAddress(array('patient' => $patient, 'include_name' => true, 'include_label' => true, 'delimiter' => '| ', 'include_prefix' => true));
            $this->cc = str_replace(',', ';', $this->cc);
            $this->cc = str_replace('|', ',', $this->cc);
            $this->cc_targets[] = 'gp';
        }
    }