示例#1
0
    }
    return $ret;
}
function facilities()
{
    $ret = [];
    $res = mysql_query("SELECT id,facility,districtID,hubID from facilities where facility!='' LIMIT 500");
    while ($row = mysql_fetch_array($res)) {
        extract($row);
        $ret[$id] = ['id' => $id, 'name' => $facility, 'district_id' => $districtID, 'hub_id' => $hubID];
    }
    return $ret;
}
$data = [];
$data['districts'] = districts();
$data['hubs'] = hubs();
$data['facilities'] = facilities();
$data['age_group'] = [1 => " < 5", 2 => " 5 - 9", 3 => " 10 - 18", 4 => "19 - 25", "26+"];
$years = [2014, 2015];
$results = [];
$i = 1;
foreach ($years as $year) {
    $month = 1;
    while ($month <= 12) {
        foreach ($data['facilities'] as $facility) {
            foreach ($data['age_group'] as $ag_k => $ag) {
                $samples_received = rand(10, 20);
                $dbs_samples = rand(1, $samples_received - 5);
                $total_results = rand(10, $samples_received - 1);
                $valid_results = rand(0, $total_results);
                $rejected_samples = $samples_received - $total_results;
示例#2
0
    return $ret;
}
function getTrmtIndctn($year)
{
    $ret = [];
    $age_grp_case = ageGroupCase();
    $sql = "SELECT facilityID,month(s.created) AS mth,count(s.id) AS num,{$age_grp_case} AS age_group,treatmentInitiationID   \n\t\t  FROM vl_samples AS s\n\t\t  LEFT JOIN vl_patients AS p ON s.patientID=p.id\n\t\t  WHERE YEAR(s.created)='{$year}'\t\t  \n\t\t  GROUP BY mth,age_group,facilityID,treatmentInitiationID";
    $res = mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_assoc($res)) {
        extract($row);
        $ret[$mth][$age_group][$facilityID][$treatmentInitiationID] = $num;
    }
    return $ret;
}
$districts = districts();
$hubs = hubs();
$facilities = facilities();
file_put_contents("../public/json/districts.json", json_encode($districts));
file_put_contents("../public/json/hubs.json", json_encode($hubs));
file_put_contents("../public/json/facilities.json", json_encode($facilities));
$year = 2013;
$current_year = date('Y');
$results = [];
while ($year <= $current_year) {
    $samples = getSamples($year);
    $dbs_samples = getSamples($year, " sampleTypeID=1 ");
    $trmt_indctn = getTrmtIndctn($year);
    $rjctn_rsns = getRejects($year);
    $rjctn_rsns2 = getRejects2($year);
    $t_rslts = getResults($year);
    $v_rslts = getResults($year, validCases());