Re: [Dhis2-devs] weeks calculation

2009-05-13 Thread Bob Jolliffe
 with Vietnamese and
 Ethiopian dates for example.  (What's a Vietnamese week?)  But its
 straightforward to implement.

 Agreed we should use the Calendar class for all this.  But how
 exactly?  Does anybody else have some experience of dealing with the
 vagaries of exchanging weekly data?  How does DHIS1.4 understand it?
 Do weeks run from Monday to Sunday or Sunday to Saturday?  Or
 Wednesday to Tuesday with the first week in the year being the first
 Wednesday after Easter :-)

 Regards
 Bob

  ---
  Regards,
  Saptarshi PURKAYASTHA
  Director R  D, HISP India
  Health Information Systems Programme
 
  My Tech Blog:  http://sunnytalkstech.blogspot.com
  You Live by CHOICE, Not by CHANCE
 
 
  2009/5/12 Murodullo Latifov murodlati...@yahoo.com
 
  Hi Caveman,
 
 
 
  - Original Message 
  From: Orvalho Joaquim Augusto orvaq...@gmail.com
  To: Bob Jolliffe bobjolli...@gmail.com
  Cc: dhis2-devs dhis2-devs@lists.launchpad.net
  Sent: Tuesday, May 12, 2009 2:08:43 PM
  Subject: Re: [Dhis2-devs] weeks calculation
 
  Well
 
  Yes this a problem for us. Because we expect to use correctly DHIS
  [reporting tools for now] and we need to map exactly the periods from
  the
  actual system to DHIS.
 
  But meanwhile there is a another problem with a lot of empty data on
  that
  system. Mine foucus has been on that and I forgot for a while these
   dateweeks troubles.
 
  Anyway, can you corect the DHIS2 code please to calculate weekdates? If
  it
  is buggy.
 
  Regards
  Caveman
 
  Are current periods in Mozambican database generated by DHIS or they
  are
  also imported from elsewhere?
 
  murod
  ___
  Mailing list: https://launchpad.net/~dhis2-devs
  Post to     : dhis2-devs@lists.launchpad.net
  Unsubscribe : https://launchpad.net/~dhis2-devs
  More help   : https://help.launchpad.net/ListHelp
 
 
 
 
 
  ___
  Mailing list: https://launchpad.net/~dhis2-devs
  Post to     : dhis2-devs@lists.launchpad.net
  Unsubscribe : https://launchpad.net/~dhis2-devs
  More help   : https://help.launchpad.net/ListHelp
 
 
  ___
  Mailing list: https://launchpad.net/~dhis2-devs
  Post to     : dhis2-devs@lists.launchpad.net
  Unsubscribe : https://launchpad.net/~dhis2-devs
  More help   : https://help.launchpad.net/ListHelp
 
 


 ___
 Mailing list: https://launchpad.net/~dhis2-devs
 Post to     : dhis2-devs@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs
 More help   : https://help.launchpad.net/ListHelp



___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-13 Thread Murodullo Latifov

Hi,


It worth looking if java uses DHIS locale or it uses system locale for 
Calendar. I think if java is not set to use any locale, it will turn to OS 
locale, if this is the case two machines running DHIS as server with different 
locales will end up with two different week calculations, if locales have 
different view of weeks.

regards,
murod



  

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-12 Thread Orvalho Joaquim Augusto

Well


Bob Jolliffe wrote:

Hi cave persons

2009/5/11 Murodullo Latifov murodlati...@yahoo.com:


How dhis2 calculate the weeks? The first week of a year for example.

Weekly periods are calculated based on their start date. If start date of the 
given week is on the previous year, end date of that period is used. Also 
Saturday is used as first day of the week.



It seem this business of Saturdays is a red herring and is not true.
Weekly periods are defined by a start date being a Monday and an end
date being a Sunday (though this doesn't seem to be enforced anywhere
- it probably should be).  We can see this in the list of periods
which are calculated in generatePeriods in WeeklyPeriodType.java.  The
list are all all Monday-Sunday periods.

It is however a bit buggy.  What I can confirm from generating loads
of period lists from various starting dates is
1.  DHIS (using the java default) does indeed have an ISO8601
interpretation of week number.  That is the first week of any given
year is a the first week with a Thursday in it.  It is good we stick
with this.  Makes it easy to answer the question how does DHIS2
handle week numbers?.
2.  Perhaps somebody who initially wrote this code seemed not quite to
appreciate how this works, which means, for example, that when we
generate the period list for the week of 29-12-2009 to 03-01-2010 we
end up with a list starting with week 1 of 2010, which doesn't
actually include the given week.  The same thing happens in the end of
2005.

