Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use getTimeFormat for encounter date of service datetime picker #7203

Merged
merged 19 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions interface/forms/note/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$(function () {
$('.datepicker').datetimepicker({
<?php $datetimepicker_timepicker = true; ?>
<?php $datetimepicker_showseconds = true; ?>
<?php $datetimepicker_showseconds = false; ?>
<?php $datetimepicker_formatInput = true; ?>
<?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
<?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
Expand Down Expand Up @@ -83,9 +83,9 @@

<td>
<span class="text"><?php echo xlt('Date'); ?></span>
<input class="datepicker form-control" type='text' size='10' class='datepicker' name='date_of_signature' id='date_of_signature'
value='<?php echo attr(date('Y-m-d', time())); ?>'
title='<?php echo xla('yyyy-mm-dd'); ?>' />
<input class="datepicker form-control" type='text' size='16' class='datepicker' name='date_of_signature' id='date_of_signature'
value='<?php echo attr(oeFormatDateTime(date('Y-m-d H:i', time()), $GLOBALS['time_display_format'])); ?>'
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note if follow oeFormatDateTime to oeFormatTime, no need to set the 2nd parameter (if defaults to 'global' which then uses $GLOBALS['time_display_format'])

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that when formatInput is used the entry needs to be standardized at some point before going into the daatabase (via the DateTimeToYYYYMMDDHHMMSS() function ).
This form also has a discrepancy in it's view.php for this date widget.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So 2 things happen for internat to work on the datetimes.

  1. A standard datetime is converted to the localize format via oeFormatDateTime in the datepicker
  2. When saved or used in scripts it is converted back to the standard datetime via the DateTimeToYYYYMMDDHHMMSS function

(rec checking out DateTimeToYYYYMMDDHHMMSS use in code to get an idea how it works)

title='<?php echo xla('Date of Signature'); ?>' />
</td>
</tr>
</table>
Expand Down
6 changes: 3 additions & 3 deletions interface/reports/amc_full_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ function formatPatientReportData($report_id, &$data, $type_report, $amc_report_t
$failed_items = $row['pass_filter'] - $row['pass_target'] - $row['excluded'];
}
$row['display_field_sub'] = ($displayFieldSubHeader != "") ? "($displayFieldSubHeader)" : null;
} else if (isset($row['is_sub'])) {
} elseif (isset($row['is_sub'])) {
$row['display_field'] = generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action_category'), $row['action_category'])
. ': ' . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action'), $row['action_item']);
// Excluded is not part of denominator in standard rules so do not use in calculation
$failed_items = $main_pass_filter - $row['pass_target'];
} else if (isset($row['is_plan'])) {
} elseif (isset($row['is_plan'])) {
$row['display_field'] = generate_display_field(array('data_type' => '1', 'list_id' => 'clinical_plans'), $row['id']);
}

Expand Down Expand Up @@ -201,7 +201,7 @@ function getRuleObjectForId($ruleId)
$subTitle = '';
if ($report_view['provider'] == "group_calculation") {
$subTitle = xl("Group Calculation Method");
} else if (is_numeric($report_view['provider'])) {
} elseif (is_numeric($report_view['provider'])) {
// grab the provider
$userService = new \OpenEMR\Services\UserService();
$provider = $userService->getUser($report_view['provider']);
Expand Down
4 changes: 2 additions & 2 deletions interface/reports/amc_tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function provide_sum_pat(patient_id,encounter_id) {
<?php echo xlt('Begin Date'); ?>:
</td>
<td>
<input type='text' name='form_begin_date' id="form_begin_date" size='20' value='<?php echo attr(oeFormatDateTime($begin_date, 0, true)); ?>' class='datepicker form-control' />
<input type='text' name='form_begin_date' id="form_begin_date" size='20' value='<?php echo attr(oeFormatDateTime($begin_date, $GLOBALS['time_display_format'], true)); ?>' class='datepicker form-control' />
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in cases where you need to use the 2nd parameter (since need to set the second parameter to true, would just use the '"global" string instead of the actual global)

</td>
</tr>

Expand All @@ -211,7 +211,7 @@ function provide_sum_pat(patient_id,encounter_id) {
<?php echo xlt('End Date'); ?>:
</td>
<td>
<input type='text' name='form_end_date' id="form_end_date" size='20' value='<?php echo attr(oeFormatDateTime($end_date, 0, true)); ?>' class='datepicker form-control' />
<input type='text' name='form_end_date' id="form_end_date" size='20' value='<?php echo attr(oeFormatDateTime($end_date, $GLOBALS['time_display_format'], true)); ?>' class='datepicker form-control' />
</td>
</tr>

Expand Down
4 changes: 2 additions & 2 deletions interface/reports/audit_log_tamper_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ function setpatient(pid, lname, fname, dob) {
<tr><td>
<span class="text"><?php echo xlt('Start Date'); ?>: </span>
</td><td>
<input type="text" size="18" class="datetimepicker" name="start_date" id="start_date" value="<?php echo attr(oeFormatDateTime($start_date, 0, true)); ?>" title="<?php echo xla('Start date'); ?>" />
<input type="text" size="18" class="datetimepicker" name="start_date" id="start_date" value="<?php echo attr(oeFormatDateTime($start_date, $GLOBALS['time_display_format'], true)); ?>" title="<?php echo xla('Start date'); ?>" />
</td>
<td>
<span class="text"><?php echo xlt('End Date'); ?>: </span>
</td><td>
<input type="text" size="18" class="datetimepicker" name="end_date" id="end_date" value="<?php echo attr(oeFormatDateTime($end_date, 0, true)); ?>" title="<?php echo xla('End date'); ?>" />
<input type="text" size="18" class="datetimepicker" name="end_date" id="end_date" value="<?php echo attr(oeFormatDateTime($end_date, $GLOBALS['time_display_format'], true)); ?>" title="<?php echo xla('End date'); ?>" />
</td>

<td>
Expand Down
4 changes: 2 additions & 2 deletions interface/reports/cdr_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<?php echo xlt('Begin Date'); ?>:
</td>
<td>
<input type='text' name='form_begin_date' id='form_begin_date' size='20' value='<?php echo attr(oeFormatDateTime($form_begin_date, 0, true)); ?>'
<input type='text' name='form_begin_date' id='form_begin_date' size='20' value='<?php echo attr(oeFormatDateTime($form_begin_date, $GLOBALS['time_display_format'], true)); ?>'
class='datepicker form-control'>
</td>
</tr>
Expand All @@ -115,7 +115,7 @@ class='datepicker form-control'>
<?php echo xlt('End Date'); ?>:
</td>
<td>
<input type='text' name='form_end_date' id='form_end_date' size='20' value='<?php echo attr(oeFormatDateTime($form_end_date, 0, true)); ?>'
<input type='text' name='form_end_date' id='form_end_date' size='20' value='<?php echo attr(oeFormatDateTime($form_end_date, $GLOBALS['time_display_format'], true)); ?>'
class='datepicker form-control'>
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions interface/reports/clinical_reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ function submitForm() {
<td class='col-form-label' width="100"><?php echo xlt('Facility'); ?>: </td>
<td width="250"> <?php dropdown_facility($facility, 'facility', false); ?> </td>
<td class='col-form-label' width="100"><?php echo xlt('From'); ?>: </td>
<td><input type='text' class='datetimepicker form-control' name='date_from' id="date_from" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_from, 0, true)); ?>'></td>
<td><input type='text' class='datetimepicker form-control' name='date_from' id="date_from" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_from, $GLOBALS['time_display_format'], true)); ?>'></td>
</tr>
<tr>
<td class='col-form-label'><?php echo xlt('Patient ID'); ?>:</td>
<td><input name='patient_id' class="numeric_only form-control" type='text' id="patient_id" title='<?php echo xla('Optional numeric patient ID'); ?>' value='<?php echo attr($patient_id); ?>' size='10' maxlength='20' /></td>
<td class='col-form-label'><?php echo xlt('To{{Range}}'); ?>: </td>
<td><input type='text' class='datetimepicker form-control' name='date_to' id="date_to" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_to, 0, true)); ?>'></td>
<td><input type='text' class='datetimepicker form-control' name='date_to' id="date_to" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_to, $GLOBALS['time_display_format'], true)); ?>'></td>
</tr>
<tr>
<td class='col-form-label'><?php echo xlt('Age Range'); ?>:</td>
Expand Down
12 changes: 6 additions & 6 deletions interface/reports/cqm.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@
$show_help = false;
if ($type_report == "standard") {
$heading_title = xl('Standard Measures');
} else if ($type_report == "cqm") {
} elseif ($type_report == "cqm") {
$heading_title = xl('Clinical Quality Measures (CQM)');
} else if ($type_report == 'cqm_2011') {
} elseif ($type_report == 'cqm_2011') {
$heading_title = 'Clinical Quality Measures (CQM) - 2011';
} else if ($type_report == "cqm_2014") {
} elseif ($type_report == "cqm_2014") {
$heading_title = 'Clinical Quality Measures (CQM) - 2014';
} else if ($is_amc_report) {
} elseif ($is_amc_report) {
$heading_title = $amc_report_types[$type_report]['title'];
$show_help = true;
$help_file_name = "cqm_amc_help.php";
Expand Down Expand Up @@ -179,7 +179,7 @@
,['value' => 'cqm_2011', 'selected' => $plan_filter == 'cqm_2011', 'label' => xl('2011 Official Clinical Quality Measures (CQM) Measure Groups')]
,['value' => 'cqm_2014', 'selected' => $plan_filter == 'cqm_2014', 'label' => xl('2014 Official Clinical Quality Measures (CQM) Measure Groups')]
];
} else if ($is_amc_report) {
} elseif ($is_amc_report) {
// latest AMC doesn't have collate options
if (empty($report_id)) {
// truncate to just the first option
Expand All @@ -205,7 +205,7 @@
}
$formData['providerReportOptions'][] = ['value' => 'group_calculation', 'selected' => $provider == 'group_calculation'
, 'label' => xl('All EP/EC Group Calculation')];
} else if ($type_report == 'standard') {
} elseif ($type_report == 'standard') {
$formData['rule_filters'] = [
['value' => 'passive_alert', 'selected' => $type_report == 'passive_alert', 'label' => xl('Passive Alert Rules')]
,['value' => 'active_alert', 'selected' => $type_report == 'active_alert', 'label' => xl('Active Alert Rules')]
Expand Down
6 changes: 3 additions & 3 deletions interface/reports/inventory_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function write_report_line(&$row)
"s.sale_date > DATE_SUB(NOW(), INTERVAL " . escape_limit($form_days) . " DAY) " .
"AND s.pid != 0 $fwcond";
$srow = sqlQuery($query, array_merge(array($drug_id, $facility_id), $fwbind));
} else if ($form_details == 2) { // warehouse details
} elseif ($form_details == 2) { // warehouse details
$query = "SELECT " .
"SUM(s.quantity) AS sale_quantity " .
"FROM drug_sales AS s " .
Expand Down Expand Up @@ -428,7 +428,7 @@ function write_report_line(&$row)
$expdays = (int) ((strtotime($irow['expiration']) - time()) / (60 * 60 * 24));
if ($expdays <= 0) {
addWarning(xl('Lot') . " '$lotno' " . xl('has expired'));
} else if ($expdays <= $gbl_expired_lot_warning_days) {
} elseif ($expdays <= $gbl_expired_lot_warning_days) {
addWarning(xl('Lot') . " '$lotno' " . xl('expires in') . " $expdays " . xl('days'));
}
}
Expand Down Expand Up @@ -621,7 +621,7 @@ function write_report_line(&$row)
"pw.pw_warehouse = di.warehouse_id " .
"WHERE 1 = 1 $fwcond $actcond " .
"GROUP BY d.name, d.drug_id, lo.option_value ORDER BY $orderby, lo.option_value";
} else if ($form_details == 2) {
} elseif ($form_details == 2) {
// Query for the main loop if warehouse/lot details are wanted.
$query = "SELECT d.*, di.on_hand, di.inventory_id, di.lot_number, " .
"di.expiration, di.warehouse_id, lo.title, fac.name AS facname, " .
Expand Down
4 changes: 2 additions & 2 deletions interface/reports/patient_list_creation.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ function srch_option_change(elem) {
<table class='text'>
<tr>
<td class='col-form-label'><?php echo xlt('From'); ?>: </td>
<td><input type='text' class='datetimepicker form-control' name='date_from' id="date_from" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_from, 0, true)); ?>'>
<td><input type='text' class='datetimepicker form-control' name='date_from' id="date_from" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_from, $GLOBALS['time_display_format'], true)); ?>'>
</td>
<td class='col-form-label'><?php echo xlt('To{{range}}'); ?>: </td>
<td><input type='text' class='datetimepicker form-control' name='date_to' id="date_to" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_to, 0, true)); ?>'>
<td><input type='text' class='datetimepicker form-control' name='date_to' id="date_to" size='18' value='<?php echo attr(oeFormatDateTime($sql_date_to, $GLOBALS['time_display_format'], true)); ?>'>
</td>
<td class='col-form-label'><?php echo xlt('Option'); ?>: </td>
<td class='col-form-label'>
Expand Down
4 changes: 2 additions & 2 deletions interface/reports/report_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<?php echo xlt('Begin Date'); ?>:
</td>
<td>
<input type='text' name='form_begin_date' id='form_begin_date' size='20' value='<?php echo attr(oeFormatDateTime($form_begin_date, 0, true)); ?>'
<input type='text' name='form_begin_date' id='form_begin_date' size='20' value='<?php echo attr(oeFormatDateTime($form_begin_date, $GLOBALS['time_display_format'], true)); ?>'
class='datepicker form-control' />
</td>
</tr>
Expand All @@ -118,7 +118,7 @@ class='datepicker form-control' />
<?php echo xlt('End Date'); ?>:
</td>
<td>
<input type='text' name='form_end_date' id='form_end_date' size='20' value='<?php echo attr(oeFormatDateTime($form_end_date, 0, true)); ?>'
<input type='text' name='form_end_date' id='form_end_date' size='20' value='<?php echo attr(oeFormatDateTime($form_end_date, $GLOBALS['time_display_format'], true)); ?>'
class='datepicker form-control' />
</td>
</tr>
Expand Down
19 changes: 13 additions & 6 deletions library/js/xl/jquery-datetimepicker-2-5-4.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will need to ensure the new library/js/xl/jquery-datetimepicker-2-5-4-translated.js has same logic for the fixed time stuff

