Here's my function:
function addr($dfcode)
{
return sql::results("select
A.CODE_,
case when b.id is null then a.ADDRESS1 else b.addr1 as Address1,
case when b.id is null then a.ADDRESS2 else b.addr2 as Address2,
case when b.id is null then a.CITY else b.city as City,
case when b.id is null then a.STATE_ else b.state as State,
case when b.id is null then a.ZIP else b.zip as Zip,
case when b.id is null then a.PHONE else b.phone as Phone,
case when b.id is null then a.FAX else b.fax as Fax
from ARE.ADS.DFE a
left outer join (
select
*
from ent.dbo.patient_data a
inner join ent.dbo.doctor_alt_address b on a.doctor_address_id = b.id
where a.CODE_ =" . $this->patient->hex . "
and b.doctor_id =" . hexstr($dfcode) . "
)b on a.CODE_ = b.doctor_id
where a.CODE_=" . hexstr($dfcode));
}
I need to array merge the above function into the foreach loop. I'm uncertain on how to do this and i'm really new to array_merge. Below i'm pulling all the doctors information that i need to build a form.
Above is a case where the doctor has an alternate address and that needs to be used if in the array merge if a.doctor_address_id = b.id from the criteria above.
$p->customForm()->log_creation($docname);
$doctor = new \CRM\Doctor($p->customForm()->dfcode($docname));
foreach ($doctor->getVars() as $k => $v)
{
$data['doctor_'. $k] = $v;
}
foreach ($patient->get_data() as $k=>$v)
{
if (is_string($v) || is_numeric($v))
$data["patient_" . $k] = strtoupper($v);
}
I hope it's not to confusing, any help would be really appreciated. I hope it's not to vague either. Thank you.
var_dump for $data
Array
(
[employee] => person
[date] => 05/08/2013
[datetime] => 05/08/2013 9:41:15 AM
[department] => stuff
[employee_ext] => 7457
[employee_email] =>
[barcode] => *NZS01*
[doctor_df_code] => 09HQ
[doctor_npi] => 1111111111
[doctor_dea] => B4574
[doctor_upin] =>
[doctor_license] =>
[doctor_phone] => (111)111-1111
[doctor_fax] => (000)000-0000
[doctor_fname] => UNDEFINED
[doctor_lname] => UNDEFINED
[doctor_title] =>
[doctor_intake_rx_caller_id] =>
[doctor_costco_rx_caller_id] =>
[doctor_reorder_rx_caller_id] =>
[doctor_address1] => 24 CABELL st
[doctor_address2] => SUITE 10
[doctor_city] => places
[doctor_state] => CA
[doctor_zip] => 91111
[doctor_active_events] =>
[doctor_dont_call] => 0
[doctor_dont_fax] => 1
)
Here's the print var for addr()
Array
(
[0] => Array
(
[CODE_] => 09HQ
[doctor_address1] => alternate addy
[doctor_address2] => 45854
[doctor_city] => different city
[doctor_state] => CA
[doctor_zip] => 963545
[doctor_phone] => (619)111-2548
[doctor_fax] => (157)123-4569
)
)
if there is an alternate address i need to overwrite it with the array merge addr()