3 * Utilities to support HCFA 1500 02/12 Version
4 * For details on format refer to:
5 * <http://www.nucc.org/index.php?option=com_content&view=article&id=186&Itemid=138>
7 * Copyright (C) 2013 Kevin Yeh <kevin.y@integralemr.com> and OEMR <www.oemr.org>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @author Kevin Yeh <kevin.y@integralemr.com>
22 * @link http://www.open-emr.org
27 * @return type Is the system configured to use the 02/12 version of the form
29 function hcfa_1500_version_02_12()
31 return $GLOBALS['cms_1500']=='1';
36 * Helper class to manage which rows and columns information belong in.
37 * This allows "out of order" creation of the content.
48 * @param type $row Which row to put this data on
49 * @param type $column Which column to put this data in
50 * @param type $width How many characters max to print on
51 * @param type $info The text to print on the form at the specified location
53 public function __construct($row,$column,$width,$info)
56 $this->column
=$column;
62 * Determine relative position of an element
64 * @return type integer
66 public function get_position()
68 return $this->row
*100+
$this->column
;
72 * Add the info to the form
76 // Override the default value for "strip" with put_hcfa to keep periods
77 put_hcfa($this->row
,$this->column
,$this->width
,$this->info
,'/#/');
82 * comparator function for hfca_info class to allow proper sorting
88 function cmp_hcfa_info($first,$second)
90 $first_value=$first->get_position();
91 $second_value=$second->get_position();
92 if($first_value==$second_value)
96 return $first_value<$second_value ?
-1 : 1;
100 * calculate where on the form a given diagnosis belongs and add it to the entries
102 * @param array $hcfa_entries
103 * @param type $number
106 function add_diagnosis(&$hcfa_entries,$number,$diag)
109 * The diagnoses go across the page.
115 $column_num = ($number%4
);
116 $row_num = (int)($number / 4);
118 // First column is at location 3, each column is 13 wide
119 $col_pos=3+
13*$column_num;
121 // First diagnosis row is 38
123 $diag = preg_replace($strip, '', strtoupper($diag));
124 $row_pos=38+
$row_num;
125 $hcfa_entries[]=new hcfa_info($row_pos,$col_pos,8,$diag);
131 * Process the diagnoses for a given claim. log any errors
136 function process_diagnoses_02_12(&$claim,&$log)
139 $hcfa_entries=array();
140 $diags = $claim->diagArray(false);
141 if($claim->diagtype
=='ICD10')
150 $hcfa_entries[]=new hcfa_info(37,42,1,$icd_indicator);
152 // Box 22. Medicaid Resubmission Code and Original Ref. No.
153 $hcfa_entries[]=new hcfa_info(38,50,10,$claim->medicaidResubmissionCode());
154 $hcfa_entries[]=new hcfa_info(38,62,10,$claim->medicaidOriginalReference());
156 // Box 23. Prior Authorization Number
157 $hcfa_entries[]=new hcfa_info(40,50,28,$claim->priorAuth());
160 foreach($diags as $diag)
164 add_diagnosis($hcfa_entries,$diag_count,$diag);
168 $log.= "***Too many diagnoses ".($diag_count+
1).":".$diag;
173 // Sort the entries to put them in the page base sequence.
174 usort($hcfa_entries,"cmp_hcfa_info");
176 foreach($hcfa_entries as $hcfa_entry)