Пример #1
0
 // if ($data_type != 21 && !isset($_POST["form_$field_id"])) continue;
 //
 // The above statement commented out 2015-01-12 because a LBF plugin might conditionally
 // disable a field that is not applicable, and we need the ability to clear out the old
 // garbage in there so it does not show up in the "report" view of the data.  So we will
 // trust that it's OK to clear any field that is defined in the layout but not returned
 // by the form.
 //
 $value = get_layout_form_value($frow);
 // If edit option P or Q, save to the appropriate different table and skip the rest.
 $source = $frow['source'];
 if ($source == 'D' || $source == 'H') {
     // Save to patient_data, employer_data or history_data.
     if ($source == 'H') {
         $new = array($field_id => $value);
         updateHistoryData($pid, $new);
     } else {
         if (strpos($field_id, 'em_') === 0) {
             $field_id = substr($field_id, 3);
             $new = array($field_id => $value);
             updateEmployerData($pid, $new);
         } else {
             $esc_field_id = escape_sql_column_name($field_id, array('patient_data'));
             sqlStatement("UPDATE patient_data SET `{$esc_field_id}` = ? WHERE pid = ?", array($value, $pid));
         }
     }
     continue;
 } else {
     if ($source == 'E') {
         // Save to shared_attributes. Can't delete entries for empty fields because with the P option
         // it's important to know when a current empty value overrides a previous value.
Пример #2
0
require_once "{$srcdir}/formdata.inc.php";
require_once "{$srcdir}/options.inc.php";
require_once "portal.inc.php";
$postid = intval($_REQUEST['postid']);
$ptid = intval($_REQUEST['ptid']);
if ($_POST['bn_save']) {
    $newdata = array();
    $fres = sqlStatement("SELECT * FROM layout_options WHERE " . "form_id = 'HIS' AND field_id != '' AND uor > 0 " . "ORDER BY group_name, seq");
    while ($frow = sqlFetchArray($fres)) {
        $data_type = $frow['data_type'];
        $field_id = $frow['field_id'];
        if (isset($_POST["form_{$field_id}"])) {
            $newdata[$field_id] = get_layout_form_value($frow);
        }
    }
    updateHistoryData($ptid, $newdata);
    // Finally, delete the request from the portal.
    $result = cms_portal_call(array('action' => 'delpost', 'postid' => $postid));
    if ($result['errmsg']) {
        die(text($result['errmsg']));
    }
    echo "<html><body><script language='JavaScript'>\n";
    echo "if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();\n";
    echo "document.location.href = 'list_requests.php';\n";
    echo "</script></body></html>\n";
    exit;
}
// Get the portal request data.
if (!$postid) {
    die(xlt('Request ID is missing!'));
}
Пример #3
0
function create_patient(&$medics, &$errors)
{
    $alertmsg = "";
    $patient_pid = get_patientid($medics);
    $pubpid = trim($medics->pubpid);
    // ID must be valid or 'NEWPATIENT'
    if (empty($pubpid)) {
        array_push($errors, "Patient ID '{$pubpid}' missing, patient skipped! ");
        return $alertmsg;
    }
    if ($pubpid != 'NEWPATIENT') {
        // 1. validate patient
        $patient_pid = 0;
        $query = "SELECT pid FROM patient_data WHERE pubpid LIKE '{$pubpid}'";
        $res = sqlStatement($query);
        $row = sqlFetchArray($res);
        if ($row) {
            $patient_pid = $row['pid'];
            if (sqlFetchArray($res)) {
                array_push($errors, "Patient ID '{$pubpid}' is ambiguous, patient skipped! ");
                return $alertmsg;
            } else {
                // array_push( $errors, "Patient ID '$pubpid' exists, updates/new encounters only. ");
            }
        }
    }
    // 2. validate insurance provider - REMOVED
    // 3. validate billing provider
    $tmp = array();
    $tmp = fetchProviderInfo($medics);
    if (!array($tmp)) {
        array_push($errors, "Provider '{$tmp}' not found, patient skipped!");
        return $alertmsg;
    }
    $patient_provider_id = $tmp['id'];
    $patient_provider_name = $tmp['username'];
    $patient_provider_facility = $tmp['facility_id'];
    // 4. get facility from  // Move to function
    $row = sqlQuery("SELECT id, name, pos_code FROM facility WHERE id = '{$patient_provider_facility}'");
    if (!$row['id']) {
        array_push($errors, "Facility '{$tmp}' not found, patient skipped! ");
        return $alertmsg;
    }
    $patient_facility_id = $row['id'];
    $patient_facility_name = $row['name'];
    $patient_facility_pos = $row['pos_code'];
    // 5. insert patient data
    if (!$patient_pid) {
        // Insert into patient_data.
        //
        $row = sqlQuery("SELECT max(pid)+1 AS pid FROM patient_data");
        $patient_pid = $row['pid'] ? $row['pid'] : 1;
        // Combine street lines
        $patient_street = $medics->street . ' ' . $medics->street2;
        // Build array
        newPatientData('', '', form2db($medics->fname), form2db($medics->lname), form2db($medics->mname), sex($medics->sex), form2db($medics->dob), form2db($patient_street), '', '', '', form2db($medics->zip), form2db($medics->city), form2db($medics->state), '', '', '', form2db($medics->phone_home), form2db($medics->phone_alternate), '', '', '', '', '', '', '', form2db($medics->ethnicity), '', '', '', '', '', '0000-00-00 00:00:00', $patient_pid, $patient_pid, '', '', '', '', '', '', form2db($medics->hippa_notice), form2db($medics->hippa_notice), '', '', '', form2db($medics->hippa_notice), '', $dos = fixDate($medics->fromdate));
        // Insert dummy row for employer_data.
        newEmployerData($patient_pid);
        // Update or Instest subscriber ins data
        if ($medics->pubpid == 'NEWPATIENT' || !empty($medics->policy_id)) {
            newInsuranceData($patient_pid, 'primary', $insurance_company_id, form2db($medics->policy_id), '', '', form2db($medics->lname), form2db($medics->mname), form2db($medics->fname), 'self', '', fixDate($medics->dob), form2db($medics->street), form2db($medics->zip), form2db($medics->city), form2db($medics->state), '', form2db($medics->phone_home), '', '', '', '', '', '', '', sex($medics->sex), fixDate($medics->eff_date));
        }
        $tmp = $medics->lname . ',' . $medics->fname;
        $alertmsg .= "New Patient Added: '{$patient_pid}' / '{$tmp}' <br>\n";
    }
    $medics->pid = $patient_pid;
    $history = array('history_father' => form2db($medics->familyinformation->father), 'history_mother' => form2db($medics->familyinformation->mother), 'history_spouse' => form2db($medics->familyinformation->spouse), 'history_siblings' => form2db($medics->familyinformation->siblings), 'history_offspring' => form2db($medics->familyinformation->offspring), 'relatives_cancer' => form2db($medics->medical->relativesexperience->cancer), 'relatives_tuberculosis' => form2db($medics->medical->relativesexperience->tuberculosis), 'relatives_diabetes' => form2db($medics->medical->relativesexperience->diabetes), 'relatives_high_blood_pressure' => form2db($medics->medical->relativesexperience->highbloodpressure), 'relatives_heart_problems' => form2db($medics->medical->relativesexperience->heartproblems), 'relatives_stroke' => form2db($medics->medical->relativesexperience->stroke), 'relatives_epilepsy' => form2db($medics->medical->relativesexperience->epilepsy), 'relatives_mental_illness' => form2db($medics->medical->relativesexperience->mentalillness), 'relatives_suicide' => form2db($medics->medical->relativesexperience->suicide), 'usertext12' => form2db($medics->medical->relativesexperience->other), 'coffee' => form2db($medics->medical->lifestyleusage->coffee), 'tobacco' => form2db($medics->medical->lifestyleusage->tobacco), 'alcohol' => form2db($medics->medical->lifestyleusage->alcohol), 'sleep_patterns' => form2db($medics->medical->lifestyleusage->sleep), 'exercise_patterns' => form2db($medics->medical->lifestyleusage->exercise), 'seatbelt_use' => form2db($medics->medical->lifestyleusage->seatbelt), 'counseling' => form2db($medics->medical->lifestyleusage->counseling), 'hazardous_activities' => form2db($medics->medical->lifestyleusage->hazardactivities), 'usertext13' => form2db($medics->medical->lifestyleusage->urinaryincontinence), 'usertext14' => form2db($medics->medical->lifestyleusage->fallhistory), 'additional_history' => form2db($medics->medical->lifestyleusage->other) . " " . form2db($medics->medical->lifestyleusage->generalnotes));
    // Insert/Update into history_data.
    if ($medics->pubpid == 'NEWPATIENT') {
        newHistoryData($patient_pid, $history);
    } else {
        updateHistoryData($patient_pid, $history);
    }
    // Add or Update History data
    add_update_history($medics, $patient_pid, $errors);
    // Create or update an issue for each historical medication.
    //
    foreach ($medics->medical->medications->medication as $medication) {
        if (isempty($medication->name)) {
            continue;
        }
        $meds = array();
        $meds['title'] = form2db($medication->name);
        $meds['dosage'] = form2db($medication->dosage);
        $meds['frequency'] = form2db($medication->frequency);
        $meds['duration'] = form2db($medication->duration);
        // TBD does not exsist in MEDICS
        $meds['id'] = form2db($medication->id);
        if (!isempty($meds['id'])) {
            $row = sqlQuery("SELECT id FROM lists WHERE id = " . $meds['id']);
            if (!$row) {
                create_issue($patient_pid, 'medication', $meds);
            } else {
                update_issue($patient_pid, 'medication', $meds);
            }
        } else {
            create_issue($patient_pid, 'medication', $meds);
        }
    }
    return $alertmsg;
}