*/

use OpenEMR\Services\Utils\DateFormatterUtils;

?>
i18n:{
en: {
Expand Down Expand Up @@ -85,22 +87,27 @@
<?php } ?>
<?php if ($datetimepicker_timepicker) { ?>
<?php if ($datetimepicker_showseconds) { ?>
<?php if ($datetimepicker_formatInput) { ?>
format: '<?php echo DateFormatRead("jquery-datetimepicker"); ?> H:i:s',
<?php if ($datetimepicker_formatInput) {
$time_format_with_secs = DateFormatterUtils::getTimeFormat(true); ?>
format: '<?php echo DateFormatRead("jquery-datetimepicker") . " " . $time_format_with_secs; ?>',
formatTime: '<?php echo $time_format_with_secs; ?>',
validateOnBlur: false,
<?php } else { ?>
format: 'Y-m-d H:i:s',
formatTime: 'H:i:s',
<?php } ?>
<?php } else { ?>
<?php if ($datetimepicker_formatInput) { ?>
format: '<?php echo DateFormatRead("jquery-datetimepicker"); ?> g:i a',
formatTime:'g:i a',
<?php if ($datetimepicker_formatInput) {
$time_format_without_secs = DateFormatterUtils::getTimeFormat(); ?>
format: '<?php echo DateFormatRead("jquery-datetimepicker") . " " . $time_format_without_secs; ?>',
formatTime: '<?php echo $time_format_without_secs; ?>',
validateOnBlur: false,
<?php } else { ?>
format: 'Y-m-d H:i',
<?php } ?>
<?php } ?>
timepicker:true,
step: '30'
step: 30
<?php } else { ?>
<?php if ($datetimepicker_formatInput) { ?>
format: '<?php echo DateFormatRead("jquery-datetimepicker"); ?>',
Expand Down