iMMAP / ngm-reportDesk

The workdesk for ReportHub
0 stars 0 forks source link

RH ET Organization doesn't match with the defined organization in the platform #45

Closed rafinkanisa closed 2 years ago

rafinkanisa commented 2 years ago

Describe the bug Similar to https://github.com/iMMAP/ngm-reportDesk/issues/39

Context I found this when I'm trying to add organization and check on the database

To Reproduce Steps to reproduce the behavior:

  1. Open the database
  2. Compare organization_tag, organization, organization_name, organization type in user collection with organization collection and organizations collection
  3. You can see there are some inconsistencies in the data

Expected behavior Any of the organization details in other related collections (e.g. user) should follow with collections "organization". This applies to all reporting collection as well. The organization collection shall refer the details to organizations collection.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context You might have to delete the unused value in organization collection if it's duplicated / the organization shouldn't be active in that country (refer to organizations collection) In case you have doubt which action shall you taken, you can always consult me first

dodiws commented 2 years ago

Created nodejs script to update organization collection with data imported from csv file. Functionally similar to mongoimport --upsert which can't do partial update in version 3.0. Still in test.

dodiws commented 2 years ago

Correcting organization_name values in organization collection

Using mongo-update-csv.js script to import data from csv file and update the organization_name field, filter by admin0pcode, organization_tag fields in organization collection.

node mongo-update-csv.js update-org-name.csv --filterFields admin0pcode,organization_tag --updateFields organization_name -d ngmReportHub -c organization

file update-org-name.csv

admin0pcode,organization_tag,organization_name
AF,ancc,Afghanistan National Re-Construction Coordination
AF,cww,Concern World Wide
AF,frdo,Female Rehabilitation Development Organization
AF,hadaf,Humanitarian Assistance and Development Association for Afghanistan
AF,icrc,International Committee of the Red Cross and Red Crescent
AF,sfl,Shelter For Life International
AF,unmas,United Nations Mine Action Service
AF,zoa,ZOA International
ET,cww,Concern World Wide
ET,unocha,Office for the Coordination of Humanitarian Affairs

Correcting organization values in organization collection

Using mongo-update-csv.js script to import data from csv file and update the organization field, filter by admin0pcode, organization_tag fields in organization collection.

node mongo-update-csv.js update-org.csv --filterFields admin0pcode,organization_tag --updateFields organization -d ngmReportHub -c organization

file update-org.csv

admin0pcode,organization_tag,organization
AF,shuhada,SHUHADA
AF,me,ME
ET,ndrmc,NDRMC

Update organization, organization_name values in user collection

Using update_organizations_data_in_user.js script to update organization, organization_name data in user collection using data from organization collection.

mongo localhost:27017/ngmReportHub update_organizations_data_in_user.js --eval 'var admin0pcode="ET"'

Remove duplicate in organization collection

Duplicate organization that organization, organization_name, and organization_type values have been made uniform can be removed/deduplicated using find_refs_to_duplicate_orgs.js script. Set admin0pcode = "ET" inside the script or from mongo shell --eval param.

// open mongo shell with find_refs_to_duplicate_orgs.js script
mongo localhost:27017/ngmHealthCluster find_refs_to_duplicate_orgs.js --eval 'var admin0pcode="ET"' --shell

// delete duplicate organizations
delete_duplicate_organizations()

// update references to duplicate organizations
update_refs_to_duplicate_orgs()
fakhrihawari commented 2 years ago

already tested on DEV Server

fakhrihawari commented 2 years ago

already on PROD