Show active patient Issues in notes.
authormdsupport <md.support@accretics.com>
Wed, 10 Apr 2013 09:01:25 +0000 (10 02:01 -0700)
committerbradymiller <bradymiller@users.sourceforge.net>
Sun, 14 Apr 2013 03:02:12 +0000 (13 20:02 -0700)
library/custom_template/custom_template.php

index 88131c2..1b111ee 100644 (file)
@@ -34,6 +34,15 @@ $fake_register_globals=false;
 //
 
 require_once("../../interface/globals.php");
+require_once("$srcdir/lists.inc");
+// mdsupport : li code
+function listitemCode ($strDisp, $strInsert) {
+       if ($strInsert) {
+               echo '<li><span><a href="#" onclick="top.restoreSession();CKEDITOR.instances.textarea1.insertText('.
+                        "'" . htmlspecialchars($strInsert,ENT_QUOTES) . "'" .');">'. htmlspecialchars(xl($strDisp,ENT_QUOTES)) . '</a></span></li>';
+       }
+}
+
 $contextName = $_REQUEST['contextName'];
 $type = $_REQUEST['type'];
 $rowContext = sqlQuery("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_list_item_long=?",array($contextName));
@@ -167,44 +176,41 @@ $(document).ready(function(){
                                     </li>
                                     <?php
                                     if($pid!=''){
-                                        $row = sqlQuery("SELECT * FROM patient_data WHERE pid=?",array($pid));
+                                        $row = sqlQuery("SELECT p.*, IF(ISNULL(p.providerID), NULL, CONCAT(u.lname,',',u.fname)) pcp ".
+                                                                                                               "FROM patient_data p LEFT OUTER JOIN users u ".
+                                                                                                               "ON u.id=p.providerID WHERE pid=?"
+                                                                                                               ,array($pid));
                                     ?>
                                     <li><a class="collapsed"><?php echo htmlspecialchars(xl('Patient Details'),ENT_QUOTES);?></a>
                                         <ul>
-                                            <li><span><a href="#" onclick="top.restoreSession();CKEDITOR.instances.textarea1.insertText('<?php echo $row['fname'];?>');"><?php echo htmlspecialchars(xl('First name',ENT_QUOTES));?></a></span></li>
-                                            <li><span><a href="#" onclick="top.restoreSession();CKEDITOR.instances.textarea1.insertText('<?php echo $row['lname'];?>');"><?php echo htmlspecialchars(xl('Last name',ENT_QUOTES));?></a></span></li>
-                                            <?php
-                                            if($row['phone_home']){
-                                            ?>
-                                            <li><span><a href="#" onclick="top.restoreSession();CKEDITOR.instances.textarea1.insertText('<?php echo $row['phone_home'];?>');"><?php echo htmlspecialchars(xl('Phone',ENT_QUOTES));?></a></span></li>
-                                            <?php
-                                            }
-                                            ?>
-                                            <?php
-                                            if($row['ss']){
-                                            ?>
-                                            <li><span><a href="#" onclick="top.restoreSession();CKEDITOR.instances.textarea1.insertText('<?php echo $row['ss'];?>');"><?php echo htmlspecialchars(xl('SSN',ENT_QUOTES));?></a></span></li>
-                                            <?php
-                                            }
-                                            ?>
-                                            <?php
-                                            if($row['DOB']){
-                                            ?>
-                                            <li><span><a href="#" onclick="top.restoreSession();CKEDITOR.instances.textarea1.insertText('<?php echo $row['DOB'];?>');"><?php echo htmlspecialchars(xl('Date Of Birth',ENT_QUOTES));?></a></span></li>
-                                            <?php
-                                            }
-                                            ?>
-                                            <?php
-                                            if($row['providerID']){
-                                                $val=sqlQuery("SELECT CONCAT(lname,',',fname) AS name FROM users WHERE id='".$row['providerID']."'");
-                                            ?>
-                                            <li><span><a href="#" onclick="top.restoreSession();CKEDITOR.instances.textarea1.insertText('<?php echo $val['name'];?>');"><?php echo htmlspecialchars(xl('PCP',ENT_QUOTES));?></a></span></li>
-                                            <?php
-                                            }
-                                            ?>
+                                        <?php
+                                               listitemCode('First name', $row['fname']);
+                                               listitemCode('Last name', $row['lname']);
+                                               listitemCode('Phone', $row['phone_home']);
+                                               listitemCode('SSN', $row['ss']);
+                                               listitemCode('Date Of Birth', $row['DOB']);
+                                               listitemCode('PCP', $row['pcp']);
+                                        ?>
                                         </ul>
                                     </li>
-                                    <?php
+                                           <?php
+                                                                               foreach ($ISSUE_TYPES as $issType => $issTypeDesc) {
+                                                                               $res = sqlStatement('SELECT title, IF(diagnosis="","",CONCAT(" [",diagnosis,"]")) codes FROM lists WHERE pid=? AND type=? AND enddate IS NULL ORDER BY title'
+                                                                                                                       ,array($pid, $issType));
+                                                                               if (sqlNumRows($res)) {
+                                                                               ?>
+                                    <li><a class="collapsed"><?php echo htmlspecialchars(xl($issTypeDesc[0]),ENT_QUOTES);?></a>
+                                        <ul>
+                                               <?php
+                                                       while ($row = sqlFetchArray($res)) {
+                                                                                                       listitemCode((strlen($row['title'])>20) ? (substr($row['title'], 0, 18).'..') : $row['title'], ($row['title'].$row['codes']));
+                                                                                               }
+                                                                                       ?>
+                                                                               </ul>
+                                                                       </li>
+                                                                       <?php
+                                                                                       }
+                                                                       }
                                     }
                                     ?>
                                 </ul>