calendar widget bug fix by mmfsystems
[openemr.git] / custom / code_types.inc.php
blob20df1741f2aa56730351ba8aca8c972af4539369
1 <?php
2 // This array provides abstraction of billing code types. This is desirable
3 // because different countries or fields of practice use different methods for
4 // coding diagnoses, procedures and supplies. Fees will not be relevant where
5 // medical care is socialized. Attribues are:
6 //
7 // id - the numeric identifier of this code type in the codes table
8 // fee - 1 if fees are used, else 0
9 // mod - the maximum length of a modifier, 0 if modifiers are not used
10 // just - the code type used for justification, empty if none
11 // rel - 1 if other billing codes may be "related" to this code type
12 // nofs - 1 if this code type should NOT appear in the Fee Sheet
14 if ($GLOBALS['ippf_specific']) {
15 // IPPF:
16 $code_types = array(
17 'ICD9' => array('id' => 2, 'fee' => 0, 'mod' => 0, 'just' => '', 'rel' => 0, 'nofs' => 0),
18 'MA' => array('id' => 12, 'fee' => 1, 'mod' => 0, 'just' => '', 'rel' => 1, 'nofs' => 0),
19 'IPPF' => array('id' => 11, 'fee' => 0, 'mod' => 0, 'just' => '', 'rel' => 0, 'nofs' => 1),
20 // 'CPT4' => array('id' => 1, 'fee' => 0, 'mod' => 0, 'just' => '', 'rel' => 0, 'nofs' => 1),
21 'ACCT' => array('id' => 13, 'fee' => 0, 'mod' => 0, 'just' => '', 'rel' => 0, 'nofs' => 1),
23 $default_search_type = 'MA';
25 else if ($GLOBALS['athletic_team']) {
26 // UK Sports Medicine:
27 $code_types = array(
28 'OSICS10' => array('id' => 9, 'fee' => 0, 'mod' => 4, 'just' => '', 'rel' => 0, 'nofs' => 0),
29 'OPCS' => array('id' => 6, 'fee' => 0, 'mod' => 0, 'just' => '', 'rel' => 0, 'nofs' => 0),
30 'PTCJ' => array('id' => 7, 'fee' => 0, 'mod' => 0, 'just' => '', 'rel' => 0, 'nofs' => 0),
31 'CPT4' => array('id' => 1, 'fee' => 0, 'mod' => 0, 'just' => '', 'rel' => 0, 'nofs' => 0),
32 'SMPC' => array('id' => 10, 'fee' => 0, 'mod' => 0, 'just' => '', 'rel' => 0, 'nofs' => 0),
34 $default_search_type = 'OSICS10';
36 else {
37 // USA Clinics:
38 $code_types = array(
39 'ICD9' => array('id' => 2, 'fee' => 0, 'mod' => 2, 'just' => '' , 'rel' => 0, 'nofs' => 0),
40 'CPT4' => array('id' => 1, 'fee' => 1, 'mod' => 2, 'just' => 'ICD9', 'rel' => 0, 'nofs' => 0),
41 'HCPCS' => array('id' => 3, 'fee' => 1, 'mod' => 2, 'just' => 'ICD9', 'rel' => 0, 'nofs' => 0),
43 $default_search_type = 'ICD9';
46 function fees_are_used() {
47 global $code_types;
48 foreach ($code_types as $value) { if ($value['fee']) return true; }
49 return false;
52 function modifiers_are_used($fee_sheet=false) {
53 global $code_types;
54 foreach ($code_types as $value) {
55 if ($fee_sheet && !empty($value['nofs'])) continue;
56 if ($value['mod']) return true;
58 return false;
61 function related_codes_are_used() {
62 global $code_types;
63 foreach ($code_types as $value) { if ($value['rel']) return true; }
64 return false;
67 // Look up descriptions for one or more billing codes. Input is of the
68 // form "type:code;type:code; etc.".
70 function lookup_code_descriptions($codes) {
71 global $code_types;
72 $code_text = '';
73 if (!empty($codes)) {
74 $relcodes = explode(';', $codes);
75 foreach ($relcodes as $codestring) {
76 if ($codestring === '') continue;
77 list($codetype, $code) = explode(':', $codestring);
78 $wheretype = "";
79 if (empty($code)) {
80 $code = $codetype;
81 } else {
82 $wheretype = "code_type = '" . $code_types[$codetype]['id'] . "' AND ";
84 $crow = sqlQuery("SELECT code_text FROM codes WHERE " .
85 "$wheretype code = '$code' ORDER BY id LIMIT 1");
86 if (!empty($crow['code_text'])) {
87 if ($code_text) $code_text .= '; ';
88 $code_text .= $crow['code_text'];
92 return $code_text;