/** * Store the state of the patient * * @param CPatient $patient Patient * * @return null|string */ static function storeState($patient) { $identity_status = CAppUI::conf("dPpatients CPatient manage_identity_status", CGroups::loadCurrent()); //Si la configuration n'est pas activé if (!$identity_status) { return null; } $last_state = $patient->loadLastState(); if ($patient->_doubloon_ids) { $doubloons = is_array($patient->_doubloon_ids) ? $patient->_doubloon_ids : explode("|", $patient->_doubloon_ids); foreach ($doubloons as $_id) { $patient_link = new CPatientLink(); $patient_link->patient_id1 = $patient->_id; $patient_link->patient_id2 = $_id; $patient_link->loadMatchingObject(); $patient_link->store(); } } if ($last_state && $patient->status == $last_state->state) { return null; } $patient_state = new self(); $patient_state->patient_id = $patient->_id; $patient_state->state = $patient->status; $patient_state->reason = $patient->_reason_state; if ($msg = $patient_state->store()) { return $msg; } return null; }