Advice on fixing bug in /library/date_functions.php

iankarlwallace wrote on Sunday, May 25, 2014:

In working on the PHPUnit tests I am finding certain sections of code that
either can’t be accessed or weren’t finished, etc.

The latest I found in /library/date_functions.php which includes a case
statement with a case for “Spanish” but I don’t think there is a
lang_languages that matches that. there are “Spanish (Spain)” and “Spanish
(Latin America)” but I am not sure if they use the same date format.
Anyway would seem that the easiest fix for this would be to treat the two
similarly by adding a case (diff off of branch PHPUnit_Testing_Fixes):

diff --git a/library/date_functions.php b/library/date_functions.php
index d3cf690…52ced0a 100755
— a/library/date_functions.php
+++ b/library/date_functions.php
@@ -13,6 +13,7 @@
// 10.07.2007 - dateformat accepts now an argument
// ============================================================

+require_once(DIR.’/translation.inc.php’);

function dateformat ($strtime = ‘’, $with_dow = false) {

@@ -68,7 +69,8 @@ switch ($languageTitle) {
$dt = date (“Y”, $strtime) . " $nom " . date(“d”, $strtime);
if ($with_dow) $dt = “$dow $dt”;
break;

  •   case "Spanish":
    
  • case “Spanish (Spain)”:
  • case “Spanish (Latin American)”:
    $dt = date (“d”, $strtime) . " $nom " . date(“Y”, $strtime);
    if ($with_dow) $dt = “$dow $dt”;
    break;

NOTE: I also added the require_once for translation since the function
uses xl() which from my understanding is coming from the
translation.inc.php file. We could include this in any release -
non-urgent.

cheers
ian


Ian Wallace - Advanced Procedures Fellow - Salud Family Health Center ©
303.681.5732

blankev wrote on Sunday, May 25, 2014:

I haven.t check this, but it could be there are just a few translations made in the language spreadsheet on Google Drive of OpenEMR.

In the past we made the decision that only languages that included a reasonable amount or activity would be included in the main SQL parts.

iankarlwallace wrote on Sunday, May 25, 2014:

Pieter - Thanks for the response. I am checking from the lang_languages table using MySQL and am only seeing the two that I mentioned referring to Spanish in anyway.

Ian

Ian Wallace 303-681-5732

On May 24, 2014, at 11:50 PM, “Pieter W” blankev@users.sf.net wrote:

I haven.t check this, but it could be there are just a few translations made in the language spreadsheet on Google Drive of OpenEMR.

In the past we made the decision that only languages that included a reasonable amount or activity would be included in the main SQL parts.

Advice on fixing bug in /library/date_functions.php

Sent from sourceforge.net because you indicated interest in OpenEMR / Discussion / Developers

To unsubscribe from further messages, please visit SourceForge.net: Log In to SourceForge.net

bradymiller wrote on Friday, May 30, 2014:

Hi Ian,

I agree with this fix(except for minor issues below). The Spanish titles were separated into two separate languages a couple years back (and the code in date_functions.php was not updated). Check your fix into github and then I’ll bring your commit into the main codebase.

For the minor issues:

  1. Also keep the case for “Spanish”, so it works for users that are using a older translation set (when the “Spanish” language existed).
  2. No need to include translation.inc.php since it’s already ubiquitous in OpenEMR codebase since it is included in the interface/globals.php script.

-brady
OpenEMR

iankarlwallace wrote on Sunday, June 01, 2014:

Brady - Thanks for looking at the code. Good idea to leave the old case
for backwards compatibility. Broke out the one file and put the commit on
a separate branch for ya. Here’s the commit information and diff:

commit 7af8b5be08784d653318b94f6e31eb3e66d51846
Author: Ian Wallace iankarlwallace@gmail.com
Date: Sat May 31 21:09:56 2014 -0700

Date functions fixes for case statement to match Spanish, Spanish

(Latin American), or Spanish (Spain).

diff --git a/library/date_functions.php b/library/date_functions.php
index d3cf690…1c0be01 100755
— a/library/date_functions.php
+++ b/library/date_functions.php
@@ -13,7 +13,6 @@
// 10.07.2007 - dateformat accepts now an argument
// ============================================================

function dateformat ($strtime = ‘’, $with_dow = false) {

// without an argument, display current date
@@ -69,6 +68,8 @@ switch ($languageTitle) {
if ($with_dow) $dt = “$dow $dt”;
break;
case “Spanish”:

  • case “Spanish (Spain)”:
  • case “Spanish (Latin American)”:
    $dt = date (“d”, $strtime) . " $nom " . date(“Y”, $strtime);
    if ($with_dow) $dt = “$dow $dt”;
    break;

cheers
ian

On Fri, May 30, 2014 at 12:02 AM, Brady Miller bradymiller@users.sf.net
wrote:

Hi Ian,

I agree with this fix(except for minor issues below). The Spanish titles
were separated into two separate languages a couple years back (and the
code in date_functions.php was not updated). Check your fix into github and
then I’ll bring your commit into the main codebase.

For the minor issues:

  1. Also keep the case for “Spanish”, so it works for users that are using
    a older translation set (when the “Spanish” language existed).
  2. No need to include translation.inc.php since it’s already ubiquitous in
    OpenEMR codebase since it is included in the interface/globals.php script.

-brady
OpenEMR http://www.open-emr.org/

Advice on fixing bug in /library/date_functions.php
https://sourceforge.net/p/openemr/discussion/202506/thread/148c2b27/?limit=25#159f

Sent from sourceforge.net because you indicated interest in
OpenEMR / Discussion / Developers

To unsubscribe from further messages, please visit
SourceForge.net: Log In to SourceForge.net


Ian Wallace - CCRMC DFM Staff Physician - (c) 303.681.5732

bradymiller wrote on Sunday, June 01, 2014:

Hi Ian,

I just committed your code to sourceforge (in future, all you need to do is provide a link to your github commit/branch):
https://github.com/openemr/openemr/commit/fb4e4dbf560c92e2dbd2fbfec6e9205c7c0ea507

Thanks for the contribution!
-brady
OpenEMR

iankarlwallace wrote on Monday, June 02, 2014:

You are welcome. I will split off some separate fixes that I found while
doing some of the phpunit fixes and send in for code review.

cheers
ian

On Sun, Jun 1, 2014 at 3:40 AM, Brady Miller bradymiller@users.sf.net
wrote:

Hi Ian,

I just committed your code to sourceforge (in future, all you need to do
is provide a link to your github commit/branch):

Date functions fixes for case statement to match Spanish, Spanish (La… · openemr/openemr@fb4e4db · GitHub

Thanks for the contribution!
-brady
OpenEMR http://www.open-emr.org/

Advice on fixing bug in /library/date_functions.php
https://sourceforge.net/p/openemr/discussion/202506/thread/148c2b27/?limit=25#7547

Sent from sourceforge.net because you indicated interest in
OpenEMR / Discussion / Developers

To unsubscribe from further messages, please visit
SourceForge.net: Log In to SourceForge.net


Ian Wallace - CCRMC DFM Staff Physician - (c) 303.681.5732

blankev wrote on Monday, June 02, 2014:

Reading you comments on date function, I wonder if you can help me with the following:

In Prescription (for HTML print) I tried to change the Date of Birth from m-d-Y into d-m-Y All other used dates except the date_of_birth were made with the usual hard changes. But the Date of Birth I can not trace to a spot where I can make the changes.

blankev wrote on Monday, June 02, 2014:

I finaly found something:

/library/classes/Prescription.class.php

DOB changes into Date_of_birth

blankev wrote on Wednesday, June 04, 2014:

epsdky,

tnx, that did change the DOB in European style dd-mm-yyyy

library/classes/Patient.class.php

In line 46 (GitHub)…

", DATE_FORMAT(DOB,’%m/%d/%Y’) as date_of_birth ".

(from function populate())

Don know if this have severe repercussions onother parts of openEMR, but will see in the future. Changed it into: %d%m%Y at least in the prescription this is OK.

iankarlwallace wrote on Wednesday, June 04, 2014:

Pieter - Just looking at the code the date formatting is actually happening
in MySQL not the date_functions.php code during the constructor function
for Patients. It’s only used in a couple of files (from a very quick “grep
-R ‘new Patient’” search):

library/freeb/OpenemrBillingServer.class.php: $this->patient = new
Patient($xuser);
library/classes/Prescription.class.php: $this->patient = new
Patient();
library/classes/Prescription.class.php: if (is_numeric($id)) {
$this->patient = new Patient($id); }

If your change is working that’s great. Essentially the date format is
hard coded into the Patient object and anyone who calls get_dob will get
which every format you have set in the populate() method. The
date_functions.php expect you to pass in a Unix timestamp (an integer
specifying the number of seconds since Jan 01 1970 at midnight UTC). You’d
have to do some massaging to get the string converted to a timestamp and
then pass to dateformat. I am not even sure then if it would format the
way you want b/c it would be based on the language_choice.

Hope that doesn’t muddy the waters.
cheers
ian

On Tue, Jun 3, 2014 at 7:24 PM, Pieter W blankev@users.sf.net wrote:

epsdky,

tnx, that did change the DOB in European style dd-mm-yyyy

library/classes/Patient.class.php

In line 46 (GitHub)…

", DATE_FORMAT(DOB,‘%m/%d/%Y’) as date_of_birth ".

(from function populate())

Don know if this have severe repercussions onother parts of openEMR, but
will see in the future. Changed it into: %d%m%Y at least in the
prescription this is OK.

Advice on fixing bug in /library/date_functions.php
https://sourceforge.net/p/openemr/discussion/202506/thread/148c2b27/?limit=25#9d50/0334

Sent from sourceforge.net because you indicated interest in
OpenEMR / Discussion / Developers

To unsubscribe from further messages, please visit
SourceForge.net: Log In to SourceForge.net


Ian Wallace - CCRMC DFM Staff Physician - (c) 303.681.5732

blankev wrote on Wednesday, June 04, 2014:

Want to have four lines of prescriptions on the same A6 printout, still looking for a stable solution. All other lines were changed hardcoded to show on the html print what the Pharmacy and the Insurance company likes to see.

Now I get For for lines of RX:
one RX line OK.
two not OK.
Four RX lines gives a result of one prescription, two prescription lines and again one line.

So somewhere there was a mis programming of this non-programmer (me)

BTW: Some time ago there was an effort to change Dates through Global.php but they must have forgotten the Prescription part.

iankarlwallace wrote on Wednesday, June 04, 2014:

Pieter - I will look again at this tonight. I think I understand what you
are trying to do not 100% sure. Will send more questions and look at code
in question to see if it’s used. Have you checked in your modifications on
a branch in the git repo so that I can pull it and take a look at your
files?

cheers
ian

On Wed, Jun 4, 2014 at 2:40 AM, Pieter W blankev@users.sf.net wrote:

Want to have four lines of prescriptions on the same A6 printout, still
looking for a stable solution. All other lines were changed hardcoded to
show on the html print what the Pharmacy and the Insurance company likes to
see.

Now I get For for lines of RX: one RX line OK. two not OK. Four RX lines
gives a result of one prescription, two prescription lines and again one
line.

So somewhere there was a mis programming of this non-programmer (me)

BTW: Some time ago there was an effort to change Dates through Global.php
but they must have forgotten the Prescription part.

Advice on fixing bug in /library/date_functions.php
https://sourceforge.net/p/openemr/discussion/202506/thread/148c2b27/?limit=25#9d50/0334/e122/8738

Sent from sourceforge.net because you indicated interest in
OpenEMR / Discussion / Developers

To unsubscribe from further messages, please visit
SourceForge.net: Log In to SourceForge.net


Ian Wallace - CCRMC DFM Staff Physician - (c) 303.681.5732

blankev wrote on Wednesday, June 04, 2014:

No, I did no do anything in GitHub. I do make my changes and if it does not work I correct the changes through an earlier version (Same V4.1.2.p5) without the changes. The copy-paste method.

Sounds rather stupid, but I feel myself not a programmer, but just a Trial and error person.

iankarlwallace wrote on Friday, June 06, 2014:

Pieter - Not stupid at all if it gets the job done. I am a physician as
well (programmer in a former job) and realize that at times you just have
to “get things done”. I just find it really hard to keep track of all the
changes that I have made to things and try to keep it central in a
repository so that I don’t loose them when I want to upgrade to the newest
version.

I haven’t been able to find time to look at this yet but it’s still on my
mind … hopefully tomorrow evening.

ian

On Wed, Jun 4, 2014 at 3:48 PM, Pieter W blankev@users.sf.net wrote:

No, I did no do anything in GitHub. I do make my changes and if it does
not work I correct the changes through an earlier version (Same V4.1.2.p5)
without the changes. The copy-paste method.

Sounds rather stupid, but I feel myself not a programmer, but just a Trial
and error person.

Advice on fixing bug in /library/date_functions.php
https://sourceforge.net/p/openemr/discussion/202506/thread/148c2b27/?limit=25#9d50/0334/e122/8738/647d/d7d4

Sent from sourceforge.net because you indicated interest in
OpenEMR / Discussion / Developers

To unsubscribe from further messages, please visit
SourceForge.net: Log In to SourceForge.net


Ian Wallace - CCRMC DFM Staff Physician - (c) 303.681.5732