← Back to team overview

dhis2-users team mailing list archive

Re: [Dhis2-devs] Generating sequential numbers in program rule

 

Hi Terence,
There could be many reasons for that.
Have you tried implementing what Nick suggested? The only limitation is
that the TextPattern option is only available for TEAttribute and not to
DataElement.


Zubair Asghar
DHIS-2 Developer
University of Oslo
zubair@xxxxxxxxx <lars@xxxxxxxxx>
https://www.dhis2.org


On Wed, Oct 10, 2018 at 2:48 PM Terence Scott <
terence.scott@xxxxxxxxxxxxxxxxxx> wrote:

> Dear Zubair
>
> Thank you for your rapid response. I have attempted to do this without
> success. I think I am misunderstanding.
>
> 1) I created the program variable "auto-increment' as suggested
> 2) In this step - is this a new program rule? I created a program rule as
> follows: "d2:hasValue #UID", Assign "#auto-increment + 1" to field
> "auto-increment". I then set this as priority 2.
> 3) I created my UID program rule as with the following action:
> "d2:concatenate( V{enrollment_date}, '-', A{Closest Health Center},
> #{auto-increment})" assigned to the attribute for UID. This is set as
> priority 1.
>
> Unfortunately, this does not create the sequential number, but the
> concatenated sequence is showing in the UID Attribute.
>
> Do I have my priorities incorrect or have I done something else
> incorrectly?
>
> Kind regards,
> Terence
>
> Terence Scott
>
> Global Alliance for Rabies Control (GARC)
> Pan-African Rabies Control Network (PARACON) Steering Committee
> terence.scott@xxxxxxxxxxxxxxxxxx
> https://paracon.rabiesalliance.org
> Skype: tpscott1987
>
>
>
> On Wed, Oct 10, 2018 at 2:01 PM Zubair Asghar Raja <zubair@xxxxxxxxx>
> wrote:
>
>> Hi Terence,
>> Should be possible using CALCULATED_VALUE.
>> Program rule variable having source type as CALCULATED_VALUE will get its
>> value assigned by some other program rule. Try these steps
>> 1. create program rule variable of source type CALCULATED_VALUE // Let
>> say "auto-increment"
>> 2. create program rule with Program Rule Action as Assign Value and
>> select variable created in step 1 and assign it "#{auto-increment} + 1"
>> 3. Use it in your program rule where ever needed for example
>> v{current-date}-#{orgunit}-#{auto-increment}
>>
>> In order to use CALCULATED_CALUE make sure you are correctly setting rule
>> *priority*.
>>
>> Zubair Asghar
>> DHIS-2 Developer
>> University of Oslo
>> zubair@xxxxxxxxx <lars@xxxxxxxxx>
>> https://www.dhis2.org
>>
>>
>> On Wed, Oct 10, 2018 at 1:25 PM Terence Scott <
>> terence.scott@xxxxxxxxxxxxxxxxxx> wrote:
>>
>>> Dear All
>>>
>>> I am creating a program rule to develop a UID for the patient. I have
>>> currently created a program rule using d2:concatenate to bring various
>>> attributes and DEs together into the Unique ID (such as date and OrgUnit
>>> code). However, I would also like to include sequential numbering after
>>> this to ensure that more than 1 case can be registered on a single day.
>>>
>>> I have looked through all of the documentation and am unable to find
>>> anything along these lines. Is it possible?
>>>
>>> Example:
>>> 2018-10-10-OrgUnit code-1;
>>> 2018-10-10-OrgUnit code-2;
>>> 2018-10-10-OrgUnit code-3; etc.  (where 1,2 and 3 are the sequential
>>> numbers generated).
>>>
>>> I have also looked at Program Rule variables and am unsure as to what
>>> the "Calculated value" source type is, as in the documentation it is listed
>>> as "TBA" with no further information.
>>>
>>> I would appreciate any help or advise.
>>>
>>> Kind regards,
>>> Terence
>>>
>>>
>>>
>>>
>>> Terence Scott
>>>
>>> Global Alliance for Rabies Control (GARC)
>>> Pan-African Rabies Control Network (PARACON) Steering Committee
>>> terence.scott@xxxxxxxxxxxxxxxxxx
>>> https://paracon.rabiesalliance.org
>>> Skype: tpscott1987
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>

Follow ups

References