I don't know if this is at the root of Orvalho's problem (I haven't
yet seen his data), but it is clearly important when moving weekly
data from one system to another.  Meanwhile I can fix the
generatePeriods method so that it will always generate the correct
list of periods for any given period.  Before I do so please confirm
that it will not break any existing data, reports or what have you.
The implication being that  generatePeriods called on the week of
29-12-2009 to 03-01-2010 will generate the list of weeks for 2009, not
2010.  And more obviously, the week of 26-12-2005 to 1-01-2006
generates the list of weeks for 2005, not 2006.

Yes this a problem for us. Because we expect to use correctly DHIS 
[reporting tools for now] and we need to map exactly the periods from 
the actual system to DHIS.


But meanwhile there is a another problem with a lot of empty data on 
that system. Mine foucus has been on that and I forgot for a while these 
 dateweeks troubles.


Anyway, can you corect the DHIS2 code please to calculate weekdates? If 
it is buggy.



Cheers
Bob

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Regards
Caveman


___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-12 Thread Murodullo Latifov

Hi Caveman,



- Original Message 
From: Orvalho Joaquim Augusto orvaq...@gmail.com
To: Bob Jolliffe bobjolli...@gmail.com
Cc: dhis2-devs dhis2-devs@lists.launchpad.net
Sent: Tuesday, May 12, 2009 2:08:43 PM
Subject: Re: [Dhis2-devs] weeks calculation

Well

Yes this a problem for us. Because we expect to use correctly DHIS [reporting 
tools for now] and we need to map exactly the periods from the actual system to 
DHIS.

But meanwhile there is a another problem with a lot of empty data on that 
system. Mine foucus has been on that and I forgot for a while these  dateweeks 
troubles.

Anyway, can you corect the DHIS2 code please to calculate weekdates? If it is 
buggy.

Regards
Caveman

Are current periods in Mozambican database generated by DHIS or they are also 
imported from elsewhere? 

murod
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp



  

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-12 Thread Bob Jolliffe
Hi Saptarshi

2009/5/12 Saptarshi Purkayastha sun...@gmail.com:
 Its bad to re-invent the wheel, but I think we just keep doing that all the
 time. The Java API has all these things built-in, but we seem to have our
 own conventions for everything...
 The Calender class does all the good work with enough locale specific
 things...

 http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#getFirstDayOfWeek()

Sorry, but its not quite as simple as that.  The Calendar class lets
you specify important things like the setFirstDayOfWeek and
setMinimalDaysInFirstWeek, but it doesn't decide on those values for
you.  And the WeeklyPeriodType is of course using the Calendar class.
When generating weekly periods for a year it has setFirstDayOfWeek to
Monday.  We don't specify MinimalDaysInFirstWeek so I checked - we get
4 as a default, which is fine.  In other words DHIS2 generates ISO8601
compliant week numbers (using the calendar class) which is excellent.

There are only three problems:
1.  there is a small bug in the generator which I would like to fix

2.  we don't validate when we construct weekly periods.  For example
we construct a weekly period with three parameters - type (weekly),
start date and end date.  When we construct we should ensure that
startdate is a Monday and that enddate is indeed 6 days apart from
startdate.  Otherwise it is possible, through the API, to construct
invalid weekly periods.  This probably shouldn't be. (in fact having
both start and enddate is strictly redundant - but I can see how it is
there in support of generality).

3.  its not clear how to deal with importing weekly data from a system
which does not use ISO8601 week numbering.  This would probably
include a number of VB/Excel/Access type applications.  Either (i) we
must be completely agnostic towards the week numbering scheme and
accept anything with a start and end date 6 days apart as a week (or
even short weeks as per US convention) or (ii) we need to have an
approved process of grafting periods into (and perhaps out of) the
ISO8601 scheme.  The first option is always a good interoperability
principle but I'm not sure we have the algorithms elsewhere, in the
reporting modules for example, to support it.  The second option is a
bit gruff, and I'm not sure how it squares with Vietnamese and
Ethiopian dates for example.  (What's a Vietnamese week?)  But its
straightforward to implement.

Agreed we should use the Calendar class for all this.  But how
exactly?  Does anybody else have some experience of dealing with the
vagaries of exchanging weekly data?  How does DHIS1.4 understand it?
Do weeks run from Monday to Sunday or Sunday to Saturday?  Or
Wednesday to Tuesday with the first week in the year being the first
Wednesday after Easter :-)

