Update X12Partner.class.php (#5793)
[openemr.git] / library / classes / X12Partner.class.php
blob0d11b1ed2de3bce8b18453d8dda263176cc6a3ce
1 <?php
3 /**
4 * class X12Partner
6 * @package OpenEMR
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
19 var $id;
20 var $name;
21 var $x12_submitter_name; // Submitter name for TPA
22 var $id_number;
23 var $x12_isa01; //
24 var $x12_isa02; //
25 var $x12_isa03; //
26 var $x12_isa04; //
27 var $x12_isa05; // Sender Interchange ID Qualifier. ZZ = mutually defined, 01 = Duns, etc.
28 var $x12_sender_id; // ISA06
29 var $x12_isa07; // Receiver Interchange ID Qualifier.
30 var $x12_receiver_id; // ISA08
31 var $x12_isa14; // Acknowledgment Requested. 0 = No, 1 = Yes.
32 var $x12_isa15; // Usage Indicator. T = testing, P = production.
33 var $x12_gs02; // Application Sender's Code. Default to ISA06.
34 var $x12_dtp03; // 270 2100C DTP03 service date for eligibility.
35 var $x12_per06; // The submitter's EDI Access Number, if any.
36 var $x12_version;
37 var $processing_format;
38 var $processing_format_array;
39 var $x12_gs03; // Application Sender's Code. If this isn't set then we will use the $x12_receiver_id(ISA08).
41 //for submitting claims via sftp
42 var $x12_sftp_login;
43 var $x12_sftp_pass;
44 var $x12_sftp_host;
45 var $x12_sftp_port;
46 var $x12_sftp_local_dir;
47 var $x12_sftp_remote_dir;
49 /**
50 * Constructor sets all Insurance attributes to their default value
53 function __construct($id = "", $prefix = "")
55 parent::__construct();
56 $this->id = $id;
57 $this->_table = "x12_partners";
58 $this->processing_format_array = $this->_load_enum("processing_format", false);
59 $this->processing_format = isset($this->processing_format_array[0]) ? $this->processing_format_array[0] : null;
60 //most recent x12 version mandated by HIPAA and CMS
61 // $this->x12_version = "004010X098A1";
62 $this->x12_version = "005010X222A1";
63 $this->x12_isa05 = "ZZ";
64 $this->x12_isa07 = "ZZ";
65 $this->x12_isa14 = "0";
66 $this->x12_dtp03 = "A";
67 if ($id != "") {
68 $this->populate();
72 function x12_partner_factory()
74 $partners = array();
75 $x = new X12Partner();
76 $sql = "SELECT id FROM " . $x->_table . " order by name";
77 $result = $x->_db->Execute($sql);
78 while ($result && !$result->EOF) {
79 $partners[] = new X12Partner($result->fields['id']);
80 $result->MoveNext();
83 return $partners;
86 function get_id()
88 return $this->id;
91 function set_id($id)
93 if (is_numeric($id)) {
94 $this->id = $id;
98 function get_name()
100 return $this->name;
103 function get_x12_submitter_name()
105 return $this->x12_submitter_name;
108 function set_x12_submitter_name($string)
110 $this->x12_submitter_name = $string;
114 * SFTP credentials for direct submit to x-12 partners.
116 * @param $string
118 function set_x12_sftp_login($string)
120 $this->x12_sftp_login = $string;
123 function get_x12_sftp_login()
125 return $this->x12_sftp_login;
128 function set_x12_sftp_pass($string)
130 $this->x12_sftp_pass = $string;
133 function get_x12_sftp_pass()
135 return $this->x12_sftp_pass;
138 function set_x12_sftp_host($string)
140 $this->x12_sftp_host = $string;
143 function get_x12_sftp_host()
145 return $this->x12_sftp_host;
148 function set_x12_sftp_port($string)
150 $this->x12_sftp_port = $string;
153 function get_x12_sftp_port()
155 return $this->x12_sftp_port;
158 function set_x12_sftp_local_dir($string)
160 $this->x12_sftp_local_dir = $string;
163 function get_x12_sftp_local_dir()
165 return $this->x12_sftp_local_dir;
168 function set_x12_sftp_remote_dir($string)
170 $this->x12_sftp_remote_dir = $string;
173 function get_x12_sftp_remote_dir()
175 return $this->x12_sftp_remote_dir;
178 function set_name($string)
180 $this->name = $string;
183 function get_id_number()
185 return $this->id_number;
188 function set_id_number($string)
190 $this->id_number = $string;
193 function get_x12_sender_id()
195 return $this->x12_sender_id;
198 function set_x12_sender_id($string)
200 $this->x12_sender_id = $string;
203 function get_x12_receiver_id()
205 return $this->x12_receiver_id;
208 function set_x12_receiver_id($string)
210 $this->x12_receiver_id = $string;
213 function get_x12_version()
215 return $this->x12_version;
218 function set_x12_version($string)
220 $this->x12_version = $string;
223 function get_x12_isa01()
225 return $this->x12_isa01;
228 function set_x12_isa01($string)
230 $this->x12_isa01 = $string;
233 function get_x12_isa02()
235 return $this->x12_isa02;
238 function set_x12_isa02($string)
240 $this->x12_isa02 = str_pad($string, 10);
243 function get_x12_isa03()
245 return $this->x12_isa03;
248 function set_x12_isa03($string)
250 $this->x12_isa03 = $string;
253 function get_x12_isa04()
255 return $this->x12_isa04;
258 function set_x12_isa04($string)
260 $this->x12_isa04 = str_pad($string, 10);
263 function get_x12_isa05()
265 return $this->x12_isa05;
268 function set_x12_isa05($string)
270 $this->x12_isa05 = $string;
273 function get_x12_isa07()
275 return $this->x12_isa07;
278 function set_x12_isa07($string)
280 $this->x12_isa07 = $string;
283 function get_x12_isa14()
285 return $this->x12_isa14;
288 function set_x12_isa14($string)
290 $this->x12_isa14 = $string;
293 function get_x12_isa15()
295 return $this->x12_isa15;
298 function set_x12_isa15($string)
300 $this->x12_isa15 = $string;
303 function get_x12_gs02()
305 return $this->x12_gs02;
308 function set_x12_gs02($string)
310 $this->x12_gs02 = $string;
313 function get_x12_dtp03()
315 return $this->x12_dtp03;
318 function set_x12_dtp03($string)
320 $this->x12_dtp03 = $string;
323 function get_x12_per06()
325 return $this->x12_per06;
328 function set_x12_per06($string)
330 $this->x12_per06 = $string;
333 function get_processing_format()
335 //this is enum so it can be string or int
336 if (!is_numeric($this->processing_format)) {
337 $ta = $this->processing_format_array;
338 return ($ta[$this->processing_format] ?? null);
341 return $this->processing_format;
344 function get_processing_format_array()
346 //flip it because normally it is an id to name lookup, for templates it needs to be a name to id lookup
347 return array_flip($this->processing_format_array);
350 function set_processing_format($string)
352 $this->processing_format = $string;
355 function get_x12_gs03()
357 return $this->x12_gs03;
360 function set_x12_gs03($string)
362 $this->x12_gs03 = $string;
365 function get_x12_isa14_array()
367 return array(
368 '0' => 'No',
369 '1' => 'Yes',
373 function get_x12_isa15_array()
375 return array(
376 'T' => 'Testing',
377 'P' => 'Production',
381 function get_idqual_array()
383 return array(
384 '01' => 'Duns (Dun & Bradstreet)',
385 '14' => 'Duns Plus Suffix',
386 '20' => 'Health Industry Number (HIN)',
387 '27' => 'Carrier ID from HCFA',
388 '28' => 'Fiscal Intermediary ID from HCFA',
389 '29' => 'Medicare ID from HCFA',
390 '30' => 'U.S. Federal Tax ID Number',
391 '33' => 'NAIC Company Code',
392 'ZZ' => 'Mutually Defined',
396 function get_x12_version_array()
398 return array(
399 '005010X222A1' => '005010X222A1',
400 '004010X098A1' => '004010X098A1',
404 function get_x12_dtp03_type_array()
406 return array(
407 'C' => 'Current Date',
408 'A' => 'Appointment Date',
409 'E' => 'Subscriber Effective Date',