Implementing Best Practice Guidelines onto PDAs – Preliminary Results and Lessons Learned

Posted November 28th, 2009 in Articles, Health by Derek

Abstract

Best Practice Guidelines (BPGs) represent a promising way to improve nursing care by reducing the time lag between research findings and subsequent changes in healthcare practices. Translating the currently paper-based BPGs into a portable, computer-based format is seen as an important step towards the widespread use of BPGs in nursing practice. In implementing the asthma BPG onto a PDA, we have discovered that the concept of an “algorithm” is distinctly different for nurses and for computer programmers. Our on-going development of the computer-based BPG is influenced by these insights into the dynamic and iterative process of nursing care.

Article (PDF):

Implementing Best Practice Guidelines onto PDAs (0)

jQuery Dynamic Form

Posted November 28th, 2009 in Uncategorized by Derek

Scenario:
Building web forms can be tricky when a form calls for a variable number of fields. A real-world example might be a sports team with an n number of players. When capturing the team player data via a web form, the typical way might be to create the form with one empty player field for each player on the team. You would obviously need to know the maximum number of players per team. Worse, you would also need to deal with non-existant form data on the server side.

Solution:
A more dynamic way is to show just the single player field with a button to add extra player fields for the n number of players on the team.
To support this solution, I’ve written a jQuery plugin that will duplicate, on-demand, any field or group of fields set within a <FIELDSET> tag. You can use the plugin to create one or more dynamic fields per form or in a group of forms.

Demo:
Click here for a demo of a dynamic form powered by jQuery.

*It’s a jQuery plugin so it can be chained to other jQuery events, effects or plugins.

Download/Contribute:
Project source here: jquery dynamic form project hosting

A PHP Pagination Function

Posted November 8th, 2009 in Uncategorized by Derek

Here’s a PHP function “getPaginationHtml()” that builds an item-pagination type HTML DIV based on parameters only, i.e. no database recordset needed. Note the user of a second function that is used by the pagination function to build the URL parameters needed for the pagination links.

Visual example:

How to call the getPaginationHtml() function:

//show the pagination html in an ordered list based on the listed arguments
echo getPaginationHtml(array('numRecords' => 12, 'numRecordsToShow' => 3, 'currPage' => 1, 'showPages'=>true));

HTML Output:


Functions:
1) getPaginationHtml()

/*
 * Get the pagination link HTML
 * @return String
 */
function getPaginationHtml ($args = array()) {

    $defaultArgs = array('numRecords'=> 1,
    					'numRecordsToShow'=>10,
                        'currPage'=>1,
                        'linkSeparator'=>'|',
                        'showPages'=>false,
                        'pageParamName'=>'page',
                        'firstClass'=>'pagination-first',
                        'prevClass'=>'pagination-first',
                        'nextClass'=>'pagination-next',
                        'lastClass'=>'pagination-last',
                        'pageClass'=>'pagination-page-link',
                        'separatorClass'=>'pagination-separator');
    $userArgs = array_merge ($defaultArgs, $args);
    foreach ($userArgs as $key=>$val) {
        ${$key} = $val;
    }

    //vars
    $links = array();
    $paramUrl = getParamUrl(array('exclude'=>'page')); //exclude the 'page' url param
    $totalPages = ceil($numRecords/$numRecordsToShow);

    //build  'num records' text
    $from = (($currPage-1)*$numRecordsToShow) + 1;
    $to = min(($from+$numRecordsToShow-1), $numRecords);
    $links[] = "
  • $from–$to of $numRecords records
  • "; //show page numbers if ($showPages) { for ($i=1; $i< = $totalPages; $i++ ) { ($i == $currPage) ? $selected = "$pageClass-selected" : $selected = ''; $links[] = "
  • $i"; } } //build 'first' link $links[] = "
  • First
  • "; //build 'prev' link $prev = max($currPage-1, 1); $links[] = "
  • < Prev
  • "; //build 'next' link $next = min($currPage+1,$totalPages); $links[] = "
  • Next >
  • "; //build 'last' link $links[] = "
  • Last
  • "; return implode("
  • $linkSeparator
  • ", $links); }

    2) getParamUrl()

    /*
     * Build the URL based on the current GET/POST parameters
     * excluding any unwanted parameters (comma separated if more than one).
     * i.e.: array('exclude'=>'page,sortname,sortorder');
     * @return String
     */
    function getParamUrl ($args = array()) {
        $defaultArgs = array('exclude'=> false);
        $userArgs = array_merge ($defaultArgs, $args);
        foreach ($userArgs as $key=>$val) {
            ${$key} = $val;
        }
        //check if GET or POST
        (isset($_GET)) ? $_params = $_GET : $_params = $_POST;
        //build the url string
        $paramUrl = array();
        foreach ($_params as $key=>$value) {
            $toExclude = explode(',', $exclude);
            if ($toExclude && !in_array($key, $toExclude)) {
                array_push($paramUrl, "$key=$value");
            }
        }
        return '?'.implode('&',$paramUrl);
    }

    Customized jQuery Tabs

    Posted November 16th, 2008 in Uncategorized by Derek

    I have always liked using tabs as a means for navigating a website. In my opinion tabs are a great way to separate content because they are a somewhat natural representation of a real-world artifact that many users are used to. And if a navigation item is familiar to users, then it helps increase usability, an often-overlooked goal of web development.

    To implement tabs in our projects I have always used the “sliding doors of CSS” technique (as described in the “Sliding Doors of CSS” written by Douglas Bowman). I particularly like this technique because it pre-loads all the necessary images needed for the tabs and because it provides an easy way to design customized tabs without the need for a ton of markup to display them on the screen.

    But lately, for the right project I have taken to using jQuery’s implementation of the tabbed interface. I like jQuery tab framework because it’s a quick way to code tabs for web applications and because its very customizable. One implementation has jQuery tabs using AJAX to call up the appropriate page automatically without the need for a controller. Using AJAX isn’t always the best practice, but for some projects, it could be the right way to go.

    That said, I wanted a way to use the sliding door tab technique mentioned above using jQuery’s tab framework. Here is a link to an example to see how I did it.

    If you want to use it for your own projects, the source files are shown in the demo on the “notes” page.