Skip to content

Commit

Permalink
Openemr mu2 - cqm revisions, take 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Saravanan Rathinakumar authored and bradymiller committed Jun 28, 2016
1 parent b63b0da commit 5be4cd7
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 24 deletions.
2 changes: 2 additions & 0 deletions custom/qrda_category1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

$qrda_file_path = $GLOBALS['OE_SITE_DIR'] . "/documents/cqm_qrda/";

$EncounterCptCodes = array('ophthalmological_services' => '92002');

function getCombinePatients($dataSheet, $reportID) {
foreach( $dataSheet as $singleDataSheet ) {
//var_dump($singleDataSheet['cqm_nqf_code'],$singleDataSheet['init_patients']);
Expand Down
54 changes: 52 additions & 2 deletions custom/qrda_category1_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ function getQRDACat1PatientData($xml, $patient_id){
//Procedures
getAllProcedures($xml, $patient_id);

//Lab Tests
getAllLabTests($xml, $patient_id);

//Interventions
getAllInterventionProcedures($xml,$patient_id);

Expand Down Expand Up @@ -612,6 +615,51 @@ function getAllProcedures($xml, $patient_id){
}
}

function getAllLabTests($xml, $patient_id){
global $encCheckUniqId, $from_date, $to_date;
$procArr = allProcPat("laboratory_test", $patient_id, $from_date, $to_date);
foreach($procArr as $procRow){
$vset = sqlQuery("select * from valueset where code = ? and nqf_code = ? ",array($procRow['procedure_code'],$xml->nqf_code));
if(!empty($vset['valueset'])){
//Entry open
$xml->open_entry();

//procedure Open
$xml->open_customTag('procedure', array('classCode'=>'PROC', 'moodCode'=>'EVN'));

$tempID = "2.16.840.1.113883.10.20.24.3.38";
$xml->self_templateid($tempID);

//$refID = getUuid();
$refID = $encCheckUniqId[$procRow['encounter']];
$xml->self_customId($refID);


$arr = array('code'=>$procRow['procedure_code'], 'codeSystem'=> $vset['code_system'],'sdtc:valueSet' => $vset['valueset']);
//code Open
$xml->open_customTag('code', $arr);
$xml->element('originalText', $procRow['procedure_name']);
//code Close
$xml->close_customTag();

$xml->element('text', $procRow['procedure_name']);

$arr = array('code'=>'completed');
$xml->self_customTag('statusCode', $arr);

$timeArr = array('low'=>date('Ymdhis', strtotime($procRow['date_ordered'])), 'high'=>date('Ymdhis', strtotime($procRow['date_ordered'])));
$xml->add_entryEffectTimeQRDA($timeArr);

//procedure Close
$xml->close_customTag();

//Entry close
$xml->close_entry();
}
}
}


function getAllInterventionProcedures($xml, $patient_id){
global $encCheckUniqId, $from_date, $to_date;
$procArr = allProcPat("intervention", $patient_id, $from_date, $to_date);
Expand Down Expand Up @@ -924,12 +972,14 @@ function getAllMedicalProbs($xml, $patient_id){

//Encounters function
function getAllPatientEncounters($xml, $patient_id){
global $encCheckUniqId, $from_date, $to_date;
global $encCheckUniqId, $from_date, $to_date,$EncounterCptCodes;
$encArr = allEncPat($patient_id, $from_date, $to_date);

foreach($encArr as $encRow){

$encRow['encounter'];
$cpt_code = $EncounterCptCodes[str_replace(' ','_',strtolower($encRow['pc_catname']))];
$cpt_code = empty($cpt_code) ? '99201' : $cpt_code;
$vset = sqlStatement("select * from valueset where code = ? and nqf_code = ?",array('99201',$xml->nqf_code));
foreach ($vset as $v){
//Entry open
Expand All @@ -949,7 +999,7 @@ function getAllPatientEncounters($xml, $patient_id){
$encCheckUniqId[$encRow['encounter']] = $refID;


$arr = array('code'=>'99201', 'codeSystem'=>$v['code_system'],'sdtc:valueSet' => $v['valueset']);
$arr = array('code'=>$cpt_code, 'codeSystem'=>$v['code_system'],'sdtc:valueSet' => $v['valueset']);
$xml->self_codeCustom($arr);

$arr = array('code'=>'completed');
Expand Down
2 changes: 1 addition & 1 deletion custom/qrda_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function payerPatient($patient_id){

function allEncPat($patient_id, $from_date, $to_date){
$encArr = array();
$patQry = "SELECT encounter, date,pc_catid FROM form_encounter WHERE pid = ? AND (DATE(date) BETWEEN ? AND ?)";
$patQry = "SELECT fe.encounter, fe.date,fe.pc_catid,opc.pc_catname FROM form_encounter fe inner join openemr_postcalendar_categories opc on opc.pc_catid = fe.pc_catid WHERE fe.pid = ? AND (DATE(fe.date) BETWEEN ? AND ?)";
$patRes = sqlStatement($patQry, array($patient_id, $from_date, $to_date));
while( $patRow = sqlFetchArray($patRes ) ){
$encArr[] = $patRow;
Expand Down
1 change: 1 addition & 0 deletions library/classes/ClinicalTypes/Encounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Encounter extends ClinicalType
const ENC_NURS_DISCHARGE = 'enc_nurs_discharge'; // encounter nursing discharge
const ENC_NONAC_INP_OUT_OR_OPTH = 'enc_nonac_inp_out_or_opth'; // encounter non-acute inpt, outpatient, or ophthalmology
const ENC_INFLUENZA = 'enc_influenza';
const ENC_OPHTHAL = 'enc_ophthal_serv';

public static function getEncounterTypes()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function test( CqmPatient $patient, $beginDate, $endDate )

if ( $patient->calculateAgeOnDate( $beginDate ) >= 18 &&
( Helper::check( ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate, $endDate, $twoEncounters ) ||
Helper::check( ClinicalType::ENCOUNTER, Encounter::ENC_OPHTHAL, $patient, $beginDate, $endDate, $twoEncounters ) ||
Helper::check( ClinicalType::ENCOUNTER, Encounter::ENC_HEA_AND_BEH, $patient, $beginDate, $endDate, $twoEncounters ) ||
Helper::check( ClinicalType::ENCOUNTER, Encounter::ENC_OCC_THER, $patient, $beginDate, $endDate, $twoEncounters ) ||
Helper::check( ClinicalType::ENCOUNTER, Encounter::ENC_PSYCH_AND_PSYCH, $patient, $beginDate, $endDate, $twoEncounters ) ||
Expand Down
92 changes: 92 additions & 0 deletions sql/4_2_2-to-4_3_1_upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ CREATE TABLE `valueset` (

-- updating nqf code for cqm measure blood pressure
UPDATE `clinical_rules` set `cqm_nqf_code` = '0018' where `id` = 'rule_htn_bp_measure_cqm';

--

#IfMissingColumn immunizations information_source
Expand Down Expand Up @@ -559,3 +560,94 @@ INSERT INTO `list_options` ( `list_id`, `option_id`, `title`, `seq`, `is_default
UPDATE `list_options` SET codes='NCI-CONCEPT-ID:C38216' WHERE list_id='drug_route' and title='Inhale';
#EndIf

#IfNotRow openemr_postcalendar_categories pc_catname Ophthalmological Services
SET @catid = (SELECT MAX(pc_catid) FROM openemr_postcalendar_categories);
INSERT INTO `openemr_postcalendar_categories` VALUES (@catid+1, 'Ophthalmological Services', '#F89219', 'Ophthalmological Services', 0, NULL, 'a:5:{s:17:"event_repeat_freq";s:1:"0";s:22:"event_repeat_freq_type";s:1:"0";s:19:"event_repeat_on_num";s:1:"1";s:19:"event_repeat_on_day";s:1:"0";s:20:"event_repeat_on_freq";s:1:"0";}', 0, 900, 0, 0, 0, 0, 0,0,1,@catid+1);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_ophthal_serv', @catid+1);
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_hea_and_beh main_cat_id 5
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_hea_and_beh' and main_cat_id = 5;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_hea_and_beh main_cat_id 9
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_hea_and_beh' and main_cat_id = 9;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_hea_and_beh main_cat_id 10
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_hea_and_beh' and main_cat_id = 10;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_18_older main_cat_id 5
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_18_older' and main_cat_id = 5;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_18_older main_cat_id 9
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_18_older' and main_cat_id = 9;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_18_older main_cat_id 10
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_18_older' and main_cat_id = 10;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_40_older main_cat_id 5
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_40_older' and main_cat_id = 5;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_40_older main_cat_id 9
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_40_older' and main_cat_id = 9;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_ser_40_older main_cat_id 10
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_ser_40_older' and main_cat_id = 10;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_ind_counsel main_cat_id 5
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_ind_counsel' and main_cat_id = 5;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_ind_counsel main_cat_id 9
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_ind_counsel' and main_cat_id = 9;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_ind_counsel main_cat_id 10
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_ind_counsel' and main_cat_id = 10;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_group_counsel main_cat_id 5
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_group_counsel' and main_cat_id = 5;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_group_counsel main_cat_id 9
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_group_counsel' and main_cat_id = 9;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_group_counsel main_cat_id 10
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_group_counsel' and main_cat_id = 10;
#EndIf


#IfRow2D enc_category_map rule_enc_id enc_pre_med_other_serv main_cat_id 5
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_other_serv' and main_cat_id = 5;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_other_serv main_cat_id 9
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_other_serv' and main_cat_id = 9;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pre_med_other_serv main_cat_id 10
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pre_med_other_serv' and main_cat_id = 10;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pregnancy main_cat_id 5
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pregnancy' and main_cat_id = 5;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pregnancy main_cat_id 9
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pregnancy' and main_cat_id = 9;
#EndIf

#IfRow2D enc_category_map rule_enc_id enc_pregnancy main_cat_id 10
DELETE FROM `enc_category_map` where rule_enc_id = 'enc_pregnancy' and main_cat_id = 10;
#EndIf

23 changes: 2 additions & 21 deletions sql/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1129,42 +1129,21 @@ INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_nur
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_off_vis', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_off_vis', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_off_vis', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_hea_and_beh', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_hea_and_beh', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_hea_and_beh', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_hea_and_beh', 12);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_occ_ther', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_occ_ther', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_occ_ther', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_psych_and_psych', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_psych_and_psych', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_psych_and_psych', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_18_older', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_18_older', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_18_older', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_18_older', 13);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_40_older', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_40_older', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_40_older', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_ser_40_older', 13);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_ind_counsel', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_ind_counsel', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_ind_counsel', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_ind_counsel', 13);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_group_counsel', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_group_counsel', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_group_counsel', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_group_counsel', 13);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_other_serv', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_other_serv', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_other_serv', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pre_med_other_serv', 13);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_out_pcp_obgyn', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_out_pcp_obgyn', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_out_pcp_obgyn', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pregnancy', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pregnancy', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_pregnancy', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_nurs_discharge', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_nurs_discharge', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_nurs_discharge', 10);
Expand All @@ -1177,6 +1156,7 @@ INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_non
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_influenza', 5);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_influenza', 9);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_influenza', 10);
INSERT INTO `enc_category_map` ( `rule_enc_id`, `main_cat_id` ) VALUES ('enc_ophthal_serv', 14);


-- --------------------------------------------------------
Expand Down Expand Up @@ -4937,6 +4917,7 @@ INSERT INTO `openemr_postcalendar_categories` VALUES (11,'Reserved','#FF7777','R
INSERT INTO `openemr_postcalendar_categories` VALUES (12, 'Health and Behavioral Assessment', '#C7C7C7', 'Health and Behavioral Assessment', 0, NULL, 'a:5:{s:17:"event_repeat_freq";s:1:"0";s:22:"event_repeat_freq_type";s:1:"0";s:19:"event_repeat_on_num";s:1:"1";s:19:"event_repeat_on_day";s:1:"0";s:20:"event_repeat_on_freq";s:1:"0";}', 0, 900, 0, 0, 0, 0, 0,0,1,12);
INSERT INTO `openemr_postcalendar_categories` VALUES (13, 'Preventive Care Services', '#CCCCFF', 'Preventive Care Services', 0, NULL, 'a:5:{s:17:"event_repeat_freq";s:1:"0";s:22:"event_repeat_freq_type";s:1:"0";s:19:"event_repeat_on_num";s:1:"1";s:19:"event_repeat_on_day";s:1:"0";s:20:"event_repeat_on_freq";s:1:"0";}', 0, 900, 0, 0, 0, 0, 0,0,1,13);

INSERT INTO `openemr_postcalendar_categories` VALUES (14, 'Ophthalmological Services', '#F89219', 'Ophthalmological Services', 0, NULL, 'a:5:{s:17:"event_repeat_freq";s:1:"0";s:22:"event_repeat_freq_type";s:1:"0";s:19:"event_repeat_on_num";s:1:"1";s:19:"event_repeat_on_day";s:1:"0";s:20:"event_repeat_on_freq";s:1:"0";}', 0, 900, 0, 0, 0, 0, 0,0,1,14);
-- --------------------------------------------------------

--
Expand Down

0 comments on commit 5be4cd7

Please sign in to comment.