Skip to content

Instantly share code, notes, and snippets.

@bradymiller
Created November 16, 2010 10:29
Show Gist options
  • Save bradymiller/701667 to your computer and use it in GitHub Desktop.
Save bradymiller/701667 to your computer and use it in GitHub Desktop.
Clinical Decisions Functions
// Display the clinical summary widget.
// Parameters:
// $patient_id - pid of selected patient
// $dateTarget - target date. If blank then will test with current date as target.
function clinical_summary_widget($patient_id,$dateTarget='')
// Test the clinic rules of entire clinic
// Parameters:
// $provider - id of a selected provider. If blank, then will test entire clinic.
// $type - rule filter (active_alert,passive_alert,cqm). If blank then will test all rules.
// $dateTarget - target date. If blank then will test with current date as target.
// Return:
// Returns a two-dimensional array of results
function test_rules_clinic($provider='',$type='',$dateTarget='')
// Test the clinic rules on a selected patient
// Parameters:
// $patient_id - pid of selected patient.
// $type - rule filter (active_alert,passive_alert,cqm)
// $dateTarget - target date. If blank then will test with current date as target.
// Return:
// Returns a array of actions
function test_rules_patient($patient_id,$type='',$dateTarget='')
// Test filter of a selected rule on a selected patient
// Parameters:
// $patient_id - pid of selected patient.
// $rule - id(string) of selected rule
// $dateTarget - target date.
// Return:
// boolean (if pass filter then true, otherwise false)
function test_filter($patient_id,$rule,$dateTarget)
// Return the number of target groups of a selected rule
// Parameters:
// $rule - id(string) of rule
// Return:
// integer, number of target groups associated with rule
function numberTargetGroups($rule)
// Test targets of a selected rule on a selected patient
// Parameters:
// $patient_id - pid of selected patient.
// $rule - id(string) of selected rule (if blank, then will ignore grouping)
// $group_id - group id of target group
// $dateTarget - target date.
// Return:
// boolean (if target passes then true, otherwise false)
function test_targets($patient_id,$rule,$group_id='',$dateTarget)
// Function to return active rules
// Parameters:
// $type - rule filter (active_alert,passive_alert,cqm)
// Return: array containing rules
function resolve_rules_sql($type='')
// Function to return applicable filters
// Parameters:
// $rule - id(string) of selected rule
// $filter_method - string label of filter type
// $include_flag - to allow selection for included or excluded filters
// Return: array containing filters
function resolve_filter_sql($rule,$filter_method,$include_flag=1)
// Function to return applicable targets
// Parameters:
// $rule - id(string) of selected rule
// $group_id - group id of target group (if blank, then will ignore grouping)
// $target_method - string label of target type
// $include_flag - to allow selection for included or excluded targets
// Return: array containing targets
function resolve_target_sql($rule,$group_id='',$target_method,$include_flag=1)
// Function to return applicable actions
// Parameters:
// $rule - id(string) of selected rule
// $group_id - group id of target group (if blank, then will ignore grouping)
// Return: array containing actions
function resolve_action_sql($rule,$group_id='')
// Function to check database filters and targets
// Parameters:
// $patient_id - pid of selected patient.
// $filter - array containing filter/target elements
// $interval - used for the interval elements
// $dateTarget - target date. blank is current date.
// Return: boolean if check passed, otherwise false
function database_check($patient_id,$filter,$interval='',$dateTarget='')
// Function to check diagnosis filters and targets
// Parameters:
// $patient_id - pid of selected patient.
// $filter - array containing diagnosis filter/target elements
// $dateTarget - target date. blank is current date.
// Return: boolean if check passed, otherwise false
function diagnosis_check($patient_id,$filter,$dateTarget)
// Function to check for existance of data in database for a patient
// Parameters:
// $patient_id - pid of selected patient.
// $table - selected mysql table
// $column - selected mysql column
// $data - selected data in the mysql database
// $min_items - mininum number of times the data element is recorded
// $intervalType - type of interval (ie. rule_interval_year)
// $intervalValue - searched for within this many times of the interval type
// $dateTarget - target date.
// Return: boolean if check passed, otherwise false
function exist_database_item($patient_id,$table,$column,$data,$min_items,$intervalType='',$intervalValue='',$dateTarget)
// Function to check for existance of data for a patient in the rule_patient_data table
// Parameters:
// $patient_id - pid of selected patient.
// $category - label in category column
// $item - label in item column
// $complete - label in complete column
// $min_items - mininum number of times the data element is recorded
// $intervalType - type of interval (ie. rule_interval_year)
// $intervalValue - searched for within this many times of the interval type
// $dateTarget - target date.
// Return: boolean if check passed, otherwise false
function exist_custom_item($patient_id,$category,$item,$complete,$min_items,$intervalType='',$intervalValue='',$dateTarget)
// Function to check for existance of data for a patient in lifestyle section
// Parameters:
// $patient_id - pid of selected patient.
// $lifestyle - selected label of mysql column of patient history
// $status - specific status of selected lifestyle element
// $dateTarget - target date. blank is current date.
// Return: boolean if check passed, otherwise false
function exist_lifestyle_item($patient_id,$lifestyle,$status,$dateTarget))
// Function to check for diagnosis of a patient
// Parameters:
// $patient_id - pid of selected patient.
// $code_type - code type (ie. ICD9)
// $diagnosis - diagnosis code or label
// $dateTarget - target date. blank is current date.
// Return: boolean if check passed, otherwise false
function exist_diagnosis_item($patient_id,$code_type,$diagnosis,$dateTarget)
// Function to return part of sql query to deal with interval
// Parameters:
// $table - selected mysql table
// $intervalType - type of interval (ie. rule_interval_year)
// $intervalValue - searched for within this many times of the interval type
// $dateTarget - target date.
// Return: string containing pertinent date interval filter for mysql query
function sql_interval_string($table,$intervalType,$intervalValue,$dateTarget)
// Function to collect generic column labels from tables.
// It currently works for date and pid.
// Will need to expand this as algorithm grows.
// Parameters:
// $label - element (pid or date)
// $table - selected mysql table
// Return: string containing official label of selected element
function collect_database_label($label,$table)
// Simple function to avoid processing of duplicate actions
// Parameters:
// $actions - 2-dimensional array with all current active targets
// $action - array of selected target to test for duplicate
// Return: boolean, true if duplicate, false if not duplicate
function is_duplicate_action($actions,$action)
// Function to find age in years (with decimal) on the target date
// Parameters:
// $dob - date of birth
// $target - date to calculate age on
// Return: decimal, years(decimal) from dob to target(date)
function convertDobtoAgeYearDecimal($dob,$target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment