public function editBuildingAction() { $id = (int) $this->_getParam('id'); $enumerationId = (int) $this->_getParam('enumerationId'); $enumerationsClosure = new EnumerationsClosure(); $parentId = $enumerationsClosure->getParentById($enumerationId); $enumeration = new Enumeration(); $enumeration->enumerationId = $parentId; $enumeration->populate(); $orm = new Building(); if ($id > 0) { $orm->buildingId = $id; $orm->populate(); } $orm->practiceId = $enumeration->ormId; $form = new WebVista_Form(array('name' => 'edit-building')); $form->setAction(Zend_Registry::get('baseUrl') . 'facilities.raw/process-edit-building'); $form->loadORM($orm, 'Building'); $form->setWindow('windowEditBuildingId'); $this->view->form = $form; $this->view->enumerationId = $enumerationId; $this->view->statesList = Address::getStatesList(); $enumeration = new Enumeration(); $enumeration->guid = '22fb4e1e-a37a-4e7a-9dae-8e220ba939e8'; $enumeration->populateByGuid(); $enumerationClosure = new EnumerationClosure(); $descendants = $enumerationClosure->getAllDescendants($enumeration->enumerationId, 1, true); $facilityCodes = array('' => ''); foreach ($descendants as $descendant) { $facilityCodes[$descendant->key] = $descendant->key . ' : ' . $descendant->name; } $this->view->facilityCodes = $facilityCodes; $this->render('edit-building'); }
public function editBuildingAction() { $id = (int) $this->_getParam('id'); $enumerationId = (int) $this->_getParam('enumerationId'); $enumerationsClosure = new EnumerationsClosure(); $parentId = $enumerationsClosure->getParentById($enumerationId); $enumeration = new Enumeration(); $enumeration->enumerationId = $parentId; $enumeration->populate(); $orm = new Building(); if ($id > 0) { $orm->buildingId = $id; $orm->populate(); } $orm->practiceId = $enumeration->ormId; $form = new WebVista_Form(array('name' => 'edit-building')); $form->setAction(Zend_Registry::get('baseUrl') . 'facilities.raw/process-edit-building'); $form->loadORM($orm, 'Building'); $form->setWindow('windowEditBuildingId'); $this->view->form = $form; $this->view->enumerationId = $enumerationId; $this->render('edit-building'); }
protected function _populateScheduleEventRow(ScheduleEvent $event, array &$columnData, $colIndex) { $buildings = array(); $eventTimeStart = strtotime($event->start); $eventTimeEnd = strtotime($event->end); // get the starting index $tmpIndex = $colIndex; $color = $event->provider->color; if ($event->roomId > 0 && strlen($event->room->color) > 0) { $color = $event->room->color; } if (substr($color, 0, 1) != '#') { $color = '#' . $color; } if (!isset($buildings[$event->buildingId])) { $building = new Building(); $building->buildingId = $event->buildingId; $building->populate(); $buildings[$building->buildingId] = $building; } $columnData[$tmpIndex]['data'][0] = $event->title . ' - ' . $buildings[$event->buildingId]->displayName . $columnData[$tmpIndex]['data'][0]; while ($eventTimeStart < $eventTimeEnd) { $eventDateTimeStart = date('Y-m-d H:i:s', $eventTimeStart); //$eventTimeStart = strtotime('+'.self::FILTER_MINUTES_INTERVAL.' minutes',$eventTimeStart); $eventTimeStart += self::FILTER_MINUTES_INTERVAL * 60; $columnData[$tmpIndex]['style'] = 'background-color:' . $color . ';border-color:lightgrey;'; $columnData[$tmpIndex]['userdata']['title'] = $event->title . ' of ' . $event->provider->optionName . ' (' . $buildings[$event->buildingId]->displayName . ')'; $tmpIndex++; } }
protected function generateRegistry(SimpleXMLElement $xml) { $registry = $xml->addChild('registry'); $user = new User(); $user->personId = (int) $this->provider->personId; $user->populateWithPersonId(); $building = new Building(); $building->buildingId = $user->defaultBuildingId; $building->populate(); $practice = $building->practice; /* XML Element: <registry-name> * Description: The registry name. * Data Element: Registry Name * Valid Values: Registry Name * Data Type: char(100) * Required: yes */ $registry->addChild('registry-name', $practice->name); /* XML Element: <registry-id> * Description: Used to identify the registry. Use Registry's Corporate TIN number. * Data Element: Registry ID * Data Type: char(9) * Required: yes */ $registry->addChild('registry-id', $practice->identifier); /* XML Element: <submission-method> * Description: Submission Method: (A-F) * A = 12 months, 80%, 3 or more measures * B = 6 months, 80%, 3 or more measures * C = 12 months, 30 consecutive, measure group * E = 12 months, 80%, measure group * F = 6 months, 80%, measure group * 2010 * A = 12 months, 80%, 3 or more measures * B = 6 months, 80%, 3 or more measures * G = 12 months, 30 patients, measure group * H = 12 months, 80%, min. of 15 patients, measure group * I = 6 months, 80%, min. of 8 patients, measure group * Note: Limit one xml file to a single submission method * Data Element: Submission Method * Valid Values: A,B,C,E,F * (12 month reporting period = January 1, 2009 through December 31, 2009; 6 month reporting period = July 1, 2009 through December 31, 2009) * 2010 * A,B,G,H,I * (12 month reporting period = January 1, 2010 through December 31, 2010; 6 month reporting period = July 1, 2010 through December 31, 2010) * Data Type: char(1) * Required: yes */ $registry->addChild('submission-method', 'A'); return $registry; }
public function populateEncounters(SimpleXMLElement $xml) { $component = $xml->addChild('component'); $section = $component->addChild('section'); $templateId = $section->addChild('templateId'); $templateId->addAttribute('root', '2.16.840.1.113883.10.20.1.3'); // <!-- Encounters section template --> $code = $section->addChild('code'); $code->addAttribute('code', '46240-8'); $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1'); $section->addChild('title', 'Encounters'); if ($this->visit !== null) { $visitIterator = array($this->visit); } else { $visitIterator = new VisitIterator(); $visitIterator->setFilters(array('patientId' => $this->_patientId)); } $rows = array(); foreach ($visitIterator as $visit) { $building = new Building(); $building->buildingId = $visit->buildingId; $building->populate(); $appointment = new Appointment(); $appointment->appointmentId = $visit->appointmentId; $appointment->populate(); $rows[] = array('encounter' => html_convert_entities($appointment->title), 'location' => html_convert_entities($building->displayName), 'date' => date('M d, Y', strtotime($visit->dateOfTreatment))); } $text = $section->addChild('text'); if ($rows) { $table = $text->addChild('table'); $thead = $table->addChild('thead'); $tr = $thead->addChild('tr'); $tr->addChild('th', 'Encounter'); $tr->addChild('th', 'Location'); $tr->addChild('th', 'Date'); $tbody = $table->addChild('tbody'); foreach ($rows as $row) { $tr = $tbody->addChild('tr'); $tr->addChild('td', $row['encounter']); $tr->addChild('td', $row['location']); $tr->addChild('td', $row['date']); } } }
public static function getBuildingDefaultLocation($personId, $defaultLocationId = null) { // get default building given user's person id, if $defaultLocationId is defined then room is returned $user = new User(); $user->personId = $personId; $user->populateWithPersonId(); $user->populate(); $building = null; $room = null; if (strlen($user->preferences) > 0) { $xmlPreferences = new SimpleXMLElement($user->preferences); $room = new Room(); $room->roomId = (int) $xmlPreferences->currentLocation; if ($room->populate()) { $building = $room->building; } } if ($defaultLocationId === null) { if ($building === null) { $building = new Building(); $building->buildingId = (int) $user->defaultBuildingId; $building->populate(); } return $building; } else { if ($room === null) { $room = new Room(); $room->roomId = (int) $defaultLocationId; $room->populate(); } return $room; } }
public function setFilters(array $filters) { if (!is_array($filters) || empty($filters)) { throw new Exception(__('Invalid filters')); } $filtersArray = array(); foreach ($filters as $filter) { if (!class_exists($filter)) { $msg = __("Filter {$filter} does not exists"); throw new Exception($msg); } $class = new $filter(); if (!$class instanceof WebVista_Model_ORM) { $msg = __("Filter {$filter} is not an instance of WebVista_Model_ORM"); throw new Exception($msg); } $filtersArray[$filter] = $filter; } $this->_rows = array(); $enumeration = new Enumeration(); $enumeration->populateByUniqueName(self::ENUM_NAME); $enumerationClosure = new EnumerationClosure(); if (isset($filtersArray['Practice'])) { $practices = $enumerationClosure->getAllDescendants($enumeration->enumerationId, 1); foreach ($practices as $enumPractice) { if (!$enumPractice->ormId > 0 || $enumPractice->ormClass != 'Practice') { continue; } $practice = new Practice(); $practice->practiceId = $enumPractice->ormId; $practice->populate(); if (isset($filtersArray['Building'])) { $buildings = $enumerationClosure->getAllDescendants($enumPractice->enumerationId, 1); foreach ($buildings as $enumBuilding) { if (!$enumBuilding->ormId > 0 || $enumBuilding->ormClass != 'Building') { continue; } $building = new Building(); $building->buildingId = $enumBuilding->ormId; $building->populate(); if (isset($filtersArray['Room'])) { $rooms = $enumerationClosure->getAllDescendants($enumBuilding->enumerationId, 1); foreach ($rooms as $enumRoom) { if (!$enumRoom->ormId > 0 || $enumRoom->ormClass != 'Room') { continue; } $room = new Room(); $room->roomId = $enumRoom->ormId; $room->populate(); $this->_rows[] = array('Practice' => $practice, 'Building' => $building, 'Room' => $room); } } else { $this->_rows[] = array('Practice' => $practice, 'Building' => $building); } } } else { $this->_rows[] = $practice; } } } else { if (isset($filtersArray['Building'])) { $buildings = $enumerationClosure->getAllDescendants($enumPractice->enumerationId, 1); foreach ($buildings as $enumBuilding) { if (!$enumBuilding->ormId > 0 || $enumBuilding->ormClass != 'Building') { continue; } $building = new Building(); $building->buildingId = $enumBuilding->ormId; $building->populate(); if (isset($filtersArray['Room'])) { $rooms = $enumerationClosure->getAllDescendants($enumBuilding->enumerationId, 1); foreach ($rooms as $enumRoom) { if (!$enumRoom->ormId > 0 || $enumRoom->ormClass != 'Room') { continue; } $room = new Room(); $room->roomId = $enumRoom->ormId; $room->populate(); $this->_rows[] = array('Building' => $building, 'Room' => $room); } } else { $this->_rows[] = $building; } } } else { if (isset($filtersArray['Room'])) { $rooms = $enumerationClosure->getAllDescendants($enumBuilding->enumerationId, 1); foreach ($rooms as $enumRoom) { if (!$enumRoom->ormId > 0 || $enumRoom->ormClass != 'Room') { continue; } $room = new Room(); $room->roomId = $enumRoom->ormId; $room->populate(); $this->_rows[] = $room; } } } } return $this; }
protected function _getEvent($id) { static $buildings = array(); $scheduleEvent = new ScheduleEvent(); $scheduleEvent->scheduleEventId = $id; $data = array('data' => '', 'userdata' => '', 'buildingId' => ''); if ($scheduleEvent->populate()) { $buildingId = (int) $scheduleEvent->buildingId; if (!isset($buildings[$buildingId])) { $building = new Building(); $building->buildingId = $buildingId; $building->populate(); $buildingName = ''; if (strlen($building->name) > 0) { $buildingName = $building->practice->name . '->' . $building->name; } $buildings[$buildingId] = $buildingName; } $data['time'] = date('h:iA', strtotime($scheduleEvent->start)) . '-' . date('h:iA', strtotime($scheduleEvent->end)); $data['data'] = $data['time'] . '<br>' . $scheduleEvent->title . '<br>' . $buildings[$buildingId]; $data['title'] = $scheduleEvent->title; $data['userdata'] = (int) $scheduleEvent->scheduleEventId; $data['buildingId'] = $buildingId; } return $data; }
function listNotesAction() { $personId = 0; $personId = (int) $this->_getParam('personId'); $filter = $this->_getParam('filter'); $clinicalNoteIterator = new ClinicalNoteIterator(); $custom = $this->_getParam('custom'); if (count($custom) > 0) { $custom = $this->_getParam('custom'); $custom['personId'] = $personId; $clinicalNoteIterator->customView($custom); } else { $data = array(); $data['personId'] = $personId; if ($filter == 'byAuthoringPersonId') { $data['authoringPersonId'] = $this->_getParam('authoringPersonId'); } if ($filter == 'byDateRange') { $data['dateRange'] = $this->_getParam('dateRange'); } if ($filter == 'byCurrentPractice' || $filter == 'bySelectedVisit') { $visitId = (int) $this->_getParam('visitId'); $visit = new Visit(); $visit->visitId = $visitId; $visit->populate(); $building = new Building(); $building->buildingId = $visit->buildingId; $building->populate(); $data['locationId'] = $building->buildingId; $data['selectedVisit'] = date('Y-m-d', strtotime($visit->timestamp)); } if ($filter == 'byVisitPractice' || $filter == 'byVisitBuilding') { $practiceId = 0; $buildingId = 0; $identity = Zend_Auth::getInstance()->getIdentity(); $userId = $identity->userId; $user = new User(); $user->userId = $userId; $user->populate(); if (strlen($user->preferences) > 0) { $this->xmlPreferences = new SimpleXMLElement($user->preferences); $currentLocation = (string) $this->xmlPreferences->currentLocation; $locationId = (int) $currentLocation; if ($locationId > 0) { $room = new Room(); $room->roomId = $locationId; $room->populate(); $practiceId = $room->building->practiceId; $buildingId = $room->buildingId; } } $data['practiceId'] = $practiceId; $data['buildingId'] = $buildingId; } $clinicalNoteIterator->setFilter($filter, $data); } //trigger_error($cnSelect->__toString(),E_USER_NOTICE); //var_dump($db->query($cnSelect)->fetchAll());exit; $notes = array(); foreach ($clinicalNoteIterator as $note) { if ($note['eSignatureId'] > 0) { $img = 'sm-signed.png'; $alt = 'Signed'; } else { $img = 'sm-editproblem.png'; $alt = 'Editing'; } $icon = '<img src="' . Zend_Registry::get('baseUrl') . 'img/' . $img . '" alt="' . $alt . '" />'; $row = array(); $row['id'] = $note['clinicalNoteId']; $row['data'][] = ''; $row['data'][] = $icon . ' ' . date('Y-m-d', strtotime($note['dateTime'])); $row['data'][] = $note['noteTitle']; $row['data'][] = $note['last_name'] . ', ' . $note['first_name'] . ' ' . substr($note['middle_name'], 0, 1); $location = ''; $locationId = (int) $note['locationId']; if ($locationId > 0) { $location = Room::location($locationId); } $row['data'][] = $location; $row['data'][] = $row['id']; $row['data'][] = 0; $xml = simplexml_load_string($note['template']); $genericData = new GenericData(); $filters = array(); $filters['objectId'] = $note['clinicalNoteId']; $filters['objectClass'] = 'ClinicalNote'; $genericDataIterator = $genericData->getIteratorByFilters($filters); $firstData = false; $childIcon = '<img src="' . Zend_Registry::get('baseUrl') . 'img/leaf.gif" alt="-" />'; foreach ($genericDataIterator as $data) { if (!$firstData) { $firstData = true; //$row['id'] .= ':'.$data->revisionId; $row['data'][6] = $data->revisionId; continue; } $tmp = array(); $tmp['id'] = $data->revisionId; $tmp['data'][] = $data->objectId; // ''; $tmp['data'][] = ' ' . $childIcon . ' ' . date('Y-m-d', strtotime($data->dateTime)); $tmp['data'][] = $note['noteTitle']; $tmp['data'][] = ''; // Author $tmp['data'][] = ''; // Location $tmp['data'][] = $note['clinicalNoteId']; $tmp['data'][] = $tmp['id']; $row['rows'][] = $tmp; } $notes[] = $row; } $acj = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $acj->suppressExit = true; $acj->direct(array("rows" => $notes)); }
function getLocationName() { if (!strlen($this->_locationName) > 0 && $this->buildingId > 0) { $building = new Building(); $building->buildingId = $this->buildingId; $building->populate(); $this->_locationName = $building->name; } return $this->_locationName; }
public function paymentReceiptAction() { // d96de46c-be90-45b0-b5f9-0b4abee76483 $referenceId = $this->_getParam('referenceId'); $personId = (int) $this->_getParam('personId'); $visitId = (int) $this->_getParam('visitId'); $data = $this->_getAttachmentData($referenceId); $patient = new Patient(); $patient->personId = $personId; if ($personId > 0) { $patient->populate(); } $person = $patient->person; $visit = new Visit(); $visit->visitId = $visitId; if ($visitId > 0) { $visit->populate(); } $practiceId = (int) $visit->practiceId; if (!$practiceId > 0) { $buildingId = (int) $visit->buildingId; if ($buildingId > 0) { $building = new Building(); $building->buildingId = $buildingId; $building->populate(); $practiceId = (int) $building->practiceId; } else { $roomId = (int) $visit->roomId; if ($roomId > 0) { $room = new Room(); $room->roomId = $roomId; $room->populate(); $practiceId = (int) $room->building->practiceId; } } } $practice = new Practice(); $practice->practiceId = $practiceId; if ($practiceId > 0) { $practice->populate(); } $primaryAddress = $practice->primaryAddress; $xml = new SimpleXMLElement('<data/>'); $xmlPractice = $xml->addChild('practice'); $this->_addChild($xmlPractice, 'name', $practice->name); $this->_addChild($xmlPractice, 'primaryLine1', $primaryAddress->line1); $primaryCityStateZip = $primaryAddress->city . ' ' . $primaryAddress->state . ' ' . $primaryAddress->postalCode; $this->_addChild($xmlPractice, 'primaryCityStateZip', $primaryCityStateZip); $this->_addChild($xmlPractice, 'mainPhone', $practice->mainPhone->number); $xmlPatient = $xml->addChild('patient'); $name = $person->firstName . ' ' . $person->middleName . ' ' . $person->lastName; $this->_addChild($xmlPatient, 'name', $name); $addresses = Address::listAddresses($personId); if (isset($addresses[Address::TYPE_BILLING])) { $address = $addresses[Address::TYPE_BILLING]; } else { if (isset($addresses[Address::TYPE_HOME])) { $address = $addresses[Address::TYPE_HOME]; } else { if (isset($addresses[Address::TYPE_MAIN])) { $address = $addresses[Address::TYPE_MAIN]; } else { if (isset($addresses[Address::TYPE_SEC])) { $address = $addresses[Address::TYPE_SEC]; } else { if (isset($addresses[Address::TYPE_OTHER])) { $address = $addresses[Address::TYPE_OTHER]; } else { $address = array_pop($addresses); } } } } } $billingCityStateZip = $address->city . ' ' . $address->state . ' ' . $address->postalCode; $this->_addChild($xmlPatient, 'billingLine1', $address->line1); $this->_addChild($xmlPatient, 'billingCityStateZip', $billingCityStateZip); $iterator = new PatientProcedureIterator(); $iterator->setFilters(array('visitId' => $visitId)); $procedures = array(); foreach ($iterator as $row) { $procedures[] = $row->code; } $iterator = new PatientDiagnosisIterator(); $iterator->setFilters(array('visitId' => $visitId)); $diagnoses = array(); foreach ($iterator as $row) { $diagnoses[] = $row->code; } $xmlNotes = $xmlPatient->addChild('notes'); $note = implode(',', $procedures) . " \t " . implode(',', $diagnoses) . " \t " . date('m/d/y', strtotime($visit->dateOfTreatment)); $this->_addChild($xmlNotes, 'note', $note); $today = date('Y-m-d'); $todaysTotal = 0; $iterator = new PaymentIterator(); $iterator->setFilters(array('visitId' => $visitId, 'company' => 'System', 'paymentDate' => $today)); $payments = array(); foreach ($iterator as $row) { $payments[] = $row; } $iterator->setFilters(array('personId' => $personId, 'unallocated' => true, 'paymentDate' => $today)); foreach ($iterator as $row) { $payments[] = $row; } foreach ($payments as $row) { $xmlPayment = $xmlPatient->addChild('payments'); $paymentDate = date('m/d/y', strtotime($row->paymentDate)); $this->_addChild($xmlPayment, 'date', $paymentDate); $this->_addChild($xmlPayment, 'description', $row->title . ' .... Thank You'); $this->_addChild($xmlPayment, 'method', $row->paymentType); $amount = (double) $row->amount; $todaysTotal += $amount; $this->_addChild($xmlPayment, 'amount', '-' . number_format($amount, 2)); $this->_addChild($xmlPayment, 'insurance', $row->insuranceDisplay); } $fees = $visit->calculateFees(); $previousBalance = $fees['total']; $this->_addChild($xmlPatient, 'previousBalance', number_format($previousBalance, 2)); $this->_addChild($xmlPatient, 'todaysTotal', '-' . number_format($todaysTotal, 2)); $totalDue = $previousBalance - $todaysTotal; $this->_addChild($xmlPatient, 'totalDue', number_format($totalDue, 2)); $totalDueFromPatient = $previousBalance; $this->_addChild($xmlPatient, 'totalDueFromPatient', number_format($totalDueFromPatient, 2)); try { $content = ReportBase::mergepdfset($xml, $data); $this->getResponse()->setHeader('Content-Type', 'application/pdf'); } catch (Exception $e) { $content = '<script>alert("' . $e->getMessage() . '")</script>'; } $this->view->content = $content; $this->render('binary-template'); }
protected function _populateCMS1500XML(SimpleXMLElement $xml, ClaimLine $claimLine) { $claimId = (int) $claimLine->claimId; $visitId = (int) $claimLine->visitId; $payerId = (int) $claimLine->insuranceProgramId; $visit = new Visit(); $visit->visitId = $visitId; $visit->populate(); $dateOfTreatment = $visit->dateOfTreatment; $patientId = (int) $visit->patientId; $providerId = (int) $visit->treatingPersonId; $insuranceProgram = new InsuranceProgram(); $insuranceProgram->insuranceProgramId = $payerId; $insuranceProgram->populate(); $insuranceAddress = $insuranceProgram->address; $insuredRelationship = InsuredRelationship::filterByPayerPersonIds($payerId, $patientId); $patient = new Patient(); $patient->personId = $patientId; $patient->populate(); $patientAddress = $patient->address; $patientPhone = $patient->phoneNumber; $provider = new Provider(); $provider->personId = $providerId; $provider->populate(); $providerAddress = $provider->person->address; $providerPhone = $provider->phoneNumber; $buildingId = (int) $visit->buildingId; $building = new Building(); $building->buildingId = $buildingId; $building->populate(); $address = $building->practice->primaryAddress; $amountTotal = 0; $claimLines = array(); $iterator = new ClaimLineIterator(); $iterator->setFilters(array('claimId' => $claimId)); foreach ($iterator as $orm) { $amount = (double) $orm->baseFee; $amountTotal += $amount; $row = array(); $row['procedure'] = $orm->procedureCode; $modifiers = array(); for ($i = 1; $i <= 4; $i++) { $field = 'modifier' . $i; $key = $orm->{$field}; if (strlen($key) > 0) { $modifiers[$i] = $key; } } $row['modifier'] = implode(',', $modifiers); $row['amount'] = $amount; $row['units'] = $orm->units; $diagnoses = array(); for ($i = 1; $i <= 8; $i++) { $field = 'diagnosisCode' . $i; $key = $orm->{$field}; if (strlen($key) > 0) { $diagnoses[$key] = $key; } } $row['diagnoses'] = $diagnoses; $row['diagnosis_pointer'] = ''; // TODO: need to resolve on the issue of multiple diagnoses per claimLine $claimLines[] = $row; } $amountPaid = $claimLine->paid; $netAmountTotal = $amountTotal - $amountPaid; if ($payerId > 0) { $xmlPayer = $xml->addChild('payer'); $this->_addChild($xmlPayer, 'name', InsuranceProgram::getInsuranceProgram($payerId)); if ($insuranceAddress->addressId > 0) { $xmlFbaddress = $xmlPayer->addChild('fbaddress'); $this->_addChild($xmlFbaddress, 'line1', $insuranceAddress->line1); $this->_addChild($xmlFbaddress, 'line2', $insuranceAddress->line2); $this->_addChild($xmlFbaddress, 'city', $insuranceAddress->city); $this->_addChild($xmlFbaddress, 'state', $insuranceAddress->state); $this->_addChild($xmlFbaddress, 'zip', $insuranceAddress->zipCode); } } $xmlPatient = $xml->addChild('patient'); $this->_addChild($xmlPatient, 'record_number', $patient->recordNumber); $this->_addChild($xmlPatient, 'last_name', $patient->lastName); $this->_addChild($xmlPatient, 'first_name', $patient->firstName); $this->_addChild($xmlPatient, 'middle_name', $patient->middleName); if ($patientAddress->addressId > 0) { $xmlFbaddress = $xmlPatient->addChild('fbaddress'); $this->_addChild($xmlFbaddress, 'line1', $patientAddress->line1); $this->_addChild($xmlFbaddress, 'line2', $patientAddress->line2); $this->_addChild($xmlFbaddress, 'city', $patientAddress->city); $this->_addChild($xmlFbaddress, 'state', $patientAddress->state); $this->_addChild($xmlFbaddress, 'zip', $patientAddress->zipCode); } $this->_addChild($xmlPatient, 'phone_number', $patientPhone->number); $this->_addChild($xmlPatient, 'date_of_birth', $patient->dateOfBirth); $subscriber = $insuredRelationship->subscriber; $subscriberAddress = $subscriber->address; if ($subscriber->personId > 0) { $xmlSubscriber = $xml->addChild('subscriber'); $this->_addChild($xmlSubscriber, 'phone_number', $subscriber->phoneNumber->number); if ($subscriberAddress->addressId > 0) { $xmlFbaddress = $xmlSubscriber->addChild('fbaddress'); $this->_addChild($xmlFbaddress, 'line1', $subscriberAddress->line1); $this->_addChild($xmlFbaddress, 'line2', $subscriberAddress->line2); $this->_addChild($xmlFbaddress, 'city', $subscriberAddress->city); $this->_addChild($xmlFbaddress, 'state', $subscriberAddress->state); $this->_addChild($xmlFbaddress, 'zip', $subscriberAddress->zipCode); } $this->_addChild($xmlSubscriber, 'last_name', $subscriber->lastName); $this->_addChild($xmlSubscriber, 'first_name', $subscriber->firstName); $this->_addChild($xmlSubscriber, 'middle_name', $subscriber->middleName); $this->_addChild($xmlSubscriber, 'group_number', $insuredRelationship->groupNumber); $this->_addChild($xmlSubscriber, 'gender', $subscriber->gender); $this->_addChild($xmlSubscriber, 'date_of_birth', $subscriber->dateOfBirth); } if ($building->buildingId > 0) { $xmlPractice = $xml->addChild('practice'); $this->_addChild($xmlPractice, 'identifier', $building->practice->identifier); $xmlTreatingFacility = $xml->addChild('treating_facility'); $this->_addChild($xmlTreatingFacility, 'identifier', $building->identifier); $this->_addChild($xmlTreatingFacility, 'name', $building->name); $xmlFbaddress = $xmlTreatingFacility->addChild('fbaddress'); $this->_addChild($xmlFbaddress, 'line1', $building->line1); $this->_addChild($xmlFbaddress, 'line2', $building->line2); $this->_addChild($xmlFbaddress, 'city', $building->city); $this->_addChild($xmlFbaddress, 'state', $building->state); $this->_addChild($xmlFbaddress, 'zip', $building->zipCode); } $xmlProvider = $xml->addChild('provider'); $this->_addChild($xmlProvider, 'identifier', $provider->identifier); $this->_addChild($xmlProvider, 'first_name', $provider->firstName); $this->_addChild($xmlProvider, 'last_name', $provider->lastName); if ($providerAddress->addressId > 0) { $xmlFbaddress = $xmlProvider->addChild('fbaddress'); $this->_addChild($xmlFbaddress, 'line1', $providerAddress->line1); $this->_addChild($xmlFbaddress, 'line2', $providerAddress->line2); $this->_addChild($xmlFbaddress, 'city', $providerAddress->city); $this->_addChild($xmlFbaddress, 'state', $providerAddress->state); $this->_addChild($xmlFbaddress, 'zip', $providerAddress->zipCode); } $xmlDiagnoses = null; foreach ($claimLines as $row) { foreach ($row['diagnoses'] as $diagnosis) { if ($xmlDiagnoses === null) { $xmlDiagnoses = $xml->addChild('diagnoses'); } $this->_addChild($xmlDiagnoses, 'array', $diagnosis); } } $xmlClaimLine = null; $dateOfService = date('m d y', strtotime($dateOfTreatment)); foreach ($claimLines as $row) { if ($xmlClaimLine === null) { $xmlClaimLine = $xml->addChild('claim_lines'); } // 0 - 5 ONLY $xmlClaimLineArr = $xmlClaimLine->addChild('array'); $this->_addChild($xmlClaimLineArr, 'date_of_treatment', $dateOfService); $this->_addChild($xmlClaimLineArr, 'procedure', $row['procedure']); $this->_addChild($xmlClaimLineArr, 'modifier', $row['modifier']); $this->_addChild($xmlClaimLineArr, 'diagnosis_pointer', $row['diagnosis_pointer']); $this->_addChild($xmlClaimLineArr, 'amount', $row['amount']); $this->_addChild($xmlClaimLineArr, 'units', $row['units']); } $xmlClaim = $xml->addChild('claim'); $this->_addChild($xmlClaim, 'amount_total', $amountTotal); $this->_addChild($xmlClaim, 'amount_paid', $amountPaid); $this->_addChild($xmlClaim, 'net_amount_total', $netAmountTotal); //$doc = new DOMDocument(); //$doc->formatOutput = true; //$doc->loadXML($xml->asXML()); //file_put_contents('/tmp/claims.xml',$doc->saveXML()); }