Skip to content

Commit

Permalink
Merge b2107ba into f766156
Browse files Browse the repository at this point in the history
  • Loading branch information
hdconradi committed Apr 3, 2018
2 parents f766156 + b2107ba commit b62c6aa
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
Expand Up @@ -1563,9 +1563,12 @@ private void checkReference(ValidatorHostContext hostContext, List<ValidationMes

if (pol.checkExists()) {
if (we == null) {
if (fetcher == null)
throw new FHIRException("Resource resolution services not provided");
we = fetcher.fetch(hostContext.appContext, ref);
if (fetcher == null) {
if (!refType.equals("contained"))
throw new FHIRException("Resource resolution services not provided");
} else {
we = fetcher.fetch(hostContext.appContext, ref);
}
}
rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, we != null, "Unable to resolve resource '"+ref+"'");
}
Expand Down
Expand Up @@ -17,12 +17,16 @@
import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus;
import org.hl7.fhir.dstu3.model.Observation.ObservationStatus;
import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent;
import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType;
import org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent;
import org.hl7.fhir.dstu3.utils.FHIRPathEngine;
import org.hl7.fhir.instance.model.api.IBaseResource;

import org.junit.*;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
Expand Down Expand Up @@ -737,6 +741,25 @@ public void testValidateReferenceWithIdentifierValid() {
assertThat(nonInfo, empty());
}

/**
* An invalid local reference should not cause a ServiceException.
*/
@Test
public void testInvalidLocalReference() {
Questionnaire resource = new Questionnaire();
resource.setStatus(PublicationStatus.ACTIVE);

QuestionnaireItemComponent item = new QuestionnaireItemComponent();
item.setLinkId("linkId-1");
item.setType(QuestionnaireItemType.CHOICE);
item.setOptions(new Reference("#invalid-ref"));
resource.addItem(item);

ValidationResult output = myVal.validateWithResult(resource);
List<SingleValidationMessage> nonInfo = logResultsAndReturnNonInformationalOnes(output);
assertThat(nonInfo, hasSize(2));
}

/**
* See #370
*/
Expand Down
Expand Up @@ -68,6 +68,21 @@ private void addValidConcept(String theSystem, String theCode) {
myValidConcepts.add(theSystem + "___" + theCode);
}

/**
* An invalid local reference should not cause a ServiceException.
*/
@Test
public void testInvalidLocalReference() {
QuestionnaireResponse resource = new QuestionnaireResponse();
resource.setStatus(QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED);

resource.setSubject(new Reference("#invalid-ref"));

ValidationResult output = myVal.validateWithResult(resource);
List<SingleValidationMessage> nonInfo = logResultsAndReturnNonInformationalOnes(output);
assertThat(nonInfo, hasSize(2));
}

@SuppressWarnings("unchecked")
@Before
public void before() {
Expand Down

0 comments on commit b62c6aa

Please sign in to comment.