Beispiel #1
0
        $field_id = $frow['field_id'];
        $table = 'patient_data';
        if (isset($_POST["form_{$field_id}"])) {
            $newdata[$table][$field_id] = get_layout_form_value($frow);
        }
    }
    if (empty($ptid)) {
        $tmp = sqlQuery("SELECT MAX(pid)+1 AS pid FROM patient_data");
        $ptid = empty($tmp['pid']) ? 1 : intval($tmp['pid']);
        if (empty($newdata['patient_data']['pubpid'])) {
            // pubpid for new patient defaults to pid.
            $newdata['patient_data']['pubpid'] = "{$ptid}";
        }
        updatePatientData($ptid, $newdata['patient_data'], true);
        updateEmployerData($ptid, $newdata['employer_data'], true);
        newHistoryData($ptid);
    } else {
        $newdata['patient_data']['id'] = $_POST['db_id'];
        updatePatientData($ptid, $newdata['patient_data']);
    }
    // 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;
}
Beispiel #2
0
<?php 
if (acl_check('patients', 'med')) {
    $tmp = getPatientData($pid, "squad");
    if ($tmp['squad'] && !acl_check('squads', $tmp['squad'])) {
        echo "<p>(" . htmlspecialchars(xl('History not authorized'), ENT_NOQUOTES) . ")</p>\n";
        echo "</body>\n</html>\n";
        exit;
    }
} else {
    echo "<p>(" . htmlspecialchars(xl('History not authorized'), ENT_NOQUOTES) . ")</p>\n";
    echo "</body>\n</html>\n";
    exit;
}
$result = getHistoryData($pid);
if (!is_array($result)) {
    newHistoryData($pid);
    $result = getHistoryData($pid);
}
?>

<?php 
if (acl_check('patients', 'med', '', array('write', 'addonly'))) {
    ?>
<div>
    <span class="title"><?php 
    echo htmlspecialchars(xl('Patient History / Lifestyle'), ENT_NOQUOTES);
    ?>
</span>
</div>
<div id='namecontainer_history' class='namecontainer_history' style='float:left;margin-right:10px'>
<?php 
/**
 * Create a patient using whatever patient_data attributes are provided.
 */
function create_skeleton_patient($patient_data)
{
    $employer_data = array();
    $tmp = sqlQuery("SELECT MAX(pid)+1 AS pid FROM patient_data");
    $ptid = empty($tmp['pid']) ? 1 : intval($tmp['pid']);
    if (!isset($patient_data['pubpid'])) {
        $patient_data['pubpid'] = $ptid;
    }
    updatePatientData($ptid, $patient_data, true);
    updateEmployerData($ptid, $employer_data, true);
    newHistoryData($ptid);
    return $ptid;
}
Beispiel #4
0
 public static function batch_despatch($var, $func, $data_credentials)
 {
     global $pid;
     if (UserService::valid($data_credentials)) {
         require_once "../../library/invoice_summary.inc.php";
         require_once "../../library/options.inc.php";
         require_once "../../library/acl.inc";
         require_once "../../library/patient.inc";
         if ($func == 'ar_responsible_party') {
             $patient_id = $pid;
             $encounter_id = $var['encounter'];
             $x['ar_responsible_party'] = ar_responsible_party($patient_id, $encounter_id);
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'getInsuranceData') {
             $type = $var['type'];
             $given = $var['given'];
             $x = getInsuranceData($pid, $type, $given);
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'generate_select_list') {
             $tag_name = $var['tag_name'];
             $list_id = $var['list_id'];
             $currvalue = $var['currvalue'];
             $title = $var['title'];
             $empty_name = $var['empty_name'];
             $class = $var['class'];
             $onchange = $var['onchange'];
             $x['generate_select_list'] = generate_select_list($tag_name, $list_id, $currvalue, $title, $empty_name, $class, $onchange);
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'xl_layout_label') {
             $constant = $var['constant'];
             $x['xl_layout_label'] = xl_layout_label($constant);
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'generate_form_field') {
             $frow = $var['frow'];
             $currvalue = $var['currvalue'];
             ob_start();
             generate_form_field($frow, $currvalue);
             $x['generate_form_field'] = ob_get_contents();
             ob_end_clean();
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'getInsuranceProviders') {
             $i = $var['i'];
             $provider = $var['provider'];
             $insurancei = getInsuranceProviders();
             $x = $insurancei;
             return $x;
         } elseif ($func == 'get_layout_form_value') {
             $frow = $var['frow'];
             $_POST = $var['post_array'];
             $x['get_layout_form_value'] = get_layout_form_value($frow);
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'updatePatientData') {
             $patient_data = $var['patient_data'];
             $create = $var['create'];
             updatePatientData($pid, $patient_data, $create);
             $x['ok'] = 'ok';
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'updateEmployerData') {
             $employer_data = $var['employer_data'];
             $create = $var['create'];
             updateEmployerData($pid, $employer_data, $create);
             $x['ok'] = 'ok';
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'newHistoryData') {
             newHistoryData($pid);
             $x['ok'] = 'ok';
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'newInsuranceData') {
             $_POST = $var[0];
             foreach ($var as $key => $value) {
                 if ($key >= 3) {
                     $var[$key] = formData($value);
                 }
                 if ($key >= 1) {
                     $parameters[$key] = $var[$key];
                 }
             }
             $parameters[12] = fixDate($parameters[12]);
             $parameters[27] = fixDate($parameters[27]);
             call_user_func_array('newInsuranceData', $parameters);
             $x['ok'] = 'ok';
             return UserService::function_return_to_xml($x);
         } elseif ($func == 'generate_layout_validation') {
             $form_id = $var['form_id'];
             ob_start();
             generate_layout_validation($form_id);
             $x = ob_get_clean();
             return $x;
         }
     } else {
         throw new SoapFault("Server", "credentials failed");
     }
 }
Beispiel #5
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;
}