← Back to team overview

dhis2-devs-core team mailing list archive

Period conversion for ADX

 

Hi

I am just looking at the task of implementing adx data import and the
first small thing to tackle is parsing period types.  You can see from
the sample here
(https://github.com/dhis2/adx/blob/master/IHE/samples/adx_data_sample1.xml)
that the string form of a period in adx is of the form:

2010-01-01/P1M

which is equivalent to the month of January 2010 (or 201001 in our
current representation).  More generally you can say this is

<start date>/<duration>

So the parser code should first look at the part of the string
beginning with P and determine the period duration from that.  Some
examples:

P1M - monthly
P7D - weekly
P1Y - yearly
P6M - six monthly
P1Q - quarterly
P2Y - 2 yearly
etc

(Though note P1Y could also indicate a financial period type.  eg
2010-04-01/P1Y would correspond to our April Financial year)

I don't intend to build a generic iso8601 parser which can recognize
any permutation of allowable periods.  Just the subset which
corresponds to what we have.   I'm trying to figure out the best place
to put this parser - toss up between Period, PeriodType and
PeriodService (all have related code).  Does anyone see an obvious
preference?


Follow ups