Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions migration/src/main/resources/migrations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
https://wiki.openmrs.org/display/docs/Prepare+for+Upgrading+From+a+Pre-1.10+to+1.10+or+Later+Version
https://github.com/rwanda-rbc-emr/openmrs-module-mohbeforeoneelevenupgrade
-->
<include file="migrations/ensure-forms-consider-practicing-providers.xml" relativeToChangelogFile="true" />
<include file="migrations/ensure-users-are-providers.xml" relativeToChangelogFile="true" />
<include file="migrations/ensure-orders-have-start-dates.xml" relativeToChangelogFile="true" />
<include file="migrations/ensure-orders-have-encounters.xml" relativeToChangelogFile="true" />
Expand Down
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"
)
;
Copy link
Member

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?

</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"
Copy link
Member

Choose a reason for hiding this comment

The 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
;
Copy link
Member

Choose a reason for hiding this comment

The 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=%"
;
Copy link
Member

Choose a reason for hiding this comment

The 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>