RCM-109 Added patient verification to return Cohorts objects for the serviceMethods #39
Conversation
@@ -299,4 +300,28 @@ public static PatientFilter toPatientFilter(PatientSearch search, CohortSearchHi | |||
c.setMemberIds(cohort.getMemberIds()); | |||
return c; | |||
} | |||
|
|||
public static Cohort verifyPatients(Cohort cohort) { |
dkayiwa
Aug 6, 2018
Member
What does verifyPatients mean?
What does verifyPatients mean?
suthagar23
Aug 6, 2018
Author
Member
Just verify the given patients in the cohort is exist or not.
Just verify the given patients in the cohort is exist or not.
dkayiwa
Aug 6, 2018
Member
The method name does not look meaningful because verify can mean very many things.
The method name does not look meaningful because verify can mean very many things.
suthagar23
Aug 6, 2018
Author
Member
Thus, Could we think of "removeNullPatientsFromCohort" ?
Thus, Could we think of "removeNullPatientsFromCohort" ?
dkayiwa
Aug 6, 2018
Member
What are null patients? Does this mean the patient collection has a list of nulls
What are null patients? Does this mean the patient collection has a list of nulls
suthagar23
Aug 6, 2018
Author
Member
Actually, patient ids collection contains the patientIds which are not reachable(by some restrictions eg. location). So it should remove those ids which have the null patient objects at that time.
What would be the most appropriate name for this method?
Actually, patient ids collection contains the patientIds which are not reachable(by some restrictions eg. location). So it should remove those ids which have the null patient objects at that time.
What would be the most appropriate name for this method?
if(patientIds != null) { | ||
Iterator<Integer> iterator = patientIds.iterator(); | ||
while (iterator.hasNext()) { | ||
Integer patientId = iterator.next(); |
dkayiwa
Aug 6, 2018
Member
Does the above line mean that the iterator can return an element which is null?
Does the above line mean that the iterator can return an element which is null?
suthagar23
Aug 6, 2018
Author
Member
Actually patientId will have the value, the patient object which is pointed by the patientId could be null at some times (by the location restrictions)
Actually patientId will have the value, the patient object which is pointed by the patientId could be null at some times (by the location restrictions)
dkayiwa
Aug 6, 2018
Member
Are you explaining this in reference to the next line which checks if patientId != null?
Are you explaining this in reference to the next line which checks if patientId != null?
suthagar23
Aug 6, 2018
Author
Member
Nope, I addressed the line 315 and line 317. In most cases, patientId will not be null (Since Im checking this against null for the confirmation).
But the patient points by that patientId can be null according to the location restrictions. So the line 315 will have the value (not null), but the line 317 may have the null object.
Nope, I addressed the line 315 and line 317. In most cases, patientId will not be null (Since Im checking this against null for the confirmation).
But the patient points by that patientId can be null according to the location restrictions. So the line 315 will have the value (not null), but the line 317 may have the null object.
dkayiwa
Aug 6, 2018
Member
Am not yet talking about location restrictions. Am simply talking about the return value of iterator.next()
Do we expect it to have null, when hasNext() returned true?
Am not yet talking about location restrictions. Am simply talking about the return value of iterator.next()
Do we expect it to have null, when hasNext() returned true?
suthagar23
Aug 6, 2018
Author
Member
Ah yes, Just got your point 😄 . No need to have this.
I have updated the code
Ah yes, Just got your point
I have updated the code
Instead of removing the patient ids from the collection, can't we just filter them at source? Where they are loaded from the database? |
Instead of adding this to the DAO resource (we might also need to add for multiple lines), why we do not add this to the Cohort constructor here (just some places will be affected - Constructor,setMemberIds and addMember methods) ? |
Looks fine to me for now. As long as those who do not have our module installed will not be affected. |
@dkayiwa Do we only use the Cohort objects for Patients? If we are using the Cohorts for other members then We can't add this patient verification to the Cohort Class. Because it will caused the problems for other members. |
Are there any major disadvantages of adding this to the DAO layer? |
We need to change multiple lines to make the changes in multiple class files. But going for the Cohort will only need to change few lines. |
Yes that is right. |
@dkayiwa I have changed the implementation. Please review again THanks. |
|
||
public static Collection<Integer> removeNullPatients(Collection<Integer> patientIds) { | ||
PatientService patientService = Context.getPatientService(); | ||
if(patientIds != null) { |
dkayiwa
Aug 6, 2018
Member
To reduce nesting, just return if the list is null.
To reduce nesting, just return if the list is null.
suthagar23
Aug 7, 2018
Author
Member
Changed
Changed
|
||
public static Boolean doesPatientExist(Integer patientId) { | ||
PatientService patientService = Context.getPatientService(); | ||
if(patientId != null && patientService.getPatient(patientId) != null) { |
dkayiwa
Aug 6, 2018
Member
Are there cases when this is called with a null patientId?
Are there cases when this is called with a null patientId?
suthagar23
Aug 7, 2018
Author
Member
Yes, If I created a Cohort, and tried to insert a member with addMember(null)
. Then it can be null
Yes, If I created a Cohort, and tried to insert a member with addMember(null)
. Then it can be null
Is it worth making all these extra calls when our module is not installed? |
Yes, I also thought this. |
4e441df
to
aa5e391
RCM-109 Added patient verification to the Cohorts RCM-109 Added patient verification to the Cohorts RCM-109 Added patient verification to the Cohorts
Why create an extra gp? Can't you use the same logic like you used for the reference application? |
In the reference application also, we have created a GP through our module and used that. What do you mean by the logic? |
Closing this for now until when we get feedback from the 0.1.0 release |
Descriptions
In reporting compatibility module used the org.openmrs.cohort.Cohort class instead of org.openmrs.Cohort class. So other modules which are using these service methods needed to add the reporting compatibility module as the required module.
To avoid this requirement, A patient verification is added to the Cohort Membership methods.
Ticket Information
Ticket : https://issues.openmrs.org/browse/RCM-109