public function listInsurersAction() { $patientId = (int) $this->_getParam('patientId'); $rows = array(); $insurancePrograms = InsuranceProgram::getInsurancePrograms(); $insuredRelationship = new InsuredRelationship(); $insuredRelationshipIterator = $insuredRelationship->getIteratorByPersonId($patientId); $subscribers = array(); // TODO: get the actual subscribers; foreach ($insuredRelationshipIterator as $item) { $company = ''; $program = ''; if (isset($insurancePrograms[$item->insuranceProgramId])) { $exp = explode('->', $insurancePrograms[$item->insuranceProgramId]); $company = $exp[0]; $program = $exp[1]; } $subscriber = ''; if (isset($subscribers[$item->subscriberId])) { $subscriber = $subscribers[$item->subscriberId]; } $effectiveEnd = date('m/d/Y', strtotime($item->effectiveEnd)); $effective = 'Until'; $effectiveToTime = strtotime($effectiveEnd); if ($effectiveToTime <= strtotime(date('m/d/Y'))) { $effective = 'Ended'; } $effective .= ' ' . $effectiveEnd; $tmp = array(); $tmp['id'] = $item->insuredRelationshipId; $tmp['data'][] = $company; $tmp['data'][] = $program; $tmp['data'][] = $item->groupName; $tmp['data'][] = $item->groupNumber; $tmp['data'][] = $item->copay; $tmp['data'][] = $subscriber; $tmp['data'][] = $effective; $tmp['data'][] = $item->active ? __('Yes') : __('No'); $rows[] = $tmp; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows)); }
public function populateXML(SimpleXMLElement $xml = null, $checked = true) { if ($xml === null) { $xml = new SimpleXMLElement('<data/>'); } $personId = (int) $this->person_id; $person = $this->person; $picture = ''; if ($person->activePhoto > 0) { $attachment = new Attachment(); $attachment->attachmentId = (int) $person->activePhoto; $attachment->populate(); $picture = base64_encode($attachment->rawData); } $xmlPatient = $xml->addChild('patient'); $xmlPerson = $xmlPatient->addChild('person'); $this->_addChild($xmlPerson, 'picture', $picture, $checked); $this->_addChild($xmlPerson, 'lastName', $person->lastName, $checked); $this->_addChild($xmlPerson, 'firstName', $person->firstName, $checked); $this->_addChild($xmlPerson, 'middleName', $person->middleName, $checked); $identifier = ''; if ($person->identifierType == 'SSN') { $identifier = $person->identifier; } $this->_addChild($xmlPerson, 'identifier', $identifier, $checked); $this->_addChild($xmlPerson, 'gender', $person->gender, $checked); $dateOfBirth = explode(' ', date('m d Y', strtotime($person->dateOfBirth))); $this->_addChild($xmlPerson, 'dobMonth', $dateOfBirth[0], $checked); $this->_addChild($xmlPerson, 'dobDay', $dateOfBirth[1], $checked); $this->_addChild($xmlPerson, 'dobYear', $dateOfBirth[2], $checked); $statistics = PatientStatisticsDefinition::getPatientStatistics($personId); $race = ''; if (isset($statistics['Race'])) { $race = $statistics['Race']; } else { if (isset($statistics['race'])) { $race = $statistics['race']; } } $this->_addChild($xmlPerson, 'race', $race, $checked); $maritalStatus = $person->maritalStatus ? $person->maritalStatus : 'Other'; $this->_addChild($xmlPerson, 'maritalStatus', $maritalStatus, $checked); $addresses = Address::listAddresses($personId); foreach ($addresses as $address) { switch ($address->type) { case Address::TYPE_MAIN: $type = 'mainAddress'; break; case Address::TYPE_SEC: $type = 'secondaryAddress'; break; case Address::TYPE_HOME: $type = 'homeAddress'; break; case Address::TYPE_EMPLOYER: $type = 'employerAddress'; break; case Address::TYPE_BILLING: $type = 'billingAddress'; break; case Address::TYPE_OTHER: default: $type = 'otherAddress'; break; } $xmlAddress = $xmlPatient->addChild($type); $this->_addChild($xmlAddress, 'line1', $address->line1, $checked); $this->_addChild($xmlAddress, 'city', $address->city, $checked); $this->_addChild($xmlAddress, 'state', $address->state, $checked); $this->_addChild($xmlAddress, 'zip', $address->postalCode, $checked); } $phoneNumbers = PhoneNumber::listPhoneNumbers($personId); foreach ($phoneNumbers as $phoneNumber) { switch ($phoneNumber->type) { case PhoneNumber::TYPE_HOME: $type = 'homePhone'; break; case PhoneNumber::TYPE_WORK: $type = 'workPhone'; break; case PhoneNumber::TYPE_BILLING: $type = 'billingPhone'; break; case PhoneNumber::TYPE_EMPLOYER: $type = 'employerPhone'; break; case PhoneNumber::TYPE_MOBILE: $type = 'mobilePhone'; break; case PhoneNumber::TYPE_EMERGENCY: $type = 'emergencyPhone'; break; case PhoneNumber::TYPE_FAX: $type = 'faxPhone'; break; case PhoneNumber::TYPE_HOME_EVE: $type = 'homeEvePhone'; break; case PhoneNumber::TYPE_HOME_DAY: $type = 'homeDayPhone'; break; case PhoneNumber::TYPE_BEEPER: $type = 'beeperPhone'; break; default: $type = 'otherPhone'; break; } $xmlPhone = $xmlPatient->addChild($type); $this->_addChild($xmlPhone, 'number', $phoneNumber->number, $checked); } if ($person->primaryPracticeId > 0) { $practice = new Practice(); $practice->practiceId = (int) $person->primaryPracticeId; $practice->populate(); $address = $practice->primaryAddress; $xmlPractice = $xmlPatient->addChild('practice'); $this->_addChild($xmlPractice, 'name', $practice->name, $checked); $xmlPrimaryAddress = $xmlPractice->addChild('primaryAddress'); $this->_addChild($xmlPrimaryAddress, 'line1', $address->line1, $checked); $this->_addChild($xmlPrimaryAddress, 'city', $address->city, $checked); $this->_addChild($xmlPrimaryAddress, 'state', $address->state, $checked); $this->_addChild($xmlPrimaryAddress, 'zip', $address->postalCode, $checked); $this->_addChild($xmlPractice, 'mainPhone', $practice->mainPhone->number, $checked); $this->_addChild($xmlPractice, 'faxNumber', $practice->fax->number, $checked); } $insuredRelationship = new InsuredRelationship(); $insuredRelationshipIterator = $insuredRelationship->getIteratorByPersonId($personId); $primary = null; $secondary = null; foreach ($insuredRelationshipIterator as $item) { if (!$item->active) { continue; } if ($primary === null) { $primary = $item; } else { if ($secondary === null) { $secondary = $item; } else { break; } } } $xmlPayer = $xmlPatient->addChild('payer'); if ($primary !== null) { $this->_addChild($xmlPayer, 'medicareNumber', $primary->insuranceProgram->payerIdentifier, $checked); } if ($secondary !== null) { $this->_addChild($xmlPayer, 'medicaidNumber', $secondary->insuranceProgram->payerIdentifier, $checked); } return $xml; }
public function populatePayers(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.9'); // <!-- Payers section template --> $code = $section->addChild('code'); $code->addAttribute('code', '48768-6'); $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1'); $section->addChild('title', 'Payers'); $rows = array(); $insurancePrograms = InsuranceProgram::getInsurancePrograms(); $insuredRelationship = new InsuredRelationship(); $insuredRelationshipIterator = $insuredRelationship->getIteratorByPersonId($this->_patientId); foreach ($insuredRelationshipIterator as $item) { $company = ''; $program = ''; if (isset($insurancePrograms[$item->insuranceProgramId])) { $exp = explode('->', $insurancePrograms[$item->insuranceProgramId]); $company = html_convert_entities($exp[0]); $program = html_convert_entities($exp[1]); } $rows[] = array('company' => $company, 'program' => $program, 'groupNumber' => html_convert_entities($item->groupNumber)); } $text = $section->addChild('text'); if ($rows) { $table = $text->addChild('table'); $thead = $table->addChild('thead'); $tr = $thead->addChild('tr'); $tr->addChild('th', 'Payer name'); $tr->addChild('th', 'Policy type / Coverage type'); $tr->addChild('th', 'Covered party ID'); $tr->addChild('th', 'Authorization(s)'); $tbody = $table->addChild('tbody'); foreach ($rows as $row) { $tr = $tbody->addChild('tr'); $tr->addChild('td', $row['company']); $tr->addChild('td', $row['program']); $tr->addChild('td', $row['groupNumber']); $tr->addChild('td', ''); } } }
public function defaultPatientHeaderAction() { $personId = (int) $this->_getParam('personId'); // e76f18cd-d388-4c53-b940-53cb81b80c5e $referenceId = $this->_getParam('referenceId'); $data = $this->_getAttachmentData($referenceId); $patient = new Patient(); $patient->personId = $personId; $patient->populate(); $person = $patient->person; $picture = ''; if ($person->activePhoto > 0) { $attachment = new Attachment(); $attachment->attachmentId = (int) $person->activePhoto; $attachment->populate(); $picture = base64_encode($attachment->rawData); } $xml = new SimpleXMLElement('<patientHeader/>'); $xmlPatient = $xml->addChild('patient'); $this->_addChild($xmlPatient, 'picture', $picture); $this->_addChild($xmlPatient, 'lastName', $person->lastName); $this->_addChild($xmlPatient, 'firstName', $person->firstName); $this->_addChild($xmlPatient, 'dateOfBirth', $person->dateOfBirth); $this->_addChild($xmlPatient, 'gender', $person->gender); $statistics = PatientStatisticsDefinition::getPatientStatistics($personId); $race = ''; if (isset($statistics['Race'])) { $race = $statistics['Race']; } else { if (isset($statistics['race'])) { $race = $statistics['race']; } } $this->_addChild($xmlPatient, 'race', $race); $this->_addChild($xmlPatient, 'maritalStatus', $person->displayMaritalStatus); $addresses = Address::listAddresses($personId); $phoneNumbers = PhoneNumber::listPhoneNumbers($personId); $address = null; 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]; } } } } } if ($address !== null) { $phone = ''; if (isset($phoneNumbers[PhoneNumber::TYPE_BILLING])) { $phone = $phoneNumbers[PhoneNumber::TYPE_BILLING]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_HOME])) { $phone = $phoneNumbers[PhoneNumber::TYPE_HOME]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_WORK])) { $phone = $phoneNumbers[PhoneNumber::TYPE_WORK]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_HOME_DAY])) { $phone = $phoneNumbers[PhoneNumber::TYPE_HOME_DAY]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_HOME_EVE])) { $phone = $phoneNumbers[PhoneNumber::TYPE_HOME_EVE]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_MOBILE])) { $phone = $phoneNumbers[PhoneNumber::TYPE_MOBILE]->number; } else { if (isset($phoneNumbers[PhoneNumber::TYPE_BEEPER])) { $phone = $phoneNumbers[PhoneNumber::TYPE_BEEPER]->number; } } } } } } } $this->_addChild($xmlPatient, 'billingLine1', $address->line1); $this->_addChild($xmlPatient, 'billingCity', $address->city); $this->_addChild($xmlPatient, 'billingState', $address->state); $this->_addChild($xmlPatient, 'billingZip', $address->postalCode); $this->_addChild($xmlPatient, 'phoneNumber', $phone); } if ($person->primaryPracticeId > 0) { $practice = new Practice(); $practice->practiceId = (int) $person->primaryPracticeId; $practice->populate(); $address = $practice->primaryAddress; $xmlPractice = $xml->addChild('practice'); $this->_addChild($xmlPractice, 'name', $practice->name); $this->_addChild($xmlPractice, 'primaryLine1', $address->line1); $this->_addChild($xmlPractice, 'primaryCity', $address->city); $this->_addChild($xmlPractice, 'primaryState', $address->state); $this->_addChild($xmlPractice, 'primaryZip', $address->postalCode); $this->_addChild($xmlPractice, 'mainPhone', $practice->mainPhone->number); $this->_addChild($xmlPractice, 'faxNumber', $practice->fax->number); } $insuredRelationship = new InsuredRelationship(); $insuredRelationshipIterator = $insuredRelationship->getIteratorByPersonId($personId); $primary = null; $secondary = null; foreach ($insuredRelationshipIterator as $item) { if (!$item->active) { continue; } if ($primary === null) { $primary = $item; } else { if ($secondary === null) { $secondary = $item; } else { break; } } } $xmlPayer = $xml->addChild('payer'); if ($primary !== null) { $this->_addChild($xmlPayer, 'primary', $primary->insuranceProgram->name); } if ($secondary !== null) { $this->_addChild($xmlPayer, 'secondary', $secondary->insuranceProgram->name); } /*$xmlGuarantor = $xml->addChild('guarantor'); $this->_addChild($xmlGuarantor,'lastName',''); $this->_addChild($xmlGuarantor,'firstName',''); $this->_addChild($xmlGuarantor,'dateOfBirth',''); $this->_addChild($xmlGuarantor,'phone','');*/ // get the current visit $xmlProvider = $xml->addChild('provider'); $lastName = ''; $firstName = ''; $dateOfBirth = ''; $phone = ''; $visit = new Visit(); $visit->populateLatestVisit($personId); if ($visit->visitId > 0) { $provider = new Provider(); $provider->personId = $visit->providerId; $provider->populate(); $person = $provider->person; $lastName = $person->lastName; $firstName = $person->firstName; $dateOfBirth = $person->dateOfBirth; $phone = $person->phoneNumber->number; } $this->_addChild($xmlProvider, 'lastName', $lastName); $this->_addChild($xmlProvider, 'firstName', $firstName); $this->_addChild($xmlProvider, 'dateOfBirth', $dateOfBirth); $this->_addChild($xmlProvider, 'phone', $phone); 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'); }