private static Func<OperationOutcome> createValidatorForTypeRef(Validator validator, ScopedNavigator instance, ElementDefinition.TypeRefComponent tr)
 {
     // In STU3, we need to do BOTH
     // First, call Validate() against the profile (which is then a profile on Reference) THEN validate the referenced resource
     if (tr.Code == FHIRDefinedType.Reference)
         return () => validator.ValidateResourceReference(instance, tr);
     else
         return () => validator.Validate(instance,tr.GetDeclaredProfiles(), statedCanonicals: null, statedProfiles: null);
 }