예제 #1
0
function generate_worksheet_config($lab_config_id)
{
    $lab_config = LabConfig::getById($lab_config_id);
    $test_ids = $lab_config->getTestTypeIds();
    $saved_db = DbUtil::switchToLabConfig($lab_config_id);
    foreach ($test_ids as $test_id) {
        $test_entry = TestType::getById($test_id);
        $query_string = "SELECT * FROM report_config WHERE test_type_id={$test_id} LIMIT 1";
        $record = query_associative_one($query_string);
        if ($record == null) {
            # Add new entry
            $query_string_add = "INSERT INTO report_config (" . "test_type_id, header, footer, margins, " . "p_fields, s_fields, t_fields, p_custom_fields, s_custom_fields " . ") VALUES (" . "'{$test_id}', 'Worksheet - " . $test_entry->name . "', '', '5,0,5,0', " . "'0,1,0,1,1,0,0', '0,0,1,1,0,0', '1,0,1,0,0,0,0,1', '', '' " . ")";
            query_insert_one($query_string_add);
        }
    }
    DbUtil::switchRestore($saved_db);
}
예제 #2
0
         echo LangUtil::$generalTerms['PENDING_RESULTS'];
     } else {
         if ($report_config->useMeasures == 1) {
             echo $test->decodeResultWithoutMeasures();
         } else {
             echo $test->decodeResult();
         }
     }
     echo "</td>";
 }
 if ($report_config->useRange == 1) {
     echo "<td>";
     if ($test->isPending() === true) {
         echo "N/A";
     } else {
         $test_type = TestType::getById($test->testTypeId);
         $measure_list = $test_type->getMeasures();
         $submeasure_list = array();
         $comb_measure_list = array();
         // print_r($measure_list);
         foreach ($measure_list as $measure) {
             $submeasure_list = $measure->getSubmeasuresAsObj();
             //echo "<br>".count($submeasure_list);
             //print_r($submeasure_list);
             $submeasure_count = count($submeasure_list);
             if ($measure->checkIfSubmeasure() == 1) {
                 continue;
             }
             if ($submeasure_count == 0) {
                 array_push($comb_measure_list, $measure);
             } else {
예제 #3
0
파일: worksheet.php 프로젝트: caseyi/BLIS
         echo "</td>";
     }
 }
 if ($report_config->useComments == 1) {
     echo "<td>";
     echo $specimen->getComments();
     echo "</td>";
 }
 if ($report_config->useReferredTo == 1) {
     echo "<td>" . $specimen->getReferredToName() . "</td>";
 }
 if ($report_config->useDoctor == 1) {
     echo "<td>" . $specimen->getDoctor() . "</td>";
 }
 if ($report_config->useTestName == 1 || $report_config->useResults == 1) {
     $test_entry = TestType::getById($test_type_id);
     $measure_list = $test_entry->getMeasures();
     foreach ($measure_list as $measure) {
         # Show range/options here
         $range = $measure->range;
         if (strpos($range, ":") !== false) {
             echo "<td>";
             echo "</td>";
         } else {
             if (strpos($range, "/") !== false) {
                 $range_parts = explode("/", $range);
                 echo "<td>";
                 echo "</td>";
                 /*
                 foreach($range_parts as $option_value)
                 {
예제 #4
0
파일: stats_lib.php 프로젝트: caseyi/BLIS
         $i++;
     }
     DbUtil::switchRestore($saved_db);
     return $retval;
 }
 public static function getRangeInfectionStats($lab_config, $date_from, $date_to)
 {
     $test_type_list = get_range_value_test_types($lab_config);
     # For each test type, fetch all measures
     # For each measure, create distribution based on range
     foreach ($test_type_list as $test_type_id) {
         # Collect measure(s) information
         $measure_list = get_test_type_measures($test_type_id);
         $measure_meta_list = array();
         foreach ($measure_list as $measure_id) {
             $measure = get_measure_by_id($measure_id);
             $measure_meta = new MeasureMeta();
             $measure_meta->name = $measure->getName();
             $measure_meta->countParts = array();
             $range = $measure->range;
             if (strpos($range, ":") === false) {
                 # Discrete value range
                 $range_options = explode("#", $range);
                 $measure_meta->rangeType = MeasureMeta::$DISCRETE;
                 $measure_meta->rangeValues = $range_options;
             } else {
                 # Continuous value range
                 $range_bounds = explode(":", $range);
                 $measure_meta->rangeType = MeasureMeta::$CONTINUOUS;
                 $measure_meta->rangeValues = $range_bounds;
             }
             $measure_meta_list[] = $measure_meta;
         }
         # Calculate stats
         $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND t.result <> ''";
         $record = query_associative_one($query_string);
         $count_all = $record['count_val'];
         # Fetch result values
         $query_string = "SELECT t.result FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND t.result <> ''";
         $resultset = query_associative_all($query_string, $row_count);
         foreach ($resultset as $record) {
             $result_string = substr($record['result'], 0, -1);
             $result_list = explode(",", $result_string);
             for ($i = 0; $i < count($result_list); $i++) {
                 $measure_meta = $measure_meta_list[$i];
                 if ($measure_meta->rangeType == MeasureMeta::$CONTINUOUS) {
                     $range_bounds = $measure_meta->rangeValues;
                     $interval = $range_bounds[1] - $range_bounds[0];
                     $base = $interval / 10;
                     $offset = $result_list[$i] - $range_bounds[0];
                     $bucket = $offset / $base;
                     echo $bucket;
                     break;
예제 #5
0
<?php

#
# Returns batch results entry form for a given test type
# Called via ajax from results_entry.php
#
include "../includes/db_lib.php";
include "../includes/page_elems.php";
LangUtil::setPageId("results_entry");
$page_elems = new PageElems();
$test_type_id = $_REQUEST['t_type'];
$date_to = $_REQUEST['date_to'];
$date_from = $_REQUEST['date_from'];
$date_from_array = explode("-", $date_from);
$date_to_array = explode("-", $date_to);
$test_type = TestType::getById($test_type_id);
$lab_config = LabConfig::getById($_SESSION['lab_config_id']);
$worksheet_config = $lab_config->getWorkSheetConfig($test_type_id);
# Fetch all measures for this test type
$measure_list = $test_type->getMeasures();
# Create a table with specimen ID field and these measures
# Fetch currently pending tests for this test type
$pending_tests = get_pending_tests_by_type_date($test_type_id, $date_from, $date_to);
if (count($pending_tests) == 0 || $pending_tests == null) {
    ?>
	<div class='sidetip_nopos'>
		<?php 
    echo get_test_name_by_id($test_type_id) . " " . LangUtil::$pageTerms['MSG_PENDINGNOTFOUND'];
    ?>
.
	</div>
예제 #6
0
파일: db_lib.php 프로젝트: nchopra/C4G-BLIS
 public function decodeResultWithoutMeasures($show_range = false)
 {
     # Converts stored result value(s) for showing on front-end
     $test_type = TestType::getById($this->testTypeId);
     $measure_list = $test_type->getMeasures();
     $result_csv = $this->getResultWithoutHash();
     $result_list = explode(",", $result_csv);
     $retval = "";
     for ($i = 0; $i < count($measure_list); $i++) {
         # Pretty print
         $curr_measure = $measure_list[$i];
         if (isset($result_list[$i])) {
             # If matching result value exists (e.g. after a new measure was added to this test type)
             if (count($measure_list) == 1) {
                 # Only one measure: Do not print measure name
                 //$retval .= $curr_measure->name."&nbsp;";
                 if ($curr_measure->getRangeType() == Measure::$RANGE_AUTOCOMPLETE) {
                     $result_string = "";
                     $value_list = explode("_", $result_list[$i]);
                     foreach ($value_list as $value) {
                         if (trim($value) == "") {
                             continue;
                         }
                         $result_string .= $value . "<br>";
                     }
                     $result_string = substr($result_string, 0, -4);
                     $retval .= "<br>" . $result_string . "&nbsp;";
                 } else {
                     if ($curr_measure->getRangeType() == Measure::$RANGE_OPTIONS) {
                         if ($result_list[$i] != $curr_measure->unit) {
                             $retval .= "<br><b>" . $result_list[$i] . "</b> &nbsp;";
                         } else {
                             $retval .= "<br>" . $result_list[$i] . "&nbsp;";
                         }
                     } else {
                         $retval .= "<br>" . $result_list[$i] . "&nbsp;";
                     }
                 }
             } else {
                 # Print measure name with each result value
                 // $retval .= $curr_measure->name."&nbsp;";
                 if ($curr_measure->getRangeType() == Measure::$RANGE_AUTOCOMPLETE) {
                     $result_string = "";
                     $value_list = str_replace("_", ",", $result_list[$i]);
                     //$retval .= ":<br>".$value_list."<br>";
                     $retval .= "<br>" . $value_list . "<br>";
                 } else {
                     if ($curr_measure->getRangeType() == Measure::$RANGE_OPTIONS) {
                         if ($result_list[$i] != $curr_measure->unit) {
                             //$retval .= "<b>".$result_list[$i]."</b> &nbsp;";
                             $retval .= "<br><b>" . $result_list[$i] . "</b> &nbsp;<br>";
                         } else {
                             //$retval .= $result_list[$i]."&nbsp;";
                             $retval .= "<br>" . $result_list[$i] . "&nbsp;<br>";
                         }
                     } else {
                         //$retval .= $result_list[$i]."&nbsp;";
                         $retval .= "<br>" . $result_list[$i] . "&nbsp;<br>";
                     }
                 }
             }
             if ($show_range === true) {
                 $retval .= $curr_measure->getRangeString();
             }
             if ($i != count($measure_list) - 1) {
                 //$retval .= "<br>";
             }
         } else {
             # Matching result value not found: Show "-"
             if (count($measure_list) == 1) {
                 $retval .= $curr_measure->name . "&nbsp;";
             }
             $retval .= " - <br>";
         }
     }
     $retval = str_replace("_", ",", $retval);
     # Replace all underscores with a comma
     return $retval;
 }
예제 #7
0
function clean_range($test, $report_config, $patient)
{
    $test_type = TestType::getById($test->testTypeId);
    $measure_list = $test_type->getMeasures();
    $range_output = '';
    $loop_count = 0;
    foreach ($measure_list as $measure) {
        $type = $measure->getRangeType();
        if ($type == Measure::$RANGE_NUMERIC) {
            $range_list_array = $measure->getRangeString($patient);
            $lower = $range_list_array[0];
            $upper = $range_list_array[1];
            $unit = $measure->unit;
            if (stripos($unit, ",") != false) {
                $units = explode(",", $unit);
                $lower_parts = explode(".", $lower);
                $upper_parts = explode(".", $upper);
                if ($lower_parts[0] != 0) {
                    $range_output .= $lower_parts[0];
                    $range_output .= $units[0];
                }
                if ($lower_parts[1] != 0) {
                    $range_output .= $lower_parts[1];
                    $range_output .= $units[1];
                }
                $range_output .= "-";
                if ($upper_parts[0] != 0) {
                    $range_output .= $upper_parts[0];
                    $range_output .= $units[0];
                }
                if ($upper_parts[1] != 0) {
                    $range_output .= $upper_parts[1];
                    $range_output .= $units[1];
                }
            } else {
                if (stripos($unit, ":") != false) {
                    $units = explode(":", $unit);
                    $range_output .= $lower;
                    $range_output .= $units[0] . "-";
                    $range_output .= $upper;
                    $range_output .= $units[0];
                    $range_output .= " " . $units[1];
                } else {
                    $range_output .= $lower . "-" . $upper;
                    $range_output .= " " . $measure->unit;
                }
            }
        } else {
            if ($measure->unit == "") {
                $range_output .= "";
            }
        }
        if ($loop_count < count($measure_list) - 1) {
            $range_output .= ", ";
        }
        $loop_count++;
    }
    // put ranges into an array
    $range_output_array = explode(", ", $range_output);
    return $range_output_array;
}
예제 #8
0
	public function getCustomWorksheetSummary($worksheet)
	{
		?>
		<table class='hor-minimalist-b' style='width:auto;'>
			<tbody>
			<tr valign='top'>
				<td><?php echo LangUtil::$generalTerms['NAME']; ?></td>
				<td><?php echo $worksheet->name; ?></td>
			</tr>
			<tr valign='top'>
				<td>Header</td>
				<td><?php echo $worksheet->headerText; ?></td>
			</tr>
			<tr valign='top'>
				<td>Title</td>
				<td><?php echo $worksheet->titleText; ?></td>
			</tr>
			<tr valign='top'>
				<td>Footer</td>
				<td><?php echo $worksheet->footerText; ?></td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$pageTerms['MARGINS']; ?> (%)</td>
				<td>
					<?php echo LangUtil::$pageTerms['TOP'];?>
					&nbsp;
					<?php echo $worksheet->margins[ReportConfig::$TOP]; ?>
					&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['BOTTOM'];?>
					&nbsp;
					<?php echo $worksheet->margins[ReportConfig::$BOTTOM]; ?>
					&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['LEFT'];?>
					&nbsp;
					<?php echo $worksheet->margins[ReportConfig::$LEFT]; ?>
					&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['RIGHT'];?>
					&nbsp;
					<?php echo $worksheet->margins[ReportConfig::$RIGHT]; ?>
				</td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$generalTerms['PATIENT_ID']; ?></td>
				<td>
					<?php
					if($worksheet->idFields[CustomWorksheet::$OFFSET_PID] == 1)
					{
						echo LangUtil::$generalTerms['YES'];
					}
					else
					{
						echo LangUtil::$generalTerms['NO'];
					}
					?>
				</td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></td>
				<td>
					<?php
					if($worksheet->idFields[CustomWorksheet::$OFFSET_DNUM] == 1)
					{
						echo LangUtil::$generalTerms['YES'];
					}
					else
					{
						echo LangUtil::$generalTerms['NO'];
					}
					?>
				</td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$generalTerms['ADDL_ID']; ?></td>
				<td>
					<?php
					if($worksheet->idFields[CustomWorksheet::$OFFSET_ADDLID] == 1)
					{
						echo LangUtil::$generalTerms['YES'];
					}
					else
					{
						echo LangUtil::$generalTerms['NO'];
					}
					?>
				</td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$pageTerms['CUSTOMFIELDS']; ?></td>
				<td>
					<span id='uf_list_box'>
					<?php
					foreach($worksheet->userFields as $field_entry)
					{
						$field_id = $field_entry[0];
						$field_name = $field_entry[1];
						$field_width = $field_entry[2];
						echo $field_name;
						echo "&nbsp;&nbsp;(";
						echo LangUtil::$pageTerms['COLUMN_WIDTH'].": ";
						echo $field_width;
						echo ")";
						echo "<br>";						
					}
					?>
					</span>
				</td>
			</tr>
		</table>
		<br>
		<div class='smaller_font' style='width:auto;'>
		<?php
		$test_type_list = $worksheet->testTypes;
		foreach($test_type_list as $test_type_id)
		{
			$test_type = TestType::getById($test_type_id);
			$measure_list = $test_type->getMeasures();
			?>
			<div>
			<b><?php echo $test_type->getName(); ?></b>
			<br>
				<div id='ttype_<?php echo $test_type->testTypeId; ?>_mlist' style='position:relative; margin-left:15px;'>
				<table class='hor-minimalist-b'>
					<thead>
					<tr>
						<th style='width:200px;'><?php echo LangUtil::$generalTerms['MEASURES']; ?></th>
						<th><?php echo LangUtil::$pageTerms['COLUMN_WIDTH']; ?> (%)</th>
					</tr>
					<?php
					foreach($measure_list as $measure)
					{
						$measure_id = $measure->measureId;
						?>
						<tr>
							<td>
								<?php echo $measure->getName(); ?>
							</td>
							<td>
								<?php echo $worksheet->columnWidths[$test_type_id][$measure_id]; ?>
							</td>
						</tr>
						<?php
					}
					?>
					</thead>
					<tbody>
					</tbody>
				</table>
				</div>
			</div>
			<br>
			<?php
		}
		?>
		</div>
	</div>
	<?php
	}
예제 #9
0
 $female_total = array();
 $cross_gender_total = array();
 $age_total = array();
 $age_total1 = array();
 $age_total2 = array();
 $curr_male_total = 0;
 $curr_female_total = 0;
 $curr_cross_gender_total = 0;
 $age_total;
 $age_total1;
 $age_total2;
 foreach ($site_list as $labConfigId) {
     $lab_config = get_lab_config_by_id($labConfigId);
     $testTypeId = $testIds[$labConfigId];
     $saved_db = DbUtil::switchToLabConfig($labConfigId);
     $testType = TestType::getById($testTypeId);
     StatsLib::setDiseaseSetList($lab_config, $testType, $date_from, $date_to);
     DbUtil::switchRestore($saved_db);
     $is_range_options = true;
     if (strpos($measure->range, "/") === false) {
         $is_range_options = false;
     }
     $range_values = array();
     if ($is_range_options) {
         # Alphanumeric options
         $range_values1 = explode("/", $measure->range);
         $range_values = str_replace("#", "/", $range_values1);
     } else {
         # Numeric ranges: Fetch ranges configured for this test-type/measure from DB
         $range_values = $disease_report->getMeasureGroupAsList();
     }
예제 #10
0
    $report_config->landscape = true;
} else {
    $report_config->landscape = false;
}
if ($_REQUEST['Clinical_Data'] == 'Y') {
    $ClinicalData = 1;
} else {
    $ClinicalData = 0;
}
$name = "../../logo_" . $lab_config_id . ".jpg";
# Header text
$align_header = array();
$align_header[0] = db_escape($_REQUEST['header']);
$align_header[1] = $_REQUEST['align'];
$report_config->headerText = db_escape(implode("??", $align_header));
$testType = TestType::getById($_REQUEST['t_type']);
$testName = $testType->name;
$title_text = "";
$count = 0;
foreach ($_REQUEST['title'] as $title_line) {
    $count++;
    $title_text .= $title_line;
    if ($count < count($_REQUEST['title'])) {
        $title_text .= "<br>";
    }
}
move_uploaded_file($_FILES["file"]["tmp_name"], $name);
$report_config->titleText = db_escape($title_text);
# Footer text
$report_config->footerText = db_escape($_REQUEST['footer']);
$report_config->designation = db_escape($_REQUEST['designation']);
예제 #11
0
function get_cumul_stats($lab_config_id, $test_type_id, $date_from, $date_to)
{
    $lab_config = LabConfig::getById($lab_config_id);
    $test_type = TestType::getById($test_type_id);
    $measure_list = $test_type->getMeasures();
    $site_settings = DiseaseReport::getByKeys($lab_config->id, 0, 0);
    $age_group_list = $site_settings->getAgeGroupAsList();
    ?>
	<table class='pretty_print' style='border-collapse: collapse;'>
	<thead>
		<tr valign='top'>
			<th><?php 
    echo LangUtil::$generalTerms['TEST'];
    ?>
</th>
			<th ><?php 
    echo LangUtil::$generalTerms['RESULTS'];
    ?>
</th>
			<?php 
    if ($site_settings->groupByGender == 1) {
        echo "<th >" . LangUtil::$generalTerms['GENDER'] . "</th>";
    }
    if ($site_settings->groupByAge == 1) {
        echo "<th >" . LangUtil::$pageTerms['RANGE_AGE'] . "</th>";
        for ($i = 1; $i < count($age_group_list); $i++) {
            echo "<th >" . LangUtil::$pageTerms['RANGE_AGE'] . "</th>";
        }
    }
    if ($site_settings->groupByGender == 1) {
        echo "<th ></th>";
    }
    ?>
			<th ><?php 
    echo LangUtil::$pageTerms['TOTAL'];
    ?>
</th>
			<th ><?php 
    echo LangUtil::$pageTerms['TOTAL_TESTS'];
    ?>
</th>
		</tr>
		<tr>
			<th ></th>
			<th ></th>
			<?php 
    if ($site_settings->groupByGender == 1) {
        echo "<th ></th>";
    }
    if ($site_settings->groupByAge == 1) {
        foreach ($age_group_list as $age_slot) {
            echo "<th>{$age_slot['0']}";
            if (trim($age_slot[1]) == "+") {
                echo "+";
            } else {
                echo " - {$age_slot['1']}";
            }
            echo "</th>";
        }
    }
    if ($site_settings->groupByGender == 1) {
        echo "<th >" . LangUtil::$pageTerms['TOTAL_MF'] . "</th>";
    }
    echo "<th ></th>";
    echo "<th ></th>";
    ?>
		<tr>
	</thead>
	<tbody>
	<?php 
    StatsLib::setDiseaseSetList($lab_config, $test_type, $date_from, $date_to);
    $measures = $test_type->getMeasures();
    foreach ($measures as $measure) {
        $male_total = array();
        $female_total = array();
        $cross_gender_total = array();
        $curr_male_total = 0;
        $curr_female_total = 0;
        $curr_cross_gender_total = 0;
        $disease_report = DiseaseReport::getByKeys($lab_config->id, $test_type->testTypeId, $measure->measureId);
        if ($disease_report == null) {
            # TODO: Check for error control
            # Alphanumeric values. Hence entry not found.
            //continue;
        }
        $is_range_options = true;
        if (strpos($measure->range, "/") === false) {
            $is_range_options = false;
        }
        $range_values = array();
        if ($is_range_options) {
            # Alphanumeric options
            $range_values = explode("/", $measure->range);
        } else {
            # Numeric ranges: Fetch ranges configured for this test-type/measure from DB
            $range_values = $disease_report->getMeasureGroupAsList();
        }
        ?>
		<tr valign='top'>
			<td><?php 
        echo $measure->getName();
        ?>
</td>
			<td>
			<?php 
        foreach ($range_values as $range_value) {
            if ($is_range_options) {
                echo "{$range_value}<br>";
            } else {
                echo "{$range_value['0']}-{$range_value['1']}<br>";
            }
            if ($site_settings->groupByGender == 1) {
                echo "<br>";
            }
        }
        ?>
			</td>
			<?php 
        if ($site_settings->groupByGender == 1) {
            # Group by gender set to true
            echo "<td>";
            for ($i = 1; $i <= count($range_values); $i++) {
                echo "M<br>F<br>";
            }
        }
        if ($site_settings->groupByAge == 1) {
            # Group by age set to true: Fetch age slots from DB
            $age_slot_list = $site_settings->getAgeGroupAsList();
            foreach ($age_slot_list as $age_slot) {
                echo "<td>";
                $range_value_count = 0;
                foreach ($range_values as $range_value) {
                    $range_value_count++;
                    if (!isset($male_total[$range_value_count])) {
                        $male_total[$range_value_count] = 0;
                        $female_total[$range_value_count] = 0;
                        $cross_gender_total[$range_value_count] = 0;
                    }
                    $curr_male_total = 0;
                    $curr_female_total = 0;
                    $curr_cross_gender_total = 0;
                    $range_type = DiseaseSetFilter::$CONTINUOUS;
                    if ($is_range_options == true) {
                        $range_type = DiseaseSetFilter::$DISCRETE;
                    }
                    if ($site_settings->groupByGender == 0) {
                        # No genderwise count required.
                        # Create filter
                        $disease_filter = new DiseaseSetFilter();
                        $disease_filter->patientAgeRange = $age_slot;
                        $disease_filter->patientGender = null;
                        $disease_filter->measureId = $measure->measureId;
                        $disease_filter->rangeType = $range_type;
                        $disease_filter->rangeValues = $range_value;
                        $curr_total = StatsLib::getDiseaseFilterCount($disease_filter);
                        $curr_cross_gender_total += $curr_total;
                        echo "{$curr_total}<br>";
                    } else {
                        # Genderwise count required.
                        # Create filter
                        $disease_filter = new DiseaseSetFilter();
                        $disease_filter->patientAgeRange = $age_slot;
                        $disease_filter->measureId = $measure->measureId;
                        $disease_filter->rangeType = $range_type;
                        $disease_filter->rangeValues = $range_value;
                        ## Count for males.
                        $disease_filter->patientGender = 'M';
                        $curr_total1 = StatsLib::getDiseaseFilterCount($disease_filter);
                        $curr_male_total += $curr_total1;
                        ## Count for females.
                        $disease_filter->patientGender = 'F';
                        $curr_total2 = StatsLib::getDiseaseFilterCount($disease_filter);
                        $curr_female_total += $curr_total2;
                        echo "{$curr_total1}<br>{$curr_total2}<br>";
                    }
                    # Build assoc list to track genderwise totals
                    $male_total[$range_value_count] += $curr_male_total;
                    $female_total[$range_value_count] += $curr_female_total;
                    $cross_gender_total[$range_value_count] += $curr_cross_gender_total;
                }
                echo "</td>";
            }
        } else {
            # Age slots not configured: Show cumulative count for all age values
            $range_value_count = 0;
            foreach ($range_values as $range_value) {
                $range_value_count++;
                if (!isset($male_total[$range_value_count])) {
                    $male_total[$range_value_count] = 0;
                    $female_total[$range_value_count] = 0;
                    $cross_gender_total[$range_value_count] = 0;
                }
                $curr_male_total = 0;
                $curr_female_total = 0;
                $curr_cross_gender_total = 0;
                $range_type = DiseaseSetFilter::$CONTINUOUS;
                if ($is_range_options == true) {
                    $range_type = DiseaseSetFilter::$DISCRETE;
                }
                if ($site_settings->groupByGender == 0) {
                    # No genderwise count required.
                    # Create filter
                    $disease_filter = new DiseaseSetFilter();
                    $disease_filter->patientAgeRange = array(0, 200);
                    $disease_filter->patientGender = null;
                    $disease_filter->measureId = $measure->measureId;
                    $disease_filter->rangeType = $range_type;
                    $disease_filter->rangeValues = $range_value;
                    $curr_total = StatsLib::getDiseaseFilterCount($disease_filter);
                    $curr_cross_gender_total += $curr_total;
                } else {
                    # Genderwise count required.
                    # Create filter
                    $disease_filter = new DiseaseSetFilter();
                    $disease_filter->patientAgeRange = array(0, 200);
                    $disease_filter->measureId = $measure->measureId;
                    $disease_filter->rangeType = $range_type;
                    $disease_filter->rangeValues = $range_value;
                    ## Count for males.
                    $disease_filter->patientGender = 'M';
                    $curr_total1 = StatsLib::getDiseaseFilterCount($disease_filter);
                    $curr_male_total += $curr_total1;
                    ## Count for females.
                    $disease_filter->patientGender = 'F';
                    $curr_total2 = StatsLib::getDiseaseFilterCount($disease_filter);
                    $curr_female_total += $curr_total2;
                }
                # Build assoc list to track genderwise totals
                $male_total[$range_value_count] += $curr_male_total;
                $female_total[$range_value_count] += $curr_female_total;
                $cross_gender_total[$range_value_count] += $curr_cross_gender_total;
            }
        }
        if ($site_settings->groupByGender == 1) {
            echo "<td>";
            for ($i = 1; $i <= count($range_values); $i++) {
                $this_male_total = $male_total[$i];
                $this_female_total = $female_total[$i];
                echo "{$this_male_total}<br>{$this_female_total}<br>";
                $this_cross_gender_total = $this_male_total + $this_female_total;
            }
            echo "</td>";
        }
        echo "<td>";
        for ($i = 1; $i <= count($range_values); $i++) {
            if ($site_settings->groupByGender == 1) {
                echo $male_total[$i] + $female_total[$i];
                echo "<br><br>";
            } else {
                echo $cross_gender_total[$i];
                echo "<br>";
            }
        }
        echo "</td>";
        # Grand total:
        # TODO: Check the following function for off-by-one error
        //$disease_total = StatsLib::getDiseaseTotal($lab_config, $test, $date_from, $date_to);
        //echo "<td >$disease_total</td>";
        echo "<td>";
        if ($site_settings->groupByGender == 1) {
            echo array_sum($male_total) + array_sum($female_total);
        } else {
            echo array_sum($cross_gender_total);
        }
        echo "</td>";
        ?>
			</tr>
			<?php 
    }
    ?>
	</tbody>
	</table>
	<?php 
}
예제 #12
0
파일: db_lib.php 프로젝트: caseyi/BLIS
 public function decodeResultWithoutMeasures($show_range = false)
 {
     # Converts stored result value(s) for showing on front-end
     # Get measure, unit pairs for this test
     $test_type = TestType::getById($this->testTypeId);
     $measure_list = $test_type->getMeasures();
     //print_r($measure_list);
     $submeasure_list = array();
     $comb_measure_list = array();
     // print_r($measure_list);
     foreach ($measure_list as $measure) {
         $submeasure_list = $measure->getSubmeasuresAsObj();
         //echo "<br>".count($submeasure_list);
         //print_r($submeasure_list);
         $submeasure_count = count($submeasure_list);
         if ($measure->checkIfSubmeasure() == 1) {
             continue;
         }
         if ($submeasure_count == 0) {
             array_push($comb_measure_list, $measure);
         } else {
             array_push($comb_measure_list, $measure);
             foreach ($submeasure_list as $submeasure) {
                 array_push($comb_measure_list, $submeasure);
             }
         }
     }
     $measure_list = $comb_measure_list;
     $result_csv = $this->getResultWithoutHash();
     //$result_csv = $this->getResultWithoutHash();
     //echo "<br>";
     //echo $result_csv;
     //echo "<br>";
     if (strpos($result_csv, "[\$]") === false) {
         $result_list = explode(",", $result_csv);
     } else {
         //$testt = "one,[$]two[/$],[$]twotwo[/$],three";
         $testt = $result_csv;
         //$test2 = strstr($testt, $);
         $start_tag = "[\$]";
         $end_tag = "[/\$]";
         //$testtt = str_replace("[$]two[/$],", "", $testt);
         $freetext_results = array();
         $ft_count = substr_count($testt, $start_tag);
         //echo $ft_count;
         $k = 0;
         while ($k < $ft_count) {
             $ft_beg = strpos($testt, $start_tag);
             $ft_end = strpos($testt, $end_tag);
             $ft_sub = substr($testt, $ft_beg + 3, $ft_end - $ft_beg - 3);
             $ft_left = substr($testt, 0, $ft_beg);
             $ft_right = substr($testt, $ft_end + 5);
             //echo "<br>".$ft_left."--".$ft_right."<br>";
             $testt = $ft_left . $ft_right;
             array_push($freetext_results, $ft_sub);
             $k++;
         }
         //echo $freetext_results."<br>".$testt;
         //$testtt = str_replace($subb, "", $testt, 1);
         //echo "$testto<br>$subb<br>";
         $result_csv = $testt;
         if (strpos($testt, ",") == 0) {
             $result_csv = substr($testt, 1, strlen($testt));
         }
         $result_list = explode(",", $result_csv);
         //echo "<br>";
         //print_r($result_list);
         //echo "<br>";
     }
     $retval = "";
     //NC3065
     //echo print_r($measure_list);
     //echo "<br>";
     //echo $result_csv;
     //echo "<br>";
     //echo print_r($result_list,true);
     //echo "Num->".count($measure_list);
     //-NC3065
     $j = 0;
     $i = 0;
     $c = 0;
     //for($i = 0; $i < count($measure_list); $i++) {
     while ($c < count($measure_list)) {
         # Pretty print
         $curr_measure = $measure_list[$c];
         if ($curr_measure->getRangeType() != Measure::$RANGE_FREETEXT) {
             if (isset($result_list[$i])) {
                 //echo "Num->".$i;
                 # If matching result value exists (e.g. after a new measure was added to this test type)
                 if (count($measure_list) == 1) {
                     # Only one measure: Do not print measure name
                     if ($curr_measure->getRangeType() == Measure::$RANGE_AUTOCOMPLETE) {
                         $result_string = "";
                         $value_list = explode("_", $result_list[$i]);
                         foreach ($value_list as $value) {
                             if (trim($value) == "") {
                                 continue;
                             }
                             $result_string .= $value . "<br>";
                         }
                         $result_string = substr($result_string, 0, -4);
                         $retval .= "<br>" . $result_string . "&nbsp;";
                     } else {
                         if ($curr_measure->getRangeType() == Measure::$RANGE_OPTIONS) {
                             if ($result_list[$i] != $curr_measure->unit) {
                                 $retval .= "<br><b>" . $result_list[$i] . "</b> &nbsp;";
                             } else {
                                 $retval .= "<br>" . $result_list[$i] . "&nbsp;";
                             }
                         } else {
                             $retval .= "<br>" . $result_list[$i] . "&nbsp;";
                         }
                     }
                 } else {
                     # Print measure name with each result value
                     if ($curr_measure->getRangeType() == Measure::$RANGE_AUTOCOMPLETE) {
                         $result_string = "";
                         $value_list = str_replace("_", ",", $result_list[$i]);
                         $retval .= "<br><b>" . $value_list . "</b>";
                     } else {
                         if ($curr_measure->getRangeType() == Measure::$RANGE_OPTIONS) {
                             if ($result_list[$i] != $curr_measure->unit) {
                                 $retval .= "<br><b>" . $result_list[$i] . "</b>" . "&nbsp;";
                             } else {
                                 $retval .= $result_list[$i] . "&nbsp;";
                             }
                         } else {
                             $retval .= "<br><b>" . $result_list[$i] . "</b>" . "&nbsp;";
                         }
                     }
                 }
                 if ($show_range === true) {
                     $retval .= $curr_measure->getRangeString();
                 }
                 if ($i != count($measure_list) - 1) {
                     $retval .= "<br>";
                 }
             } else {
                 # Matching result value not found: Show "-"
                 if (count($measure_list) == 1) {
                 }
                 $retval .= " - <br>";
             }
             $i++;
         } else {
             $ft_result = $freetext_results[$j];
             if (count($measure_list) == 1) {
                 $retval .= "<br>" . $ft_result . "&nbsp;";
             } else {
                 $retval .= "<br>" . $ft_result . "&nbsp;";
             }
             if ($show_range === true) {
                 $retval .= $curr_measure->getRangeString();
             }
             if ($i != count($measure_list) - 1) {
                 $retval .= "<br>";
             }
             $j++;
         }
         $c++;
     }
     //end
     //$retval = str_replace("_",",",$retval); # Replace all underscores with a comma
     return $retval;
 }