Not able to find program cloning feature released in dhis v2.41.0

I was trying to duplicate just the metadata of the program to create a similar looking program but an new emply one. I found a feature request which is present here [[DHIS2-15279] Clone program - Jira (Jira). I also found out that the feature has been released in 2.41.0 According to dhis2-releases/releases/2.41/ReleaseNote-2.41.0.md at master · dhis2/dhis2-releases · GitHub. However, I couldn’t find any information in documentation regarding DHIS2-15279. I also self explored 2.41 but couldn’t find any function regaring the feature. Could someone guide me to how to do it.

I am also open to using any other tools or scripts if someone has written it. I want to duplicate my program with all the datasets and validators intact. The duplicated program must be a new empty one.

Thank you

Hi @Ritesh_Thapa

Welcome back to the community!

Thank you for sharing the Jira ticket. As you can see, the ticket is still in ‘Testing’ phase so it’s not yet implemented in any version. In the ticket’s comments, there’s a link that explains how the feature will work (in the backend): docs.dhis2.org - using-the-api - metadata - #copy-program

Although the process won’t be as easy as the ‘Program copy’ feature mentioned above, I think you could achieve this by using the Import/Export app. If you’d like to test this, use the Metadata export and Metadata dependency export to get the program details and dependencies. After that you will rename the unique properties for programIndicators’ (name, shortName), progam’s name…etc

Hi @Gassim,
It seems the feature has been released. If you see in the release note according to dhis2-releases/releases/2.41/ReleaseNote-2.41.0.md at master · dhis2/dhis2-releases · GitHub at 2.41.0 it has been released and has been included in official documentation as well.

In Metadata - DHIS2 Documentation, we can find the copy program feature as well in 2.41.0.

It says to send a post request to /api/programs/<program_id>/copy. I sent a post request to https://play.im.dhis2.org/stable-2-41-2/api/programs/IpHINAT79UW/copy with empty body. I got response as

{
“httpStatus”: “Conflict”,
“httpStatusCode”: 409,
“status”: “ERROR”,
“message”: “ERROR: duplicate key value violates unique constraint "programstage_name_key"\n Detail: Key (name)=(Birth) already exists.”,
“errorCode”: “E1004”
}
Am i doing something wrong? How does it work? Do I need to send something in body? I can’t find anything in documentation.

Hi @Ritesh_Thapa,

  • the error you have posted above is triggered because of the database used in our Play environments
  • we use the test Sierra Leone database in our Play environments
  • this database has constraints (program stage name) which are not part of the DHIS2 database schema
  • our advice is to test this feature without using the Sierra Leone database, options:
    • test it locally using an empty DB
    • download the Sierra Leone DB , remove the constraint in question (there may be more), and then initialize the DB using the modified script
    • or use some other DB/script you may already have
1 Like