Regards
Bob

 ---
 Regards,
 Saptarshi PURKAYASTHA
 Director R  D, HISP India
 Health Information Systems Programme

 My Tech Blog:  http://sunnytalkstech.blogspot.com
 You Live by CHOICE, Not by CHANCE


 2009/5/12 Murodullo Latifov murodlati...@yahoo.com

 Hi Caveman,



 - Original Message 
 From: Orvalho Joaquim Augusto orvaq...@gmail.com
 To: Bob Jolliffe bobjolli...@gmail.com
 Cc: dhis2-devs dhis2-devs@lists.launchpad.net
 Sent: Tuesday, May 12, 2009 2:08:43 PM
 Subject: Re: [Dhis2-devs] weeks calculation

 Well

 Yes this a problem for us. Because we expect to use correctly DHIS
 [reporting tools for now] and we need to map exactly the periods from the
 actual system to DHIS.

 But meanwhile there is a another problem with a lot of empty data on that
 system. Mine foucus has been on that and I forgot for a while these
  dateweeks troubles.

 Anyway, can you corect the DHIS2 code please to calculate weekdates? If it
 is buggy.

 Regards
 Caveman

 Are current periods in Mozambican database generated by DHIS or they are
 also imported from elsewhere?

 murod
 ___
 Mailing list: https://launchpad.net/~dhis2-devs
 Post to     : dhis2-devs@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs
 More help   : https://help.launchpad.net/ListHelp





 ___
 Mailing list: https://launchpad.net/~dhis2-devs
 Post to     : dhis2-devs@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs
 More help   : https://help.launchpad.net/ListHelp


 ___
 Mailing list: https://launchpad.net/~dhis2-devs
 Post to     : dhis2-devs@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs
 More help   : https://help.launchpad.net/ListHelp



___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-12 Thread Saptarshi Purkayastha
2009/5/12 Bob Jolliffe bobjolli...@gmail.com

 Hi Saptarshi

 2009/5/12 Saptarshi Purkayastha sun...@gmail.com:
  Its bad to re-invent the wheel, but I think we just keep doing that all
 the
  time. The Java API has all these things built-in, but we seem to have our
  own conventions for everything...
  The Calender class does all the good work with enough locale specific
  things...
 
 
 http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#getFirstDayOfWeek()http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#getFirstDayOfWeek%28%29

 Sorry, but its not quite as simple as that.  The Calendar class lets
 you specify important things like the setFirstDayOfWeek and
 setMinimalDaysInFirstWeek, but it doesn't decide on those values for
 you.


Thankfully it decided for me based on my current locale.
Calendar.getInstance() gives me the calendar for the locale and the
getFirstDayOfWeek() returned 1 (SUNDAY) as my locale was en_US... I changed
my locale to English (United Kingdom) (en_GB) and it returns 2 (MONDAY). So
it should work fine for system with the same locale and we really shouldn't
decide.

There are also REAL ways of converting between locale Calendars and
Timezones and that should be able to solve any import/export from different
locales. There are also various subclasses of the Calendar class available
online for other than GregorianCalendar.

