public function getOpnoteWithCataractElementInCurrentEpisode($patient) { if ($episode = $patient->getEpisodeForCurrentSubspecialty()) { $event_type = EventType::model()->find('class_name=?', array('OphTrOperationnote')); $criteria = new CDbCriteria(); $criteria->compare('episode_id', $episode->id); $criteria->compare('event_type_id', $event_type->id); return Element_OphTrOperationnote_Cataract::model()->with('event')->find($criteria); } }
protected function appendOpNoteValues(&$record, $event_id, $anaesthetic_type, $anaesthetic_delivery, $anaesthetic_comments, $anaesthetic_complications, $cataract_report, $incision_site, $cataract_complication_notes, $cataract_predicted_refraction, $cataract_iol_type, $cataract_iol_power, $tamponade_used, $surgeon, $surgeon_role, $assistant, $assistant_role, $supervising_surgeon, $supervising_surgeon_role, $opnote_comments) { $anaesthetic = Element_OphTrOperationnote_Anaesthetic::model()->find('event_id = :event_id', array(':event_id' => $event_id)); if ($anaesthetic_type) { $record['anaesthetic_type'] = $anaesthetic->anaesthetic_type['name']; } if ($anaesthetic_delivery) { $record['anaesthetic_delivery'] = $anaesthetic->anaesthetic_delivery['name']; } if ($anaesthetic_comments) { $record['anaesthetic_comments'] = $anaesthetic['anaesthetic_comment']; } if ($anaesthetic_complications) { $complications = array(); if (isset($anaesthetic->anaesthetic_complications)) { foreach ($anaesthetic->anaesthetic_complications as $complication) { $complications[] = $complication['name']; } $record['anaesthetic_complications'] = implode(',', $complications); } } if ($cataract_report) { foreach (array('cataract_report', 'cataract_predicted_refraction', 'cataract_iol_type', 'cataract_iol_power') as $k) { $record[$k] = ''; } if ($cataract_element = Element_OphTrOperationnote_Cataract::model()->find('event_id = :event_id', array(':event_id' => $event_id))) { $record['cataract_report'] = trim(preg_replace('/\\s\\s+/', ' ', $cataract_element['report'])); $record['cataract_predicted_refraction'] = $cataract_element->predicted_refraction; if ($cataract_element->iol_type) { $record['cataract_iol_type'] = $cataract_element->iol_type->name; } else { $record['cataract_iol_type'] = 'None'; } $record['cataract_iol_power'] = $cataract_element->iol_power; } } if ($incision_site) { $record['incision_site'] = 'Unknown'; $record['length_of_incision'] = 'Unknown'; $record['meridian'] = 'Unknown'; $record['incision_type'] = 'Unknown'; $record['iol_position'] = 'Unknown'; $cataract_operation_details_element = Element_OphTrOperationnote_Cataract::model()->find('event_id = :event_id', array(':event_id' => $event_id)); if ($cataract_operation_details_element) { $incisionSite = OphTrOperationnote_IncisionSite::model()->find('id = :id', array(':id' => $cataract_operation_details_element['incision_site_id'])); if ($incisionSite) { $record['incision_site'] = $incisionSite->name; } if ($cataract_operation_details_element['length']) { $record['length_of_incision'] = $cataract_operation_details_element['length']; } if ($cataract_operation_details_element['meridian']) { $record['meridian'] = $cataract_operation_details_element['meridian']; } $incision = OphTrOperationnote_IncisionType::model()->find('id = :id', array(':id' => $cataract_operation_details_element['incision_type_id'])); if ($incision) { $record['incision_type'] = $incision->name; } $iolPosition = OphTrOperationnote_IOLPosition::model()->find('id = :id', array(':id' => $cataract_operation_details_element['iol_position_id'])); if ($iolPosition) { $record['iol_position'] = $iolPosition->name; } } } if ($cataract_complication_notes) { $record['Cataract Complication Notes'] = 'Unknown'; if ($cataract_complication_notes_element = Element_OphTrOperationnote_Cataract::model()->find('event_id = :event_id', array(':event_id' => $event_id))) { if ($cataract_complication_notes_element['complication_notes']) { $record['Cataract Complication Notes'] = $cataract_complication_notes_element['complication_notes']; } } } if ($tamponade_used) { if ($tamponade_element = Element_OphTrOperationnote_Tamponade::model()->find('event_id = :event_id', array(':event_id' => $event_id))) { $record['tamponade_used'] = $tamponade_element->gas_type->name; } else { $record['tamponade_used'] = 'None'; } } if ($surgeon || $surgeon_role || $assistant || $assistant_role || $supervising_surgeon || $supervising_surgeon_role) { $surgeon_element = Element_OphTrOperationnote_Surgeon::model()->findByAttributes(array('event_id' => $event_id)); foreach (array('surgeon', 'assistant', 'supervising_surgeon') as $surgeon_type) { $role = $surgeon_type . '_role'; if (${$surgeon_type} || ${$role}) { $surgeon = $surgeon_element->{$surgeon_type}; if (${$surgeon_type}) { $record[$surgeon_type] = $surgeon ? $surgeon->getFullName() : 'None'; } if (${$role}) { $record["{$surgeon_type}_role"] = $surgeon ? $surgeon->role : 'None'; } } } } if ($this->opnote_comments) { $comments = Element_OphTrOperationnote_Comments::model()->find('event_id = :event_id', array(':event_id' => $event_id)); $record['opnote_comments'] = trim(preg_replace('/\\s\\s+/', ' ', $comments['comments'])); } }
/** * Update the complications and the operative devices. * * @param Element_OphTrOperationnote_Cataract $element * @param $data * @param $index */ protected function saveComplexAttributes_Element_OphTrOperationnote_Cataract($element, $data, $index) { $element->updateComplications(isset($data['OphTrOperationnote_CataractComplications']) ? $data['OphTrOperationnote_CataractComplications'] : array()); $element->updateOperativeDevices(isset($data['OphTrOperationnote_CataractOperativeDevices']) ? $data['OphTrOperationnote_CataractOperativeDevices'] : array()); }