cht-core
cht-core copied to clipboard
Users in projects have multiple configured roles
When configurable roles (https://github.com/medic/medic/commit/a64d241d9f408786c9797b3d15d156ff1eecf65a) were implemented, the intention was to transition away from users having multiple assigned configured roles to just one role.
The user doc in the _users db and the user-settings doc in the medic database both have an array of roles as this is consistent with CouchDB, but the configuration UI has a dropdown so in practice users will have an array of length 1.
However, in practice, in projects that are up to date, users are created and updated (via the API endpoint or directly in CouchDB) to have multiple roles. For example, a user recently edited in an up to date project has the following roles:
district-manager
, kujua_user
, data_entry
, supervisor
, mrdt
, supervisor_mrdt
With the configured roles being: national_admin, district_admin, data_entry, analytics, gateway, chw_uhc, supervisor, supervisor_mrdt, mrdt, mrdt_2, pm.
If this is the direction that projects are going, we should probably update the admin UI to support this.
I think we should probably support users with multiple roles as it makes life easier for configurers. For example if you want to have a chp
role and a mrdt
role which is available to some CHPs then you don't have to copy all the permissions from chp
to mrdt
you only have to include the new ones. This is especially useful for AB testing, phased feature rollouts, research initiatives, and so on.
The actual permissions should be a union of the permissions in each group - this should already be the case but check to ensure it's working as expected everywhere.
There may be a use case for the mrdt
role removing permissions that are granted to a chp
but that is outside the scope of this issue. The workaround for this is define a mrdt
role with all the desired permissions and remove the chp
role from mrdt
users.
Moved to 3.12.0 to free up engineers to work on 3.11.0.
Removing from 3.12 pending admin console design conversations.
Ready for AT in #7794
This also fixes #7592 so you may like to AT this at the same time.
The admin app has been updated to allow selection of multiple roles via checkboxes, instead of a single role via a dropdown.
Testing Details
Environment: Local, development setup
Platform: WebApp
Browser: Chrome
Branch: 7592-users-have-multiple-roles
Tests scenarios
The option to select the role is now through checkboxes.
The "role" column in the App Management section is not present.
Result from GET /api/v1/users - The role is shown as "type" and it is only showing the first one.
[
{
"id": "org.couchdb.user:admin",
"rev": "1-163f4c0e3383d0e1efaaa5f4ebc02f6d",
"username": "admin",
"type": "admin"
},
{
"id": "org.couchdb.user:cleo",
"rev": "1-c812741f49fa466f94a8908732ae4ed9",
"username": "cleo",
"place": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4",
"_rev": "2-3f7128163c64c00ef174620dd26bfc82",
"parent": "",
"type": "district_hospital",
"is_name_generated": "true",
"name": "Cleopatra's Health Facility",
"external_id": "",
"notes": "",
"contact": {
"_id": "1f1804e1-38b8-41d8-93ab-447175f1e91b",
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
}
},
"geolocation": "",
"meta": {
"created_by": "admin",
"created_by_person_uuid": "",
"created_by_place_uuid": ""
},
"reported_date": 1668723442931,
"place_id": "86587"
},
"contact": {
"_id": "1f1804e1-38b8-41d8-93ab-447175f1e91b",
"_rev": "2-a6b7e295a7a6e0e63dd4061a8cf40f10",
"type": "person",
"name": "Cleopatra",
"short_name": "",
"date_of_birth": "1972-11-17",
"date_of_birth_method": "approx",
"ephemeral_dob": {
"age_label": "",
"age_years": "50",
"age_months": "",
"dob_method": "approx",
"dob_approx": "1972-11-17T00:00:00.000-06:00",
"dob_raw": "1972-11-17T00:00:00.000-06:00",
"dob_iso": "1972-11-17"
},
"phone": "",
"phone_alternate": "",
"sex": "female",
"role": "chw",
"external_id": "",
"notes": "",
"meta": {
"created_by": "admin",
"created_by_person_uuid": "",
"created_by_place_uuid": ""
},
"reported_date": 1668723442931,
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
},
"patient_id": "27194"
},
"type": "analytics"
},
{
"id": "org.couchdb.user:filippo",
"rev": "2-f548e4f14b2ac58a795954b134897a71",
"username": "filippo",
"place": {
"_id": "64cafcbc-9f78-4992-ac32-35a3e61ece23",
"_rev": "2-d8c398cfe64bb2698e404dcd50fdb3cf",
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
},
"type": "health_center",
"is_name_generated": "true",
"name": "Filippo's Area",
"external_id": "",
"notes": "",
"contact": {
"_id": "52a6124c-9aa1-4142-b501-880f72d6a13e",
"parent": {
"_id": "64cafcbc-9f78-4992-ac32-35a3e61ece23",
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
}
}
},
"geolocation": "",
"meta": {
"created_by": "admin",
"created_by_person_uuid": "",
"created_by_place_uuid": ""
},
"reported_date": 1668723459968,
"place_id": "43412"
},
"contact": {
"_id": "52a6124c-9aa1-4142-b501-880f72d6a13e",
"_rev": "2-536cf88b70de5d599429a03c7e6acc24",
"type": "person",
"name": "Filippo",
"short_name": "",
"date_of_birth": "1978-11-17",
"date_of_birth_method": "approx",
"ephemeral_dob": {
"age_label": "",
"age_years": "44",
"age_months": "",
"dob_method": "approx",
"dob_approx": "1978-11-17T00:00:00.000-06:00",
"dob_raw": "1978-11-17T00:00:00.000-06:00",
"dob_iso": "1978-11-17"
},
"phone": "",
"phone_alternate": "",
"sex": "male",
"role": "chw",
"external_id": "",
"notes": "",
"meta": {
"created_by": "admin",
"created_by_person_uuid": "",
"created_by_place_uuid": ""
},
"reported_date": 1668723459968,
"parent": {
"_id": "64cafcbc-9f78-4992-ac32-35a3e61ece23",
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
}
},
"patient_id": "65857"
},
"type": "chw"
}
]
Result from GET /api/v2/users - The role is shown as "roles" and it is showing all the assigned roles.
[
{
"id": "org.couchdb.user:admin",
"rev": "1-163f4c0e3383d0e1efaaa5f4ebc02f6d",
"username": "admin",
"roles": [
"admin"
]
},
{
"id": "org.couchdb.user:cleo",
"rev": "1-c812741f49fa466f94a8908732ae4ed9",
"username": "cleo",
"place": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4",
"_rev": "2-3f7128163c64c00ef174620dd26bfc82",
"parent": "",
"type": "district_hospital",
"is_name_generated": "true",
"name": "Cleopatra's Health Facility",
"external_id": "",
"notes": "",
"contact": {
"_id": "1f1804e1-38b8-41d8-93ab-447175f1e91b",
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
}
},
"geolocation": "",
"meta": {
"created_by": "admin",
"created_by_person_uuid": "",
"created_by_place_uuid": ""
},
"reported_date": 1668723442931,
"place_id": "86587"
},
"roles": [
"analytics",
"data_entry",
"gateway",
"program_officer",
"mm-online"
],
"contact": {
"_id": "1f1804e1-38b8-41d8-93ab-447175f1e91b",
"_rev": "2-a6b7e295a7a6e0e63dd4061a8cf40f10",
"type": "person",
"name": "Cleopatra",
"short_name": "",
"date_of_birth": "1972-11-17",
"date_of_birth_method": "approx",
"ephemeral_dob": {
"age_label": "",
"age_years": "50",
"age_months": "",
"dob_method": "approx",
"dob_approx": "1972-11-17T00:00:00.000-06:00",
"dob_raw": "1972-11-17T00:00:00.000-06:00",
"dob_iso": "1972-11-17"
},
"phone": "",
"phone_alternate": "",
"sex": "female",
"role": "chw",
"external_id": "",
"notes": "",
"meta": {
"created_by": "admin",
"created_by_person_uuid": "",
"created_by_place_uuid": ""
},
"reported_date": 1668723442931,
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
},
"patient_id": "27194"
}
},
{
"id": "org.couchdb.user:filippo",
"rev": "2-f548e4f14b2ac58a795954b134897a71",
"username": "filippo",
"place": {
"_id": "64cafcbc-9f78-4992-ac32-35a3e61ece23",
"_rev": "2-d8c398cfe64bb2698e404dcd50fdb3cf",
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
},
"type": "health_center",
"is_name_generated": "true",
"name": "Filippo's Area",
"external_id": "",
"notes": "",
"contact": {
"_id": "52a6124c-9aa1-4142-b501-880f72d6a13e",
"parent": {
"_id": "64cafcbc-9f78-4992-ac32-35a3e61ece23",
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
}
}
},
"geolocation": "",
"meta": {
"created_by": "admin",
"created_by_person_uuid": "",
"created_by_place_uuid": ""
},
"reported_date": 1668723459968,
"place_id": "43412"
},
"roles": [
"chw",
"chw_supervisor"
],
"contact": {
"_id": "52a6124c-9aa1-4142-b501-880f72d6a13e",
"_rev": "2-536cf88b70de5d599429a03c7e6acc24",
"type": "person",
"name": "Filippo",
"short_name": "",
"date_of_birth": "1978-11-17",
"date_of_birth_method": "approx",
"ephemeral_dob": {
"age_label": "",
"age_years": "44",
"age_months": "",
"dob_method": "approx",
"dob_approx": "1978-11-17T00:00:00.000-06:00",
"dob_raw": "1978-11-17T00:00:00.000-06:00",
"dob_iso": "1978-11-17"
},
"phone": "",
"phone_alternate": "",
"sex": "male",
"role": "chw",
"external_id": "",
"notes": "",
"meta": {
"created_by": "admin",
"created_by_person_uuid": "",
"created_by_place_uuid": ""
},
"reported_date": 1668723459968,
"parent": {
"_id": "64cafcbc-9f78-4992-ac32-35a3e61ece23",
"parent": {
"_id": "31af2fe0-6ba7-43e6-84c0-6d45c1fe35a4"
}
},
"patient_id": "65857"
}
}
]
@tatilepizs I see this has been marked "ready to merge" but no comment as to whether AT passed or not?
Sorry, @garethbowen I should have added that note in the testing comment 😅
Everything looks good, it is Ready to merge
Merged!