I would suggest not to make the starting week to something constant. Instead
letting the locale decide I think is the right way forward. As for hacks to
get data from Access/Excel/Flat files... it has to be the way the person
importing has to understand and take care.



  And the WeeklyPeriodType is of course using the Calendar class.
 When generating weekly periods for a year it has setFirstDayOfWeek to
 Monday.  We don't specify MinimalDaysInFirstWeek so I checked - we get
 4 as a default, which is fine.  In other words DHIS2 generates ISO8601
 compliant week numbers (using the calendar class) which is excellent.

 There are only three problems:
 1.  there is a small bug in the generator which I would like to fix

 2.  we don't validate when we construct weekly periods.  For example
 we construct a weekly period with three parameters - type (weekly),
 start date and end date.  When we construct we should ensure that
 startdate is a Monday and that enddate is indeed 6 days apart from
 startdate.  Otherwise it is possible, through the API, to construct
 invalid weekly periods.  This probably shouldn't be. (in fact having
 both start and enddate is strictly redundant - but I can see how it is
 there in support of generality).

 3.  its not clear how to deal with importing weekly data from a system
 which does not use ISO8601 week numbering.  This would probably
 include a number of VB/Excel/Access type applications.  Either (i) we
 must be completely agnostic towards the week numbering scheme and
 accept anything with a start and end date 6 days apart as a week (or
 even short weeks as per US convention) or (ii) we need to have an
 approved process of grafting periods into (and perhaps out of) the
 ISO8601 scheme.  The first option is always a good interoperability
 principle but I'm not sure we have the algorithms elsewhere, in the
 reporting modules for example, to support it.  The second option is a
 bit gruff, and I'm not sure how it squares with Vietnamese and
 Ethiopian dates for example.  (What's a Vietnamese week?)  But its
 straightforward to implement.

 Agreed we should use the Calendar class for all this.  But how
 exactly?  Does anybody else have some experience of dealing with the
 vagaries of exchanging weekly data?  How does DHIS1.4 understand it?
 Do weeks run from Monday to Sunday or Sunday to Saturday?  Or
 Wednesday to Tuesday with the first week in the year being the first
 Wednesday after Easter :-)

 Regards
 Bob

  ---
  Regards,
  Saptarshi PURKAYASTHA
  Director R  D, HISP India
  Health Information Systems Programme
 
  My Tech Blog:  http://sunnytalkstech.blogspot.com
  You Live by CHOICE, Not by CHANCE
 
 
  2009/5/12 Murodullo Latifov murodlati...@yahoo.com
 
  Hi Caveman,
 
 
 
  - Original Message 
  From: Orvalho Joaquim Augusto orvaq...@gmail.com
  To: Bob Jolliffe bobjolli...@gmail.com
  Cc: dhis2-devs dhis2-devs@lists.launchpad.net
  Sent: Tuesday, May 12, 2009 2:08:43 PM
  Subject: Re: [Dhis2-devs] weeks calculation
 
  Well
 
  Yes this a problem for us. Because we expect to use correctly DHIS
  [reporting tools for now] and we need to map exactly the periods from
 the
  actual system to DHIS.
 
  But meanwhile there is a another problem with a lot of empty data on
 that
  system. Mine foucus has been on that and I forgot for a while these
   dateweeks troubles.
 
  Anyway, can you corect the DHIS2 code please to calculate weekdates? If
 it
  is buggy.
 
  Regards
  Caveman
 
  Are current periods in Mozambican database generated by DHIS or they are
  also imported from elsewhere?
 
  murod

Re: [Dhis2-devs] weeks calculation

2009-05-11 Thread Murodullo Latifov

Hi Caveman,



- Original Message 
From: Orvalho Joaquim Augusto orvaq...@gmail.com
To: dhis2-devs dhis2-devs@lists.launchpad.net
Sent: Monday, May 11, 2009 2:57:42 AM
Subject: [Dhis2-devs] weeks calculation

I could not find on dhis2 docs so I am asking:

How dhis2 calculate the weeks? The first week of a year for example.

Weekly periods are calculated based on their start date. If start date of the 
given week is on the previous year, end date of that period is used. Also 
Saturday is used as first day of the week.

Thank you
Caveman



___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp



  

___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-11 Thread Orvalho Joaquim Augusto

Thanks!

That is really usefull.

Caveman


Murodullo Latifov wrote:

Hi Caveman,



- Original Message 
From: Orvalho Joaquim Augusto orvaq...@gmail.com
To: dhis2-devs dhis2-devs@lists.launchpad.net
Sent: Monday, May 11, 2009 2:57:42 AM
Subject: [Dhis2-devs] weeks calculation

I could not find on dhis2 docs so I am asking:

How dhis2 calculate the weeks? The first week of a year for example.

Weekly periods are calculated based on their start date. If start date of the 
given week is on the previous year, end date of that period is used. Also 
Saturday is used as first day of the week.

Thank you
Caveman



___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp



  





___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-11 Thread Bob Jolliffe
Hi

2009/5/11 Murodullo Latifov murodlati...@yahoo.com:

 Hi Caveman,



 - Original Message 
 From: Orvalho Joaquim Augusto orvaq...@gmail.com
 To: dhis2-devs dhis2-devs@lists.launchpad.net
 Sent: Monday, May 11, 2009 2:57:42 AM
 Subject: [Dhis2-devs] weeks calculation

 I could not find on dhis2 docs so I am asking:

 How dhis2 calculate the weeks? The first week of a year for example.

 Weekly periods are calculated based on their start date. If start date of the 
 given week is on the previous year, end date of that period is used. Also
 Saturday is used as first day of the week.

The code is here:
./dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java

I find it a bit confusing.  It seems that we try to define a week as
Saturday to Friday, and then say that as long as the endDate is in a
different year to the startDate then we are in week 1.  So week 1 is
the first week in the year with a Friday in it?  This doesn't sound
right.  Also according to documentation on top of class, a weekly
period must have a startDate on a Monday and endDate on a Sunday.

But week numbers according to ISO8601 are equivalent to the number of
Thursdays - ie. first week in the year with a Thursday is week 1.
This is the way that, for example the javascript in the calendar.js
would calculate it.  And presumably any sql week function we might
use.  Also weeks would start on Monday (which agrees with our class
documentation).

So for the week of 29/12/2008 to 04/01/2009, by our calculation that
would be week 1 of 2009.  And it would be week 1 by ISO 8601.

But for the week of 28/12/2009 to 3/01/2010 which is coming up, our
calculation would have this as week 1 of 2010, whereas ISO8601 would
have it as week 52 or 53 of 2010.  Week 1 would be the week of
04/01/2010.

As I say - its a bit confusing.

Though perhaps in the end the actual week number doesn't matter.  What
might matter most is the convention we consistently adopt and
document.  Though it would be nice if our conception of week 1
coincided with the ISO8601 conception.  But not so nice as to break
all the annual reports ... Do we ever exchange a week number with
another system?  Do we need to be able to define this more flexibly to
accomodate different national reporting requirements which might
interpret the first week of the year differently?  I haven't even
begun to think of this in terms of localised calendar systems :-)

Regards
Bob


 Thank you
 Caveman



 ___
 Mailing list: https://launchpad.net/~dhis2-devs
 Post to     : dhis2-devs@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs
 More help   : https://help.launchpad.net/ListHelp





 ___
 Mailing list: https://launchpad.net/~dhis2-devs
 Post to     : dhis2-devs@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs
 More help   : https://help.launchpad.net/ListHelp


___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-11 Thread Orvalho Joaquim Augusto

Well this comment is interesting.

And the question raises from my needs here. I am moving data from a not 
dhis2 system to dhis2. And we must do it weekly because dhis2 is not yet 
adopted.


I noticed that I had weeks changed on dhis2.

And now to adjust to dhis2 I need to know how dhis2 does. And Bob raises 
this. What I do? I use the algorithm from that java Class?


Caveman

Bob Jolliffe wrote:

Hi

2009/5/11 Murodullo Latifov murodlati...@yahoo.com:

Hi Caveman,



- Original Message 
From: Orvalho Joaquim Augusto orvaq...@gmail.com
To: dhis2-devs dhis2-devs@lists.launchpad.net
Sent: Monday, May 11, 2009 2:57:42 AM
Subject: [Dhis2-devs] weeks calculation

I could not find on dhis2 docs so I am asking:

How dhis2 calculate the weeks? The first week of a year for example.

Weekly periods are calculated based on their start date. If start date of the 
given week is on the previous year, end date of that period is used. Also
Saturday is used as first day of the week.


The code is here:
./dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java

I find it a bit confusing.  It seems that we try to define a week as
Saturday to Friday, and then say that as long as the endDate is in a
different year to the startDate then we are in week 1.  So week 1 is
the first week in the year with a Friday in it?  This doesn't sound
right.  Also according to documentation on top of class, a weekly
period must have a startDate on a Monday and endDate on a Sunday.

But week numbers according to ISO8601 are equivalent to the number of
Thursdays - ie. first week in the year with a Thursday is week 1.
This is the way that, for example the javascript in the calendar.js
would calculate it.  And presumably any sql week function we might
use.  Also weeks would start on Monday (which agrees with our class
documentation).

So for the week of 29/12/2008 to 04/01/2009, by our calculation that
would be week 1 of 2009.  And it would be week 1 by ISO 8601.

But for the week of 28/12/2009 to 3/01/2010 which is coming up, our
calculation would have this as week 1 of 2010, whereas ISO8601 would
have it as week 52 or 53 of 2010.  Week 1 would be the week of
04/01/2010.

As I say - its a bit confusing.

Though perhaps in the end the actual week number doesn't matter.  What
might matter most is the convention we consistently adopt and
document.  Though it would be nice if our conception of week 1
coincided with the ISO8601 conception.  But not so nice as to break
all the annual reports ... Do we ever exchange a week number with
another system?  Do we need to be able to define this more flexibly to
accomodate different national reporting requirements which might
interpret the first week of the year differently?  I haven't even
begun to think of this in terms of localised calendar systems :-)

Regards
Bob


Thank you
Caveman



___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp





___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp






___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-11 Thread Bob Jolliffe
Hi Orvalho

