Skip to content

Commit

Permalink
Merge pull request openemr#7326 from stephenwaite/mo-rel-702-stuff
Browse files Browse the repository at this point in the history
More recent commits for rel 702
  • Loading branch information
stephenwaite committed Apr 18, 2024
2 parents b942eb2 + fa92b86 commit 0186814
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 35 deletions.
5 changes: 4 additions & 1 deletion interface/billing/billing_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,11 @@ function toencounter(pid, pubpid, pname, enc, datestr, dobstr) {
// Process a click to go to an patient.
function topatient(pid, pubpid, pname, enc, datestr, dobstr) {
top.restoreSession();
paturl = 'patient_file/summary/demographics_full.php?pid=' + encodeURIComponent(pid);
paturl = 'patient_file/summary/insurance_edit.php?pid=' + encodeURIComponent(pid);
parent.left_nav.setPatient(pname, pid, pubpid, '', dobstr);
parent.left_nav.loadFrame('ens1', 'enc',
'patient_file/history/encounters.php?pid=' + encodeURIComponent(pid));
parent.left_nav.loadFrame('dem1', 'pat', paturl);
}

function popMBO(pid, enc, mboid) {
Expand Down
20 changes: 13 additions & 7 deletions interface/billing/sl_eob_invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function updateFields(payField, adjField, balField, coPayField, isFirstProcCode)
$payer_type = $matches[1];
}

if (!empty($_POST['form_save']) || !empty($_POST['form_cancel']) || !empty($_POST['isLastClosed']) || !empty($_POST['billing_note'])) {
if (!empty($_POST['form_save']) || !empty($_POST['form_cancel']) || !empty($_POST['isLastClosed']) || !empty($_POST['enc_billing_note'])) {
if (!empty($_POST['form_save'])) {
if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
CsrfUtils::csrfNotVerified();
Expand Down Expand Up @@ -417,7 +417,7 @@ function updateFields(payField, adjField, balField, coPayField, isFirstProcCode)
if (!$debug && !$save_stay && !$_POST['isLastClosed']) {
echo "doClose();\n";
}
if (!$debug && ($save_stay || $_POST['isLastClosed'] || $_POST['billing_note'])) {
if (!$debug && ($save_stay || $_POST['isLastClosed'] || $_POST['enc_billing_note'])) {
if ($_POST['isLastClosed']) {
// save last closed level
$form_done = 0 + $_POST['form_done'];
Expand All @@ -430,9 +430,9 @@ function updateFields(payField, adjField, balField, coPayField, isFirstProcCode)
}
}

if ($_POST['billing_note']) {
// save last closed level
sqlStatement("UPDATE form_encounter SET billing_note = ? WHERE pid = ? AND encounter = ?", array($_POST['billing_note'], $patient_id, $encounter_id));
if ($_POST['enc_billing_note']) {
// save enc billing note
sqlStatement("UPDATE form_encounter SET billing_note = ? WHERE pid = ? AND encounter = ?", array($_POST['enc_billing_note'], $patient_id, $encounter_id));
}

// will reload page w/o reposting
Expand Down Expand Up @@ -509,8 +509,14 @@ function updateFields(payField, adjField, balField, coPayField, isFirstProcCode)
</div>
<div class="form-row">
<div class="form-group col-lg">
<label class="col-form-label" for="billing_note"><?php echo xlt('Billing Note'); ?>:</label>
<textarea name="billing_note" id="billing_note" class="form-control" cols="5" rows="2"><?php echo text(($pdrow['billing_note'] ?? '')) . "\n" . text(($bnrow['billing_note'] ?? '')); ?></textarea>
<label class="col-form-label" for="pt_billing_note"><?php echo xlt('Patient Billing Note'); ?>:</label>
<textarea name="pt_billing_note" id="pt_billing_note" class="form-control" cols="5" rows="1" readonly><?php echo text($pdrow['billing_note'] ?? ''); ?></textarea>
</div>
</div>
<div class="form-row">
<div class="form-group col-lg">
<label class="col-form-label" for="enc_billing_note"><?php echo xlt('Encounter Billing Note'); ?>:</label>
<textarea name="enc_billing_note" id="enc_billing_note" class="form-control" cols="5" rows="2"><?php echo text($bnrow['billing_note'] ?? ''); ?></textarea>
</div>
</div>
<div class="form-row">
Expand Down
41 changes: 37 additions & 4 deletions interface/billing/sl_eob_process.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function era_callback(&$out)
writeMessageLine($bgcolor, 'infdetail', rtrim($out['warnings']), true);
}

// Simplify some claim attributes for cleaner code.
// Simplify some claim attributes for cleaner code.
$service_date = parse_date(isset($out['dos']) ? $out['dos'] : $out['claim_date']);
$check_date = $paydate ? $paydate : parse_date($out['check_date']);
$production_date = $paydate ? $paydate : parse_date($out['production_date']);
Expand All @@ -359,7 +359,19 @@ function era_callback(&$out)

$error = $inverror;

// This loops once for each service item in this claim.
// create array of cpts and mods for complex matching
$codes_arr_keys = array_keys($codes);
foreach ($codes_arr_keys as $key => $value) {
$tmp = explode(":", $value);
$count = count($tmp) - 1;
$cpt = $tmp[0];
$cpts[] = $cpt;
for ($i = 1; $i <= $count; $i++) {
$mods[$cpt][] = $tmp[$i] ?? null;
}
}

// This loops once for each service item in this claim.
foreach ($out['svc'] as $svc) {
// Treat a modifier in the remit data as part of the procedure key.
// This key will then make its way into SQL-Ledger.
Expand All @@ -369,6 +381,21 @@ function era_callback(&$out)
}

$prev = $codes[$codekey] ?? '';
// However sometimes a secondary insurance (take USAA LIFE for instance)
// sometimes doesn't return the modifier that was on the service item
// processed by the primary payer so try to deal with that
if (!$prev) {
if (!$svc['mod']) {
if (in_array($svc['code'], $cpts)) {
foreach ($cpts as $k => $v) {
if ($v == $codekey) {
$codekey = $cpt . ':' . implode(':', $mods[$v]);
}
}
}
}
$prev = $codes[$codekey] ?? '';
}
$codetype = ''; //will hold code type, if exists

// This reports detail lines already on file for this service item.
Expand All @@ -389,9 +416,15 @@ function era_callback(&$out)
unset($codes[$codekey]);
} else { // If the service item is not in our database...
// This is not an error. If we are not in error mode and not debugging,
// insert the service item into SL. Then display it (in green if it
// insert the service item into billing. Then display it (in green if it
// was inserted, or in red if we are in error mode).
$description = "CPT4:$codekey Added by $inslabel $production_date";
// Check the global to see if this is preferred to be an error.
if ($GLOBALS['add_unmatched_code_from_ins_co_era_to_billing'] ?? '') {
$description = "CPT4:$codekey Added by $inslabel $production_date";
} else {
$error = true;
$description = "CPT4:$codekey returned by $inslabel $production_date";
}
if (!$error && !$debug) {
SLEOB::arPostCharge(
$pid,
Expand Down
2 changes: 1 addition & 1 deletion interface/code_systems/list_staged.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
$supported_file = 1;
}
} elseif ($db == 'CQM_VALUESET') {
if (preg_match("/ep_.*_cms_([0-9]{8}).xml.zip/", $file, $matches)) {
if (preg_match("/e[p,c]_.*_cms_([0-9]{8}).xml.zip/", $file, $matches)) {
$version = "Standard";
$date_release = substr($matches[1], 0, 4) . "-" . substr($matches[1], 4, -2) . "-" . substr($matches[1], 6);
$temp_date = array('date' => $date_release, 'version' => $version, 'path' => $mainPATH . "/" . $matches[0]);
Expand Down
2 changes: 1 addition & 1 deletion interface/main/tabs/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
jsGlobals.enable_group_therapy = <?php echo js_escape($GLOBALS['enable_group_therapy']); ?>;
jsGlobals.languageDirection = jsLanguageDirection;
jsGlobals.date_display_format = <?php echo js_escape($GLOBALS['date_display_format']); ?>;
jsGlobals.timezone = <?php echo js_escape($GLOBALS['gbl_time_zone']); ?>;
jsGlobals.timezone = <?php echo js_escape($GLOBALS['gbl_time_zone'] ?? ''); ?>;
jsGlobals.assetVersion = <?php echo js_escape($GLOBALS['v_js_includes']); ?>;
var WindowTitleAddPatient = <?php echo ($GLOBALS['window_title_add_patient_name'] ? 'true' : 'false' ); ?>;
var WindowTitleBase = <?php echo js_escape($openemr_name); ?>;
Expand Down
12 changes: 10 additions & 2 deletions interface/reports/appointments_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,22 @@ function oldEvt(eventid) {
} else {
$pid_list = array(); // Initialize list of PIDs for Superbill option
$apptdate_list = array(); // same as above for the appt details
$totalAppontments = count($appointments);
$totalAppointments = count($appointments);
$canceledAppointments = 0;

$cntr = 1; // column labels above start at 1
foreach ($appointments as $appointment) {
if (
$appointment['pc_apptstatus'] == "x"
&& empty($chk_with_canceled_appt)
) {
$canceledAppointments++;
continue;
} elseif (
$appointment['pc_apptstatus'] == "x"
&& !empty($chk_with_canceled_appt)
) {
$canceledAppointments++;
}
$cntr++;
array_push($pid_list, $appointment['pid']);
Expand Down Expand Up @@ -572,7 +579,8 @@ function oldEvt(eventid) {

if (empty($_POST['form_csvexport'])) { ?>
<tr>
<td colspan="10" align="left"><?php echo xlt('Total number of appointments'); ?>:&nbsp;<?php echo text($totalAppontments);?></td>
<td colspan="2" align="left"><?php echo xlt('Total number of appointments'); ?>:&nbsp;<?php echo text($totalAppointments);?></td>
<td colspan="2" align="left"><?php echo xlt('Total number of canceled appointments'); ?>:&nbsp;<?php echo text($canceledAppointments);?></td>
</tr>
</tbody>
</table>
Expand Down
7 changes: 7 additions & 0 deletions library/globals.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,13 @@ function gblTimeZones()
xl('Enable swap secondary insurance')
),

'add_unmatched_code_from_ins_co_era_to_billing' => array(
xl('Enable adding unmatched code from insurance company to billing table'),
'bool', // data type
'0', // default
xl('Enable adding unmatched code from insurance company to billing table')
),

),

// E-Sign Tab
Expand Down
32 changes: 18 additions & 14 deletions library/standard_tables_capture.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,13 @@ function valueset_import($type)
sqlStatementNoLog("START TRANSACTION");
if (is_dir($dir) && $handle = opendir($dir)) {
while (false !== ($filename = readdir($handle))) {
// skip the zip file that's in the tmp file dir
if (stripos($filename, ".zip")) {
continue;
}
if (stripos($filename, ".xml")) {
$abs_path = $dir . $filename;
$xml = simplexml_load_file($abs_path, null, null, 'ns0', true);
$xml = simplexml_load_file($abs_path, null, 0, 'ns0', true);
foreach ($xml->DescribedValueSet as $vset) {
$vset_attr = $vset->attributes();
$nqf = $vset->xpath('ns0:Group[@displayName="NQF Number"]/ns0:Keyword');
Expand All @@ -628,13 +632,13 @@ function valueset_import($type)
description = values(description),
valueset_name = values(valueset_name)",
array(
$nqf_code,
$con_attr->code,
$con_attr->codeSystem,
$con_attr->codeSystemName,
$vset_attr->ID,
$con_attr->displayName,
$vset_attr->displayName
(string) $nqf_code,
(string) $con_attr->code,
(string) $con_attr->codeSystem,
(string) $con_attr->codeSystemName,
(string) $vset_attr->ID,
(string) $con_attr->displayName,
(string) $vset_attr->displayName
)
);
sqlStatementNoLog(
Expand All @@ -643,13 +647,13 @@ function valueset_import($type)
description = values(description),
valueset_name = values(valueset_name)",
array(
$nqf_code,
$vset_attr->ID,
$con_attr->codeSystem,
(string) $nqf_code,
(string) $vset_attr->ID,
(string) $con_attr->codeSystem,
'OID',
$vset_attr->ID,
$vset_attr->displayName,
$vset_attr->displayName
(string) $vset_attr->ID,
(string) $vset_attr->displayName,
(string) $vset_attr->displayName
)
);
}
Expand Down
2 changes: 2 additions & 0 deletions sql/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8838,6 +8838,8 @@ INSERT INTO `supported_external_dataloads` (`load_type`, `load_source`, `load_re
('ICD10', 'CMS', '2023-10-01', 'Code Descriptions.zip', '15404ef88e0ffa15474e6d6076aa0a8a');
INSERT INTO `supported_external_dataloads` (`load_type`, `load_source`, `load_release_date`, `load_filename`, `load_checksum`) VALUES
('ICD10', 'CMS', '2023-10-01', 'Zip File 3 2024 ICD-10-PCS Codes File.zip', '30e096ed9971755c4dfc134b938f3c1f');
INSERT INTO `supported_external_dataloads` (`load_type`, `load_source`, `load_release_date`, `load_filename`, `load_checksum`) VALUES
('CQM_VALUESET', 'NIH_VSAC', '2023-05-04', 'ec_only_cms_20230504.xml.zip', 'b77b3c2a88d23de0ec427c1cfc5088ce');
-- --------------------------------------------------------

--
Expand Down
2 changes: 1 addition & 1 deletion src/Billing/ParseERA.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static function parseERA($filename, $cb)
}
$out['loopid'] = '1000A';
$out['payer_name'] = trim($seg[2]);
$out['payer_id'] = trim($seg[4] ?? null); // will be overwritten if in REF*2U below
$out['payer_id'] = trim($seg[4] ?? ''); // will be overwritten if in REF*2U below
} elseif ($segid == 'N3' && $out['loopid'] == '1000A') {
$out['payer_street'] = trim($seg[1]);
// TBD: N302 may exist as an additional address line.
Expand Down
14 changes: 10 additions & 4 deletions src/Services/AppointmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ public function getAppointment($eid)
pce.pc_room,
pce.pc_pid,
pce.pc_hometext,
pce.pc_title,
f1.name as facility_name,
f1_map.uuid as facility_uuid,
f2.name as billing_location_name,
Expand All @@ -288,9 +289,14 @@ public function getAppointment($eid)

public function insert($pid, $data)
{
$startTime = date("H:i:s", strtotime($data['pc_startTime']));
// TODO: Why are we adding strings with numbers? How is this even working
$endTime = $startTime . $data['pc_duration'];
$startUnixTime = strtotime($data['pc_startTime']);
$startTime = date('H:i:s', $startUnixTime);

// DateInterval _needs_ a valid constructor, so set it to 0s then update.
$endTimeInterval = new \DateInterval('PT0S');
$endTimeInterval->s = $data['pc_duration'];

$endTime = (new \DateTime())->setTimestamp($startUnixTime)->add($endTimeInterval);
$uuid = (new UuidRegistry())->createUuid();

$sql = " INSERT INTO openemr_postcalendar_events SET";
Expand Down Expand Up @@ -323,7 +329,7 @@ public function insert($pid, $data)
$data["pc_eventDate"],
$data['pc_apptstatus'],
$startTime,
$endTime,
$endTime->format('H:i:s'),
$data["pc_facility"],
$data["pc_billing_location"],
$data["pc_aid"] ?? null
Expand Down

0 comments on commit 0186814

Please sign in to comment.