5 * Copyright 2014 Kevin McCormick Longview, Texas
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; version 3 or later. You should have
16 * received a copy of the GNU General Public License along with this program;
17 * if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * <http://opensource.org/licenses/gpl-license.php>
23 * @link: http://www.open-emr.org
30 * error code values in AK or IK segments
32 * @param string the segment field ak304, ak403, ak501
33 * @param string the code
36 function edih_997_code_text ( $ak_seg_field, $ak_code ) {
37 // the Availity 997 file has codes with certain errors
38 // which correspond to the messages in these arrays
42 $aktext['ak304'] = array(
43 '1' => 'Unrecognized segment ID',
44 '2' => 'Unexpected segment',
45 '3' => 'Mandatory segment missing',
46 '4' => 'Loop occurs over maximum times',
47 '5' => 'Segment exceeds maximum use',
48 '6' => 'Segment not in defined transaction set',
49 '7' => 'Segment not in proper sequence',
50 '8' => 'Segment has field errors',
51 'I4' => 'Segment not used in implementation',
52 'I6' => 'Implementation dependent segment missing',
53 'I7' => 'Implementation loop occurs less than minimum times',
54 'I8' => 'Implementation segment below minimum use',
55 'I9' => 'Implementation dependent not used segment present'
58 $aktext['ak403'] = array(
59 '1' => 'Mandatory data element missing',
60 '2' => 'Conditional required data element missing',
61 '3' => 'Too many data elements',
62 '4' => 'Data element too short',
63 '5' => 'Data element too long',
64 '6' => 'Invalid character in data element',
65 '7' => 'Invalid code value',
66 '8' => 'Invalid date',
67 '9' => 'Invalid time',
68 '10' => 'Exclusion condition violated - segment includes two values that should not occur together',
69 '12' => 'Too many repetitions',
70 '13' => 'Too many components',
71 'I10' => 'Implementation not used',
72 'I11' => 'Implementation too few repetitions',
73 'I12' => 'Implementation pattern match failure',
74 'I13' => 'Implementation dependent not used data element present',
75 'I6' => 'Code value not used in implimentation',
76 'I9' => 'Implementation dependent data element missing'
79 $aktext['ak501'] = array(
80 'A' => 'Accepted advised',
81 'E' => 'Accepted, but errors were noted',
82 'M' => 'Rejected, message authentication code (MAC) failed',
83 'P' => 'Partially Accepted',
84 'R' => 'Rejected advised',
85 'W' => 'Rejected, assurance failed validity tests',
86 'X' => 'Rejected, content after decryption could not be analyzed'
89 $aktext['ak502'] = array(
90 '1' => 'Functional Group not supported',
91 '2' => 'Functional Group Version not supported',
92 '3' => 'Functional Group Trailer missing',
93 '4' => 'Group Control Number in the Functional Group Header and Trailer do not agree',
94 '5' => 'Number of included Transaction Sets does not match actual count',
95 '6' => 'Group Control Number violates syntax',
96 '10' => 'Authentication Key Name unknown',
97 '11' => 'Encryption Key Name unknown',
98 '12' => 'Requested Service (Authentication or Encryption) not available',
99 '13' => 'Unknown security recipient',
100 '14' => 'Unknown security originator',
101 '15' => 'Syntax error in decrypted text',
102 '16' => 'Security not supported',
103 '17' => 'Incorrect message length (Encryption only)',
104 '18' => 'Message authentication code failed',
105 '19' => 'Functional Group Control Number not unique within Interchange',
106 '23' => 'S3E Security End Segment missing for S3S Security Start Segment',
107 '24' => 'S3S Security Start Segment missing for S3E Security End Segment',
108 '25' => 'S4E Security End Segment missing for S4S Security Start Segment',
109 '26' => 'S4S Security Start Segment missing for S4E Security End Segment',
110 'I6' => 'Implementation dependent segment missing',
112 // array_key_exists($ak_seg_field, $aktext) && array_key_exists($ak_code, $aktext[$ak_seg_field]) )
113 return ( isset($aktext[$ak_seg_field][$ak_code]) ) ?
$aktext[$ak_seg_field][$ak_code] : '';
114 //if ( isset($aktext[$ak_seg_field][$ak_code]) ) {
115 // return $aktext[$ak_seg_field][$ak_code];
123 * code values for TA1 segment
125 * @param string the code
128 function edih_997_ta1_code($code) {
129 // codes in TA1 segment elements 4 and 5, since codes are distinct form, all values in one array
131 $ta1code = array('A' => 'Interchange accepted with no errors.',
132 'R' => 'Interchange rejected because of errors. Sender must resubmit file.',
133 'E' => 'Interchange accepted, but errors are noted. Sender must not resubmit file.',
135 '001' => 'The Interchange Control Number in the header and trailer do not match. Use the value from the header in the acknowledgment.',
136 '002' => 'This Standard as noted in the Control Standards Identifier is not supported.',
137 '003' => 'This Version of the controls is not supported',
138 '004' => 'The Segment Terminator is invalid',
139 '005' => 'Invalid Interchange ID Qualifier for sender',
140 '006' => 'Invalid Interchange Sender ID',
141 '007' => 'Invalid Interchange ID Qualifier for receiver',
142 '008' => 'Invalid Interchange Receiver ID',
143 '009' => 'Unknown Interchange Receiver ID',
144 '010' => 'Invalid Authorization Information Qualifier value',
145 '011' => 'Invalid Authorization Information value',
146 '012' => 'Invalid Security Information Qualifier value',
147 '013' => 'Invalid Security Information value',
148 '014' => 'Invalid Interchange Date value',
149 '015' => 'Invalid Interchange Time value',
150 '016' => 'Invalid Interchange Standards Identifier value',
151 '017' => 'Invalid Interchange Version ID value',
152 '018' => 'Invalid Interchange Control Number',
153 '019' => 'Invalid Acknowledgment Requested value',
154 '020' => 'Invalid Test Indicator value',
155 '021' => 'Invalid Number of Included Group value',
156 '022' => 'Invalid control structure',
157 '023' => 'Improper (Premature) end-of-file (Transmission)',
158 '024' => 'Invalid Interchange Content (e.g., invalid GS Segment)',
159 '025' => 'Duplicate Interchange Control Number',
160 '026' => 'Invalid Data Element Separator',
161 '027' => 'Invalid Component Element Separator',
162 '028' => 'Invalid delivery date in Deferred Delivery Request',
163 '029' => 'Invalid delivery time in Deferred Delivery Request',
164 '030' => 'Invalid delivery time Code in Deferred Delivery Request',
165 '031' => 'Invalid grade of Service Code'
167 if ( array_key_exists($code, $ta1code) ) {
168 return $ta1code[$code];
170 return "Code $code not found in TA1 codes table. <br />";