예제 #1
0
        public async Task <Guid> CreateUnsavedQueryAsync(PatientCohort cohort, IUserContext user)
        {
            var nonce = NonceOrThrowIfNull(user);

            using (var cn = new SqlConnection(dbOptions.ConnectionString))
            {
                await cn.OpenAsync();

                var queryId = await cn.ExecuteScalarAsync <Guid>(
                    queryCreateUnsaved,
                    new { user = user.UUID, nonce },
                    commandType : CommandType.StoredProcedure,
                    commandTimeout : dbOptions.DefaultTimeout
                    );

                if (cohort.Any() && cohort.Count <= cohortOptions.RowLimit)
                {
                    var cohortTable = new PatientCohortTable(queryId, cohort.SeasonedPatients(cohortOptions.ExportLimit, queryId));

                    using (var bc = new SqlBulkCopy(cn))
                    {
                        bc.DestinationTableName = PatientCohortTable.Table;

                        await bc.WriteToServerAsync(cohortTable.Rows);
                    }
                }

                return(queryId);
            }
        }
예제 #2
0
 public void Any_Returns_False_If_There_Are_No_PatientIds()
 {
     Assert.False(emptyPatCohort.Any());
 }
예제 #3
0
 public void Any_Returns_True_If_There_Are_PatientIds()
 {
     Assert.True(patCohort.Any());
 }