Skip to content

Commit

Permalink
issue #2556 - add the conditional reference that failed to the error
Browse files Browse the repository at this point in the history
details

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
  • Loading branch information
lmsurpre committed Sep 15, 2021
1 parent 5ced2c6 commit c2ff06d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public void testBundleTransactionInvalidConditionalReferenceNoQueryParameters()

OperationOutcome outcome = response.readEntity(OperationOutcome.class);
assertEquals(outcome.getIssue().get(0).getCode(), IssueType.INVALID);
assertEquals(outcome.getIssue().get(0).getDetails().getText().getValue(), "Invalid conditional reference: no query parameters found");
assertTrue(outcome.getIssue().get(0).getDetails().getText().getValue().startsWith("Invalid conditional reference:") &&
outcome.getIssue().get(0).getDetails().getText().getValue().endsWith("no query parameters found"));
}

@Test(dependsOnMethods = { "testCreatePatients" })
Expand Down Expand Up @@ -133,7 +134,8 @@ public void testBundleTransactionInvalidConditionalReferenceResultParameter() th

OperationOutcome outcome = response.readEntity(OperationOutcome.class);
assertEquals(outcome.getIssue().get(0).getCode(), IssueType.INVALID);
assertEquals(outcome.getIssue().get(0).getDetails().getText().getValue(), "Invalid conditional reference: only filtering parameters are allowed");
assertTrue(outcome.getIssue().get(0).getDetails().getText().getValue().startsWith("Invalid conditional reference:") &&
outcome.getIssue().get(0).getDetails().getText().getValue().endsWith("only filtering parameters are allowed"));
}

@Test(dependsOnMethods = { "testCreatePatients" })
Expand Down Expand Up @@ -161,7 +163,9 @@ public void testBundleTransactionConditionalReferenceNoResult() throws Exception

OperationOutcome outcome = response.readEntity(OperationOutcome.class);
assertEquals(outcome.getIssue().get(0).getCode(), IssueType.NOT_FOUND);
assertEquals(outcome.getIssue().get(0).getDetails().getText().getValue(), "Error resolving conditional reference: search returned no results");

assertTrue(outcome.getIssue().get(0).getDetails().getText().getValue().startsWith("Error resolving conditional reference:") &&
outcome.getIssue().get(0).getDetails().getText().getValue().endsWith("returned no results"));
}

@Test(dependsOnMethods = { "testCreatePatients" })
Expand Down Expand Up @@ -189,7 +193,8 @@ public void testBundleTransactionConditionalReferenceMultipleMatches() throws Ex

OperationOutcome outcome = response.readEntity(OperationOutcome.class);
assertEquals(outcome.getIssue().get(0).getCode(), IssueType.MULTIPLE_MATCHES);
assertEquals(outcome.getIssue().get(0).getDetails().getText().getValue(), "Error resolving conditional reference: search returned multiple results");
assertTrue(outcome.getIssue().get(0).getDetails().getText().getValue().startsWith("Error resolving conditional reference:") &&
outcome.getIssue().get(0).getDetails().getText().getValue().endsWith("returned multiple results"));
}

private Patient buildPatient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2180,11 +2180,13 @@ private void resolveConditionalReferences(Resource resource, Map<String, String>
int total = bundle.getTotal().getValue();

if (total == 0) {
throw buildRestException("Error resolving conditional reference: search returned no results", IssueType.NOT_FOUND);
throw buildRestException("Error resolving conditional reference: search '" + Encode.forHtml(conditionalReference) +
"' returned no results", IssueType.NOT_FOUND);
}

if (total > 1) {
throw buildRestException("Error resolving conditional reference: search returned multiple results", IssueType.MULTIPLE_MATCHES);
throw buildRestException("Error resolving conditional reference: search '" + Encode.forHtml(conditionalReference) +
"' returned multiple results", IssueType.MULTIPLE_MATCHES);
}

localRefMap.put(conditionalReference, type + "/" + bundle.getEntry().get(0).getResource().getId());
Expand Down Expand Up @@ -3270,8 +3272,8 @@ private List<Issue> validateResource(Resource resource) throws FHIRValidationExc
}
}

if (log.isLoggable(Level.FINE)) {
log.fine("Required profile list: " + profiles);
if (log.isLoggable(Level.FINER)) {
log.finer("Required profile list: " + profiles);
}

// Build the list of profiles that didn't specify a version
Expand Down

0 comments on commit c2ff06d

Please sign in to comment.