quick minor path updates (#1968)
[openemr.git] / library / gen_hcfa_1500.inc.php
blobf47a74e4f5e9bb871f26f3641607ecdcb23670a8
1 <?php
2 /*
3 * This program creates the HCFA 1500 claim form.
5 * @package OpenEMR
6 * @author Rod Roark <rod@sunsetsystems.com>
7 * @author Stephen Waite <stephen.waite@cmsvt.com>
8 * @copyright Copyright (c) 2011 Rod Roark <rod@sunsetsystems.com>
9 * @copyright Copyright (C) 2018 Stephen Waite <stephen.waite@cmsvt.com>
10 * @link http://www.open-emr.org
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("gen_hcfa_1500_02_12.inc.php");
15 require_once(dirname(__FILE__) . "/invoice_summary.inc.php");
17 use OpenEMR\Billing\Claim;
19 $hcfa_curr_line = 1;
20 $hcfa_curr_col = 1;
21 $hcfa_data = '';
22 $hcfa_proc_index = 0;
24 /**
25 * take the data element and place it at the correct coordinates on the page
27 * @global int $hcfa_curr_line
28 * @global type $hcfa_curr_col
29 * @global type $hcfa_data
30 * @param type $line
31 * @param type $col
32 * @param type $maxlen
33 * @param type $data
34 * @param type $strip regular expression for what to strip from the data. period and has are the defaults
35 * 02/12 version needs to include periods in the diagnoses hence the need to override
37 function put_hcfa($line, $col, $maxlen, $data, $strip = '/[.#]/')
39 global $hcfa_curr_line, $hcfa_curr_col, $hcfa_data;
40 if ($line < $hcfa_curr_line) {
41 die("Data item at ($line, $col) precedes current line.");
44 while ($hcfa_curr_line < $line) {
45 $hcfa_data .= "\n";
46 ++$hcfa_curr_line;
47 $hcfa_curr_col = 1;
50 if ($col < $hcfa_curr_col) {
51 die("Data item at ($line, $col) precedes current column.");
54 while ($hcfa_curr_col < $col) {
55 $hcfa_data .= " ";
56 ++$hcfa_curr_col;
59 $data = preg_replace($strip, '', strtoupper($data));
60 $len = min(strlen($data), $maxlen);
61 $hcfa_data .= substr($data, 0, $len);
62 $hcfa_curr_col += $len;
65 function gen_hcfa_1500($pid, $encounter, &$log)
67 global $hcfa_data, $hcfa_proc_index;
69 $hcfa_data = '';
70 $hcfa_proc_index = 0;
72 $today = time();
73 $claim = new Claim($pid, $encounter);
75 $log .= "Generating HCFA claim $pid-$encounter for " .
76 $claim->patientFirstName() . ' ' .
77 $claim->patientMiddleName() . ' ' .
78 $claim->patientLastName() . ' on ' .
79 date('Y-m-d H:i', $today) . ".\n";
81 while ($hcfa_proc_index < $claim->procCount()) {
82 if ($hcfa_proc_index) {
83 $hcfa_data .= "\014"; // append form feed for new page
86 gen_hcfa_1500_page($pid, $encounter, $log, $claim);
89 $log .= "\n";
90 return $hcfa_data;
93 function gen_hcfa_1500_page($pid, $encounter, &$log, &$claim)
95 global $hcfa_curr_line, $hcfa_curr_col, $hcfa_data, $hcfa_proc_index;
97 $hcfa_curr_line = 1;
98 $hcfa_curr_col = 1;
100 // According to:
101 // http://www.ngsmedicare.com/NGSMedicare/PartB/EducationandSupport/ToolsandMaterials/CMS_ClaimFormInst.aspx
102 // Medicare interprets sections 9 and 11 of the claim form in its own
103 // special way. This flag tells us to do that. However I'm not 100%
104 // sure that it applies nationwide, and if you find that it is not right
105 // for you then set it to false. -- Rod 2009-03-26
106 $new_medicare_logic = $claim->claimType() == 'MB';
108 // Payer name, attn, street.
109 put_hcfa(2, 41, 31, $claim->payerName());
110 put_hcfa(3, 41, 31, $claim->payerAttn());
111 put_hcfa(4, 41, 31, $claim->payerStreet());
113 // Payer city, state, zip.
114 $tmp = $claim->payerCity() ? ($claim->payerCity() . ', ') : '';
115 put_hcfa(5, 41, 31, $tmp . $claim->payerState() . ' ' . $claim->payerZip());
117 // Box 1. Insurance Type
118 // claimTypeRaw() gets the integer value from insurance_companies.ins_type_code.
119 // Previous version of this code called claimType() which maps ins_type_code to
120 // a 2-character code and that was not specific enough.
121 $ct = $claim->claimTypeRaw();
122 $tmpcol = 45; // Other
123 if ($ct == 2) {
124 $tmpcol = 1; // Medicare
125 } else if ($ct == 3) {
126 $tmpcol = 8; // Medicaid
127 } else if ($ct == 5) {
128 $tmpcol = 15; // TriCare (formerly CHAMPUS)
129 } else if ($ct == 4) {
130 $tmpcol = 24; // Champus VA
131 } else if ($ct == 6) {
132 $tmpcol = 31; // Group Health Plan (only BCBS?)
133 } else if ($ct == 7) {
134 $tmpcol = 39; // FECA
137 put_hcfa(8, $tmpcol, 1, 'X');
139 // Box 1a. Insured's ID Number
140 put_hcfa(8, 50, 17, $claim->policyNumber());
142 // Box 2. Patient's Name
143 $tmp = $claim->patientLastName() . ', ' . $claim->patientFirstName();
144 if ($claim->patientMiddleName()) {
145 $tmp .= ', ' . substr($claim->patientMiddleName(), 0, 1);
148 put_hcfa(10, 1, 28, $tmp);
150 // Box 3. Patient's Birth Date and Sex
151 $tmp = $claim->patientDOB();
152 put_hcfa(10, 31, 2, substr($tmp, 4, 2));
153 put_hcfa(10, 34, 2, substr($tmp, 6, 2));
154 put_hcfa(10, 37, 4, substr($tmp, 0, 4));
155 put_hcfa(10, $claim->patientSex() == 'M' ? 42 : 47, 1, 'X');
157 // Box 4. Insured's Name
158 $tmp = $claim->insuredLastName() . ', ' . $claim->insuredFirstName();
159 if ($claim->insuredMiddleName()) {
160 $tmp .= ', ' . substr($claim->insuredMiddleName(), 0, 1);
163 put_hcfa(10, 50, 28, $tmp);
165 // Box 5. Patient's Address
166 put_hcfa(12, 1, 28, $claim->patientStreet());
168 // Box 6. Patient Relationship to Insured
169 $tmp = $claim->insuredRelationship();
170 $tmpcol = 47; // Other
171 if ($tmp === '18') {
172 $tmpcol = 33; // self
173 } else if ($tmp === '01') {
174 $tmpcol = 38; // spouse
175 } else if ($tmp === '19') {
176 $tmpcol = 42; // child
179 put_hcfa(12, $tmpcol, 1, 'X');
181 // Box 7. Insured's Address
182 put_hcfa(12, 50, 28, $claim->insuredStreet());
184 // Box 5 continued. Patient's City and State
185 put_hcfa(14, 1, 20, $claim->patientCity());
186 put_hcfa(14, 26, 2, $claim->patientState());
188 // Box 8. Reserved for NUCC Use in 02/12
190 // Box 7 continued. Insured's City and State
191 put_hcfa(14, 50, 20, $claim->insuredCity());
192 put_hcfa(14, 74, 2, $claim->insuredState());
194 // Box 5 continued. Patient's Zip Code and Telephone
195 put_hcfa(16, 1, 10, $claim->patientZip());
196 $tmp = $claim->patientPhone();
197 put_hcfa(16, 15, 3, substr($tmp, 0, 3));
198 put_hcfa(16, 19, 7, substr($tmp, 3));
200 // Box 7 continued. Insured's Zip Code and Telephone
201 put_hcfa(16, 50, 10, $claim->insuredZip());
202 $tmp = $claim->insuredPhone();
203 put_hcfa(16, 65, 3, substr($tmp, 0, 3));
204 put_hcfa(16, 69, 7, substr($tmp, 3));
206 // Box 9. Other Insured's Name
207 if ($new_medicare_logic) {
208 // TBD: Medigap stuff? How do we know if this is a Medigap transfer?
209 } else {
210 if ($claim->payerCount() > 1) {
211 $tmp = $claim->insuredLastName(1) . ', ' . $claim->insuredFirstName(1);
212 if ($claim->insuredMiddleName(1)) {
213 $tmp .= ', ' . substr($claim->insuredMiddleName(1), 0, 1);
216 put_hcfa(18, 1, 28, $tmp);
220 // Box 11. Insured's Group Number
221 if ($new_medicare_logic) {
222 // If this is Medicare secondary then we need the primary's policy number
223 // here, otherwise the word "NONE".
224 $tmp = $claim->payerSequence() == 'P' ? 'NONE' : $claim->policyNumber(1);
225 } else {
226 $tmp = $claim->groupNumber();
229 put_hcfa(18, 50, 30, $tmp);
231 // Box 9a. Other Insured's Policy or Group Number
232 if ($new_medicare_logic) {
233 // TBD: Medigap stuff?
234 } else {
235 if ($claim->payerCount() > 1) {
236 put_hcfa(20, 1, 28, $claim->policyNumber(1));
240 // Box 10a. Employment Related
241 put_hcfa(20, $claim->isRelatedEmployment() ? 35 : 41, 1, 'X');
243 // Box 11a. Insured's Birth Date and Sex
244 if ($new_medicare_logic) {
245 $tmpdob = $tmpsex = '';
246 if ($claim->payerSequence() != 'P') {
247 $tmpdob = $claim->insuredDOB(1);
248 $tmpsex = $claim->insuredSex(1);
250 } else {
251 $tmpdob = $claim->insuredDOB();
252 $tmpsex = $claim->insuredSex();
255 if ($tmpdob) {
256 put_hcfa(20, 53, 2, substr($tmpdob, 4, 2));
257 put_hcfa(20, 56, 2, substr($tmpdob, 6, 2));
258 put_hcfa(20, 59, 4, substr($tmpdob, 0, 4));
261 if ($tmpsex) {
262 put_hcfa(20, $tmpsex == 'M' ? 68 : 75, 1, 'X');
265 // Box 9b. Reserved for NUCC Use in 02/12
267 // Box 10b. Auto Accident
268 put_hcfa(22, $claim->isRelatedAuto() ? 35 : 41, 1, 'X');
269 if ($claim->isRelatedAuto()) {
270 put_hcfa(22, 45, 2, $claim->autoAccidentState());
273 // Box 11b. Insured's Employer/School Name
274 if ($new_medicare_logic) {
275 $tmp = $claim->payerSequence() == 'P' ? '' : $claim->groupName(1);
276 } else {
277 $tmp = $claim->groupName();
280 put_hcfa(22, 50, 30, $tmp);
282 // Box 9c. Reserved for NUCC Use in 02/12
284 // Box 10c. Other Accident
285 put_hcfa(24, $claim->isRelatedOther() ? 35 : 41, 1, 'X');
287 // Box 11c. Insurance Plan Name or Program Name
288 if ($new_medicare_logic) {
289 $tmp = '';
290 if ($claim->payerSequence() != 'P') {
291 $tmp = $claim->planName(1);
292 if (!$tmp) {
293 $tmp = $claim->payerName(1);
296 } else {
297 $tmp = $claim->planName();
300 put_hcfa(24, 50, 30, $tmp);
302 // Box 9d. Other Insurance Plan Name or Program Name
303 if ($new_medicare_logic) {
304 // TBD: Medigap stuff?
305 } else {
306 if ($claim->payerCount() > 1) {
307 put_hcfa(26, 1, 28, $claim->planName(1));
311 // Box 10d. Claim Codes medicaid_referral_code
313 if ($claim->epsdtFlag()) {
314 put_hcfa(26, 34, 2, $claim->medicaidReferralCode());
317 // Box 11d. Is There Another Health Benefit Plan
319 if (!$new_medicare_logic) {
320 put_hcfa(26, $claim->payerCount() > 1 ? 52 : 57, 1, 'X');
323 // Box 12. Patient's or Authorized Person's Signature
324 put_hcfa(29, 7, 17, 'Signature on File');
325 // Note: Date does not apply unless the person physically signs the form.
327 // Box 13. Insured's or Authorized Person's Signature
328 put_hcfa(29, 55, 17, 'Signature on File');
330 // Box 14. Date of Current Illness/Injury/Pregnancy
331 // this will cause onsetDate in Encounter summary to override misc billing so not perfect yet but fine for now
332 $tmp = ($claim->onsetDate()) ? $claim->onsetDate() : $claim->miscOnsetDate();
333 if (!empty($tmp)) {
334 put_hcfa(32, 2, 2, substr($tmp, 4, 2));
335 put_hcfa(32, 5, 2, substr($tmp, 6, 2));
336 put_hcfa(32, 8, 4, substr($tmp, 0, 4));
337 // Include Box 14 Qualifier
338 put_hcfa(32, 16, 3, $claim->box14Qualifier());
341 // Box 15. First Date of Same or Similar Illness, if applicable
342 $tmp = $claim->dateInitialTreatment();
343 if (!empty($tmp)) {
344 // Only include the Box 15 qualifier if using version 02/12 and there is a Box 15 date.
345 put_hcfa(32, 31, 3, $claim->box15Qualifier());
348 put_hcfa(32, 37, 2, substr($tmp, 4, 2));
349 put_hcfa(32, 40, 2, substr($tmp, 6, 2));
350 put_hcfa(32, 43, 4, substr($tmp, 0, 4));
352 // Box 16. Dates Patient Unable to Work in Current Occupation
353 if ($claim->isUnableToWork()) {
354 $tmp = $claim->offWorkFrom();
355 put_hcfa(32, 54, 2, substr($tmp, 4, 2));
356 put_hcfa(32, 57, 2, substr($tmp, 6, 2));
357 put_hcfa(32, 60, 4, substr($tmp, 0, 4));
358 $tmp = $claim->offWorkTo();
359 put_hcfa(32, 68, 2, substr($tmp, 4, 2));
360 put_hcfa(32, 71, 2, substr($tmp, 6, 2));
361 put_hcfa(32, 74, 4, substr($tmp, 0, 4));
364 // Referring provider stuff. Reports are that for primary care providers,
365 // Medicare forbids an entry here and other payers require one.
366 // There is still confusion over this.
367 if ($claim->referrerLastName() || $claim->billingProviderLastName() &&
368 (empty($GLOBALS['MedicareReferrerIsRenderer']) || $claim->claimType() != 'MB')) {
369 // Box 17a. Referring Provider Alternate Identifier
370 // Commented this out because UPINs are obsolete, leaving the code as an
371 // example in case some other identifier needs to be supported.
372 /*****************************************************************
373 if ($claim->referrerUPIN() && $claim->claimType() != 'MB') {
374 put_hcfa(33, 30, 2, '1G');
375 put_hcfa(33, 33, 15, $claim->referrerUPIN());
377 *****************************************************************/
378 if ($claim->claimType() == 'MC') {
379 put_hcfa(33, 30, 2, 'ZZ');
380 put_hcfa(33, 33, 14, $claim->referrerTaxonomy());
383 // Box 17. Name of Referring Provider or Other Source
384 if (strlen($claim->billingProviderLastName()) !=0) {
385 $tmp2 = $claim->billingProviderLastName() . ', ' . $claim->billingProviderFirstName();
386 if ($claim->billingProviderMiddleName()) {
387 $tmp2 .= ', ' . substr($claim->billingProviderMiddleName(), 0, 1);
390 put_hcfa(34, 1, 3, $claim->billing_options['provider_qualifier_code']);
391 put_hcfa(34, 4, 25, $tmp2);
392 if ($claim->billingProviderNPI()) {
393 put_hcfa(34, 33, 15, $claim->billingProviderNPI());
395 } else {
396 $tmp = $claim->referrerLastName() . ', ' . $claim->referrerFirstName();
397 if ($claim->referrerMiddleName()) {
398 $tmp .= ', ' . substr($claim->referrerMiddleName(), 0, 1);
401 put_hcfa(34, 1, 3, 'DN');
402 put_hcfa(34, 4, 25, $tmp);
403 if ($claim->referrerNPI()) {
404 put_hcfa(34, 33, 15, $claim->referrerNPI());
409 // Box 18. Hospitalization Dates Related to Current Services
410 if ($claim->isHospitalized()) {
411 $tmp = $claim->hospitalizedFrom();
412 put_hcfa(34, 54, 2, substr($tmp, 4, 2));
413 put_hcfa(34, 57, 2, substr($tmp, 6, 2));
414 put_hcfa(34, 60, 4, substr($tmp, 0, 4));
415 $tmp = $claim->hospitalizedTo();
416 put_hcfa(34, 68, 2, substr($tmp, 4, 2));
417 put_hcfa(34, 71, 2, substr($tmp, 6, 2));
418 put_hcfa(34, 74, 4, substr($tmp, 0, 4));
421 // Box 19. Reserved for Local Use
422 put_hcfa(36, 1, 48, $claim->additionalNotes());
424 // Box 20. Outside Lab
425 put_hcfa(36, $claim->isOutsideLab() ? 52 : 57, 1, 'X');
426 if ($claim->isOutsideLab()) {
427 // Note here that put_hcfa strips the decimal point, as required.
428 // We right-justify this amount (ending in col. 69).
429 put_hcfa(36, 63, 8, sprintf('%8s', $claim->outsideLabAmount()));
432 // Box 21. Diagnoses
433 process_diagnoses_02_12($claim, $log);
435 $proccount = $claim->procCount(); // number of procedures
437 // Charges, adjustments and payments are accumulated by line item so that
438 // each page of a multi-page claim will stand alone. Payments include the
439 // co-pay for the first page only.
440 $clm_total_charges = 0;
441 $clm_amount_adjusted = 0;
442 $clm_amount_paid = $hcfa_proc_index ? 0 : $claim->patientPaidAmount();
444 // Procedure loop starts here.
445 for ($svccount = 0; $svccount < 6 && $hcfa_proc_index < $proccount; ++$hcfa_proc_index) {
446 $dia = $claim->diagIndexArray($hcfa_proc_index);
448 if (!$claim->cptCharges($hcfa_proc_index)) {
449 $log .= "*** Procedure '" . $claim->cptKey($hcfa_proc_index) .
450 "' has no charges!\n";
453 if (empty($dia)) {
454 $log .= "*** Procedure '" . $claim->cptKey($hcfa_proc_index) .
455 "' is not justified!\n";
458 $clm_total_charges += $claim->cptCharges($hcfa_proc_index);
460 // Compute prior payments and "hard" adjustments.
461 for ($ins = 1; $ins < $claim->payerCount(); ++$ins) {
462 if ($claim->payerSequence($ins) > $claim->payerSequence()) {
463 continue; // skip future payers
466 $payerpaid = $claim->payerTotals($ins, $claim->cptKey($hcfa_proc_index));
467 $clm_amount_paid += $payerpaid[1];
468 $clm_amount_adjusted += $payerpaid[2];
471 ++$svccount;
472 $lino = $svccount * 2 + 41;
474 // Drug Information. Medicaid insurers want this with HCPCS codes.
476 $ndc = $claim->cptNDCID($hcfa_proc_index);
477 if ($ndc) {
478 if (preg_match('/^(\d\d\d\d\d)-(\d\d\d\d)-(\d\d)$/', $ndc, $tmp)) {
479 $ndc = $tmp[1] . $tmp[2] . $tmp[3];
480 } else if (preg_match('/^\d{11}$/', $ndc)) {
481 } else {
482 $log .= "*** NDC code '$ndc' has invalid format!\n";
485 put_hcfa($lino, 1, 50, "N4$ndc " . $claim->cptNDCUOM($hcfa_proc_index) .
486 $claim->cptNDCQuantity($hcfa_proc_index));
489 //Note Codes.
490 put_hcfa($lino, 25, 7, $claim->cptNotecodes($hcfa_proc_index));
492 // 24i and 24j Top. ID Qualifier and Rendering Provider ID
493 if ($claim->supervisorNumber()) {
494 // If there is a supervising provider and that person has a
495 // payer-specific provider number, then we assume that the SP
496 // must be identified on the claim and this is how we do it
497 // (but the NPI of the actual rendering provider appears below).
498 // BCBS of TN indicated they want it this way. YMMV. -- Rod
499 put_hcfa($lino, 65, 2, $claim->supervisorNumberType());
500 put_hcfa($lino, 68, 10, $claim->supervisorNumber());
501 } else if ($claim->providerNumber($hcfa_proc_index)) {
502 put_hcfa($lino, 65, 2, $claim->providerNumberType($hcfa_proc_index));
503 put_hcfa($lino, 68, 10, $claim->providerNumber($hcfa_proc_index));
504 } else if ($claim->claimType() == 'MC') {
505 put_hcfa($lino, 65, 2, 'ZZ');
506 put_hcfa($lino, 68, 14, $claim->providerTaxonomy());
509 ++$lino;
511 // 24a. Date of Service
512 $tmp = $claim->serviceDate();
513 put_hcfa($lino, 1, 2, substr($tmp, 4, 2));
514 put_hcfa($lino, 4, 2, substr($tmp, 6, 2));
515 put_hcfa($lino, 7, 2, substr($tmp, 2, 2));
516 put_hcfa($lino, 10, 2, substr($tmp, 4, 2));
517 put_hcfa($lino, 13, 2, substr($tmp, 6, 2));
518 put_hcfa($lino, 16, 2, substr($tmp, 2, 2));
520 // 24b. Place of Service
521 put_hcfa($lino, 19, 2, $claim->facilityPOS());
523 // 24c. EMG
524 // Not currently supported.
526 // 24d. Procedures, Services or Supplies
527 put_hcfa($lino, 25, 7, $claim->cptCode($hcfa_proc_index));
528 // replace colon with space for printing
529 put_hcfa($lino, 33, 12, str_replace(':', ' ', $claim->cptModifier($hcfa_proc_index)));
531 // 24e. Diagnosis Pointer
532 $tmp = '';
533 foreach ($claim->diagIndexArray($hcfa_proc_index) as $value) {
534 $value=chr($value+64);
535 $tmp .= $value;
538 put_hcfa($lino, 45, 4, $tmp);
540 // 24f. Charges
541 put_hcfa($lino, 50, 8, str_replace(
542 '.',
543 ' ',
544 sprintf('%8.2f', $claim->cptCharges($hcfa_proc_index))
547 // 24g. Days or Units
548 put_hcfa($lino, 59, 3, $claim->cptUnits($hcfa_proc_index));
550 // 24h. EPSDT Family Plan
552 if ($claim->epsdtFlag()) {
553 put_hcfa($lino, 63, 2, '03');
556 // 24j. Rendering Provider NPI
557 put_hcfa($lino, 68, 10, $claim->providerNPI($hcfa_proc_index));
560 // 25. Federal Tax ID Number
561 put_hcfa(56, 1, 15, $claim->billingFacilityETIN());
562 if ($claim->federalIdType()=='SY') {
563 put_hcfa(56, 17, 1, 'X'); // The SSN checkbox
564 } else {
565 put_hcfa(56, 19, 1, 'X'); // The EIN checkbox
568 // 26. Patient's Account No.
569 // Instructions say hyphens are not allowed.
570 put_hcfa(56, 23, 15, "$pid-$encounter");
572 // 27. Accept Assignment
573 put_hcfa(56, $claim->billingFacilityAssignment() ? 38 : 43, 1, 'X');
575 // 28. Total Charge
576 put_hcfa(56, 52, 8, str_replace('.', ' ', sprintf('%8.2f', $clm_total_charges)));
577 if (!$clm_total_charges) {
578 $log .= "*** This claim has no charges!\n";
581 // 29. Amount Paid
582 put_hcfa(56, 62, 8, str_replace('.', ' ', sprintf('%8.2f', $clm_amount_paid)));
584 // 30. Reserved for NUCC use.
586 // 33. Billing Provider: Phone Number
587 $tmp = $claim->billingContactPhone();
588 put_hcfa(57, 66, 3, substr($tmp, 0, 3));
589 put_hcfa(57, 70, 3, substr($tmp, 3)); // slight adjustment for better look smw 030315
590 put_hcfa(57, 73, 1, '-');
591 put_hcfa(57, 74, 4, substr($tmp, 6));
593 // 32. Service Facility Location Information: Name
594 put_hcfa(58, 23, 25, $claim->facilityName());
596 // 33. Billing Provider: Name
597 if ($claim->federalIdType() == "SY") { // check entity type for NM*102 1 == person, 2 == non-person entity
598 $firstName = $claim->providerFirstName();
599 $lastName = $claim->providerLastName();
600 $middleName = $claim->providerMiddleName();
601 $suffixName = $claim->providerSuffixName();
602 $billingProviderName = $lastName . ", " . $firstName. ", " . $middleName. ", " . $suffixName;
603 put_hcfa(58, 50, 25, $billingProviderName);
604 } else {
605 put_hcfa(58, 50, 25, $claim->billingFacilityName());
608 // 32. Service Facility Location Information: Street
609 put_hcfa(59, 23, 25, $claim->facilityStreet());
611 // 33. Billing Provider: Name
612 put_hcfa(59, 50, 25, $claim->billingFacilityStreet());
614 // 31. Signature of Physician or Supplier
616 if ($GLOBALS['cms_1500_box_31_format']==0) {
617 put_hcfa(60, 1, 20, 'Signature on File');
618 } else if ($GLOBALS['cms_1500_box_31_format']==1) {
619 put_hcfa(60, 1, 22, $claim->providerFirstName()." ".$claim->providerLastName());
622 // 32. Service Facility Location Information: City State Zip
623 $tmp = $claim->facilityCity() ? ($claim->facilityCity() . ' ') : '';
624 put_hcfa(60, 23, 27, $tmp . $claim->facilityState() . ' ' .
625 $claim->facilityZip());
627 // 33. Billing Provider: City State Zip
628 $tmp = $claim->billingFacilityCity() ? ($claim->billingFacilityCity() . ' ') : '';
629 put_hcfa(60, 50, 27, $tmp . $claim->billingFacilityState() . ' ' .
630 $claim->billingFacilityZip());
632 // 31. Signature of Physician or Supplier: Date
633 if ($GLOBALS['cms_1500_box_31_date']>0) {
634 if ($GLOBALS['cms_1500_box_31_date']==1) {
635 $date_of_service= $claim->serviceDate();
636 $MDY=substr($date_of_service, 4, 2)." ".substr($date_of_service, 6, 2)." ".substr($date_of_service, 2, 2);
637 } else if ($GLOBALS['cms_1500_box_31_date']==2) {
638 $MDY=date("m/d/y");
641 put_hcfa(61, 6, 10, $MDY);
644 // 32a. Service Facility NPI
645 put_hcfa(61, 23, 10, $claim->facilityNPI());
647 // 32b. Service Facility Other ID
648 // Note that Medicare does NOT want this any more.
649 if ($claim->providerGroupNumber()) {
650 put_hcfa(61, 36, 2, $claim->providerNumberType());
651 put_hcfa(61, 38, 11, $claim->providerGroupNumber());
654 // 33a. Billing Facility NPI
655 put_hcfa(61, 50, 10, $claim->billingFacilityNPI());
657 // 33b. Billing Facility Other ID
658 // Note that Medicare does NOT want this any more.
659 if ($claim->claimType() == 'MC') {
660 put_hcfa(61, 63, 2, 'ZZ');
661 put_hcfa(61, 65, 14, $claim->providerTaxonomy());
662 } elseif ($claim->providerGroupNumber() && $claim->claimType() != 'MB') {
663 put_hcfa(61, 63, 2, $claim->providerNumberType());
664 put_hcfa(61, 65, 14, $claim->providerGroupNumber());
667 // Put an extra line here for compatibility with old hcfa text generated form
668 put_hcfa(62, 1, 1, ' ');
669 // put a couple more in so that multiple claims correctly print through the text file download
670 put_hcfa(63, 1, 1, ' ');
671 put_hcfa(64, 1, 1, ' ');
672 return;