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

Sync practitioners of a role to device #769

Open
wants to merge 23 commits into
base: add-reconfigurable-registers-and-profiles
Choose a base branch
from

Conversation

allan-on
Copy link
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
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
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
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
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
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 ?

@@ -140,6 +142,11 @@ protected LoginResponse doInBackground(Void... params) {
}

}

// Save the registered ANM
getOpenSRPContext().allSharedPreferences().updateANMUserName(mUsername);
Copy link
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