7 * @link http://www.open-emr.org
8 * @author Ken Chapple <ken@mi-squared.com>
9 * @author Daniel Pflieger <daniel@mi-squared.com>, <daniel@growlingflea.com>
10 * @copyright Copyright (c) 2021 Ken Chapple <ken@mi-squared.com>
11 * @copyright Copyright (c) 2021 Daniel Pflieger <daniel@mi-squared.com>, <daniel@growlingflea.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 use OpenEMR\Common\ORDataObject\ORDataObject
;
17 class X12Partner
extends ORDataObject
21 var $x12_submitter_id;
22 var $x12_submitter_name;
23 var $x12_submitter_array;
29 var $x12_isa05; // Sender Interchange ID Qualifier. ZZ = mutually defined, 01 = Duns, etc.
30 var $x12_sender_id; // ISA06
31 var $x12_isa07; // Receiver Interchange ID Qualifier.
32 var $x12_receiver_id; // ISA08
33 var $x12_isa14; // Acknowledgment Requested. 0 = No, 1 = Yes.
34 var $x12_isa15; // Usage Indicator. T = testing, P = production.
35 var $x12_gs02; // Application Sender's Code. Default to ISA06.
36 var $x12_dtp03; // 270 2100C DTP03 service date for eligibility.
37 var $x12_per06; // The submitter's EDI Access Number, if any.
39 var $processing_format;
40 var $processing_format_array;
41 var $x12_gs03; // Application Sender's Code. If this isn't set then we will use the $x12_receiver_id(ISA08).
43 //for submitting claims via sftp
48 var $x12_sftp_local_dir;
49 var $x12_sftp_remote_dir;
52 * Constructor sets all Insurance attributes to their default value
55 function __construct($id = "", $prefix = "")
57 parent
::__construct();
59 $this->_table
= "x12_partners";
60 $this->processing_format_array
= $this->_load_enum("processing_format", false);
61 $this->processing_format
= isset($this->processing_format_array
[0]) ?
$this->processing_format_array
[0] : null;
62 //most recent x12 version mandated by HIPAA and CMS
63 // $this->x12_version = "004010X098A1";
64 $this->x12_version
= "005010X222A1";
65 $this->x12_isa05
= "ZZ";
66 $this->x12_isa07
= "ZZ";
67 $this->x12_isa14
= "0";
68 $this->x12_dtp03
= "A";
74 function x12_partner_factory()
77 $x = new X12Partner();
78 $sql = "SELECT id FROM " . $x->_table
. " order by name";
79 $result = $x->_db
->Execute($sql);
80 while ($result && !$result->EOF
) {
81 $partners[] = new X12Partner($result->fields
['id']);
95 if (is_numeric($id)) {
105 function get_x12_submitter_array()
107 $query = "SELECT id, organization FROM users WHERE abook_type = 'bill_svc'";
108 $res = sqlStatement($query);
109 $x12_submitter_array[0] = null;
110 while ($row = sqlFetchArray($res)) {
111 $x12_submitter_array[$row['id']] = $row['organization'];
114 return $x12_submitter_array;
117 function set_x12_submitter_id($id)
119 $this->x12_submitter_id
= $id;
122 function get_x12_submitter_id()
124 return $this->x12_submitter_id
;
127 function get_x12_submitter_name()
129 $xa = $this->get_x12_submitter_array();
130 return $xa[$this->get_x12_submitter_id()] ??
null;
134 * SFTP credentials for direct submit to x-12 partners.
138 function set_x12_sftp_login($string)
140 $this->x12_sftp_login
= $string;
143 function get_x12_sftp_login()
145 return $this->x12_sftp_login
;
148 function set_x12_sftp_pass($string)
150 $this->x12_sftp_pass
= $string;
153 function get_x12_sftp_pass()
155 return $this->x12_sftp_pass
;
158 function set_x12_sftp_host($string)
160 $this->x12_sftp_host
= $string;
163 function get_x12_sftp_host()
165 return $this->x12_sftp_host
;
168 function set_x12_sftp_port($string)
170 $this->x12_sftp_port
= $string;
173 function get_x12_sftp_port()
175 return $this->x12_sftp_port
;
178 function set_x12_sftp_local_dir($string)
180 $this->x12_sftp_local_dir
= $string;
183 function get_x12_sftp_local_dir()
185 return $this->x12_sftp_local_dir
;
188 function set_x12_sftp_remote_dir($string)
190 $this->x12_sftp_remote_dir
= $string;
193 function get_x12_sftp_remote_dir()
195 return $this->x12_sftp_remote_dir
;
198 function set_name($string)
200 $this->name
= $string;
203 function get_id_number()
205 return $this->id_number
;
208 function set_id_number($string)
210 $this->id_number
= $string;
213 function get_x12_sender_id()
215 return $this->x12_sender_id
;
218 function set_x12_sender_id($string)
220 $this->x12_sender_id
= $string;
223 function get_x12_receiver_id()
225 return $this->x12_receiver_id
;
228 function set_x12_receiver_id($string)
230 $this->x12_receiver_id
= $string;
233 function get_x12_version()
235 return $this->x12_version
;
238 function set_x12_version($string)
240 $this->x12_version
= $string;
243 function get_x12_isa01()
245 return $this->x12_isa01
;
248 function set_x12_isa01($string)
250 $this->x12_isa01
= $string;
253 function get_x12_isa02()
255 return $this->x12_isa02
;
258 function set_x12_isa02($string)
260 $this->x12_isa02
= str_pad($string, 10);
263 function get_x12_isa03()
265 return $this->x12_isa03
;
268 function set_x12_isa03($string)
270 $this->x12_isa03
= $string;
273 function get_x12_isa04()
275 return $this->x12_isa04
;
278 function set_x12_isa04($string)
280 $this->x12_isa04
= str_pad($string, 10);
283 function get_x12_isa05()
285 return $this->x12_isa05
;
288 function set_x12_isa05($string)
290 $this->x12_isa05
= $string;
293 function get_x12_isa07()
295 return $this->x12_isa07
;
298 function set_x12_isa07($string)
300 $this->x12_isa07
= $string;
303 function get_x12_isa14()
305 return $this->x12_isa14
;
308 function set_x12_isa14($string)
310 $this->x12_isa14
= $string;
313 function get_x12_isa15()
315 return $this->x12_isa15
;
318 function set_x12_isa15($string)
320 $this->x12_isa15
= $string;
323 function get_x12_gs02()
325 return $this->x12_gs02
;
328 function set_x12_gs02($string)
330 $this->x12_gs02
= $string;
333 function get_x12_dtp03()
335 return $this->x12_dtp03
;
338 function set_x12_dtp03($string)
340 $this->x12_dtp03
= $string;
343 function get_x12_per06()
345 return $this->x12_per06
;
348 function set_x12_per06($string)
350 $this->x12_per06
= $string;
353 function get_processing_format()
355 //this is enum so it can be string or int
356 if (!is_numeric($this->processing_format
)) {
357 $ta = $this->processing_format_array
;
358 return ($ta[$this->processing_format
] ??
null);
361 return $this->processing_format
;
364 function get_processing_format_array()
366 //flip it because normally it is an id to name lookup, for templates it needs to be a name to id lookup
367 return array_flip($this->processing_format_array
);
370 function set_processing_format($string)
372 $this->processing_format
= $string;
375 function get_x12_gs03()
377 return $this->x12_gs03
;
380 function set_x12_gs03($string)
382 $this->x12_gs03
= $string;
385 function get_x12_isa14_array()
393 function get_x12_isa15_array()
401 function get_idqual_array()
404 '01' => 'Duns (Dun & Bradstreet)',
405 '14' => 'Duns Plus Suffix',
406 '20' => 'Health Industry Number (HIN)',
407 '27' => 'Carrier ID from HCFA',
408 '28' => 'Fiscal Intermediary ID from HCFA',
409 '29' => 'Medicare ID from HCFA',
410 '30' => 'U.S. Federal Tax ID Number',
411 '33' => 'NAIC Company Code',
412 'ZZ' => 'Mutually Defined',
416 function get_x12_version_array()
419 '005010X222A1' => '005010X222A1',
420 '004010X098A1' => '004010X098A1',
424 function get_x12_dtp03_type_array()
427 'C' => 'Current Date',
428 'A' => 'Appointment Date',
429 'E' => 'Subscriber Effective Date',