$REDCAP_TOKEN,'content' => 'record','format' => 'json', 'type' => 'flat','records' => $RECORD,'events'=>array($EVENT)); # - - - - - - - - - - - - - - - - - - # # Curl Commands $exp = curl_init(); curl_setopt($exp, CURLOPT_URL, $API_URL); curl_setopt($exp, CURLOPT_POSTFIELDS, http_build_query($DATA, '', '&')); curl_setopt($exp, CURLOPT_RETURNTRANSFER, true); curl_setopt($exp, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($exp, CURLOPT_VERBOSE, 0); curl_setopt($exp, CURLOPT_FOLLOWLOCATION, true); curl_setopt($exp, CURLOPT_AUTOREFERER, true); curl_setopt($exp, CURLOPT_MAXREDIRS, 10); curl_setopt($exp, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($exp, CURLOPT_FRESH_CONNECT, 1); $output = curl_exec($exp); $list=json_decode($output, true); curl_close($exp); # $record_id=$list[0]['record_id']; $low_risk=$list[0]['clinic_risk_cat___0']; $pos_dep_risk=$list[0]['clinic_risk_cat___1']; $prevent_risk=$list[0]['clinic_risk_cat___2']; $sub_abuse_risk=$list[0]['clinic_risk_cat___3']; $dom_abuse_risk=$list[0]['clinic_risk_cat___4']; $sa_low_risk=$list[0]['clinic_risk_cat___5']; $last_name=$list[0]['last_name']; $letter_head=$CC_GLOBAL['letter_head'].$CC_GLOBAL['letter_1'].$last_name.$CC_GLOBAL['letter_2']; if($low_risk==1){ $letter_risk=$CC_GLOBAL['low_risk']; } else { $pd_letter=($pos_dep_risk==1)? $CC_GLOBAL['pos_dep_risk'] : ''; $prev_letter=($prevent_risk==1)? $CC_GLOBAL['prevent_risk'] : ''; $sa_letter=($sub_abuse_risk==1)? $CC_GLOBAL['sub_abuse_risk'] : ''; $da_letter=($dom_abuse_risk==1)? $CC_GLOBAL['dom_abuse_risk'] : ''; $low_sa_letter=($sa_low_risk==1)? $CC_GLOBAL['sa_low_risk'] : ''; if($pd_letter!=''){ $letter_risk="has ".$pd_letter; $letter_risk.=($low_sa_letter!='')? "; ".$low_sa_letter : ''; $letter_risk.=($sa_letter!='')? "; ".$sa_letter : ''; $letter_risk.=($da_letter!='')? "; ".$da_letter : ''; } else { if($prev_letter!=''){ $letter_risk="has ".$prev_letter; $letter_risk.=($low_sa_letter!='')? "; ".$low_sa_letter : ''; $letter_risk.=($sa_letter!='')? "; ".$sa_letter : ''; $letter_risk.=($da_letter!='')? "; ".$da_letter : ''; } else { if($low_sa_letter!=''){ $letter_risk="has ".$low_sa_letter; $letter_risk.=($sa_letter!='')? "; ".$sa_letter : ''; $letter_risk.=($da_letter!='')? "; ".$da_letter : ''; } else { if($sa_letter!=''){ $letter_risk="has ".$sa_letter; $letter_risk.=($da_letter!='')? "; ".$da_letter : ''; } else { if($da_letter!=''){ $letter_risk="has ".$da_letter; } } } } } } $letter_risk.=".\n\n"; $ccwl_outcome=$list[0]['ccwl_outcome']; if($ccwl_outcome==0){ $outcome_no_success_att=$list[0]['outcome_no_success_att']; $letter_worklog=$CC_GLOBAL['ccwl_0']."\nWe have made ".$outcome_no_success_att." attempts to contact the patient.\n".$CC_GLOBAL['ccwl_0_no_success']."\n"; } if($ccwl_outcome==1){ $contacted_ns=$list[0]['contacted_not_scheduled']; if($contacted_ns==0){ $letter_worklog=$CC_GLOBAL['ccwl_1']."\n".$CC_GLOBAL['ccwl_1_cns0']."\n".$CC_GLOBAL['ccwl_1_cont_screen']."\n"; } if($contacted_ns==1){ $pat_not_int_0=(($list[0]['pat_not_int___0'])==1)? 'The patient has a provider in the community' : ''; $pat_not_int_1=(($list[0]['pat_not_int___1'])==1)? 'The patient does not think she needs behavioral health services at this time.' : ''; $pat_not_int_2=(($list[0]['pat_not_int___2'])==1)? 'The patient is aware of the need for behavioral health services, but is not ready for or wanting these services at this time.' : ''; $pat_not_int_3=(($list[0]['pat_not_int___3'])==1)? 'The patient is concerned about child welfare or legal consequences if she seeks behavioral health care.' : ''; $pat_not_int_4=(($list[0]['pat_not_int___4'])==1)? 'The patient is concerned about her partner, family members or friends knowing and/or not approving of behavioral health services.' : ''; $pat_not_int_5=(($list[0]['pat_not_int___5'])==1)? $list[0]['pat_not_int_other'] : ''; $pat_not_int="The patient is not interested because: ".$pat_not_int_1." ".$pat_not_int_2." ".$pat_not_int_3." ".$pat_not_int_4." ".$pat_not_int_5."\n\n"; $letter_worklog=$CC_GLOBAL['ccwl_1']."\n".$CC_GLOBAL['ccwl_1_cns1']." ".$pat_not_int."\n".$CC_GLOBAL['ccwl_1_cont_screen']."\n"; } if($contacted_ns==2){ $int_un_0=(($list[0]['int_but_unable___0'])==1)? " - Work conflict\n" : ''; $int_un_1=(($list[0]['int_but_unable___1'])==1)? " - Difficulties with transportation\n" : ''; $int_un_2=(($list[0]['int_but_unable___2'])==1)? " - Childcare responsibilities\n" : ''; $int_un_3=(($list[0]['int_but_unable___3'])==1)? " - Inability to afford DTC\n" : ''; $int_un_4=(($list[0]['int_but_unable___4'])==1)? " - ".$list[0]['int_but_unable_other']."\n" : ''; $int_un=$int_un_0.$int_un_1.$int_un_2.$int_un_3.$int_un_4; $letter_worklog=$CC_GLOBAL['ccwl_1']."\n".$CC_GLOBAL['ccwl_1_cns2']."\n".$int_un."\n".$CC_GLOBAL['ccwl_1_cns2_cont']."\n"; } } if($ccwl_outcome==2){ if($list[0]['contacted_scheduled']==1){$contacted_scheduled='a home video visit.';} if($list[0]['contacted_scheduled']==2){$contacted_scheduled='a telemedicine appointment.';} if($list[0]['contacted_scheduled']==3){$contacted_scheduled='a scheduled in-person appointment.';} if($list[0]['contacted_scheduled']==4){$contacted_scheduled='our walk-in clinic.';} if($list[0]['contacted_scheduled']==''){$contacted_scheduled='';} $letter_worklog=$CC_GLOBAL['ccwl_2']." ".$contacted_scheduled."\n"; } if($ccwl_outcome==3){ $clinic_risk_cat_1=$list[0]['clinic_risk_cat___1']; if($clinic_risk_cat_1=='1'){ $contact_pd_1=(($list[0]['contacted_info_pd___1'])==1)? " - Moodivate app\n" : ''; $contact_pd_2=(($list[0]['contacted_info_pd___2'])==1)? " - Individual peer support\n" : ''; $contact_pd_3=(($list[0]['contacted_info_pd___3'])==1)? " - Online group peer support\n" : ''; $contact_pd_4=(($list[0]['contacted_info_pd___4'])==1)? " - In-person group peer support\n" : ''; $contact_pd_99=(($list[0]['contacted_info_pd___99'])==1)? " - ".$list[0]['contacted_info_pd_other']."\n" : ''; $contact_pd="Depression Support: \n".$contact_pd_1.$contact_pd_2.$contact_pd_3.$contact_pd_4.$contact_pd_99; } $clinic_risk_cat_3=$list[0]['clinic_risk_cat___3']; if($clinic_risk_cat_3==1){ $contact_sa_1=(($list[0]['contacted_info_sa___1'])==1)? " - Reset app\n" : ''; $contact_sa_2=(($list[0]['contacted_info_sa___2'])==1)? " - Reset O app\n" : ''; $contact_sa_3=(($list[0]['contacted_info_sa___3'])==1)? " - Online group peer support\n" : ''; $contact_sa_4=(($list[0]['contacted_info_sa___4'])==1)? " - Group peer support (NA/AA)\n" : ''; $contact_sa_5=(($list[0]['contacted_info_sa___5'])==1)? " - Individual peer support (FAVOR)\n" : ''; $contact_sa_99=(($list[0]['contacted_info_sa___99'])==1)? " - ".$list[0]['contacted_info_sa_other']."\n" : ''; $contact_sa="Substance Abuse Support: \n".$contact_sa_1.$contact_sa_2.$contact_sa_3.$contact_sa_4.$contact_sa_5.$contact_sa_99; } $con_sa=($contact_sa!='')? $contact_sa : ''; $con_pd=($contact_pd!='')? $contact_pd : ''; $letter_worklog=$CC_GLOBAL['ccwl_3']."\n".$con_pd.$con_sa."\n".$CC_GLOBAL['ccwl_3_con']."\n"; } if($ccwl_outcome==4){ $letter_worklog=$CC_GLOBAL['ccwl_4']."\n"; } if($ccwl_outcome==99){ $letter_worklog=$list[0]['outcome_other']."\n"; } $letter_bottom=$CC_GLOBAL['letter_bottom']; $letter_text=$letter_head.$letter_risk.$letter_worklog.$letter_bottom; # - - - - - - - - - - - - - - - - - - - - - - - - - # # E. Import Risk Category and Coded Values for # Text Messages: # - - - - - - - - - - - - - - - - - - - - - - - - - # $import_info=array('record_id'=>$RECORD,'redcap_event_name'=>$EVENT,'letter_text'=>$letter_text); $import=json_encode(array($import_info)); $DATA_IMPORT=array('token'=>$REDCAP_TOKEN,'content'=>'record', 'format'=>'json','type'=>'flat','data'=>$import); $imp = curl_init(); curl_setopt($imp, CURLOPT_URL, $API_URL); curl_setopt($imp, CURLOPT_POSTFIELDS, http_build_query($DATA_IMPORT, '', '&')); curl_setopt($imp, CURLOPT_RETURNTRANSFER, true); curl_setopt($imp, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($imp, CURLOPT_VERBOSE, 0); curl_setopt($imp, CURLOPT_FOLLOWLOCATION, true); curl_setopt($imp, CURLOPT_AUTOREFERER, true); curl_setopt($imp, CURLOPT_MAXREDIRS, 10); curl_setopt($imp, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($imp, CURLOPT_FRESH_CONNECT, 1); curl_exec($imp); curl_close($imp); ?>