Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Fi 601 Pass comma-separated patients to US Core #419

Merged
merged 8 commits into from
Jan 24, 2020

Conversation

arscan
Copy link
Contributor

@arscan arscan commented Jan 21, 2020

Pass a comma separated list of patients to US Core. A few loose ends need fixing, and unit tests need to be updated. For discussion. FYI @czh-orz @Jammjammjamm

Submitter:

  • This pull request describes why these changes were made
  • Internal ticket for this PR:
  • Internal ticket links to this PR
  • Internal ticket is properly labeled (Community/Program)
  • Internal ticket has a justification for its Community/Program label
  • Code diff has been reviewed for extraneous/missing code
  • Tests are included and test edge cases
  • Tests/code quality metrics have been run locally and pass

Reviewer 1:

Name:

  • Code is maintainable and reusable, reuses existing code and infrastructure
    where appropriate, and accomplishes the task's purpose
  • The tests appropriately test the new code, including edge cases
  • You have tried to break the code

Reviewer 2:

Name:

  • Code is maintainable and reusable, reuses existing code and infrastructure
    where appropriate, and accomplishes the task's purpose
  • The tests appropriately test the new code, including edge cases
  • You have tried to break the code

@arscan arscan added the WIP Work in progress label Jan 21, 2020
@arscan arscan changed the title Fi 601 mutli patient uscore Fi 601 Pass comma-separated patients to US Core Jan 21, 2020
Copy link
Contributor

@Jammjammjamm Jammjammjamm left a comment

Choose a reason for hiding this comment

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

I think this is a reasonable approach.


revinclude_test[:test_code] += %(
end
skip 'No Provenance resources were returned from this search' unless any_provenances
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to use our skip_unless helper wherever possible.

revinclude_test[:test_code] = %(
any_provenances = false
could_not_resolve_all = []
resolved_one = false
Copy link
Contributor

Choose a reason for hiding this comment

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

These aren't always needed, for example in the AllergyIntolerance sequence.

@@ -250,10 +258,17 @@ def create_revinclude_test(sequence)
assert_response_ok(reply)
assert_bundle_response(reply)
#{resource_variable} = fetch_all_bundled_resources(reply.resource).select { |resource| resource.resourceType == '#{resource_name}'}
skip 'No #{resource_name} resources were returned from this search' unless #{resource_variable}.present?
any_provenances ||= provenance_results.present?
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 break out of the iteration once we've found some?

search_test[:test_code] =
if is_first_search
# rcs question: are comparators ever be in the first search?
Copy link
Contributor

Choose a reason for hiding this comment

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

They are not currently and I'd say they are unlikely to be in the future.

generator/uscore/uscore_generator.rb Outdated Show resolved Hide resolved
revinclude_test[:test_code] = search_params
revinclude_test[:test_code] = %(
any_provenances = false
could_not_resolve_all = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be given a more clear name? Maybe something along the lines of required_search_params?

reply = get_resource_by_params(versioned_resource_class('#{sequence[:resource]}'), search_params)
assert_response_ok(reply)
assert_bundle_response(reply)
@#{sequence[:resource].underscore}_ary = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is now a hash, I'd love it if it wasn't named *_ary. The US Core resources work out so that *s works as a plural for them all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering if this would make more sense, and quickly scanned to see if we could just replace with 's'. But I didn't end up doing it because it is easy to drop an s in places by mistake in the generator. But I can readd.

@@ -1,46 +0,0 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

These fixtures are not generated and need to be restored.

conformance_supports :<%=resource%><%="
delayed_sequence" if delayed_sequence%>
<%=search_validator%>
details %(
The #{title} Sequence tests `#{title.gsub(/\s+/, '')}` resources associated with the provided patient.
)

def patient_ids
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this go in SequenceBase? I know putting more stuff in SequnceBase is unfortunate, but I think it makes sense since this method seems necessary to support the new field in TestingInstance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so -- to me it is a matter of scope. Should all tests everywhere need access to this method? I don't think so. Yeah it's unfortunate that all testing instances will have this field, but hopefully we can fix that at some point.

@@ -759,7 +816,7 @@ def get_search_param_hash(search_parameters, sequence, grab_first_value = false)
search_parameters.each_with_object({}) do |param, params|
params[param] =
if param == 'patient'
'@instance.patient_id'
'patient'
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hah, we should just remove it. I didn't look too closely at the logic, was doing a replace any time we are doing @instance.patient_id because they are now in a loop block where patient is defined.

style fix for block

Co-Authored-By: Stephen MacVicar <Jammjammjamm@users.noreply.github.com>
reply = get_resource_by_params(versioned_resource_class('#{sequence[:resource]}'), search_params)
assert_response_ok(reply)
assert_bundle_response(reply)
could_not_resolve_all = []
Copy link

Choose a reason for hiding this comment

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

We don't need the resolved_one logic in any of the first searches because we're not resolving the values from the resources. They're all either just patient or patient + some fixed value.

@ghost
Copy link

ghost commented Jan 23, 2020

I think the only thing that needs to loop through patients are the first searches for patient-based resources. Once all the resources are in the array, we can use resolve_element_from_path to look through all the resources. Then pretty much nothing else has to change I think.

@arscan
Copy link
Contributor Author

arscan commented Jan 24, 2020

Note: temporarily removed the generated unit tests because major refactor needed. We have decided to go this route though so our plan is to merge to allow end-to-end tests with other downstream updates and backfill unit tests to catch edge cases over the coming weeks.

@arscan arscan merged commit a2ffbde into development Jan 24, 2020
@arscan arscan deleted the FI-601-mutli-patient-uscore branch January 24, 2020 20:04
@radamson radamson mentioned this pull request Aug 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants