Eye module improvements with other minor improvements
[openemr.git] / library / edihistory / codes / edih_997_codes.php
blob261ff6e6d0739df03224f104505a79c858d08b3e
1 <?php
2 /*
3 * test_997_codes.php
4 *
5 * Copyright 2014 Kevin McCormick Longview, Texas
6 *
7 *
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
24 * @package ediHistory
29 /**
30 * error code values in AK or IK segments
32 * @param string the segment field ak304, ak403, ak501
33 * @param string the code
34 * @return string
36 function edih_997_code_text($ak_seg_field, $ak_code)
38 // the Availity 997 file has codes with certain errors
39 // which correspond to the messages in these arrays
41 $ret_str = '';
43 $aktext['ak304'] = array(
44 '1' => 'Unrecognized segment ID',
45 '2' => 'Unexpected segment',
46 '3' => 'Mandatory segment missing',
47 '4' => 'Loop occurs over maximum times',
48 '5' => 'Segment exceeds maximum use',
49 '6' => 'Segment not in defined transaction set',
50 '7' => 'Segment not in proper sequence',
51 '8' => 'Segment has field errors',
52 'I4' => 'Segment not used in implementation',
53 'I6' => 'Implementation dependent segment missing',
54 'I7' => 'Implementation loop occurs less than minimum times',
55 'I8' => 'Implementation segment below minimum use',
56 'I9' => 'Implementation dependent not used segment present'
59 $aktext['ak403'] = array(
60 '1' => 'Mandatory data element missing',
61 '2' => 'Conditional required data element missing',
62 '3' => 'Too many data elements',
63 '4' => 'Data element too short',
64 '5' => 'Data element too long',
65 '6' => 'Invalid character in data element',
66 '7' => 'Invalid code value',
67 '8' => 'Invalid date',
68 '9' => 'Invalid time',
69 '10' => 'Exclusion condition violated - segment includes two values that should not occur together',
70 '12' => 'Too many repetitions',
71 '13' => 'Too many components',
72 'I10' => 'Implementation not used',
73 'I11' => 'Implementation too few repetitions',
74 'I12' => 'Implementation pattern match failure',
75 'I13' => 'Implementation dependent not used data element present',
76 'I6' => 'Code value not used in implimentation',
77 'I9' => 'Implementation dependent data element missing'
80 $aktext['ak501'] = array(
81 'A' => 'Accepted advised',
82 'E' => 'Accepted, but errors were noted',
83 'M' => 'Rejected, message authentication code (MAC) failed',
84 'P' => 'Partially Accepted',
85 'R' => 'Rejected advised',
86 'W' => 'Rejected, assurance failed validity tests',
87 'X' => 'Rejected, content after decryption could not be analyzed'
90 $aktext['ak502'] = array(
91 '1' => 'Functional Group not supported',
92 '2' => 'Functional Group Version not supported',
93 '3' => 'Functional Group Trailer missing',
94 '4' => 'Group Control Number in the Functional Group Header and Trailer do not agree',
95 '5' => 'Number of included Transaction Sets does not match actual count',
96 '6' => 'Group Control Number violates syntax',
97 '10' => 'Authentication Key Name unknown',
98 '11' => 'Encryption Key Name unknown',
99 '12' => 'Requested Service (Authentication or Encryption) not available',
100 '13' => 'Unknown security recipient',
101 '14' => 'Unknown security originator',
102 '15' => 'Syntax error in decrypted text',
103 '16' => 'Security not supported',
104 '17' => 'Incorrect message length (Encryption only)',
105 '18' => 'Message authentication code failed',
106 '19' => 'Functional Group Control Number not unique within Interchange',
107 '23' => 'S3E Security End Segment missing for S3S Security Start Segment',
108 '24' => 'S3S Security Start Segment missing for S3E Security End Segment',
109 '25' => 'S4E Security End Segment missing for S4S Security Start Segment',
110 '26' => 'S4S Security Start Segment missing for S4E Security End Segment',
111 'I6' => 'Implementation dependent segment missing',
113 // array_key_exists($ak_seg_field, $aktext) && array_key_exists($ak_code, $aktext[$ak_seg_field]) )
114 return ( isset($aktext[$ak_seg_field][$ak_code]) ) ? $aktext[$ak_seg_field][$ak_code] : '';
115 //if ( isset($aktext[$ak_seg_field][$ak_code]) ) {
116 // return $aktext[$ak_seg_field][$ak_code];
117 //} else {
118 // return "";
124 * code values for TA1 segment
126 * @param string the code
127 * @return string
129 function edih_997_ta1_code($code)
131 // codes in TA1 segment elements 4 and 5, since codes are distinct form, all values in one array
133 $ta1code = array('A' => 'Interchange accepted with no errors.',
134 'R' => 'Interchange rejected because of errors. Sender must resubmit file.',
135 'E' => 'Interchange accepted, but errors are noted. Sender must not resubmit file.',
136 '000' => 'No error',
137 '001' => 'The Interchange Control Number in the header and trailer do not match. Use the value from the header in the acknowledgment.',
138 '002' => 'This Standard as noted in the Control Standards Identifier is not supported.',
139 '003' => 'This Version of the controls is not supported',
140 '004' => 'The Segment Terminator is invalid',
141 '005' => 'Invalid Interchange ID Qualifier for sender',
142 '006' => 'Invalid Interchange Sender ID',
143 '007' => 'Invalid Interchange ID Qualifier for receiver',
144 '008' => 'Invalid Interchange Receiver ID',
145 '009' => 'Unknown Interchange Receiver ID',
146 '010' => 'Invalid Authorization Information Qualifier value',
147 '011' => 'Invalid Authorization Information value',
148 '012' => 'Invalid Security Information Qualifier value',
149 '013' => 'Invalid Security Information value',
150 '014' => 'Invalid Interchange Date value',
151 '015' => 'Invalid Interchange Time value',
152 '016' => 'Invalid Interchange Standards Identifier value',
153 '017' => 'Invalid Interchange Version ID value',
154 '018' => 'Invalid Interchange Control Number',
155 '019' => 'Invalid Acknowledgment Requested value',
156 '020' => 'Invalid Test Indicator value',
157 '021' => 'Invalid Number of Included Group value',
158 '022' => 'Invalid control structure',
159 '023' => 'Improper (Premature) end-of-file (Transmission)',
160 '024' => 'Invalid Interchange Content (e.g., invalid GS Segment)',
161 '025' => 'Duplicate Interchange Control Number',
162 '026' => 'Invalid Data Element Separator',
163 '027' => 'Invalid Component Element Separator',
164 '028' => 'Invalid delivery date in Deferred Delivery Request',
165 '029' => 'Invalid delivery time in Deferred Delivery Request',
166 '030' => 'Invalid delivery time Code in Deferred Delivery Request',
167 '031' => 'Invalid grade of Service Code'
169 if (array_key_exists($code, $ta1code)) {
170 return $ta1code[$code];
171 } else {
172 return "Code $code not found in TA1 codes table. <br />";