-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UP-45 Ensure all forms specify a provider type as we created provider… #10
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> | ||
|
||
<!-- NOTE: This has to come before the setting of all users to be providers in this migration process. --> | ||
|
||
<!-- First, we ensure that a role exists to associate with Providers to be selected on forms --> | ||
|
||
<changeSet id="rwandaemr-ensure-practicing-provider-role-exists" author="IMB"> | ||
<preConditions onFail="MARK_RAN"> | ||
<sqlCheck expectedResult="0"> | ||
SELECT count(*) FROM role WHERE role = "Practicing provider" | ||
</sqlCheck> | ||
</preConditions> | ||
<sql> | ||
INSERT INTO `role`( | ||
role, | ||
description, | ||
uuid | ||
) | ||
VALUES ( | ||
"Practicing provider", | ||
"Role to differentiate practicing providers from other user providers", | ||
"36a4a54d-ab0a-11ea-8991-3c6aa7d72242" | ||
) | ||
; | ||
</sql> | ||
</changeSet> | ||
|
||
<!-- | ||
Next, we create new user_role for current providers using the above role | ||
1. We sanity check that only one Role is found that matches what we are expecting | ||
2. We create user_role for all current providers to differentiate them from all | ||
other providers to be | ||
3. We modify forms to only select only consider providers with the new role or | ||
the already specified ones on form. | ||
--> | ||
|
||
<changeSet id="rwandaemr-ensure-forms-select-practicing-providers" author="IMB"> | ||
<preConditions onFail="HALT"> | ||
<sqlCheck expectedResult="1"> | ||
SELECT count(*) FROM role WHERE role = "Practicing provider" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is necessary, as this won't execute if the above changeset fails, but I guess it can't hurt. |
||
</sqlCheck> | ||
</preConditions> | ||
<sql> | ||
|
||
INSERT INTO user_role( | ||
user_id, | ||
role | ||
) | ||
SELECT | ||
distinct(US.user_id), | ||
"Practicing provider" | ||
FROM | ||
provider Pr | ||
LEFT JOIN | ||
users US | ||
ON | ||
Pr.person_id=US.person_id | ||
WHERE | ||
US.retired!=1 AND Pr.retired!=1 | ||
; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per above comment, we might choose to implement this as inserting into providermanagement_* tables to associate provider roles, rather than inserting user roles. We need to figure this out. |
||
|
||
|
||
UPDATE | ||
htmlformentry_html_form | ||
SET | ||
xml_data = REPLACE(xml_data, '<encounterProvider', '<encounterProvider role="Practicing provider"') | ||
WHERE | ||
xml_data LIKE "%<encounterProvider%" AND xml_data NOT LIKE "%role=%" | ||
; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you might want your where clause to be more specific, eg. AND xml_data NOT LIKE "%<encounterProvider role=%". It's possible that "role=" appears elsewhere in your xml for other reasons. |
||
</sql> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an area where we might need to at least consider how we are modeling providers in Rwanda going forward. The standard in OpenMRS RefApp and PihCore is to use the ProviderManagement module (originally written for Rwanda ironically), which adds a "ProviderRole" attribute to Provider. This is intentionally not the same as a "User Role", as User Roles are intended to be more about permissions and are attached to users, while Providers are not required to be linked to users.
There is an " tag in htmlformentry that utilizes this, and we'd presumably change all of our tags to tags.
@mogoodrich can you comment on this and help us to work out the approach you'd recommend here?