forked from LibreHealthIO/lh-ehr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_hcfa_1500_02_12.inc.php
174 lines (154 loc) · 4.56 KB
/
gen_hcfa_1500_02_12.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/**
* Utilities to support HCFA 1500 02/12 Version
* For details on format refer to:
* <http://www.nucc.org/index.php?option=com_content&view=article&id=186&Itemid=138>
*
* Copyright (C) 2013 Kevin Yeh <[email protected]> and OEMR <www.oemr.org>
*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
*
* @package LibreHealth EHR
* @author Kevin Yeh <[email protected]>
* @link http://librehealth.io
*/
/**
*
* @return type Is the system configured to use the 02/12 version of the form
*/
function hcfa_1500_version_02_12()
{
return $GLOBALS['cms_1500']=='1';
}
/**
* Helper class to manage which rows and columns information belong in.
* This allows "out of order" creation of the content.
*/
class hcfa_info
{
protected $row;
protected $column;
protected $width;
protected $info;
/**
*
* @param type $row Which row to put this data on
* @param type $column Which column to put this data in
* @param type $width How many characters max to print on
* @param type $info The text to print on the form at the specified location
*/
public function __construct($row,$column,$width,$info)
{
$this->row=$row;
$this->column=$column;
$this->width=$width;
$this->info=$info;
}
/**
* Determine relative position of an element
*
* @return type integer
*/
public function get_position()
{
return $this->row*100+$this->column;
}
/**
* Add the info to the form
*/
public function put()
{
// Override the default value for "strip" with put_hcfa to keep periods
put_hcfa($this->row,$this->column,$this->width,$this->info,'/#/');
}
}
/**
* comparator function for hfca_info class to allow proper sorting
*
* @param type $first
* @param type $second
* @return int
*/
function cmp_hcfa_info($first,$second)
{
$first_value=$first->get_position();
$second_value=$second->get_position();
if($first_value==$second_value)
{
return 0;
}
return $first_value<$second_value ? -1 : 1;
}
/**
* calculate where on the form a given diagnosis belongs and add it to the entries
*
* @param array $hcfa_entries
* @param type $number
* @param type $diag
*/
function add_diagnosis(&$hcfa_entries,$number,$diag)
{
/*
* The diagnoses go across the page.
* Positioned
* A B C D
* E F G H
* I J K L
*/
$column_num = ($number%4);
$row_num = (int)($number / 4);
// First column is at location 3, each column is 13 wide
$col_pos=3+13*$column_num;
// First diagnosis row is 38
$strip='/[.#]/';
$diag = preg_replace($strip, '', strtoupper($diag));
$row_pos=38+$row_num;
$hcfa_entries[]=new hcfa_info($row_pos,$col_pos,8,$diag);
}
/**
* Process the diagnoses for a given claim. log any errors
*
* @param type $claim
* @param string $log
*/
function process_diagnoses_02_12(&$claim,&$log)
{
$hcfa_entries=array();
$diags = $claim->diagArray(false);
$icd_indicator='0';
$hcfa_entries[]=new hcfa_info(37,42,1,$icd_indicator);
// Box 22. Medicaid Resubmission Code and Original Ref. No.
$hcfa_entries[]=new hcfa_info(38,50,10,$claim->medicaidResubmissionCode());
$hcfa_entries[]=new hcfa_info(38,62,15,$claim->medicaidOriginalReference());
// Box 23. Prior Authorization Number
$hcfa_entries[]=new hcfa_info(40,50,28,$claim->priorAuth());
$diag_count=0;
foreach($diags as $diag)
{
if($diag_count<12)
{
add_diagnosis($hcfa_entries,$diag_count,$diag);
}
else
{
$log.= "***Too many diagnoses ".($diag_count+1).":".$diag;
}
$diag_count++;
}
// Sort the entries to put them in the page base sequence.
usort($hcfa_entries,"cmp_hcfa_info");
foreach($hcfa_entries as $hcfa_entry)
{
$hcfa_entry->put();
}
}
?>