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

(fix)O3-2197: Unable to remove a patient from a list #757

Closed
wants to merge 1 commit into from

Conversation

jwnasambu
Copy link
Contributor

@jwnasambu jwnasambu commented Jul 12, 2023

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.

@jwnasambu jwnasambu marked this pull request as draft July 12, 2023 13:30
const desktopLayout = isDesktop(layoutType);

// eslint-disable-next-line no-console
console.log(cohortMembershipUuid);
Copy link
Member

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: '',
Copy link
Member

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.

Copy link
Member

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 .

Copy link
Member

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)

Copy link
Member

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"
}'

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

@dkayiwa , any update here ☝️

Copy link
Member

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 }) => {
Copy link
Member

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">
Copy link
Member

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.

@jwnasambu jwnasambu force-pushed the (fix)O3-2197 branch 2 times, most recently from 6732c01 to 7bb76dd Compare August 1, 2023 21:37
Copy link
Member

@vasharma05 vasharma05 left a 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: '',
Copy link
Member

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
Copy link
Member

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"

Copy link
Member

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: '',
Copy link
Member

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(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return deleteData(
return postData(

Copy link
Contributor Author

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: '',
Copy link
Member

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.

@jwnasambu jwnasambu marked this pull request as ready for review August 8, 2023 11:33
@jwnasambu
Copy link
Contributor Author

@ibacher Kindly free to review the proposed changes on this PR please!

@jwnasambu jwnasambu marked this pull request as draft August 16, 2023 14:09
@jwnasambu jwnasambu marked this pull request as ready for review August 16, 2023 16:08
ariaLabel={`Remove patient from the ${cohortName} list`}
size={desktopLayout ? 'sm' : 'lg'}
flipped>
<ExtensionSlot name={'cohort-member-action-items'} />
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<ExtensionSlot name={'cohort-member-action-items'} />
<ExtensionSlot name="cohort-member-action-items" />

ariaLabel="Remove patient from the list"
size={desktopLayout ? 'sm' : 'lg'}
flipped>
<OverflowMenuItem
Copy link
Member

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?

Comment on lines 70 to 74
id: index,
id: patient.membershipUuid,
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

@jwnasambu
Copy link
Contributor Author

@ibacher thanks for the review and your time! I will fix it shortly am in the middle of another ticket.

@denniskigen denniskigen changed the title (fix)O3-2197:Unable to remove a patient from a list (fix)O3-2197: Unable to remove a patient from a list Sep 21, 2023
@jwnasambu jwnasambu marked this pull request as draft October 3, 2023 13:41
@jwnasambu jwnasambu marked this pull request as draft October 3, 2023 13:41
@jwnasambu jwnasambu marked this pull request as draft October 3, 2023 13:41
@jwnasambu jwnasambu force-pushed the (fix)O3-2197 branch 2 times, most recently from a5cf005 to 4ad40f2 Compare October 3, 2023 13:54
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.

6 participants