Import patient list in CSV file

Hi, i have a list of patient that i would to import with basic information like firstname , lastname. Do you have any idea simple way on how to do it ?

Thank you, Regards

sadly the default import/export wizard are “more technical”

created,orgUnit,createdAtClient,trackedEntityInstance,lastUpdated,trackedEntityType,lastUpdatedAtClient,storedBy,coordinates,potentialDuplicate,lastUpdatedByUserInfo,deleted,inactive,featureType,geometry,createdByUserInfo,lastUpdated,code,storedBy,displayName,created,valueType,attribute,value
2014-07-23T12:45:49.669,DiszpKrYNg8,2014-07-23T12:45:49.669,oi3PMIGYJH8,2014-07-23T12:45:49.787,nEenWmSyUEp,,,,false,,false,false,NONE,,,2016-01-12T09:10:35.884,MMD_PER_NAM,,"First name",2016-01-12T09:10:26.986,TEXT,w75KJ2mc4zz,Evelyn
2014-07-23T12:45:49.669,DiszpKrYNg8,2014-07-23T12:45:49.669,oi3PMIGYJH8,2014-07-23T12:45:49.787,nEenWmSyUEp,,,,false,,false,false,NONE,,,2016-01-12T09:10:35.884,,,"Last name",2016-01-12T09:10:26.986,TEXT,zDhUuAYrxNC,Jackson
2014-07-23T12:45:49.669,DiszpKrYNg8,2014-07-23T12:45:49.669,oi3PMIGYJH8,2014-07-23T12:45:49.787,nEenWmSyUEp,,,,false,,false,false,NONE,,,2016-01-12T09:10:35.884,,,Gender,2016-01-12T09:10:26.986,TEXT,cejWyOfXge6,Female

the produced csv has 1 line per attribute.

you might have more luck with some external app in the application store.
but you will need to map the “columns” to the associated “attribute”

1 Like

@Stephan_Mestach thank you for your help, can you tell me which external app i may use in order to import. Please @Gassim can you help

I think there used to be other apps.
I found this one : DHIS2 App Hub

1 Like

Hi @Ornella

Firstly I’ll discourage doing this directly into the database. Why not send the csv data over API? I believe this would be way easier and safer.

If you want to do this via sql query, you may have to interact with more than just a single table. And if care is not taken, it could lead to data integrity issue/errors. Here are the key tables you may have to interact with:

  1. trackedentityinstance: Contains information about the tracked entity instances.
  2. program: Stores information about programs.
  3. programinstance: Links tracked entity instances to programs, representing enrollments in a program.
  4. trackedentityattributevalue: Stores values for the attributes associated with tracked entity instances.

Here’s the order in which you should insert data into the respective tables:

  1. Insert into trackedentityinstance:
  • This step creates the tracked entity instance with its basic information.
  1. Insert into trackedentityattributevalue (if there are attributes associated with the tracked entity):
  • Insert attribute values for the tracked entity instance.
  1. Insert into programinstance:
  • This step enrolls the tracked entity instance into a program.
  1. Insert into programstageinstance (if there are events associated with the program stages):
  • Create events for the tracked entity instance in the different stages of the program.

I hope you find this helpful!

1 Like

Hi @Stephan_Mestach

Thanks for mentioning Bulk Load. @Ornella you have documentation and video tutorials on how to use this app here If you use and have any problems, please let us know!

1 Like

@eyeseetea, @Stephan_Mestach, @Quoda i manage to install Bulk-Load, then i download the template screenshoot below so i do not need to fill the TEI it will automatically be generated by the system

2 Likes

Hi

Yes, the TEI ids will be generated by the system if you will leave it empty. However, if you also want to create events for the stages of this tracker program then you would need to assign the ID and map them out in the other sheets of the file.

I would suggest to download one tracker/patient info with some stages and have a look on how it is translated in to this excel file.

2 Likes

here is the error that i get when i import

How can i solve it please, the organisation unit is “Four-Place”

2 Likes

about tei id I guess it’s perhaps a good thing to pre assign them in the excel
if you import “twice” the same file you will create duplicate TEI (except if you have an attributes marked as unique)

you can generate the uid upfront with something like :
https://play.im.dhis2.org/stable-2-41-0/api/system/id.csv?limit=100

for the error

does you user have access to that program and that orgunit in the tracker capture web app ?

1 Like

@Stephan_Mestach i did the importation i noticed i did not import everything so when i import again the remaining here is what i get.


For the first importation, i get this error and i do not import all

And now when i import the remaining list


here is the error that i get

1 Like

The error is a bit too short to tell… what’s going on.

I guess you’ll need to look at the server logs and look for a stacktrace/logs around your import.

or open the network view of the browser to verify/share what is sent and what is returned during the import.

1 Like

I left the OU column empty, i removed the name it works

@Stephan_Mestach i do not what is going on when i import i noticed that it did not import everything unfortunately when retry it says success but when i check the list still does not see them. I really do not understand.

1 Like

I’ve never used the app.

Are you the OU is not supposed to be the uid of the orgunit (not the name)
(names are rarely unique in a full pyramid)

@Stephan_Mestach what i did is to download the template and edit it by putting the TEI that i need to import. Here is example

I left “org Unit” column empty, unfortunately it say “Success” still does not import.

@Ornella DHIS2 requires that every data be created against an org unit.
In the template, make sure you’re using org unit ids (not names), that:

  1. exist in your system.
  2. have access to your program

what i see is that your data can pass validation checks in the bulk upload app (possibly why it says “success”), but the dhis2 api will not allow the creation of these events without being associated with any org unit.