Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Care Opportunities: Prevention and ASCVD Risk Calculation. Exporting. #182

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ Homestead.json
/public/assets/js/web3-old.js
/public/assets/js/abi-decoder-old.js
/node_modules
.vscode
.DS_Store
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ USER www-data

# Install all PHP dependencies
RUN composer install --no-interaction
RUN composer update shihjay2/tcpdi-merger --no-interaction

USER root

Expand Down
34 changes: 18 additions & 16 deletions app/Http/Controllers/ChartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,19 +756,21 @@ public function care_opportunities(Request $request, $type)
$dropdown_array['items'] = $items;
$data['panel_dropdown'] = $this->dropdown_build($dropdown_array);
if ($type == 'prevention') {
$key = '48126e4e8ea3b83bc808850c713a5743';
$url = 'https://epssdata.ahrq.gov/';
$post = http_build_query([
$key = '48126e4e8ea3b83bc808850c713a5743'; //this is Dr. Chen's key DH
// $url = 'https://epssdata.ahrq.gov/'; //this may be an older url DH
$url = 'https://data.uspreventiveservicestaskforce.org/api/json'; //this is the one currently recommended on the uspstf web site DH
// $post = http_build_query([ //change from post to get DH
$get = http_build_query([
'key' => $key,
'age' => round($age, 0, PHP_ROUND_HALF_DOWN),
'sex' => $gender,
'pregnant' => ucfirst($row->pregnant),
'sexuallyActive' => $row->sexuallyactive,
'tobacco' => $row->tobacco
]);
$cr = curl_init($url);
curl_setopt($cr, CURLOPT_POST, 1);
curl_setopt($cr, CURLOPT_POSTFIELDS, $post);
$cr = curl_init($url . '?' . $get);
// curl_setopt($cr, CURLOPT_POST, 1); //not needed for get
// curl_setopt($cr, CURLOPT_POSTFIELDS, $post); //not needed for get
curl_setopt($cr, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cr, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$data1 = curl_exec($cr);
Expand Down Expand Up @@ -2205,7 +2207,7 @@ public function chart_action(Request $request, $table, $action, $id, $index)
$this->audit('Delete');

// $this->api_data('delete', 'rx_list', 'rxl_id', $old_rxl_id);
// UMA placeholder
// UMA (User-managed access) placeholder
$arr['message'] = trans('noshform.eie') . "!";
}
$arr['response'] = 'OK';
Expand Down Expand Up @@ -3076,7 +3078,7 @@ public function demographics(Request $request)
$return .= $this->header_build($header_arr, trans('noshform.contacts'));
foreach ($contact_arr as $key2 => $value2) {
if ($value2 !== '' && $value2 !== null) {
$return .= '<div class="row"><div class="col-md-3"><b>' . $key2 . '</b></div><div class="col-md-8">' . $value2 . '</div></div>';
$return .= '<div class="row"><div class="col-md-3"><b>' . $key2 . '</b></div><">' . $value2 . '</div></div>';
}
}
$return .= '</div></div></div>';
Expand All @@ -3090,7 +3092,7 @@ public function demographics(Request $request)
$return .= $this->header_build($header_arr, trans('noshform.other'));
foreach ($other_arr as $key4 => $value4) {
if ($value4 !== '' && $value4 !== null) {
$return .= '<div class="row"><div class="col-md-3"><b>' . $key4 . '</b></div><div class="col-md-8">' . $value4 . '</div></div>';
$return .= '<div class="row"><div class="col-md-3"><b>' . $key4 . '</b></div><">' . $value4 . '</div></div>';
}
}
$return .= '</div></div></div>';
Expand Down Expand Up @@ -3579,7 +3581,7 @@ public function encounter(Request $request, $eid, $section='s')
'standardpsych',
'standardpsych1'
];
$depreciated_array = [
$deprecated_array = [
'standardmedical',
'standardmedical1'
];
Expand Down Expand Up @@ -3635,8 +3637,8 @@ public function encounter(Request $request, $eid, $section='s')
}
if ($ros) {
$ros_val = $ros->ros;
// Convert depreciated encounter type to current
if (in_array($encounter->encounter_template, $depreciated_array)) {
// Convert deprecated encounter type to current
if (in_array($encounter->encounter_template, $deprecated_array)) {
$ros_arr = $this->array_ros();
foreach ($ros_arr as $ros_k => $ros_v) {
if ($ros->{$ros_k} !== '' && $ros->{$ros_k} !== null) {
Expand Down Expand Up @@ -3765,8 +3767,8 @@ public function encounter(Request $request, $eid, $section='s')
$pe = DB::table('pe')->where('eid', '=', $eid)->first();
if ($pe) {
$pe_val = $pe->pe;
// Convert depreciated encounter type to current
if (in_array($encounter->encounter_template, $depreciated_array)) {
// Convert deprecated encounter type to current
if (in_array($encounter->encounter_template, $deprecated_array)) {
$pe_arr = $this->array_pe();
foreach ($pe_arr as $pe_k => $pe_v) {
if ($pe->{$pe_k} !== '' && $pe->{$pe_k} !== null) {
Expand Down Expand Up @@ -4945,7 +4947,7 @@ public function encounter_details(Request $request, $eid)
$provider_arr = $this->array_providers();
$encounter_type_arr = $this->array_encounter_type();
if ($eid == '0') {
// Remove depreciated encounter types for new encounters
// Remove deprecated encounter types for new encounters
unset($encounter_type_arr['standardmedical']);
unset($encounter_type_arr['standardmedical1']);
}
Expand Down Expand Up @@ -9005,7 +9007,7 @@ public function social_history(Request $request)
$return .= $this->header_build($header_arr, trans('noshform.habits'));
foreach ($habits_arr as $key2 => $value2) {
if ($value2 !== '' && $value2 !== null) {
$return .= '<div class="col-md-3"><b>' . $key2 . '</b></div><div class="col-md-8">' . $value2 . '</div>';
$return .= '<div class="col-md-3"><b>' . $key2 . '</b></div><">' . $value2 . '</div>';
}
}
$return .= '</div></div></div>';
Expand Down
66 changes: 41 additions & 25 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1493,8 +1493,8 @@ protected function array_encounter_type()
'medical' => trans('noshform.medical_encounter'),
'phone' => trans('noshform.phone_encounter'),
'virtual' => trans('noshform.virtual_encounter'),
'standardmedical1' => 'Standard Medical Visit V2', // Depreciated
'standardmedical' => 'Standard Medical Visit V1', // Depreciated
'standardmedical1' => 'Standard Medical Visit V2', // deprecated
'standardmedical' => 'Standard Medical Visit V1', // deprecated
'standardpsych' => trans('noshform.standardpsych'),
'standardpsych1' => trans('noshform.standardpsych1'),
'clinicalsupport' => trans('noshform.clinicalsupport'),
Expand Down Expand Up @@ -2778,16 +2778,20 @@ protected function ascvd_calc()
if ($vitals->bp_systolic > 200) {
$sbp = '200';
} elseif ($vitals->bp_systolic < 90) {
$spb = '90';
$sbp = '90';
} else {
$spb = $vitals->bp_systolic;
$sbp = $vitals->bp_systolic;
}
}
$htn = false;
$chol = false;
$rx = DB::table('rx_list')->where('pid', '=', Session::get('pid'))->whereNull('rxl_date_inactive')->whereNull('rxl_date_old')->get();
if ($rx->count()) {
$htn_url = 'https://rxnav.nlm.nih.gov/REST/rxclass/classMembers.json?classId=N0000001616&relaSource=NDFRT&rela=may_treat';
// $htn_url = 'https://rxnav.nlm.nih.gov/REST/rxclass/classMembers.json?classId=N0000001616&relaSource=NDFRT&rela=may_treat';
// according to https://rxnav.nlm.nih.gov/RxClassIntro.html NDFRT was replaced with MEDRT in 2018. In addition MESH identifiers
// like D006973 for HTN replace the NDFRT ids like N0000001616
// JSON structure is the same.
$htn_url = 'https://rxnav.nlm.nih.gov/REST/rxclass/classMembers.json?classId=D006973&relaSource=MEDRT&rela=may_treat';
$htn_ch = curl_init();
curl_setopt($htn_ch,CURLOPT_URL, $htn_url);
curl_setopt($htn_ch,CURLOPT_FAILONERROR,1);
Expand All @@ -2801,28 +2805,36 @@ protected function ascvd_calc()
foreach ($htn_group['drugMemberGroup']['drugMember'] as $htn_item) {
$htn_arr[] = strtolower($htn_item['minConcept']['name']);
}
$chol_url = 'https://rxnav.nlm.nih.gov/REST/rxclass/classMembers.json?classId=N0000001592&relaSource=NDFRT&rela=may_treat';
$chol_ch = curl_init();
curl_setopt($chol_ch,CURLOPT_URL, $chol_url);
curl_setopt($chol_ch,CURLOPT_FAILONERROR,1);
curl_setopt($chol_ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($chol_ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($chol_ch,CURLOPT_TIMEOUT, 15);
$chol_json = curl_exec($chol_ch);
curl_close($chol_ch);
$chol_group = json_decode($chol_json, true);
$chol_arr = [];
foreach ($chol_group['drugMemberGroup']['drugMember'] as $chol_item) {
$chol_arr[] = strtolower($chol_item['minConcept']['name']);
}
// This hyperlipidemia Rx class search is replaced with a simple statin array on line 2825.
// Reason - 1) many meds which treat high cholesterol are not statins; 2) the list of statins
// is pretty short.
// $chol_url = 'https://rxnav.nlm.nih.gov/REST/rxclass/classMembers.json?classId=N0000001592&relaSource=NDFRT&rela=may_treat';
// Handy for drug - disease NDFRT - MEDRT code lookups: https://bioportal.bioontology.org/ontologies/NDFRT?p=classes&conceptid=N0000001580
// $chol_ch = curl_init();
// curl_setopt($chol_ch,CURLOPT_URL, $chol_url);
// curl_setopt($chol_ch,CURLOPT_FAILONERROR,1);
// curl_setopt($chol_ch,CURLOPT_FOLLOWLOCATION,1);
// curl_setopt($chol_ch,CURLOPT_RETURNTRANSFER,1);
// curl_setopt($chol_ch,CURLOPT_TIMEOUT, 15);
// $chol_json = curl_exec($chol_ch);
// curl_close($chol_ch);
// $chol_group = json_decode($chol_json, true);
// $chol_arr = [];
// foreach ($chol_group['drugMemberGroup']['drugMember'] as $chol_item) {
// $chol_arr[] = strtolower($chol_item['minConcept']['name']);
// }
$chol_arr = ['atorvastatin', 'fluvastatin', 'lovastatin', 'pitavastatin', 'pravastatin', 'rosuvastatin', 'simvastatin']; // DH
foreach ($rx as $rx_item) {
$rx_name = explode(' ', $rx_item->rxl_medication);
$rx_full_name = $rx_item->rxl_medication;
$rx_name = explode(' ', $rx_item->rxl_medication);
$rx_name_first = strtolower($rx_name[0]);
if (in_array($rx_name_first, $htn_arr)) {
$htn = true;
$htn = true; // ...where $htn means 'being treated for HTN => taking antihypertensive medicine'
}
if (in_array($rx_name_first, $chol_arr)) {
$chol = true;
foreach ($chol_arr as $ca) {
if (stripos($rx_full_name, $ca) !== false) { //don't use rx_name_first! Stripos is case insensitive.
$chol = true; // ...where $chol means 'taking a statin'
}
}
}
}
Expand Down Expand Up @@ -2860,6 +2872,7 @@ protected function ascvd_calc()
'age' => $age
];
$data_string = json_encode($data);
echo $data_string;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
Expand All @@ -2877,6 +2890,7 @@ protected function ascvd_calc()
$result_arr['message'] .= '<li>' . $missing_item . '</li>';
}
$result_arr['message'] .= '</ul></div>';
$result_arr['message'] .= '</ul></div>';
}
return $result_arr;
}
Expand Down Expand Up @@ -8044,7 +8058,7 @@ protected function form_practiceinfo($result, $table, $id, $subtype)
}
if ($subtype == 'settings') {
$encounter_type_arr = $this->array_encounter_type();
// Remove depreciated encounter types for new encounters
// Remove deprecated encounter types for new encounters
unset($encounter_type_arr['standardmedical']);
unset($encounter_type_arr['standardmedical1']);
$settings_arr = [
Expand Down Expand Up @@ -8919,8 +8933,9 @@ protected function form_rx_list($result, $table, $id, $subtype)
'selectpicker' => true,
'default_value' => $rx['label']
];
// DH Removed because it causes entry in rx_list
// Removed because it causes error in rx_list
// of 0000-00-00. With code commented out entry is null.
// which causes problems with the Conditions list.
// $items[] = [
// 'name' => 'rxl_date_inactive',
// 'type' => 'hidden',
Expand All @@ -8939,6 +8954,7 @@ protected function form_rx_list($result, $table, $id, $subtype)
];
// DH Removed because it causes entry in rx_list
// of 0000-00-00. With code commented out entry is null.
// Was causing problems with the Medications list.
// $items[] = [
// 'name' => 'rxl_date_old',
// 'type' => 'hidden',
Expand Down
Loading