OEModule\PASAPI\resources\Patient::saveModel PHP Метод

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

Assign the Patient resource attributes to the given Patient model and save it.
public saveModel ( Patient $patient ) : boolean | null
$patient Patient
Результат boolean | null
    public function saveModel(\Patient $patient)
    {
        $this->assignProperty($patient, 'nhs_num', 'NHSNumber');
        $this->assignProperty($patient, 'hos_num', 'HospitalNumber');
        $this->assignProperty($patient, 'dob', 'DateOfBirth');
        $this->assignProperty($patient, 'date_of_death', 'DateOfDeath');
        $this->assignProperty($patient, 'is_deceased', 'IsDeceased');
        $this->mapGender($patient);
        $this->mapEthnicGroup($patient);
        $this->mapGp($patient);
        $this->mapPractice($patient);
        $this->mapNhsNumberStatus($patient);
        if (!$patient->validate()) {
            $this->addModelErrors($patient->getErrors());
            return;
        }
        $patient->save();
        // Set the contact details
        $contact = $patient->contact;
        $this->assignProperty($contact, 'title', 'Title');
        $this->assignProperty($contact, 'first_name', 'FirstName');
        $this->assignProperty($contact, 'last_name', 'Surname');
        $this->assignProperty($contact, 'primary_phone', 'TelephoneNumber');
        if (!$contact->validate()) {
            $this->addModelErrors($contact->getErrors());
            return;
        }
        $contact->save();
        $this->mapAddresses($contact);
        if (!$this->errors) {
            return true;
        }
    }