function print_patient_info()
{
    global $patient_id;
    $patient_info = get_patient_info($patient_id);
    // get important information
    $first_name = $patient_info['first_name'];
    $last_name = $patient_info['last_name'];
    $dob = $patient_info['date_of_birth'];
    echo "<strong>Name:</strong> {$first_name} {$last_name}";
    echo "<br><strong>DOB:</strong> {$dob}";
}
<?php

// This stuff is to fill in the fields we already know
// If the user visits the clinic again, we want to auto-fill these fields out.
if (!isset($_GET['token']) or !is_valid_token($_GET['token'])) {
    die("Valid token required.");
}
$token = $_GET['token'];
$patient_id = get_patient_id_from_token($token);
// An associate array of fields filled out. Used to echo out values later.
$fields_filled_out = get_patient_info($patient_id);
// Store first_name, last_name, date_of_birth in this assoc. array
// Now check to see if we have a previous Demographics input filled out
// There will only be ONE row in the database. If the patient comes again, they will UPDATE the row.
global $db;
$result = $db->query("SELECT preferred_name, gender, daily_work_performed, completed_education, has_history_tobacco, alcohol_usage, ethnicity FROM PatientDemographics WHERE patient_id = '{$patient_id}'");
if ($result->num_rows !== 0) {
    $row = $result->fetch_assoc();
    $fields_filled_out = array_merge($fields_filled_out, $row);
    //concatenate fields together
}
// Called during in-line HTML statements to print stuff out
function print_field($field_name)
{
    global $fields_filled_out;
    // This isset if is required because if it's the first time a patient is filling out this form
    // Then the key in this $fields_filled_out associative array will not exist
    if (isset($fields_filled_out[$field_name])) {
        echo $fields_filled_out[$field_name];
    }
}