2009/5/11 Orvalho Joaquim Augusto orvaq...@gmail.com:
 Well this comment is interesting.

 And the question raises from my needs here. I am moving data from a not
 dhis2 system to dhis2. And we must do it weekly because dhis2 is not yet
 adopted.

 I noticed that I had weeks changed on dhis2.

Do you have some examples?  i.e. ones which show that week 1 is
indicated as something specific for a particular year which is
different to the DHIS2 way.  Then maybe we can start thinking about
how DHIS2 should best handle.  Is your data coming from Excel?

Regards
Bob

PS. I see mysql makes use of a mode argument
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_week
I guess ISO8601 mode would be mode 3 under this scheme.

PPS.  Excel does not have a weeknum function built in.  There is an
analysis toolpack plugin which implements something non-standard -
somteimes described as the US norm - the first week (like other weeks)
ends on Sunday.  It can be any number of days long from 1 to 7.

PPPS.  David Wheeler has done some excellent work on the OpenFormula
SubCommittee of the ODF OASIS TC on figuring out the differences
between all these.  It looks like ODF will eventually adopt two
functions WEEKNUM (which implements the incorrect Excel algorithm) and
ISO_WEEKNUM which implements the correct algorithm.



 And now to adjust to dhis2 I need to know how dhis2 does. And Bob raises
 this. What I do? I use the algorithm from that java Class?

 Caveman

 Bob Jolliffe wrote:

 Hi

 2009/5/11 Murodullo Latifov murodlati...@yahoo.com:

 Hi Caveman,



 - Original Message 
 From: Orvalho Joaquim Augusto orvaq...@gmail.com
 To: dhis2-devs dhis2-devs@lists.launchpad.net
 Sent: Monday, May 11, 2009 2:57:42 AM
 Subject: [Dhis2-devs] weeks calculation

 I could not find on dhis2 docs so I am asking:

 How dhis2 calculate the weeks? The first week of a year for example.

 Weekly periods are calculated based on their start date. If start date of
 the given week is on the previous year, end date of that period is used.
 Also
 Saturday is used as first day of the week.

 The code is here:
 ./dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java

 I find it a bit confusing.  It seems that we try to define a week as
 Saturday to Friday, and then say that as long as the endDate is in a
 different year to the startDate then we are in week 1.  So week 1 is
 the first week in the year with a Friday in it?  This doesn't sound
 right.  Also according to documentation on top of class, a weekly
 period must have a startDate on a Monday and endDate on a Sunday.

 But week numbers according to ISO8601 are equivalent to the number of
 Thursdays - ie. first week in the year with a Thursday is week 1.
 This is the way that, for example the javascript in the calendar.js
 would calculate it.  And presumably any sql week function we might
 use.  Also weeks would start on Monday (which agrees with our class
 documentation).

 So for the week of 29/12/2008 to 04/01/2009, by our calculation that
 would be week 1 of 2009.  And it would be week 1 by ISO 8601.

 But for the week of 28/12/2009 to 3/01/2010 which is coming up, our
 calculation would have this as week 1 of 2010, whereas ISO8601 would
 have it as week 52 or 53 of 2010.  Week 1 would be the week of
 04/01/2010.

 As I say - its a bit confusing.

 Though perhaps in the end the actual week number doesn't matter.  What
 might matter most is the convention we consistently adopt and
 document.  Though it would be nice if our conception of week 1
 coincided with the ISO8601 conception.  But not so nice as to break
 all the annual reports ... Do we ever exchange a week number with
 another system?  Do we need to be able to define this more flexibly to
 accomodate different national reporting requirements which might
 interpret the first week of the year differently?  I haven't even
 begun to think of this in terms of localised calendar systems :-)

 Regards
 Bob

 Thank you
 Caveman



 ___
 Mailing list: https://launchpad.net/~dhis2-devs
 Post to     : dhis2-devs@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs
 More help   : https://help.launchpad.net/ListHelp





 ___
 Mailing list: https://launchpad.net/~dhis2-devs
 Post to     : dhis2-devs@lists.launchpad.net
 Unsubscribe : https://launchpad.net/~dhis2-devs
 More help   : https://help.launchpad.net/ListHelp





___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] weeks calculation

2009-05-11 Thread Orvalho Joaquim Augusto

Thank for this helpfull ofert.

I talk within your words.

Bob Jolliffe wrote:

Hi Orvalho

2009/5/11 Orvalho Joaquim Augusto orvaq...@gmail.com:

Well this comment is interesting.

And the question raises from my needs here. I am moving data from a not
dhis2 system to dhis2. And we must do it weekly because dhis2 is not yet
adopted.

