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

Change the -package operation to put each Questionnaire and it's resources into separate Bundles. #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ public String execute(String resourceString, String questionnaireId) {
return null;
}

// create a single new bundle for all of the resources
Bundle completeBundle = new Bundle();
// create the bundle that will contain all of the bundles for each questionnaire
Bundle outerBundle = new Bundle();

// list of items in bundle to avoid duplicates
List<String> bundleContents = new ArrayList<>();
if (questionnaireId == null) {
// process the orders to find the topics
FhirBundleProcessor fhirBundleProcessor = new FhirBundleProcessor(fileStore, baseUrl);
Expand All @@ -93,23 +91,34 @@ public String execute(String resourceString, String questionnaireId) {
Bundle bundle = fileStore.getFhirResourcesByTopicAsFhirBundle("R4", "Questionnaire", topic.toLowerCase(), baseUrl);
List<BundleEntryComponent> bundleEntries = bundle.getEntry();
for (BundleEntryComponent entry : bundleEntries) {
processResource(entry.getResource(), bundleContents, completeBundle);
Bundle newBundle = new Bundle();
// list of items in bundle to avoid duplicates
List<String> bundleContents = new ArrayList<>();
processResource(entry.getResource(), bundleContents, newBundle);
addResourceToBundle(newBundle, bundleContents, outerBundle);
} // Questionnaires
} // topics
} else {
// get only the specified Questionnaire
Resource questionnaireResource = fileStore.getFhirResourceByIdAsFhirResource("R4", "Questionnaire", questionnaireId, baseUrl);
if (questionnaireResource != null) {
processResource(questionnaireResource, bundleContents, completeBundle);
/* TODO: The single requested Questionnaire with it's supporting resources are not contained in an outer bundle.
* This should be changed when the Questionnaire is requested via canonical URL instead of ID.
* The DTR app should be able to either handle the a secondary nested Bundle or work in either scenario with or without it.
*/

// list of items in bundle to avoid duplicates
List<String> bundleContents = new ArrayList<>();
processResource(questionnaireResource, bundleContents, outerBundle);
}
}


// add the bundle to the output parameters if it contains any resources
if (!completeBundle.isEmpty()) {
if (!outerBundle.isEmpty()) {
ParametersParameterComponent parameter = new ParametersParameterComponent();
parameter.setName("return");
parameter.setResource(completeBundle);
parameter.setResource(outerBundle);
outputParameters.addParameter(parameter);
} else {
logger.info("No matching Questionnaires found");
Expand Down