Hide dashboard card 2 (#7423)
[openemr.git] / Documentation / Readme_edihistory.html
blobe961146d29545117b8cf5eeef7efc756863f0a58
1 <!--
2 README_edihistory.html
4 Copyright 2016 Kevin McCormick <kevin@records>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 MA 02110-1301, USA.
22 -->
24 <!DOCTYPE html>
25 <html lang="en">
27 <head>
28 <title>EDI History for x12 files</title>
29 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
30 <meta name="generator" content="Bluefish 2.2.8" />
31 <style>
32 body { background-color: #E6EDFA; max-width: 1024px; }
33 div#edih_readme { float: left; padding: 2em; max-width: 800px; line-height: 1.2em; background-color: #DCECE8; }
34 code { background-color: #FAF4E6; line-height: 1em; border-width: 1em; }
35 pre { background-color: #FAF4E6; line-height: 1em; border-width: 1em; }
36 </style>
37 </head>
39 <body>
40 <div id="edih_readme">
41 <h3>README Claim History Project</h3>
42 <p>
43 This file contains notes and hints for developing and using the files and scripts in this &quot;EDI History&quot; project.
44 </p>
45 <p>
46 This applies to version 2 of my edi_history project. <strong>Use at your own risk.</strong> The intended use is for health care facilities only. The scripts in this project are intended to create a system for managing x12 edi files. These are the mysterious x12 format data files known as 837 Claim, 835 Payment, 270 Benefit Inquiry, 271 Benefit Response, 276 Claim Status Inquiry, 277/277CA Claim Status, and 278 Authorization; and do not forget 999 Acknowledgement. (The 824 type is not dealt with, but if anyone gets these, it should not be too hard to interpret.) These are the &quot;Health Care&quot; types used for billing and insurance information. The prior version had scripts for certain proprietary formats, but this version is x12 format only.
47 </p>
48 <p>
49 In order to best use these scripts, you must diligently upload all your edi files using the &quot;New Files&quot; tab. Of course, in order to upload you must first download. In order to download, you must complete some registrations, obtain accounts with usernames and passwords, and configure OpenEMR with the information for your x12 partner(s).
50 </p>
51 <p>
52 Since the information in the EDI files is <strong>HIPAA protected</strong>, do not use these scripts on a public server! (or any computer where access is not restricted) The files and tables are stored in the OpenEMR directory under &quot;openemr/sites/[sitedir]/edi/history/&quot; Use the OpenEMR access control scheme to determine which users can use the scripts, probably &quot;accounting&quot;. The files and contained information will be as secure as your OpenEMR installation.
53 </p>
54 <p><em>Upgrade</em><br />
55 The &quot;upgrade&quot; process consists of renaming existing .csv files to <em>old_[files|claims]_[type].csv</em> and moving the existing &quot;era&quot; files to the newly created &quot;f835&quot; directory. This is handled by the <em>csv_setup()</em> function in <em>edih_csv_inc.php</em>. Otherwise, the only actons are the creation of the new directories. If you want the <em>/history/</em> directory to be clear of old cruft, then you can manually delete or move the &quot;old&quot; csv files under the <em>/csv</em> directory and also remove the <em>era</em>, <em>text</em>, <em>ibr</em>, <em>ebr</em>, and <em>dpr</em> directories, if present. Do not delete any of the following directories: archive, csv, f270, f271, f276, f277, f278, f835, f997, log, or tmp.
56 </p>
57 <p>
58 If for some reason the scripted upgrade does not work, you may wish to manually upgrade. I suggest you make a copy of the existing /history directory tree. Then delete the &quot;/history&quot; tree (not the /edi, just the /history -- this leaves all the batch files under /edi/[name].batch.txt). Then select the EDI History module in the OpenEMR left nav, which will create the new /history tree. Then copy all the x12 files to their new directories (note: era &gt; f835). Make sure the files ownership matches the OpenEMR ownershp. Then use the &quot;Process&quot; button on the New Files tab. De-select the html and errors output checkboxes. New csv tables will be created and all the files will be processed. You may have to upload one file to activate the Process button.
59 <br />
60 The [sitedir] is often called &quot;default&quot; and [/path/to/mydir] is your choice. Directory path details may vary.<br />
61 <pre><code>
62 cd /var/www/htdocs/openemr/sites/[sitedir]/edi<br />
63 cp -a history [/path/to/mydir]<br />
64 rm -rf history<br />
65 </code></pre>
66 Click EDI History in left nav (setup script will run. Check the log under the Notes tab)<br />
67 Now copy your existing x12 edi files into their respective directories. Note [ftype] will be like f277, f835, f997, etc.<br />
68 <pre><code>
69 cp [/path/to/mydir]/history/[ftype]/* /var/www/htdocs/openemr/sites/[sitedir]/documents/edi/history/[ftype]/<br />
70 </code></pre>
71 Repeat for each file type, but do not copy the csv files. <br />
72 &nbsp;&nbsp;&ndash; the dpr, text, ebr, ibr types are no longer used, so don't bother.<br />
73 &nbsp;&nbsp;&ndash; the era directory is now the f835 directory<br />
74 Find your OpenEMR &quot;owner group&quot; with:<br />
75 <pre><code>
76 ls -l /var/www/htdocs/openemr<br />
77 &nbsp;&nbsp;<samp>-rw-r--r-- 1 apache apache 969 Mar 24 02:25 COPYRIGHT_AND_LICENSE</samp><br />
78 </code></pre>
79 Verify file ownership and permissions. (example: owner apache, group apache)<br />
80 The directories permissions should be &quot;0755&quot; (&quot;drwxr-xr-x&quot;) and x12 files &quot;0400&quot; (&quot;-r--------&quot;)<br />
81 <pre><code>
82 cd /var/www/htdocs/openemr/sites/[sitedir]/documents/edi/history<br />
83 chown apache:apache [ftype]/*<br />
84 chmod 0400 [ftype]/*<br />
85 </code></pre>
86 </p>
87 <h3>Usage</h3>
88 <p><em>New Files</em><br />
89 &nbsp;-- Browse and Submit<br />
90 Select multiple files from your user directory where you have downloaded the files from your x12 partner. If there is a limit on uploaded files, you should be notified so you can repeat the process and get all files uploaded. Each file is checked and classified. If a file is rejected, that is because it was not interpreted as an x12 format file or not a type the scripts can deal with (there are many types). The scripts should be able to parse any valid Health Care category x12 file, so please submit a comment on the OpenEMR forum if you have a valid x12 file that is rejected. For .zip files, there must not be sub directories, because the parsing script does not handle sub directories.<br />
91 &nbsp;-- Process<br />
92 After new files are uploaded, click the &quot;Process&quot; button. You can (de)select html and/or errors-only, but they are on by default, so you will see a listing of summary information about the files, with particular details where the script detected a possible problem, like a rejected claim.
93 </p>
94 <p><em>CSV Tables</em><br />
95 On this tab, there is a select list to choose a table to view. Also, select a period or date range to limit the response. The tables are rows of information intended to allow you to select files or transactions of interest. The jQuery DataTables plugin has sorting and searching capability. The &quot;H&quot; link will open a formatted report of the data and the &quot;T&quot; link will open a rendition of the actual data segments from the edi file. The &quot;Trace&quot; column generally has a reference to the transaction in another file, such as claim status tracing back to the submitted claim. In the 835 &quot;Payment&quot; tables, the trace is to the payment check/eft number. Unfortunately, in my opinion the standard OpemEMR claim generation file does not create a correct value in the BHT segment, so tracing to the exact claim submission is not reliable. (See note below) <br />
96 <em>Per Encounter</em><br />
97 Enter the claim id (xxxx-xxxxx) (from the 837 CLM01 value). The csv tables will be searched and a dialog will open with links to the corresponding 837, 277, and 835 transactions, and 997/999 if the batch file was rejected.
98 </p>
99 <p><em>Notes</em><br />
100 Select a log file to view, or the notes file. The notes file is just a textbox you can use to make little reminders. The log files are daily records of actions done. The &quot;Archive&quot; button will cause log files older than 7 days to be put in a zip file.
101 </p>
102 <p><em>Archive</em><br />
103 The edi files are quite fascinating when they are new, but once the billing cycle is complete they may be of little interest. The idea of the Archive tab is to enable you to select an ageing period and put all the older files and their csv data rows into a zip archive stored under /history/archive. The batch files under the /sites/[sitedir]/edi directory are not archived, since I do not want to accidentally break anything. You can change the available periods by editing the edih_view.php file in the Archive div. The &quot;Report&quot; button will produce a report on your edi files and the &quot;Archive&quot; button will do the deed. There is also a &quot;Restore&quot; button which will unpack the selected archive file and replace the files and csv data rows. You will have to manually delete archive files that you no longer want. After you have performed an Archive, you will probably want to reload the EDI History page which will refresh the the select lists and clear the output under each tab.
104 </p>
105 <p><em>General Thoughts</em><br />
106 The 999/997 x12 type is the acknowledgment which lists submission errors. It must include the <em>TA1</em> segment in order for the scripts to be able to match these response files with the corresponding batch file you submitted. I think it would be possible to edit the <em>billing_process.php</em> script to give a unique ID for the GS06 value, in which case the TA1 segment would probably not be required, but a few code edits would be needied in the edi_history scripts as well.
107 </p>
109 In the old version, I used file name patterns to classify files, but version 2 uses information in the GS segment for this purpose. If that fails for some reason, the file name pattern is tried. The patterns are found in <em>edih_csv_inc.php</em> in the function <em>csv_parameters()</em>.
110 </p>
112 For 835 ERA files, I assume the internal grouping of the files is by check/eft from a particular payer. The 835 files table has a row for each check/eft number, so there are likely more rows than files.
113 </p>
115 It also happens that a clearinghouse will append several ISA--IEA envelopes into a single file. I assume they are all of the same type. Each ISA control number receives a line in the files table, so this is another reason there could be more rows than files in a files table.
116 </p>
118 <h3>OpenEMR Integration</h3>
121 Access control is entirely under the OpenEMR scheme and will likely require the access permissions of &quot;accounting.&quot;
122 </p>
124 Since the information in the EDI files is likely HIPAA protected, do not use these scripts on a public server!
125 </p>
127 If this project proves to be useful and reliable, then I would suggest modifying the ERA batch posting script so it is activated from a tab button. A scan of database check numbers compared to a scan of files_f835.csv &quot;Trace&quot; numbers should identify all unprocessed payments and the files can be queued accordingly.<br />
128 </p>
130 Secondly, the x12 batch files could be stored under designated directories to avoid a hodgepodge situation in the /edi directory.
131 </p>
132 </p>
133 Thirdly, There is a rough draft script &quot;test_edih_sftp_files.php&quot; in the &quot;/openemr/library/edihistory/$quot; directory which outlines a possibility for automated file transfers using sftp.
135 <h3>File Locations:</h3>
137 The installed directory tree would be:
138 </p>
139 <ul>
140 <li>/openemr/interface/billing </li>
141 <li>/openemr/library/edihistory</li>
142 <li>/openemr/library/css</li>
143 <li>/openemr/library/js</li>
144 </ul>
147 Installed files:
148 </p>
149 <ul>
150 <li>/openemr/Documentation
151 <ul>
152 <li>Readme_edihistory.html</li>
153 </ul>
154 </li>
155 <li>/openemr/interface/billing </li>
156 <ul>
157 <li>edih_view.php</li>
158 <li>edih_main.php</li>
159 </ul>
160 <li>/openemr/library/edihistory </li>
161 <ul>
162 <li>edih_archive.php</li>
163 <li>edih_csv_data.php</li>
164 <li>edih_csv_inc.php</li>
165 <li>edih_csv_parse.php</li>
166 <li>edih_io.php</li>
167 <li>edih_segments.php</li>
168 <li>edih_uploads.php</li>
169 <li>edih_x12file_class.php</li>
170 <li>edih_271_html.php</li>
171 <li>edih_277_html.php</li>
172 <li>edih_278_html.php</li>
173 <li>edih_835_html.php</li>
174 <li>edih_997_error.php</li>
175 </ul>
176 <li>/openemr/library/edihistory/codes</li>
177 <ul>
178 <li>edih_271_code_class.php</li>
179 <li>edih_835_code_class.php</li>
180 <li>edih_997_codes.php</li>
181 </ul>
182 <li>/openemr/library/css</li>
183 <ul>
184 <li>edi_history_v2.css</li>
185 </ul>
186 <ul>
187 <li>/openemr/library/js/DataTables-1.10.11</li>
188 <ul>
189 <li>datatables.min.js</li>
190 </ul>
191 <li>/library/js/jquery-ui-1.10.4.custom/js/</li>
192 <ul>
193 <li>jquery-1.10.2.min.js</li>
194 <li>jquery-ui-1.10.4.custom.min.js</li>
195 </ul>
196 <li>/library/js/jquery-ui-1.10.4.custom/custom-theme/css/</li>
197 <ul>
198 <li>jquery-ui-1.10.4.custom.min.css</li>
199 </ul>
200 <li>/library/js/DataTables-1.10.11/DataTables-1.10.11/css/</li>
201 <ul>
202 <li>jquery.dataTables.min.css</li>
203 <li>dataTables.jqueryui.min.css</li>
204 </ul>
205 </ul>
206 </ul>
208 The <em>csv_setup()</em> function creates a file storage directory tree: <br />
209 &nbsp;&nbsp; openemr/sites/[sitedir]/documents/edi/history <br />
210 with subdirectories: archive csv f270 f271 f276 f277 f278 f835 f997 log tmp
211 </p>
213 and these csv files under: /openemr/sites/[sitedir]/documents/edi/history/csv<br />
214 &nbsp;&nbsp; claims_[ftype].csv files_[ftype].csv tables are created for each file type on first appearance
215 </p>
217 The path to these files is set by <em>csv_edih_basedir()</em> based upon the OpenEMR directory paths.
218 </p>
220 Note: I suggest the following edit to the OpenEMR <em>/interface/billing/billing_process.php</em> script:
221 <br />
222 &nbsp; In the file openemr/interface/billing/billing_process.php<br />
223 &nbsp; in &quot;function append_claim(&amp;$segs)&quot;<br />
224 near line 82 (after the &quot;if (elems[0] == 'ST') { }&quot; block)
225 </p>
226 <pre><code>
227 // add this mod
228 if ($elems[0] == 'BHT') {
229 // give each claim a unique BHT number,: isa-control-num and st-num are concatenated
231 $bat_content .= str_replace("*0123*", sprintf("*%s%04d*", $bat_icn, $bat_stcount), $seg) . "~";
232 continue;
235 </code></pre>
237 The EDI methods and files are cryptic and mysterious. The formats are definitely not what I would call
238 user-friendly. The contents and meaning of the various files, loops, and segments may be better understood
239 with serious research. There are so called &quot;Companion Documents&quot; published by some insurance companies
240 and possibly by your clearinghouse. Search for &quot;X12 835 837 277 999 Companion Document&quot; and see if you find
241 anything useful.
242 </p>
243 </div>
244 </body>
246 </html>