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) {
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.
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.
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:
Also keep the case for “Spanish”, so it works for users that are using a older translation set (when the “Spanish” language existed).
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 - 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;
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:
Also keep the case for “Spanish”, so it works for users that are using
a older translation set (when the “Spanish” language existed).
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.
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.
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.
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.
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.
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.
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?
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.
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.
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.
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.