Skip to content

Sync practitioners of a role to device#769

Open
allan-on wants to merge 23 commits intoadd-reconfigurable-registers-and-profilesfrom
sync-practitioners-of-a-role-to-device
Open

Sync practitioners of a role to device#769
allan-on wants to merge 23 commits intoadd-reconfigurable-registers-and-profilesfrom
sync-practitioners-of-a-role-to-device

Conversation

@allan-on
Copy link
Copy Markdown
Contributor

Add syncing of (CHW) practitioners from the server as part of opensrp/opensrp-client-goldsmith#81


ekigamba and others added 22 commits March 1, 2021 16:10
- Add PractitionerRole and Practitioner models
- Fetch practitioners and practitioner roles to map the current user practitioner-role
- Save the current user practitioner-role-code in preferences

Fixes tasks in opensrp/opensrp-client-goldsmith#80
…m:OpenSRP/opensrp-client-core into add-practitioner-role-in-preference
Refactored Toolbar configs to be merged in NavigationOptions
Comment on lines +392 to +406
public String getUserPractitionerRole() {
return preferences.getString(USER_PRACTITIONER_ROLE, null);
}

@Nullable
public String getUserPractitionerIdentifier() {
return preferences.getString(USER_PRACTITIONER_IDENTIFIER, null);
}

public void setUserPractitionerRole(String practitionerRole) {
preferences.edit().putString(USER_PRACTITIONER_ROLE, practitionerRole).commit();
}

public void setUserPractitionerIdentifier(String identifier) {
preferences.edit().putString(USER_PRACTITIONER_IDENTIFIER, identifier).commit();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenSRP supports multi tenancy on the same device where two user accounts can be active without requiring a data clearing or a fresh installation. Should then the preference keys here have the +username suffix like other user-dependent preference keys?

Comment on lines +87 to +94
public String getFormattedBaseUrl() {
String baseUrl = CoreLibrary.getInstance().context().configuration().dristhiBaseURL();
String endString = "/";
if (baseUrl.endsWith(endString)) {
baseUrl = baseUrl.substring(0, baseUrl.lastIndexOf(endString));
}
return baseUrl;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this method exist anywhere else? Should it be refactored placed in a Utility class for shared use?

Comment on lines +1032 to +1036
private void initializeAdapter(Set<? extends IView> iviews) {
Set<IView> mySet = new HashSet<>();

initializeAdapter(mySet);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this private method belong here?


Practitioner loggedInPractitioner = null;
for (Practitioner practitioner : practitioners) {
if (practitioner != null && mUsername.equals(practitioner.getUsername())) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this condition is satisfied, is it OK to break out of the loop for efficiency ?


PractitionerRole loggedInPractitionerRole = null;
for (PractitionerRole practitionerRole : practitionerRoles) {
if (loggedInPractitioner.getIdentifier().equals(practitionerRole.getPractitionerIdentifier())) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this condition is satisfied, is it OK to break out of the loop for efficiency ?

}

// Save the registered ANM
getOpenSRPContext().allSharedPreferences().updateANMUserName(mUsername);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this call required here (maybe it is)?

It is also invoked at a later time once the authentication is successful, afterLoginCheck listener fires and this line is executed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants