-
Notifications
You must be signed in to change notification settings - Fork 228
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
(fix)O3-2197: Unable to remove a patient from a list #757
Conversation
const desktopLayout = isDesktop(layoutType); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(cohortMembershipUuid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're logging for debugging purposes, it's probably better to put this in the callback than here.
return deleteData( | ||
`${cohortUrl}/cohortmember/${cohortMembershipUuid}`, | ||
{ | ||
voidReason: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not voiding the cohortMember, just adding an endDate to the record.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call the deleteData
instead of postData
@jwnasambu .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vasharma05 Deleting isn't the correct thing in this instance. Removing a patient from a cohort makes them no longer a cohort member, so their membership expires. It doesn't void the membership (that's a different operation).
@jwnasambu POST is better than DELETE; however, we need to post something more like the full existing record with an endDate (and remove the voidReason property)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ibacher and @dkayiwa !
I tried both the DELETE and POST methods, but POST request didn't make any change.
Do we need to use the DELETE or the POST method?
Thanks!
POST Request:
curl --location 'https://dev3.openmrs.org/openmrs/ws/rest/v1/cohortm/cohortmember/90fec1c6-8799-4c65-98ea-9053f1568457' \
--header 'Content-Type: application/json' \
--header 'Cookie: JSESSIONID=375DCF7704E139C04853E6277331448F' \
--data '{
"endDate": "2023-08-07T12:11:12.558Z"
}'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P.S. DELETE method is deleting the cohortmember as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkayiwa , any update here ☝️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cohortMembershipUuid: string; | ||
} | ||
|
||
const OverflowMenuComponent: React.FC<OverflowMenuComponentProps> = ({ cohortMembershipUuid }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a better name for this... overflow-menu.component sounds like its actually the overflow menu, not the object containing the overflow menu. Maybe overflow-menu-cell?
}, [cohortMembershipUuid, t]); | ||
|
||
return ( | ||
<TableCell className="cds--table-column-menu"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need a TableCell here since the component that uses this component already wraps it in one.
packages/esm-patient-list-app/src/patient-table/patient-table.component.tsx
Outdated
Show resolved
Hide resolved
6732c01
to
7bb76dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small corrections. otherwise looks good!
return deleteData( | ||
`${cohortUrl}/cohortmember/${cohortMembershipUuid}`, | ||
{ | ||
voidReason: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call the deleteData
instead of postData
@jwnasambu .
ariaLabel="Remove patient from the list" | ||
size={desktopLayout ? 'sm' : 'lg'} | ||
flipped> | ||
<OverflowMenuItem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an ExtensionSlot in here, with slot name = "cohort-member-action-items"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vasharma05 Was the intention here to have the "Remove Patient" stuff as an extension?
return deleteData( | ||
`${cohortUrl}/cohortmember/${cohortMembershipUuid}`, | ||
{ | ||
voidReason: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vasharma05 Deleting isn't the correct thing in this instance. Removing a patient from a cohort makes them no longer a cohort member, so their membership expires. It doesn't void the membership (that's a different operation).
@jwnasambu POST is better than DELETE; however, we need to post something more like the full existing record with an endDate (and remove the voidReason property)
} | ||
|
||
export async function createPatientList(cohort: NewCohortDataPayload, ac = new AbortController()) { | ||
return deleteData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return deleteData( | |
return postData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibacher and @vasharma05 thanks for the review let share the proposed changes shortly!
return deleteData( | ||
`${cohortUrl}/cohortmember/${cohortMembershipUuid}`, | ||
{ | ||
voidReason: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P.S. DELETE method is deleting the cohortmember as expected.
packages/esm-patient-list-app/src/patient-table/patient-table.component.tsx
Outdated
Show resolved
Hide resolved
bb49cf2
to
a450115
Compare
@ibacher Kindly free to review the proposed changes on this PR please! |
e1c2d84
to
e4eab9b
Compare
ariaLabel={`Remove patient from the ${cohortName} list`} | ||
size={desktopLayout ? 'sm' : 'lg'} | ||
flipped> | ||
<ExtensionSlot name={'cohort-member-action-items'} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<ExtensionSlot name={'cohort-member-action-items'} /> | |
<ExtensionSlot name="cohort-member-action-items" /> |
ariaLabel="Remove patient from the list" | ||
size={desktopLayout ? 'sm' : 'lg'} | ||
flipped> | ||
<OverflowMenuItem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vasharma05 Was the intention here to have the "Remove Patient" stuff as an extension?
id: index, | ||
id: patient.membershipUuid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
@ibacher thanks for the review and your time! I will fix it shortly am in the middle of another ticket. |
fe42776
to
2fe3cb5
Compare
a5cf005
to
4ad40f2
Compare
4ad40f2
to
c8f859d
Compare
Requirements
Summary
Created a overflow-menu to enable a user delete a patient from a given patient list
Screenshots
This is the output using post method
Uploading screencast 2023-08-23 4 PM-50-35.mp4…
This is the output using delete method
screencast.2023-08-07.10.PM-57-20.mp4
Related Issue
https://issues.openmrs.org/browse/O3-2197
Other
None.