SLIC index file

View Snippet
                    <?php 

/* Init page */
require('../ui.php');
begin_document('');

/* EULA */
show_info('Classification system for subaxial cervical spine injury', 'Vaccaro, A. R., Hulbert, R. J., Patel, A. A., Fisher, C., Dvorak, M., Lehman, R. A., et al. (2007). The subaxial cervical spine injury classification system: a novel approach to recognize the importance of morphology, neurology, and integrity of the disco-ligamentous complex. Spine, 32(21), 2365–2374. doi:10.1097/BRS.0b013e3181557b92');

/* Content */
begin_page_content('start', 'Select risk items');

    begin_form('index_ra.php');
    
    	// Morphology
        begin_form_elements('Morphology:');
            add_radiobutton('no_abnormality', 'No abnormality', 'morphology');
            add_radiobutton('compression', 'Compression', 'morphology');
            add_radiobutton('burst', 'Compression with burst', 'morphology');
            add_radiobutton('distraction', 'Distraction', 'morphology');
            add_radiobutton('rotation_translation', 'Rotation / translation', 'morphology');
        end_form_elements();
        
        // DLC
        begin_form_elements('Disco-ligamentous complex:');
            add_radiobutton('intact', 'Intact', 'dlc');
            add_radiobutton('indeterminate', 'Indeterminate', 'dlc');
            add_radiobutton('disrupted', 'Disrupted', 'dlc');
        end_form_elements();
        
        // Neurology
        begin_form_elements('Neurological status:');
            add_radiobutton('intact', 'Intact', 'neurol');
            add_radiobutton('root_injury', 'Root injury', 'neurol');
            add_radiobutton('complete_cord_injury', 'Complete cord injury', 'neurol');
            add_radiobutton('incomplete_cord_injury', 'Incomplete cord injury', 'neurol');
            add_checkbox('continous_compression', 'Continious cord compression in setting of neuro deficit');
        end_form_elements();
     
        
        add_submit_button('Submit');
    end_form();
end_page_content();


/* Finish */
end_document();

?>
                  

SLIC risk assessment

View Snippet
                    <?php

/* Init page */
require('../ui.php');
begin_document('');

/* Content */
begin_page_content('slic_score', 'SLIC score');

	/* First check if all parameters are set */
	if ( isset($_POST['morphology']) && isset($_POST['dlc']) && isset($_POST['neurol'])  ) { 

		/* Process input from form */	
		switch ($_POST['morphology']) {
			case 'no_abnormality':
				$morphology = 0;
				break;
			case 'compression':
				$morphology = 1	;
				break;
			case 'burst':
				$morphology = 2;
				break;
			case 'distraction':
				$morphology = 3;
				break;
			case 'rotation_translation':
				$morphology = 4;
				break;
		} 
		
		switch ($_POST['dlc']) {
			case 'intact':
				$dlc = 0;
				break;
			case 'indeterminate':
				$dlc = 1;
				break;
			case 'disrupted':
				$dlc = 2;
				break;	
		}
		
		switch ($_POST['neurol']) {
			case 'intact':
				$neurol = 0;
				break;
			case 'root_injury':
				$neurol = 1;
				break;
			case 'complete_cord_injury':
				$neurol = 2;
				break;
			case 'incomplete_cord_injury':
				$neurol = 3;
				break;
		}
		
		$_POST['continous_compression'] ? $cont_compr = 1 : $cont_compr = 0;
		
		
		
		/* generate sum score */
		$sum_score = $morphology + $dlc + $neurol + $cont_compr;
		
		/* calculate risk */
		if ($sum_score < 4) {
			// conservative treatment
			$treatment = 'non-operative';
			
		} else if ($sum_score > 4) {
			// surgical treatment
			$treatment = 'operative';
			
		} else {
			// indeterminate
			$treatment = 'indeterminate';
			
		}
		
		/* give output to user */
		add_paragraph('<h3>The treatment suggestion is: ' . $treatment . '</h3>');
		add_paragraph('<h4>SLIC score is: ' . $sum_score . '</h4>');
		
		/* summarize input */
		$riskFactors  = '<p>based on these parameters: <ul>'; 
		$riskFactors .= '<li>Morphology: ' . $_POST['morphology'] . '</li>';
		$riskFactors .= '<li>DLC: ' . $_POST['dlc'] . '</li>';
		$riskFactors .= '<li>Neurol status: ' . $_POST['neurol'] . '</li>';
		$riskFactors .= '<li>Continuous compression: ' . $cont_compr . '</li>';
		$riskFactors .= '</ul></p>';
		echo $riskFactors;
		
	} else {
		// Not all parameters set, so refuse to continue
		add_paragraph('Not all parameters have been set. Please answer all items.');
		add_button('javascript:history.go(-1)', 'false', 'Return to questions');
	}

end_page_content();

/* Finish */
end_document();

?>
                  

basic UI functions in jQuery Mobile (date: Mar 4, 2014)

View Snippet
                    <?php

/*
 *  Global variables
 */
// $themeTintColor = '#188A10';

/* 
 * Begin and end document 
 */
function begin_document($local_js_file) {
    if ($local_js_file != '') {
        $local_js = '<script src="' . $local_js_file . '"></script>'; // in same dir
    }
    
    // Create HTMl header
    $header_code = 
    '<!DOCTYPE html>' . 
    '<html>' .
    '<head>' .
    	'<title>Decision support</title>' .
    	'<meta name="viewport" content="width=device-width, initial-scale=1" />' .
    	'<link rel="stylesheet" href="../jquery/DSS_dev.min.css" />' .
    	'<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.1/jquery.mobile.structure-1.4.1.min.css" />'.
		'<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>'.
		'<script src="http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.js"></script>'.
		'<style type=\'text/css\'>a:link, a:visited {color: #188A10;}</style>' .
    	$local_js . // if applicable, otherwise empty string
    '</head>' .
    '<body>';
    
    echo $header_code;
}


function end_document() {
    $footer_code = 
    '</body>' .
    '</html>';
    
    echo $footer_code;
}


/*
 * Begin and end page
 */
function begin_page_content($page_id, $header_title) {
    // Create div with page role including header
    echo '<!-- start new page -->' . 
        '<div data-role="page" id="' . $page_id . '">' .
            '<div data-role="header" data-theme="a">' .
                '<h1>' . $header_title . '</h1>' .
            '</div>' .
            
            '<div data-role="content">'; // end here, content comes from separate functions
}


function end_page_content() {
    // End content div
    echo '</div>';
    
    // End page div
    echo '</div> <!-- end page -->';
}


function add_paragraph($text) {
    echo '<p>' . $text . '</p>';
}


function add_paragraph_with_header($header_size, $header_text, $text) {
    echo '<h' . $header_size . '>' . $header_text . '</h' . $header_size . '>';
    echo '<p>' . $text . '</p>';
}


function add_button($url_link, $data_ajax_setting, $url_text) {
    echo '<p><a href="' . $url_link . '" data-ajax="' . $data_ajax_setting . '" data-role="button">' . $url_text . '</a></p>';
}



/*
 *  Show information & EULA
 */ 
function show_info($background_text, $reference_text) {
	begin_page_content('eula', 'Info');
		add_paragraph_with_header('4', 'Background', $background_text);
		add_paragraph_with_header('4', 'Reference', $reference_text);
		add_paragraph_with_header('4', 'Programming', 'The source code of this module is <a href="http://www.snipsave.com/user/profile/PieterKubben">available online</a>.');
		add_paragraph_with_header('4', 'Disclaimer', 'You can use this module if you agree with the <a href="http://dign.eu/eula">end-user license agreement</a>.');
		add_button('#start', 'true', 'Agree &amp; continue');  // so next page must have "start" as id !!
	end_page_content();
} 
 


/*
 *  Listview
 */
function begin_listview($list_divider_text) {
    echo '<ul data-role="listview" data-inset="false">'.
         '<li data-role="list-divider" data-theme="a">' . $list_divider_text . '</li>';
}


function end_listview() {
    echo '</ul>';
}


function add_listitem($url_link, $data_ajax_setting, $url_text) {
    // Use data-ajax = true for internal link, data-ajax = false for external (non-jQuery) link 
    echo '<li><a href="' . $url_link . '" data-ajax="' . $data_ajax_setting . '">' . $url_text . '</a></li>';
}



/*
 *  Begin and end form (belongs to content div)
 */ 
function begin_form($form_action_file) {
    echo '<form method="post" data-ajax="false" action="' . $form_action_file . '">';
}


function end_form() {
    echo '</form>';
}


/*
 *  Form items
 */
function begin_form_elements($legend_text) {
    echo '<fieldset data-role="controlgroup">'. 
         '<legend>' . $legend_text . '</legend>';
}


function end_form_elements() {
    echo '</fieldset><br/>';
}


function add_checkbox($id, $label_text) {
    echo '<label for="' . $id . '">' . $label_text . '</label>' .
         '<input type="checkbox" name="' . $id . '" id="' . $id . '" value = "' . $id . '">'; //$id . '">'; 
}


function add_radiobutton($id, $label_text, $group_name) {
    echo '<label for="' . $id . '">' . $label_text . '</label>' .
         '<input type="radio" name="' . $group_name . '" id="' . $id . '" value = "' . $id . '">';
}


function add_textarea($id) {
    echo '<textarea rows="5" cols="10" id="' . $id . '"></textarea>';
}


function add_submit_button($button_text) {
    echo '<input type="submit" data-theme="d" name="submit" id="submit" value="' . $button_text . '">';
}



?>
                  

PHASES risk assessment

View Snippet
                    <?php

/* Init page */
require('../ui.php');
begin_document('');

/* Content */
begin_page_content('risk', '5yr rupture risk');

	/* First check if all parameters are set */
	if ( isset($_POST['population']) && isset($_POST['hypertension']) && isset($_POST['age']) && 
			isset($_POST['size']) && isset($_POST['earlier_sah']) && isset($_POST['site']) ) { 

		/* Process input from form */	
		switch ($_POST['population']) {
			case 'us_eu':
				$population = 0;
				break;
			case 'jap':
				$population = 3;
				break;
			case 'fin':
				$population = 5;
				break;
		} 
		
		switch ($_POST['hypertension']) {
			case 'no':
				$hypertension = 0;
				break;
			case 'yes':
				$hypertension = 1;
				break;
		}
		
		switch ($_POST['age']) {
			case 'under_70':
				$age = 0;
				break;
			case '70_or_more':
				$age = 1;
				break;
		}
		
		switch ($_POST['size']) {
			case 'under_7.0':
				$size = 0;
				break;
			case '7.0-9.9':
				$size = 3;
				break;
			case '10.0-19.9':
				$size = 6;
				break;
			case 'over_20.0':
				$size = 10;
				break;
		}
		
		switch ($_POST['earlier_sah']) {
			case 'no':
				$earlier_sah = 0;
				break;
			case 'yes':
				$earlier_sah = 1;
				break;
		}
		
		switch ($_POST['site']) {
			case 'ica':
				$site = 0;
				break;
			case 'mca':
				$site = 2;
				break;
			case 'aca':
			case 'pcom_post':
				$site = 4;
				break;
		}
		
		
		/* generate sum score */
		$phasesScore = $population + $hypertension + $age + $size + $earlier_sah + $site;
		
		/* calculate risk */
		switch ($phasesScore) {
			case 0:
			case 1:
			case 2:
				$risk = 0.4;
				break;
			case 3: 
				$risk = 0.7;
				break;
			case 4:
				$risk = 0.9;
				break;
			case 5: 
				$risk = 1.3;
				break;
			case 6:
				$risk = 1.7;
				break;
			case 7:
				$risk = 2.4;
				break;
			case 8:
				$risk = 3.2;
				break;
			case 9:
				$risk = 4.3;
				break;
			case 10:
				$risk = 5.3;
				break;
			case 11:
				$risk = 7.2;
				break;
			default: 			// meaning score 12 or larger
				$risk = 17.8; 
				break;
		}
		
		/* give output to user */
		add_paragraph('<h3>The 5-year risk of aneurysm rupture is: ' . $risk . '%</h3>');
		add_paragraph('<h4>PHASES risk score is: ' . $phasesScore . '</h4>');
		
		/* summarize input */
		$riskFactors  = '<p>based on these parameters: <ul>'; 
		$riskFactors .= '<li>Population: ' . $_POST['population'] . '</li>';
		$riskFactors .= '<li>Hypertension: ' . $_POST['hypertension'] . '</li>';
		$riskFactors .= '<li>Age: ' . $_POST['age'] . '</li>';
		$riskFactors .= '<li>Size: ' . $_POST['size'] . '</li>';
		$riskFactors .= '<li>Earlier SAH: ' . $_POST['earlier_sah'] . '</li>';
		$riskFactors .= '<li>Site: ' . $_POST['site'] . '</li>';
		$riskFactors .= '</ul></p>';
		echo $riskFactors;
		
	} else {
		// Not all parameters set, so refuse to continue
		add_paragraph('Not all parameters have been set. Please answer all items.');
		add_button('javascript:history.go(-1)', 'false', 'Return to questions');
	}

end_page_content();

/* Finish */
end_document();

?>
                  

PHASES index file

View Snippet
                    <?php 

/* Init page */
require('../ui.php');
begin_document('');

/* EULA */
show_info('To estimate 5-year aneurysm rupture risk by risk factor status.', 'Greving, J. P., Wermer, M. J. H., Brown, R. D., Morita, A., Juvela, S., Yonekura, M., et al. (2014). Development of the PHASES score for prediction of risk of rupture of intracranial aneurysms: a pooled analysis of six prospective cohort studies. Lancet Neurology, 13(1), 59-66. doi:10.1016/S1474-4422(13)70263-1');

/* Content */
begin_page_content('start', 'Select risk items');

    begin_form('index_ra.php');
    
    	// Population
        begin_form_elements('Population:');
            add_radiobutton('us_eu', 'North American / European (other than Finnish)', 'population');
            add_radiobutton('jap', 'Japanese', 'population');
            add_radiobutton('fin', 'Finnish', 'population');
        end_form_elements();
        
        // Hypertension
        begin_form_elements('Hypertension:');
            add_radiobutton('no', 'No', 'hypertension');
            add_radiobutton('yes', 'Yes', 'hypertension');
        end_form_elements();
        
        // Age
        begin_form_elements('Age:');
            add_radiobutton('under_70', '< 70 years', 'age');
            add_radiobutton('70_or_more', '&#8805; 70 years', 'age');
        end_form_elements();
        
        // Size
        begin_form_elements('Size of aneurysm:');
            add_radiobutton('under_7.0', '< 7.0 mm', 'size');
            add_radiobutton('7.0-9.9', '7.0 - 9.9 mm', 'size');
            add_radiobutton('10.0-19.9', '10.0 - 19.9 mm', 'size');
            add_radiobutton('over_20.0', '&#8805; 20 mm', 'size');
        end_form_elements();
        
        // Earlier SAH
        begin_form_elements('Earlier SAH from another aneurysm:');
            add_radiobutton('no', 'No', 'earlier_sah');
            add_radiobutton('yes', 'Yes', 'earlier_sah');
        end_form_elements();
        
        // Site
        begin_form_elements('Site of aneurysm:');
            add_radiobutton('ica', 'Internal Carotid Artery', 'site');
            add_radiobutton('mca', 'Medial Cerebral Artery', 'site');
            add_radiobutton('aca', 'Anterior Cerebral Artery', 'site');
            add_radiobutton('pcom_post', 'Posterior Cerebral / Communicating Artery', 'site');
        end_form_elements();
        
        add_submit_button('Submit');
    end_form();
end_page_content();


/* Finish */
end_document();

?>