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

dataservice family relationship filtering by participant ID returns relationships that don't include the given participant #463

Open
fiendish opened this issue Oct 24, 2018 · 5 comments
Labels
bug Something isn't working

Comments

@fiendish
Copy link
Contributor

fiendish commented Oct 24, 2018

https://kf-api-dataservice.kidsfirstdrc.org/family-relationships?participant_id=PT_43KBFVQ3&limit=1

returns (neither participant matches the requested one)
{
_links: {
self: "/family-relationships"
},
_status: {
code: 200,
message: "success"
},
limit: 1,
results: [
{
_links: {
collection: "/family-relationships",
participant1: "/participants/PT_F76RVQ1J",
participant2: "/participants/PT_9A61PCYB",
self: "/family-relationships/FR_N23TR0NB"
},
created_at: "2018-06-12T14:51:15.589638+00:00",
external_id: null,
kf_id: "FR_N23TR0NB",
modified_at: "2018-06-12T14:51:15.589643+00:00",
participant1_to_participant2_relation: "Mother",
participant2_to_participant1_relation: "Child",
source_text_notes: null,
visible: true
}
],
total: 2
}

@fiendish fiendish changed the title dataservice family relationship filtering by participant ID is broken dataservice family relationship filtering by participant ID returns relationships that don't include the given participant Oct 24, 2018
@fiendish fiendish added the bug Something isn't working label Oct 24, 2018
@dankolbman
Copy link
Contributor

participant_id isn't a field on the family-relationships model. I think the problem here is that we are not verbose about filters that are invalid and return all results by default.

You could probably get what you want with this query:
https://kf-api-dataservice.kidsfirstdrc.org/family-relationships?participant1_id=PT_43KBFVQ3&limit=1

@fiendish
Copy link
Contributor Author

fiendish commented Oct 24, 2018

@dankolbman It does filter though, as evidenced by getting total: 2 vs a much higher number. I think this is intended to be a filter, but it's giving the wrong family members (I think from the right family).

@dankolbman
Copy link
Contributor

Hm I see. It looks like participant_id is a special filter that tries to get all relationships for the given participant. There may be an error in this function here https://github.com/kids-first/kf-api-dataservice/blob/master/dataservice/api/family_relationship/models.py#L79 @znatty22

@znatty22
Copy link
Member

Yea I remember this was intentional, but it is a little confusing. We had requests for getting back all the family relationships for a participant and its family members. So this filter returns relationships for the participant and the participant's family members - https://github.com/kids-first/kf-api-dataservice/blob/f4805a7b17f3b8b80c1daa938e897dcd9434610f/dataservice/api/family_relationship/models.py#L87

@fiendish
Copy link
Contributor Author

shouldn't that use a family id, then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants