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

healthcare: add search study by tags #1015

Merged
merged 4 commits into from
Oct 14, 2019

Conversation

noerog
Copy link
Collaborator

@noerog noerog commented Oct 10, 2019

No description provided.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 10, 2019
Copy link
Contributor

@tbpg tbpg left a comment

Choose a reason for hiding this comment

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

This is slick. We considered adding this option directly to the client library package, but were hoping for a cleaner solution. This is definitely a good workaround in the meantime (forever?) since it's better than nothing.

@broady and @jadekler, should we add a query param option? We decided against it a while back. I think this is the only API that would use it since the Healthcare API conforms to an external spec -- it's not a normal GCP API. But, it might be nice to avoid having to do this every time you want to call one of the Healthcare endpoints that requires query parameters.


// Create a struct to append the query parameter because the library does not currently
// natively support this.
type queryParam struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Name this queryParamOpt or queryParamOption?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed to queryParamOpt.

healthcare "google.golang.org/api/healthcare/v1beta1"
)

// Create a struct to append the query parameter because the library does not currently
Copy link
Contributor

Choose a reason for hiding this comment

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

Please start the comment with the thing being described.

Something like:

// queryParam is an googleapi.Option (https://godoc.org/google.golang.org/api/googleapi#CallOption) which adds query parameters to an API call.

A link to what interface this is fulfilling also seems helpful.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

// Refine your search by appending DICOM tags to the
// request in the form of query parameters. This sample
// searches for studies containing a patient's name.
resp, err := call.Do(queryParam{"PatientName", "Sally Zhang"})
Copy link
Contributor

Choose a reason for hiding this comment

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

It's generally good practice to include the struct field names when initializing a struct. This is probably OK since it's in the same package, but it might be slightly more clear/less error prone to do:

patientName := queryParam{key: "PatientName", value: "Sally Zhang"}
resp, err := call.Do(patientName)

(Or inline if it doesn't seem too long.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

return fmt.Errorf("Get: %v", err)
}

fmt.Fprintf(w, "Found studies: %+v\n", resp)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we print this more nicely since it's just an http.Response (https://godoc.org/net/http#Response)? Any expectations about the format? Check the status code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@jeanbza
Copy link
Contributor

jeanbza commented Oct 11, 2019

This is slick. We considered adding this option directly to the client library package, but were hoping for a cleaner solution. This is definitely a good workaround in the meantime (forever?) since it's better than nothing.

@broady and @jadekler, should we add a query param option? We decided against it a while back. I think this is the only API that would use it since the Healthcare API conforms to an external spec -- it's not a normal GCP API. But, it might be nice to avoid having to do this every time you want to call one of the Healthcare endpoints that requires query parameters.

Sorry, pretty out of the loop. Is there a relevant part of this CL I can look at? And, could you link to the historical context you're referencing?

@tbpg
Copy link
Contributor

tbpg commented Oct 11, 2019

Sorry, pretty out of the loop. Is there a relevant part of this CL I can look at? And, could you link to the historical context you're referencing?

I looked but can't find a CL. I may have only done it locally. But, this part defines a new Option: https://github.com/GoogleCloudPlatform/golang-samples/pull/1015/files#diff-01edc149e7aa2090350558b0c0bf8970R28. Should we add a QueryParam option to https://godoc.org/google.golang.org/api/googleapi#CallOption?

Copy link
Contributor

@tbpg tbpg left a comment

Choose a reason for hiding this comment

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

Thanks!


package snippets

// [START healthcare_search_studies]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the right region tag? I don't see it in the tracker (might be missing it).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's actually not in the tracker yet, I'll add it now.

@tbpg tbpg merged commit 3039810 into GoogleCloudPlatform:master Oct 14, 2019
@noerog noerog deleted the chc-search-tags branch October 14, 2019 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants