@Override
  protected void validateResourceForStorage(
      QuestionnaireResponse theResource, ResourceTable theEntityToSave) {
    super.validateResourceForStorage(theResource, theEntityToSave);
    if (!myValidateResponses) {
      return;
    }

    QuestionnaireResponse qa = (QuestionnaireResponse) theResource;
    if (qa == null
        || qa.getQuestionnaire() == null
        || qa.getQuestionnaire().getReference() == null
        || qa.getQuestionnaire().getReference().isEmpty()) {
      return;
    }

    FhirValidator val = myRefImplCtx.newValidator();
    val.setValidateAgainstStandardSchema(false);
    val.setValidateAgainstStandardSchematron(false);

    FhirQuestionnaireResponseValidator module = new FhirQuestionnaireResponseValidator();
    module.setResourceLoader(new JpaResourceLoader());
    val.registerValidatorModule(module);

    ValidationResult result =
        val.validateWithResult(
            myRefImplCtx
                .newJsonParser()
                .parseResource(getContext().newJsonParser().encodeResourceToString(qa)));
    if (!result.isSuccessful()) {
      IBaseOperationOutcome oo =
          getContext()
              .newJsonParser()
              .parseResource(
                  OperationOutcome.class,
                  myRefImplCtx.newJsonParser().encodeResourceToString(result.toOperationOutcome()));
      throw new UnprocessableEntityException(getContext(), oo);
    }
  }