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

LBAC-16 Added implementation to restrict the encounters of the patients from other locations #23

Merged
merged 1 commit into from Aug 3, 2018

Conversation

@suthagar23
Copy link
Member

@suthagar23 suthagar23 commented Aug 3, 2018

Description

  • Added the restrictions to these following methods from the EncounterService class which is directly getting the Encounter object from the DAO. It can restrict by the encounters from other locations.
    1. getEncounter()
    2. getEncounterByUuid()
    3. getEncounters()
    4. getEncountersByPatientId()
    5. getEncountersByPatient()
    6. getEncountersByVisit()
    7. getEncountersNotAssignedToAnyVisit()
    8. getEncountersByVisitsAndPatient()
    9. getAllEncounter()

Ticket

Ticket : https://issues.openmrs.org/browse/LBAC-16

…ts from other locations
Map.Entry<Integer, List<Encounter>> entry = mapIterator.next();
List<Encounter> encounterList = entry.getValue();
entry.setValue(removeEncountersIfNotBelongToGivenLocation(encounterList, sessionLocationUuid));
//TODO: remove the entry from the map, if the encounter list is empty and update the map index

This comment has been minimized.

@dkayiwa

dkayiwa Aug 3, 2018
Member

When are you planning to address this TODO?

This comment has been minimized.

@suthagar23

suthagar23 Aug 3, 2018
Author Member

Here If I remove this value from the Map, then I need to update the integer index as well. So It should be done using some preferred way. It's not very much needed for the first use case. So decided to do it later.

for (Iterator<Encounter> iterator = encounterList.iterator(); iterator.hasNext(); ) {
Encounter thisEncounter = iterator.next();
if(!doesEncounterBelongToGivenLocation(thisEncounter, sessionLocationUuid)) {
iterator.remove();

This comment has been minimized.

@dkayiwa

dkayiwa Aug 3, 2018
Member

Doesn't this remove land you in problems of manipulating a collection in the process of iterating over it?

This comment has been minimized.

@suthagar23

suthagar23 Aug 3, 2018
Author Member

Nope, this is a safety method to remove from the collections, and I used this in the existing implementations as well.

@dkayiwa dkayiwa merged commit c22cb74 into openmrs:master Aug 3, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants