minor bug fix
[openemr.git] / library / gen_hcfa_1500.inc.php
blobc455e0e0cb3d1d5530898366881800c86bbf7e0c
1 <?php
2 // Copyright (C) 2008-2011 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("Claim.class.php");
11 $hcfa_curr_line = 1;
12 $hcfa_curr_col = 1;
13 $hcfa_data = '';
14 $hcfa_proc_index = 0;
16 function put_hcfa($line, $col, $maxlen, $data) {
17 global $hcfa_curr_line, $hcfa_curr_col, $hcfa_data;
18 if ($line < $hcfa_curr_line)
19 die("Data item at ($line, $col) precedes current line.");
20 while ($hcfa_curr_line < $line) {
21 $hcfa_data .= "\n";
22 ++$hcfa_curr_line;
23 $hcfa_curr_col = 1;
25 if ($col < $hcfa_curr_col)
26 die("Data item at ($line, $col) precedes current column.");
27 while ($hcfa_curr_col < $col) {
28 $hcfa_data .= " ";
29 ++$hcfa_curr_col;
31 $data = preg_replace('/[.#]/', '', strtoupper($data));
32 $len = min(strlen($data), $maxlen);
33 $hcfa_data .= substr($data, 0, $len);
34 $hcfa_curr_col += $len;
37 function gen_hcfa_1500($pid, $encounter, &$log) {
38 global $hcfa_data, $hcfa_proc_index;
40 $hcfa_data = '';
41 $hcfa_proc_index = 0;
43 $today = time();
44 $claim = new Claim($pid, $encounter);
46 $log .= "Generating HCFA claim $pid-$encounter for " .
47 $claim->patientFirstName() . ' ' .
48 $claim->patientMiddleName() . ' ' .
49 $claim->patientLastName() . ' on ' .
50 date('Y-m-d H:i', $today) . ".\n";
52 while ($hcfa_proc_index < $claim->procCount()) {
53 if ($hcfa_proc_index) $hcfa_data .= "\014"; // append form feed for new page
54 gen_hcfa_1500_page($pid, $encounter, $log, $claim);
57 $log .= "\n";
58 return $hcfa_data;
61 function gen_hcfa_1500_page($pid, $encounter, &$log, &$claim) {
62 global $hcfa_curr_line, $hcfa_curr_col, $hcfa_data, $hcfa_proc_index;
64 $hcfa_curr_line = 1;
65 $hcfa_curr_col = 1;
67 // According to:
68 // http://www.ngsmedicare.com/NGSMedicare/PartB/EducationandSupport/ToolsandMaterials/CMS_ClaimFormInst.aspx
69 // Medicare interprets sections 9 and 11 of the claim form in its own
70 // special way. This flag tells us to do that. However I'm not 100%
71 // sure that it applies nationwide, and if you find that it is not right
72 // for you then set it to false. -- Rod 2009-03-26
73 $new_medicare_logic = $claim->claimType() == 'MB';
75 // Payer name, attn, street.
76 put_hcfa(2, 41, 31, $claim->payerName());
77 put_hcfa(3, 41, 31, $claim->payerAttn());
78 put_hcfa(4, 41, 31, $claim->payerStreet());
80 // Payer city, state, zip.
81 $tmp = $claim->payerCity() ? ($claim->payerCity() . ', ') : '';
82 put_hcfa(5, 41, 31, $tmp . $claim->payerState() . ' ' . $claim->payerZip());
84 // Box 1. Insurance Type
85 $ct = $claim->claimType();
86 $tmpcol = 45; // Other
87 if ($ct === 'MB') $tmpcol = 1; // Medicare
88 else if ($ct === 'MC') $tmpcol = 8; // Medicaid
89 else if ($ct === 'CH') $tmpcol = 15; // Champus
90 else if ($ct === 'CH') $tmpcol = 24; // Champus VA (why same code?)
91 else if ($ct === 'BL') $tmpcol = 31; // Group Health Plan (only BCBS?)
92 else if ($ct === '16') $tmpcol = 39; // FECA
93 put_hcfa(8, $tmpcol, 1, 'X');
95 // Box 1a. Insured's ID Number
96 put_hcfa(8, 50, 17, $claim->policyNumber());
98 // Box 2. Patient's Name
99 $tmp = $claim->patientLastName() . ', ' . $claim->patientFirstName();
100 if ($claim->patientMiddleName())
101 $tmp .= ', ' . substr($claim->patientMiddleName(),0,1);
102 put_hcfa(10, 1, 28, $tmp);
104 // Box 3. Patient's Birth Date and Sex
105 $tmp = $claim->patientDOB();
106 put_hcfa(10, 31, 2, substr($tmp,4,2));
107 put_hcfa(10, 34, 2, substr($tmp,6,2));
108 put_hcfa(10, 37, 4, substr($tmp,0,4));
109 put_hcfa(10, $claim->patientSex() == 'M' ? 42 : 47, 1, 'X');
111 // Box 4. Insured's Name
112 $tmp = $claim->insuredLastName() . ', ' . $claim->insuredFirstName();
113 if ($claim->insuredMiddleName())
114 $tmp .= ', ' . substr($claim->insuredMiddleName(),0,1);
115 put_hcfa(10, 50, 28, $tmp);
117 // Box 5. Patient's Address
118 put_hcfa(12, 1, 28, $claim->patientStreet());
120 // Box 6. Patient Relationship to Insured
121 $tmp = $claim->insuredRelationship();
122 $tmpcol = 47; // Other
123 if ($tmp === '18') $tmpcol = 33; // self
124 else if ($tmp === '01') $tmpcol = 38; // spouse
125 else if ($tmp === '19') $tmpcol = 42; // child
126 put_hcfa(12, $tmpcol, 1, 'X');
128 // Box 7. Insured's Address
129 put_hcfa(12, 50, 28, $claim->insuredStreet());
131 // Box 5 continued. Patient's City and State
132 put_hcfa(14, 1, 20, $claim->patientCity());
133 put_hcfa(14, 26, 2, $claim->patientState());
135 // Box 8. Patient (Marital) Status
136 $tmp = $claim->patientStatus();
137 $tmpcol = 47; // Other
138 if ($tmp === 'S') $tmpcol = 35; // Single
139 else if ($tmp === 'M') $tmpcol = 41; // Married
140 put_hcfa(14, $tmpcol, 1, 'X');
142 // Box 7 continued. Insured's City and State
143 put_hcfa(14, 50, 20, $claim->insuredCity());
144 put_hcfa(14, 74, 2, $claim->insuredState());
146 // Box 5 continued. Patient's Zip Code and Telephone
147 put_hcfa(16, 1, 10, $claim->patientZip());
148 $tmp = $claim->patientPhone();
149 put_hcfa(16, 15, 3, substr($tmp,0,3));
150 put_hcfa(16, 19, 7, substr($tmp,3));
152 // Box 8 continued. Patient (Employment) Status
153 $tmp = $claim->patientOccupation();
154 if ($tmp === 'STUDENT' ) put_hcfa(16, 41, 1, 'X');
155 else if ($tmp === 'PT STUDENT') put_hcfa(16, 47, 1, 'X');
156 else if ($tmp !== 'UNEMPLOYED') put_hcfa(16, 35, 1, 'X');
158 // Box 7 continued. Insured's Zip Code and Telephone
159 put_hcfa(16, 50, 10, $claim->insuredZip());
160 $tmp = $claim->insuredPhone();
161 put_hcfa(16, 65, 3, substr($tmp,0,3));
162 put_hcfa(16, 69, 7, substr($tmp,3));
164 // Box 9. Other Insured's Name
165 if ($new_medicare_logic) {
166 // TBD: Medigap stuff? How do we know if this is a Medigap transfer?
168 else {
169 if ($claim->payerCount() > 1) {
170 $tmp = $claim->insuredLastName(1) . ', ' . $claim->insuredFirstName(1);
171 if ($claim->insuredMiddleName(1))
172 $tmp .= ', ' . substr($claim->insuredMiddleName(1),0,1);
173 put_hcfa(18, 1, 28, $tmp);
177 // Box 11. Insured's Group Number
178 if ($new_medicare_logic) {
179 // If this is Medicare secondary then we need the primary's policy number
180 // here, otherwise the word "NONE".
181 $tmp = $claim->payerSequence() == 'P' ? 'NONE' : $claim->policyNumber(1);
183 else {
184 $tmp = $claim->groupNumber();
186 put_hcfa(18, 50, 30, $tmp);
188 // Box 9a. Other Insured's Policy or Group Number
189 if ($new_medicare_logic) {
190 // TBD: Medigap stuff?
192 else {
193 if ($claim->payerCount() > 1) {
194 put_hcfa(20, 1, 28, $claim->policyNumber(1));
198 // Box 10a. Employment Related
199 put_hcfa(20, $claim->isRelatedEmployment() ? 35 : 41, 1, 'X');
201 // Box 11a. Insured's Birth Date and Sex
202 if ($new_medicare_logic) {
203 $tmpdob = $tmpsex = '';
204 if ($claim->payerSequence() != 'P') {
205 $tmpdob = $claim->insuredDOB(1);
206 $tmpsex = $claim->insuredSex(1);
209 else {
210 $tmpdob = $claim->insuredDOB();
211 $tmpsex = $claim->insuredSex();
213 if ($tmpdob) {
214 put_hcfa(20, 53, 2, substr($tmpdob,4,2));
215 put_hcfa(20, 56, 2, substr($tmpdob,6,2));
216 put_hcfa(20, 59, 4, substr($tmpdob,0,4));
218 if ($tmpsex) {
219 put_hcfa(20, $tmpsex == 'M' ? 68 : 75, 1, 'X');
222 // Box 9b. Other Insured's Birth Date and Sex
223 if ($new_medicare_logic) {
224 // TBD: Medigap stuff?
226 else {
227 if ($claim->payerCount() > 1) {
228 $tmp = $claim->insuredDOB(1);
229 put_hcfa(22, 2, 2, substr($tmp,4,2));
230 put_hcfa(22, 5, 2, substr($tmp,6,2));
231 put_hcfa(22, 8, 4, substr($tmp,0,4));
232 put_hcfa(22, $claim->insuredSex(1) == 'M' ? 18 : 24, 1, 'X');
236 // Box 10b. Auto Accident
237 put_hcfa(22, $claim->isRelatedAuto() ? 35 : 41, 1, 'X');
238 if ($claim->isRelatedAuto())
239 put_hcfa(22, 45, 2, $claim->autoAccidentState());
241 // Box 11b. Insured's Employer/School Name
242 if ($new_medicare_logic) {
243 $tmp = $claim->payerSequence() == 'P' ? '' : $claim->groupName(1);
245 else {
246 $tmp = $claim->groupName();
248 put_hcfa(22, 50, 30, $tmp);
250 // Box 9c. Other Insured's Employer/School Name
251 if ($new_medicare_logic) {
252 // TBD: Medigap stuff?
254 else {
255 if ($claim->payerCount() > 1) {
256 put_hcfa(24, 1, 28, $claim->groupName(1));
260 // Box 10c. Other Accident
261 put_hcfa(24, $claim->isRelatedOther() ? 35 : 41, 1, 'X');
263 // Box 11c. Insurance Plan Name or Program Name
264 if ($new_medicare_logic) {
265 $tmp = '';
266 if ($claim->payerSequence() != 'P') {
267 $tmp = $claim->planName(1);
268 if (!$tmp) $tmp = $claim->payerName(1);
271 else {
272 $tmp = $claim->planName();
274 put_hcfa(24, 50, 30, $tmp);
276 // Box 9d. Other Insurance Plan Name or Program Name
277 if ($new_medicare_logic) {
278 // TBD: Medigap stuff?
280 else {
281 if ($claim->payerCount() > 1) {
282 put_hcfa(26, 1, 28, $claim->planName(1));
286 // Box 11d. Is There Another Health Benefit Plan
287 if (!$new_medicare_logic) {
288 put_hcfa(26, $claim->payerCount() > 1 ? 52 : 57, 1, 'X');
291 // Box 12. Patient's or Authorized Person's Signature
292 put_hcfa(29, 7, 17, 'Signature on File');
293 // Note: Date does not apply unless the person physically signs the form.
295 // Box 13. Insured's or Authorized Person's Signature
296 put_hcfa(29, 55, 17, 'Signature on File');
298 // Box 14. Date of Current Illness/Injury/Pregnancy
299 $tmp = $claim->onsetDate();
300 put_hcfa(32, 2, 2, substr($tmp,4,2));
301 put_hcfa(32, 5, 2, substr($tmp,6,2));
302 put_hcfa(32, 8, 4, substr($tmp,0,4));
304 // Box 15. First Date of Same or Similar Illness, if applicable
305 $tmp = $claim->dateInitialTreatment();
306 put_hcfa(32,36, 2, substr($tmp,4,2));
307 put_hcfa(32,39, 2, substr($tmp,6,2));
308 put_hcfa(32,42, 4, substr($tmp,0,4));
310 // Box 16. Dates Patient Unable to Work in Current Occupation
311 if ($claim->isUnableToWork()) {
312 $tmp = $claim->offWorkFrom();
313 put_hcfa(32, 54, 2, substr($tmp,4,2));
314 put_hcfa(32, 57, 2, substr($tmp,6,2));
315 put_hcfa(32, 60, 4, substr($tmp,0,4));
316 $tmp = $claim->offWorkTo();
317 put_hcfa(32, 68, 2, substr($tmp,4,2));
318 put_hcfa(32, 71, 2, substr($tmp,6,2));
319 put_hcfa(32, 74, 4, substr($tmp,0,4));
322 // Referring provider stuff. Reports are that for primary care doctors,
323 // Medicare forbids an entry here and other payers require one.
324 // There is still confusion over this.
326 if ($claim->referrerLastName() &&
327 (empty($GLOBALS['MedicareReferrerIsRenderer']) || $claim->claimType() != 'MB'))
329 // Box 17a. Referring Provider Alternate Identifier
330 if ($claim->referrerUPIN() && $claim->claimType() != 'MB') {
331 put_hcfa(33, 30, 2, '1G');
332 put_hcfa(33, 33, 15, $claim->referrerUPIN());
335 // Box 17. Name of Referring Provider or Other Source
336 $tmp = $claim->referrerLastName() . ', ' . $claim->referrerFirstName();
337 if ($claim->referrerMiddleName())
338 $tmp .= ', ' . substr($claim->referrerMiddleName(),0,1);
339 put_hcfa(34, 1, 25, $tmp);
341 // Box 17b. Referring Provider NPI
342 if ($claim->referrerNPI()) {
343 put_hcfa(34, 33, 15, $claim->referrerNPI());
347 // Box 18. Hospitalization Dates Related to Current Services
348 if ($claim->isHospitalized()) {
349 $tmp = $claim->hospitalizedFrom();
350 put_hcfa(34, 54, 2, substr($tmp,4,2));
351 put_hcfa(34, 57, 2, substr($tmp,6,2));
352 put_hcfa(34, 60, 4, substr($tmp,0,4));
353 $tmp = $claim->hospitalizedTo();
354 put_hcfa(34, 68, 2, substr($tmp,4,2));
355 put_hcfa(34, 71, 2, substr($tmp,6,2));
356 put_hcfa(34, 74, 4, substr($tmp,0,4));
359 // Box 19. Reserved for Local Use
360 put_hcfa(36, 1, 48, $claim->additionalNotes());
362 // Box 20. Outside Lab
363 put_hcfa(36, $claim->isOutsideLab() ? 52 : 57, 1, 'X');
364 if ($claim->isOutsideLab()) {
365 // Note here that put_hcfa strips the decimal point, as required.
366 // We right-justify this amount (ending in col. 69).
367 put_hcfa(36, 63, 8, sprintf('%8s', $claim->outsideLabAmount()));
370 // Box 21. Diagnoses
371 $tmp = $claim->diagArray();
372 $diags = array();
373 foreach ($tmp as $diag) $diags[] = $diag;
374 if (!empty($diags[0])) {
375 put_hcfa(38, 3, 3, substr($diags[0], 0, 3));
376 put_hcfa(38, 7, 2, substr($diags[0], 3));
378 if (!empty($diags[2])) {
379 put_hcfa(38, 30, 3, substr($diags[2], 0, 3));
380 put_hcfa(38, 34, 2, substr($diags[2], 3));
383 // Box 22. Medicaid Resubmission Code and Original Ref. No.
384 put_hcfa(38, 50, 10, $claim->medicaidResubmissionCode());
385 put_hcfa(38, 62, 10, $claim->medicaidOriginalReference());
387 // Box 21 continued. Diagnoses
388 if (!empty($diags[1])) {
389 put_hcfa(40, 3, 3, substr($diags[1], 0, 3));
390 put_hcfa(40, 7, 2, substr($diags[1], 3));
392 if (!empty($diags[3])) {
393 put_hcfa(40, 30, 3, substr($diags[3], 0, 3));
394 put_hcfa(40, 34, 2, substr($diags[3], 3));
397 // Box 23. Prior Authorization Number
398 put_hcfa(40, 50, 28, $claim->priorAuth());
400 $proccount = $claim->procCount(); // number of procedures
402 // Charges, adjustments and payments are accumulated by line item so that
403 // each page of a multi-page claim will stand alone. Payments include the
404 // co-pay for the first page only.
405 $clm_total_charges = 0;
406 $clm_amount_adjusted = 0;
407 $clm_amount_paid = $hcfa_proc_index ? 0 : $claim->patientPaidAmount();
409 // Procedure loop starts here.
411 for ($svccount = 0; $svccount < 6 && $hcfa_proc_index < $proccount; ++$hcfa_proc_index) {
412 $dia = $claim->diagIndexArray($hcfa_proc_index);
414 if (!$claim->cptCharges($hcfa_proc_index)) {
415 $log .= "*** Procedure '" . $claim->cptKey($hcfa_proc_index) .
416 "' has no charges!\n";
419 if (empty($dia)) {
420 $log .= "*** Procedure '" . $claim->cptKey($hcfa_proc_index) .
421 "' is not justified!\n";
424 $clm_total_charges += $claim->cptCharges($hcfa_proc_index);
426 // Compute prior payments and "hard" adjustments.
427 for ($ins = 1; $ins < $claim->payerCount(); ++$ins) {
428 if ($claim->payerSequence($ins) > $claim->payerSequence())
429 continue; // skip future payers
430 $payerpaid = $claim->payerTotals($ins, $claim->cptKey($hcfa_proc_index));
431 $clm_amount_paid += $payerpaid[1];
432 $clm_amount_adjusted += $payerpaid[2];
435 ++$svccount;
436 $lino = $svccount * 2 + 41;
438 // Drug Information. Medicaid insurers want this with HCPCS codes.
440 $ndc = $claim->cptNDCID($hcfa_proc_index);
441 if ($ndc) {
442 if (preg_match('/^(\d\d\d\d\d)-(\d\d\d\d)-(\d\d)$/', $ndc, $tmp)) {
443 $ndc = $tmp[1] . $tmp[2] . $tmp[3];
445 else if(preg_match('/^\d{11}$/', $ndc)){
448 else {
449 $log .= "*** NDC code '$ndc' has invalid format!\n";
451 put_hcfa($lino, 1, 50, "N4$ndc " . $claim->cptNDCUOM($hcfa_proc_index) .
452 $claim->cptNDCQuantity($hcfa_proc_index));
455 //Note Codes.
456 put_hcfa($lino, 25, 7, $claim->cptNotecodes($hcfa_proc_index));
458 // 24i and 24j Top. ID Qualifier and Rendering Provider ID
459 if ($claim->supervisorNumber()) {
460 // If there is a supervising provider and that person has a
461 // payer-specific provider number, then we assume that the SP
462 // must be identified on the claim and this is how we do it
463 // (but the NPI of the actual rendering provider appears below).
464 // BCBS of TN indicated they want it this way. YMMV. -- Rod
465 put_hcfa($lino, 65, 2, $claim->supervisorNumberType());
466 put_hcfa($lino, 68, 10, $claim->supervisorNumber());
468 else if ($claim->providerNumber($hcfa_proc_index)) {
469 put_hcfa($lino, 65, 2, $claim->providerNumberType($hcfa_proc_index));
470 put_hcfa($lino, 68, 10, $claim->providerNumber($hcfa_proc_index));
473 ++$lino;
475 // 24a. Date of Service
476 $tmp = $claim->serviceDate();
477 put_hcfa($lino, 1, 2, substr($tmp,4,2));
478 put_hcfa($lino, 4, 2, substr($tmp,6,2));
479 put_hcfa($lino, 7, 2, substr($tmp,2,2));
480 put_hcfa($lino,10, 2, substr($tmp,4,2));
481 put_hcfa($lino,13, 2, substr($tmp,6,2));
482 put_hcfa($lino,16, 2, substr($tmp,2,2));
484 // 24b. Place of Service
485 put_hcfa($lino, 19, 2, $claim->facilityPOS());
487 // 24c. EMG
488 // Not currently supported.
490 // 24d. Procedures, Services or Supplies
491 put_hcfa($lino, 25, 7, $claim->cptCode($hcfa_proc_index));
492 // replace colon with space for printing
493 put_hcfa($lino, 33, 12, str_replace(':', ' ', $claim->cptModifier($hcfa_proc_index)));
495 // 24e. Diagnosis Pointer
496 $tmp = '';
497 foreach ($claim->diagIndexArray($hcfa_proc_index) as $value) $tmp .= $value;
498 put_hcfa($lino, 45, 4, $tmp);
500 // 24f. Charges
501 put_hcfa($lino, 50, 8, str_replace('.', ' ',
502 sprintf('%8.2f', $claim->cptCharges($hcfa_proc_index))));
504 // 24g. Days or Units
505 put_hcfa($lino, 59, 3, $claim->cptUnits($hcfa_proc_index));
507 // 24h. EPSDT Family Plan
508 // Not currently supported.
510 // 24j. Rendering Provider NPI
511 put_hcfa($lino, 68, 10, $claim->providerNPI($hcfa_proc_index));
514 // 25. Federal Tax ID Number
515 // FrreB hard coded EIN. Changed it to included SSN as well.
516 put_hcfa(56, 1, 15, $claim->billingFacilityETIN());
517 if($claim->federalIdType()=='SY'){
518 put_hcfa(56, 16, 1, 'X'); // The SSN checkbox
520 else{
521 put_hcfa(56, 19, 1, 'X'); // The EIN checkbox
524 // 26. Patient's Account No.
525 // Instructions say hyphens are not allowed, but freeb used them.
526 put_hcfa(56, 23, 15, "$pid-$encounter");
528 // 27. Accept Assignment
529 put_hcfa(56, $claim->billingFacilityAssignment() ? 38 : 43, 1, 'X');
531 // 28. Total Charge
532 put_hcfa(56, 52, 8, str_replace('.',' ',sprintf('%8.2f',$clm_total_charges)));
533 if (!$clm_total_charges) {
534 $log .= "*** This claim has no charges!\n";
537 // 29. Amount Paid
538 put_hcfa(56, 62, 8, str_replace('.',' ',sprintf('%8.2f',$clm_amount_paid)));
540 // 30. Balance Due
541 // For secondary payers this reflects primary "contracted rate" adjustments,
542 // so in general box 30 will not equal box 28 minus box 29.
543 put_hcfa(56, 71, 8, str_replace('.',' ',sprintf('%8.2f',
544 $clm_total_charges - $clm_amount_paid - $clm_amount_adjusted)));
546 // 33. Billing Provider: Phone Number
547 $tmp = $claim->billingContactPhone();
548 put_hcfa(57, 66, 3, substr($tmp,0,3));
549 put_hcfa(57, 70, 7, substr($tmp,3));
551 // 32. Service Facility Location Information: Name
552 put_hcfa(58, 23, 25, $claim->facilityName());
554 // 33. Billing Provider: Name
555 put_hcfa(58, 50, 25, $claim->billingFacilityName());
557 // 32. Service Facility Location Information: Street
558 put_hcfa(59, 23, 25, $claim->facilityStreet());
560 // 33. Billing Provider: Name
561 put_hcfa(59, 50, 25, $claim->billingFacilityStreet());
563 // 31. Signature of Physician or Supplier
564 // FreeB printed the rendering provider's name and the current date here,
565 // but according to my instructions it must be a real signature and date,
566 // or else "Signature on File" or "SOF".
567 put_hcfa(60, 1, 20, 'Signature on File');
569 // $tmp = $claim->providerFirstName();
570 // if ($claim->providerMiddleName()) $tmp .= ' ' . substr($claim->providerMiddleName(),0,1);
571 // put_hcfa(60, 1, 20, $tmp . ' ' . $claim->providerLastName());
573 // 32. Service Facility Location Information: City State Zip
574 $tmp = $claim->facilityCity() ? ($claim->facilityCity() . ' ') : '';
575 put_hcfa(60, 23, 27, $tmp . $claim->facilityState() . ' ' .
576 $claim->facilityZip());
578 // 33. Billing Provider: City State Zip
579 $tmp = $claim->billingFacilityCity() ? ($claim->billingFacilityCity() . ' ') : '';
580 put_hcfa(60, 50, 27, $tmp . $claim->billingFacilityState() . ' ' .
581 $claim->billingFacilityZip());
583 // 32a. Service Facility NPI
584 put_hcfa(61, 24, 10, $claim->facilityNPI());
586 // 32b. Service Facility Other ID
587 // Note that Medicare does NOT want this any more.
588 if ($claim->providerGroupNumber()) {
589 put_hcfa(61, 36, 2, $claim->providerNumberType());
590 put_hcfa(61, 38, 11, $claim->providerGroupNumber());
593 // 33a. Billing Facility NPI
594 put_hcfa(61, 51, 10, $claim->billingFacilityNPI());
596 // 33b. Billing Facility Other ID
597 // Note that Medicare does NOT want this any more.
598 if ($claim->providerGroupNumber() && $claim->claimType() != 'MB') {
599 put_hcfa(61, 63, 2, $claim->providerNumberType());
600 put_hcfa(61, 65, 14, $claim->providerGroupNumber());
603 // Put an extra line here for compatibility with old hcfa text generated form
604 put_hcfa(62, 1, 1, ' ');
606 return;