I noticed that I had weeks changed on dhis2.


Do you have some examples?  i.e. ones which show that week 1 is
indicated as something specific for a particular year which is
different to the DHIS2 way.  Then maybe we can start thinking about
how DHIS2 should best handle.  Is your data coming from Excel?



It is not Excel.

Some physiology of what we have:
The System being used now is called Modulo Basico (modbas for now on). 
That system is in MsAccess. It stores data for each form in one table. 
The table contains for record identification these fields (all in 
strings): year (YR), week (MTH, it is no mistake), district code (DC), 
province code (PC) and health center (HC).


The data comens on diferent columns identified by A1, A2 up to An 
(depending on the form).


As this is what Ministry of Health uses and dhis2 is being prepared to 
be used in large scale we feed dhis2 using some rudimentar steps:

1. There is a scheduled program per day to convert the tables in MDB
 in modbas to mysql (db2sync instead of mysql migration tool because 
db2syn exports well the keys)
2. Under the mysql server machine there is a python script that take 
data feeds dhis2 tables.


Step 2 uses periodid generated by dhis2 using the ranges.

For the months this is fine. But for weeks we need to know which week is 
based on the ranges given by periodid.


Is this clear enough?

And do you need really data to check?


Regards
Bob

PS. I see mysql makes use of a mode argument
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_week
I guess ISO8601 mode would be mode 3 under this scheme.

Thanks.

But on dhis2 it seems different isn't that?

Regards
Caveman



PPS.  Excel does not have a weeknum function built in.  There is an
analysis toolpack plugin which implements something non-standard -
somteimes described as the US norm - the first week (like other weeks)
ends on Sunday.  It can be any number of days long from 1 to 7.

PPPS.  David Wheeler has done some excellent work on the OpenFormula
SubCommittee of the ODF OASIS TC on figuring out the differences
between all these.  It looks like ODF will eventually adopt two
functions WEEKNUM (which implements the incorrect Excel algorithm) and
ISO_WEEKNUM which implements the correct algorithm.




And now to adjust to dhis2 I need to know how dhis2 does. And Bob raises
this. What I do? I use the algorithm from that java Class?

Caveman

Bob Jolliffe wrote:

Hi

2009/5/11 Murodullo Latifov murodlati...@yahoo.com:

Hi Caveman,



- Original Message 
From: Orvalho Joaquim Augusto orvaq...@gmail.com
To: dhis2-devs dhis2-devs@lists.launchpad.net
Sent: Monday, May 11, 2009 2:57:42 AM
Subject: [Dhis2-devs] weeks calculation

I could not find on dhis2 docs so I am asking:

How dhis2 calculate the weeks? The first week of a year for example.

Weekly periods are calculated based on their start date. If start date of
the given week is on the previous year, end date of that period is used.
Also
Saturday is used as first day of the week.

The code is here:
./dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java

I find it a bit confusing.  It seems that we try to define a week as
Saturday to Friday, and then say that as long as the endDate is in a
different year to the startDate then we are in week 1.  So week 1 is
the first week in the year with a Friday in it?  This doesn't sound
right.  Also according to documentation on top of class, a weekly
period must have a startDate on a Monday and endDate on a Sunday.

But week numbers according to ISO8601 are equivalent to the number of
Thursdays - ie. first week in the year with a Thursday is week 1.
This is the way that, for example the javascript in the calendar.js
would calculate it.  And presumably any sql week function we might
use.  Also weeks would start on Monday (which agrees with our class
documentation).

So for the week of 29/12/2008 to 04/01/2009, by our calculation that
would be week 1 of 2009.  And it would be week 1 by ISO 8601.

But for the week of 28/12/2009 to 3/01/2010 which is coming up, our
calculation would have this as week 1 of 2010, whereas ISO8601 would
have it as week 52 or 53 of 2010.  Week 1 would be the week of
04/01/2010.

As I say - its a bit confusing.

Though perhaps in the end the actual week number doesn't matter.  What
might matter most is the convention we consistently adopt and
document.  Though it would be nice if our conception of week 1
coincided with the ISO8601 conception.  But not so nice as to break
all the annual reports ... Do we ever exchange a week number with
another system?  Do we need to be able to define this more 

Re: [Dhis2-devs] weeks calculation

2009-05-11 Thread Orvalho Joaquim Augusto

Ahh.. :-)

Thanks
Caveman


Bob Jolliffe wrote:

2009/5/11 Orvalho Joaquim Augusto orvaq...@gmail.com:

Thank for this helpfull ofert.

I talk within your words.

Bob Jolliffe wrote:

Hi Orvalho

2009/5/11 Orvalho Joaquim Augusto orvaq...@gmail.com:

Well this comment is interesting.

And the question raises from my needs here. I am moving data from a not
dhis2 system to dhis2. And we must do it weekly because dhis2 is not yet
adopted.

I noticed that I had weeks changed on dhis2.

Do you have some examples?  i.e. ones which show that week 1 is
indicated as something specific for a particular year which is
different to the DHIS2 way.  Then maybe we can start thinking about
how DHIS2 should best handle.  Is your data coming from Excel?


It is not Excel.

Some physiology of what we have:
The System being used now is called Modulo Basico (modbas for now on). That
system is in MsAccess. It stores data for each form in one table. The table
contains for record identification these fields (all in strings): year (YR),
week (MTH, it is no mistake), district code (DC), province code (PC) and
health center (HC).

The data comens on diferent columns identified by A1, A2 up to An (depending
on the form).

As this is what Ministry of Health uses and dhis2 is being prepared to be
used in large scale we feed dhis2 using some rudimentar steps:
1. There is a scheduled program per day to convert the tables in MDB
 in modbas to mysql (db2sync instead of mysql migration tool because db2syn
exports well the keys)
2. Under the mysql server machine there is a python script that take data
feeds dhis2 tables.

Step 2 uses periodid generated by dhis2 using the ranges.

For the months this is fine. But for weeks we need to know which week is
based on the ranges given by periodid.

Is this clear enough?

And do you need really data to check?


No I don't need lots of data.  Just something like year 2005 (weeks
are ok), 2006 (dhis is one week ahead), 2007 (weeks are ok)  I am
just trying to figure out the problem and what weeknumber system your
system (and DHIS2) is using.  Empirically like this is the easiest.

Cheers
Bob



Regards
Bob

PS. I see mysql makes use of a mode argument

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_week
I guess ISO8601 mode would be mode 3 under this scheme.

Thanks.

But on dhis2 it seems different isn't that?

Regards
Caveman



PPS.  Excel does not have a weeknum function built in.  There is an
analysis toolpack plugin which implements something non-standard -
somteimes described as the US norm - the first week (like other weeks)
ends on Sunday.  It can be any number of days long from 1 to 7.

PPPS.  David Wheeler has done some excellent work on the OpenFormula
SubCommittee of the ODF OASIS TC on figuring out the differences
between all these.  It looks like ODF will eventually adopt two
functions WEEKNUM (which implements the incorrect Excel algorithm) and
ISO_WEEKNUM which implements the correct algorithm.




And now to adjust to dhis2 I need to know how dhis2 does. And Bob raises
this. What I do? I use the algorithm from that java Class?

Caveman

Bob Jolliffe wrote:

Hi

2009/5/11 Murodullo Latifov murodlati...@yahoo.com:

Hi Caveman,



- Original Message 
From: Orvalho Joaquim Augusto orvaq...@gmail.com
To: dhis2-devs dhis2-devs@lists.launchpad.net
Sent: Monday, May 11, 2009 2:57:42 AM
Subject: [Dhis2-devs] weeks calculation

I could not find on dhis2 docs so I am asking:

How dhis2 calculate the weeks? The first week of a year for example.

Weekly periods are calculated based on their start date. If start date
of
the given week is on the previous year, end date of that period is
used.
Also
Saturday is used as first day of the week.

The code is here:
./dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java

I find it a bit confusing.  It seems that we try to define a week as
Saturday to Friday, and then say that as long as the endDate is in a
different year to the startDate then we are in week 1.  So week 1 is
the first week in the year with a Friday in it?  This doesn't sound
right.  Also according to documentation on top of class, a weekly
period must have a startDate on a Monday and endDate on a Sunday.

But week numbers according to ISO8601 are equivalent to the number of
Thursdays - ie. first week in the year with a Thursday is week 1.
This is the way that, for example the javascript in the calendar.js
would calculate it.  And presumably any sql week function we might
use.  Also weeks would start on Monday (which agrees with our class
documentation).

So for the week of 29/12/2008 to 04/01/2009, by our calculation that
would be week 1 of 2009.  And it would be week 1 by ISO 8601.

But for the week of 28/12/2009 to 3/01/2010 which is coming up, our
calculation would have this as week 1 of 2010, whereas ISO8601 would
have it as week 52 or 53 of 2010.  Week 1 would be the week of
04/01/2010.

As I say - its a bit confusing.

Though