function get_patient_id_create_if_new($first_name, $last_name, $birthday) { global $db; $id = get_patient_id($first_name, $last_name, $birthday); if (empty($id)) { // ID was null, so the patient is new, so let's insert them // We are preferring prepared statements, especially for INSERTion $query = "INSERT INTO Patients"; $query .= "(first_name, last_name, date_of_birth, created, last_modified)"; $query .= "VALUES (?, ?, ?, now(), now())"; $birthday = sql_friendly_date($birthday); if (!($stmt = $db->prepare($query))) { echo "Prepare failed: (" . $db->errno . ") " . $db->error; } if (!$stmt->bind_param("sss", $first_name, $last_name, $birthday)) { echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; } if ($stmt->execute()) { //header("Location: ../../"); This will direct to the next form to be added } else { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } $id = $stmt->insert_id; // The new patient_id of what we INSERTed } return $id; }
function get_field_input($type, $uid, $program) { $pxid = get_patient_id($uid); list($px_fname, $px_lname, $px_brgy, $px_address) = explode("|", get_pxdetails_couch($uid)); $px_fname = trim($px_fname); $px_lname = trim($px_lname); $px_brgy = trim($px_brgy); $px_address = trim($px_address); //echo $px_lname.'/'.$px_fname.'/'.$px_brgy.'/'.$px_address."<br >"; //print_r($_SESSION["str_old_px_id"]); if ($type == 'newpx') { echo "<td align='center'>"; echo "<input type='checkbox' name='{$uid}' CHECKED></input>"; echo "</td>"; } elseif ($type == 'oldpx') { $q_check_family = mysql_query("SELECT family_id FROM m_family_members WHERE patient_id='{$pxid}'") or die("Cannot query: 100" . mysql_error()); if (mysql_num_rows($q_check_family) != 0) { echo "<td>Yes</td>"; echo "<td><a href='{$_SERVER['PHP_SELF']}?type={$_GET['type']}&title={$_GET['title']}&uid={$uid}&program={$program}&action=sync'>Sync Health Data</a>"; if (!empty($_GET["uid"]) && !empty($_GET["program"]) && ($_GET["action"] = 'sync' && $_GET["uid"] == $uid)) { check_program($uid, $_GET["program"]); } echo "</td>"; } else { $px_address = str_replace("'s", "", $px_address); $px_address = str_replace("'", "", $px_address); echo "<td>"; echo "<a onclick=\"create_folder('{$px_fname}','{$px_lname}','{$px_brgy}','{$px_address}','{$pxid}')\">Create</a> "; echo "<a onclick=\"assign_relative('{$px_fname}','{$px_lname}','{$px_brgy}','{$px_address}','{$pxid}')\">Assign</a> "; echo "</td>"; echo "<td>Assign to family first</td>"; } } else { } }
function print_single_attachment($array) { echo '<table>'; echo '<tr><td>(This attachment is invalid for clinical use unless accompanied by main report)</td></tr>'; echo '<tr><th colspan=10 align=left>Attachment of sample_id=' . $array['sample_id'] . ' and patient_id=' . get_patient_id($array['sample_id']) . '</th></tr>'; echo '<tr><th colspan=10 align=left>Attachment:' . $array['attachment_id'] . '</th></tr>'; echo '<tr><th colspan=10 align=left>Description:' . $array['description'] . '</th></tr>'; $filetype = $array['filetype']; if ($filetype == 'jpeg' || $filetype == 'jpg' || $filetype == 'gif') { $filename = create_file($array['file'], $array['sample_id'], $array['attachment_id'], $array['filetype']); echo '<tr><td><img src="' . $filename . '" height=500 width=500></td></tr>'; } elseif ($filetype == 'txt') { echo '<tr><td><pre>' . htmlspecialchars($array['file']) . '</pre></td></tr>'; } else { echo ' <tr> <td>cannot display</td> </tr>'; } echo '</table>'; }