Example #1
0
function specimen_list_to_json($specimen_list)
{
    $json_params = array('id', 'name');
    $assoc_list = array();
    foreach ($specimen_list as $specimen_id) {
        $specimen = get_specimen_type_by_id($specimen_id);
        $specimen_type_id = $specimen->specimenTypeId;
        $specimen_name = $specimen->getName();
        $assoc_list[$specimen_type_id] = $specimen_name;
    }
    return list_to_json($assoc_list, $json_params);
}
Example #2
0
<?php

# Returns a JSON list of test types for a site location via Ajax
# Called from pages where site/location drop down box is used
include "../includes/db_lib.php";
function list_to_json($value_list, $json_params)
{
    $count = 0;
    $return_string = "";
    $return_string .= "[";
    foreach ($value_list as $key => $value) {
        $return_string .= "{" . $json_params[0] . ": " . $key . ", " . $json_params[1] . ": '" . $value . "'}";
        $count += 1;
        if ($count != count($value_list)) {
            $return_string .= ", ";
        }
    }
    $return_string .= "]";
    return $return_string;
}
$test_list = get_test_types_by_site_map($_REQUEST['site']);
$json_params = array('optionValue', 'optionDisplay');
echo list_to_json($test_list, $json_params);
Example #3
0
<?php

#
# Sends matching specimen types for jquery.token-input plugin
#
include "../includes/ajax_lib.php";
include "../includes/db_lib.php";
$q = $_REQUEST['q'];
$specimen_list = search_specimen_types_catalog($q);
$json_params = array('id', 'name');
echo list_to_json($specimen_list, $json_params);
Example #4
0
<?php

#
# Returns token input values for "autocomplete" type measure
# Called via Ajax from results_entry.php
#
include "../includes/ajax_lib.php";
include "../includes/db_lib.php";
function find_matched($list, $search_string)
{
    $retval = array();
    foreach ($list as $value) {
        if (strcasecmp(substr($value, 0, strlen($search_string)), $search_string) == 0) {
            $retval[] = $value;
        }
    }
    return $retval;
}
$measure_id = $_REQUEST['id'];
$q = $_REQUEST['q'];
$measure = Measure::getById($measure_id);
$value_map = array();
$range_values = $measure->getRangeValues();
$matched_range_values = find_matched($range_values, $q);
foreach ($matched_range_values as $range_value) {
    $value_map[$range_value] = $range_value;
}
$json_params = array('id', 'name');
echo list_to_json($value_map, $json_params);
Example #5
0
                    ?>
);">
							</input>
						<?php 
                }
            } else {
                if ($range_type == Measure::$RANGE_AUTOCOMPLETE) {
                    # Autocomplete values
                    # Use jquery.token-input plugin
                    $json_params = array('id', 'name');
                    $value_map = explode("_", trim($field_value));
                    $values_f = array();
                    for ($js = 0; $js < count($value_map); $js++) {
                        $values_f[$value_map[$js]] = $value_map[$js];
                    }
                    $json_values = list_to_json($values_f, $json_params);
                    $url_string = "ajax/measure_autocomplete.php?id=" . $measure->measureId;
                    $hint_text = "Type to enter results";
                    echo "<div>";
                    $page_elems->getTokenList(-1, $field_id, "result_" . $test_type->testTypeId . "_" . $measure->measureId, $url_string, $hint_text, $json_values);
                    echo "</div>";
                } else {
                    if ($range_type == Measure::$RANGE_FREETEXT) {
                        # Text box
                        $field_value = preg_replace("/[^a-zA-Z0-9,+.;:_\\s]/", "", $field_value);
                        echo "<textarea name='{$field_name}' id='{$field_id}' class='uniform_width results_entry'>{$field_value}</textarea>";
                    }
                }
            }
        }
        echo "</span>";
Example #6
0
<?php

#
# Sends matching test measure names for jquery.token-input plugin
#
include "../includes/ajax_lib.php";
include "../includes/db_lib.php";
$q = $_REQUEST['q'];
$measure_list = search_measures_catalog($q);
$json_params = array('id', 'name');
echo list_to_json($measure_list, $json_params);
Example #7
0
<?php

# Returns a JSON list of usernames for a site location via Ajax
# Called from reports.php
include "../includes/db_lib.php";
function list_to_json($value_list, $json_params)
{
    $count = 0;
    $return_string = "";
    $return_string .= "[";
    foreach ($value_list as $key => $value) {
        $return_string .= "{" . $json_params[0] . ": " . $key . ", " . $json_params[1] . ": '" . $value . "'}";
        $count += 1;
        if ($count != count($value_list)) {
            $return_string .= ", ";
        }
    }
    $return_string .= "]";
    return $return_string;
}
$user_list = get_users_by_site_map($_REQUEST['site']);
$json_params = array('optionValue', 'optionDisplay');
echo list_to_json($user_list, $json_params);