Display fix: width in manila for demographics (#1909)
[openemr.git] / library / gen_hcfa_1500_02_12.inc.php
blob78438c3c5c1f167a11c46c195f0fb7ee37575bd1
1 <?php
2 /*
3 * Utilities to support HCFA 1500 02/12 Version
4 * For details on format refer to:
5 * <http://www.nucc.org/index.php?option=com_content&view=article&id=186&Itemid=138>
7 * @package OpenEMR
8 * @author Kevin Yeh <kevin.y@integralemr.com>
9 * @author Stephen Waite <stephen.waite@cmsvt.com>
10 * @copyright Copyright (c) 2013 Kevin Yeh <kevin.y@integralemr.com>
11 * @copyright Copyright (c) 2018 Stephen Waite <stephen.waite@cmsvt.com>
12 * @link https://github.com/openemr/openemr/tree/master
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 /**
17 * Helper class to manage which rows and columns information belong in.
18 * This allows "out of order" creation of the content.
20 class hcfa_info
22 protected $row;
23 protected $column;
24 protected $width;
25 protected $info;
27 /**
29 * @param type $row Which row to put this data on
30 * @param type $column Which column to put this data in
31 * @param type $width How many characters max to print on
32 * @param type $info The text to print on the form at the specified location
34 public function __construct($row, $column, $width, $info)
36 $this->row=$row;
37 $this->column=$column;
38 $this->width=$width;
39 $this->info=$info;
42 /**
43 * Determine relative position of an element
45 * @return type integer
47 public function get_position()
49 return $this->row*100+$this->column;
52 /**
53 * Add the info to the form
55 public function put()
57 // Override the default value for "strip" with put_hcfa to keep periods
58 put_hcfa($this->row, $this->column, $this->width, $this->info, '/#/');
62 /**
63 * comparator function for hfca_info class to allow proper sorting
65 * @param type $first
66 * @param type $second
67 * @return int
69 function cmp_hcfa_info($first, $second)
71 $first_value=$first->get_position();
72 $second_value=$second->get_position();
73 if ($first_value==$second_value) {
74 return 0;
77 return $first_value<$second_value ? -1 : 1;
80 /**
81 * calculate where on the form a given diagnosis belongs and add it to the entries
83 * @param array $hcfa_entries
84 * @param type $number
85 * @param type $diag
87 function add_diagnosis(&$hcfa_entries, $number, $diag)
90 * The diagnoses go across the page.
91 * Positioned
92 * A B C D
93 * E F G H
94 * I J K L
96 $column_num = ($number%4);
97 $row_num = (int)($number / 4);
99 // First column is at location 3, each column is 13 wide
100 $col_pos=3+13*$column_num;
102 // First diagnosis row is 38
103 $strip='/[.#]/';
104 $diag = preg_replace($strip, '', strtoupper($diag));
105 $row_pos=38+$row_num;
106 $hcfa_entries[]=new hcfa_info($row_pos, $col_pos, 8, $diag);
110 * Process the diagnoses for a given claim. log any errors
112 * @param type $claim
113 * @param string $log
115 function process_diagnoses_02_12(&$claim, &$log)
118 $hcfa_entries=array();
119 $diags = $claim->diagArray(false);
120 if ($claim->diagtype=='ICD10') {
121 $icd_indicator='0';
122 } else {
123 $icd_indicator='9';
126 $hcfa_entries[]=new hcfa_info(37, 42, 1, $icd_indicator);
128 // Box 22. Medicaid Resubmission Code and Original Ref. No.
129 $hcfa_entries[]=new hcfa_info(38, 50, 10, $claim->medicaidResubmissionCode());
130 $hcfa_entries[]=new hcfa_info(38, 62, 15, $claim->medicaidOriginalReference());
132 // Box 23. Prior Authorization Number
133 $hcfa_entries[]=new hcfa_info(40, 50, 28, $claim->priorAuth());
135 $diag_count=0;
136 foreach ($diags as $diag) {
137 if ($diag_count<12) {
138 add_diagnosis($hcfa_entries, $diag_count, $diag);
139 } else {
140 $log.= "***Too many diagnoses ".($diag_count+1).":".$diag;
143 $diag_count++;
146 // Sort the entries to put them in the page base sequence.
147 usort($hcfa_entries, "cmp_hcfa_info");
149 foreach ($hcfa_entries as $hcfa_entry) {
150 $hcfa_entry->put();