diff --git a/README.md b/README.md index 7aaac36..93cddde 100644 --- a/README.md +++ b/README.md @@ -72,21 +72,21 @@ __Install directly in Package Manager Console or Command Line Interface__ ```C# Package Manager -Install-Package RedcapAPI -Version 1.3.6 +Install-Package RedcapAPI -Version 1.3.7 ``` ```C# .NET CLI -dotnet add package RedcapAPI --version 1.3.6 +dotnet add package RedcapAPI --version 1.3.7 ``` ```C# Paket CLI -paket add RedcapAPI --version 1.3.6 +paket add RedcapAPI --version 1.3.7 ``` diff --git a/RedcapApi.Tests/RedcapApi.Tests.csproj b/RedcapApi.Tests/RedcapApi.Tests.csproj index c63f825..39707f7 100644 --- a/RedcapApi.Tests/RedcapApi.Tests.csproj +++ b/RedcapApi.Tests/RedcapApi.Tests.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -14,10 +14,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/RedcapApi/Api/RedcapApi.cs b/RedcapApi/Api/RedcapApi.cs index 72a6f3c..c25f395 100644 --- a/RedcapApi/Api/RedcapApi.cs +++ b/RedcapApi/Api/RedcapApi.cs @@ -82,7 +82,7 @@ public RedcapApi(string redcapApiUrl, bool useInsecureCertificates = false) /// an array of arm numbers that you wish to pull events for (by default, all events are pulled) /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Arms for the project in the format specified(only ones with Events available) public async Task ExportArmsAsync(string token, RedcapFormat format = RedcapFormat.json, string[] arms = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -97,9 +97,9 @@ public async Task ExportArmsAsync(string token, RedcapFormat format = Re { "format", format.GetDisplayName() } }; // Optional - if (arms?.Length > 0) + if(arms?.Length > 0) { - for (var i = 0; i < arms.Length; i++) + for(var i = 0; i < arms.Length; i++) { payload.Add($"arms[{i}]", arms[i]); } @@ -110,7 +110,7 @@ public async Task ExportArmsAsync(string token, RedcapFormat format = Re // Execute send request return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -147,9 +147,9 @@ public async Task ExportArmsAsync(string token, Content content = Conten { "format", format.GetDisplayName() } }; // Optional - if (arms?.Length > 0) + if(arms?.Length > 0) { - for (var i = 0; i < arms.Length; i++) + for(var i = 0; i < arms.Length; i++) { payload.Add($"arms[{i}]", arms[i]); } @@ -160,7 +160,7 @@ public async Task ExportArmsAsync(string token, Content content = Conten // Execute send request return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -214,7 +214,7 @@ public async Task ImportArmsAsync(string token, Override overrideBhav }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -268,7 +268,7 @@ public async Task ImportArmsAsync(string token, Content content, Over }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -322,7 +322,7 @@ public async Task ImportArmsAsync(string token, Content content, Over }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -351,7 +351,7 @@ public async Task DeleteArmsAsync(string token, string[] arms, Cancellat { this.CheckToken(token); - if (arms.Length < 1) + if(arms.Length < 1) { throw new InvalidOperationException($"No arm to delete, please specify arm"); } @@ -362,14 +362,14 @@ public async Task DeleteArmsAsync(string token, string[] arms, Cancellat { "action", RedcapAction.Delete.GetDisplayName() } }; // Required - for (var i = 0; i < arms.Length; i++) + for(var i = 0; i < arms.Length; i++) { payload.Add($"arms[{i}]", arms[i]); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -401,7 +401,7 @@ public async Task DeleteArmsAsync(string token, Content content = Conten { this.CheckToken(token); - if (arms.Length < 1) + if(arms.Length < 1) { throw new InvalidOperationException($"No arm to delete, please specify arm"); } @@ -412,14 +412,14 @@ public async Task DeleteArmsAsync(string token, Content content = Conten { "action", action.GetDisplayName() } }; // Required - for (var i = 0; i < arms.Length; i++) + for(var i = 0; i < arms.Length; i++) { payload.Add($"arms[{i}]", arms[i]); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -460,7 +460,7 @@ public async Task ExportDagsAsync(string token, Content content = Conten exportDagsResults = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return exportDagsResults; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return exportDagsResults; @@ -494,7 +494,7 @@ public async Task ExportDagsAsync(string token, Content content = Conten /// /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of DAGs added or updated public async Task ImportDagsAsync(string token, Content content, RedcapAction action, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -516,7 +516,7 @@ public async Task ImportDagsAsync(string token, Content content, Redc importDagsResults = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return importDagsResults; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return importDagsResults; @@ -535,7 +535,7 @@ public async Task ImportDagsAsync(string token, Content content, Redc /// delete /// an array of unique group names that you wish to delete /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of DAGs deleted public async Task DeleteDagsAsync(string token, Content content, RedcapAction action, string[] dags, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -544,7 +544,7 @@ public async Task DeleteDagsAsync(string token, Content content, RedcapA { this.CheckToken(token); - if (dags.Length < 1) + if(dags.Length < 1) { throw new InvalidOperationException($"No dags to delete."); } @@ -555,14 +555,14 @@ public async Task DeleteDagsAsync(string token, Content content, RedcapA { "action", action.GetDisplayName() } }; // Required - for (var i = 0; i < dags.Length; i++) + for(var i = 0; i < dags.Length; i++) { payload.Add($"dags[{i}]", dags[i]); } deleteDagsResult = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return deleteDagsResult; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return deleteDagsResult; @@ -601,7 +601,7 @@ public async Task SwitchDagAsync(string token, RedcapDag dag, Content co switchDagResult = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return switchDagResult; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return switchDagResult; @@ -639,7 +639,7 @@ public async Task ExportUserDagAssignmentAsync(string token, Content con exportUserDagAssignmentResult = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return exportUserDagAssignmentResult; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return exportUserDagAssignmentResult; @@ -684,7 +684,7 @@ public async Task ImportUserDagAssignmentAsync(string token, Content if(data.Count < 1) { throw new InvalidOperationException($"No data to import, please specify data to import."); - } + } var _serializedData = JsonConvert.SerializeObject(data); var payload = new Dictionary @@ -698,7 +698,7 @@ public async Task ImportUserDagAssignmentAsync(string token, Content }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return ImportUserDagAssignmentResults; @@ -733,7 +733,7 @@ public async Task ExportEventsAsync(string token, RedcapFormat format, s { this.CheckToken(token); - if (arms.Length < 1) + if(arms.Length < 1) { throw new InvalidOperationException($"Please specify the arm you wish to export the events from."); } @@ -745,9 +745,9 @@ public async Task ExportEventsAsync(string token, RedcapFormat format, s { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (arms?.Length > 0) + if(arms?.Length > 0) { - for (var i = 0; i < arms.Length; i++) + for(var i = 0; i < arms.Length; i++) { payload.Add($"arms[{i}]", arms[i]); @@ -755,7 +755,7 @@ public async Task ExportEventsAsync(string token, RedcapFormat format, s } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -788,10 +788,10 @@ public async Task ExportEventsAsync(string token, Content content, Redca { this.CheckToken(token); - if (arms.Length < 1) + if(arms.Length < 1) { throw new InvalidOperationException($"Please specify the arm you wish to export the events from."); - } + } var payload = new Dictionary { @@ -801,9 +801,9 @@ public async Task ExportEventsAsync(string token, Content content, Redca { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (arms?.Length > 0) + if(arms?.Length > 0) { - for (var i = 0; i < arms.Length; i++) + for(var i = 0; i < arms.Length; i++) { payload.Add($"arms[{i}]", arms[i]); @@ -811,7 +811,7 @@ public async Task ExportEventsAsync(string token, Content content, Redca } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -849,7 +849,7 @@ public async Task ImportEventsAsync(string token, Override overRideBe { this.CheckToken(token); - if (data.Count < 1) + if(data.Count < 1) { throw new ArgumentNullException($"Events can not be empty or null"); } @@ -866,7 +866,7 @@ public async Task ImportEventsAsync(string token, Override overRideBe }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -906,7 +906,7 @@ public async Task ImportEventsAsync(string token, Content content, Re { this.CheckToken(token); - if (data.Count < 1) + if(data.Count < 1) { throw new ArgumentNullException($"Events can not be empty or null"); } @@ -923,7 +923,7 @@ public async Task ImportEventsAsync(string token, Content content, Re }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -953,7 +953,7 @@ public async Task DeleteEventsAsync(string token, string[] events, Cance { this.CheckToken(token); - if (events.Length < 1) + if(events.Length < 1) { throw new InvalidOperationException($"No events to delete..."); } @@ -965,9 +965,9 @@ public async Task DeleteEventsAsync(string token, string[] events, Cance { "action", RedcapAction.Delete.GetDisplayName() } }; // Required - if (events?.Length > 0) + if(events?.Length > 0) { - for (var i = 0; i < events.Length; i++) + for(var i = 0; i < events.Length; i++) { payload.Add($"events[{i}]", events[i]); @@ -975,7 +975,7 @@ public async Task DeleteEventsAsync(string token, string[] events, Cance } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1000,7 +1000,7 @@ public async Task DeleteEventsAsync(string token, string[] events, Cance /// delete /// Array of unique event names /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of Events deleted public async Task DeleteEventsAsync(string token, Content content, RedcapAction action, string[] events, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1008,7 +1008,7 @@ public async Task DeleteEventsAsync(string token, Content content, Redca { this.CheckToken(token); - if (events.Length < 1) + if(events.Length < 1) { throw new InvalidOperationException($"No events to delete..."); } @@ -1020,9 +1020,9 @@ public async Task DeleteEventsAsync(string token, Content content, Redca { "action", action.GetDisplayName() } }; // Required - if (events?.Length > 0) + if(events?.Length > 0) { - for (var i = 0; i < events.Length; i++) + for(var i = 0; i < events.Length; i++) { payload.Add($"events[{i}]", events[i]); @@ -1030,7 +1030,7 @@ public async Task DeleteEventsAsync(string token, Content content, Redca } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1060,7 +1060,7 @@ public async Task DeleteEventsAsync(string token, Content content, Redca /// csv, json [default], xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// The list that is returned will contain the original field name (variable) of the field and also the export field name(s) of that field. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns a list of the export/import-specific version of field names for all fields (or for one field, if desired) in a project in the format specified and ordered by their field order . /// The list that is returned will contain the three following attributes for each field/choice: 'original_field_name', 'choice_value', and 'export_field_name'. The choice_value attribute represents the raw coded value for a checkbox choice. For non-checkbox fields, the choice_value attribute will always be blank/empty. The export_field_name attribute represents the export/import-specific version of that field name. /// @@ -1078,20 +1078,19 @@ public async Task ExportFieldNamesAsync(string token, RedcapFormat forma { "returnFormat", returnFormat.GetDisplayName() } }; - if (!IsNullOrEmpty(field)) + if(!IsNullOrEmpty(field)) { payload.Add("field", field); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; } } - /// /// Export List of Export Field Names (i.e. variables used during exports and imports)

/// @@ -1114,7 +1113,7 @@ public async Task ExportFieldNamesAsync(string token, RedcapFormat forma /// csv, json [default], xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// The list that is returned will contain the original field name (variable) of the field and also the export field name(s) of that field. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns a list of the export/import-specific version of field names for all fields (or for one field, if desired) in a project in the format specified and ordered by their field order . /// The list that is returned will contain the three following attributes for each field/choice: 'original_field_name', 'choice_value', and 'export_field_name'. The choice_value attribute represents the raw coded value for a checkbox choice. For non-checkbox fields, the choice_value attribute will always be blank/empty. The export_field_name attribute represents the export/import-specific version of that field name. /// @@ -1132,13 +1131,13 @@ public async Task ExportFieldNamesAsync(string token, Content content = { "returnFormat", returnFormat.GetDisplayName() } }; - if (!IsNullOrEmpty(field)) + if(!IsNullOrEmpty(field)) { payload.Add("field", field); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1170,7 +1169,7 @@ public async Task ExportFieldNamesAsync(string token, Content content = /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'. /// File path which the file will be saved. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// the contents of the file public async Task ExportFileAsync(string token, string record, string field, string eventName, string repeatInstance = "1", RedcapReturnFormat returnFormat = RedcapReturnFormat.json, string filePath = null, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1178,27 +1177,27 @@ public async Task ExportFileAsync(string token, string record, string fi { this.CheckToken(token); - if (IsNullOrEmpty(filePath)) + if(IsNullOrEmpty(filePath)) { throw new ArgumentNullException($"Must contain a file path to save the file."); } /* * FilePath check.. */ - if (!Directory.Exists(filePath) && !IsNullOrEmpty(filePath)) + if(!Directory.Exists(filePath) && !IsNullOrEmpty(filePath)) { Log.Warning($"The directory provided does not exist! Creating a folder for you."); Directory.CreateDirectory(filePath); } - if (IsNullOrEmpty(record)) + if(IsNullOrEmpty(record)) { throw new ArgumentNullException($"No record provided to export"); } - if (IsNullOrEmpty(field) || IsNullOrEmpty(eventName)) + if(IsNullOrEmpty(field) || IsNullOrEmpty(eventName)) { throw new ArgumentNullException($"No field provided to export"); } - if (IsNullOrEmpty(eventName)) + if(IsNullOrEmpty(eventName)) { throw new ArgumentNullException($"No eventName provided to export"); } @@ -1215,7 +1214,7 @@ public async Task ExportFileAsync(string token, string record, string fi }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1247,7 +1246,7 @@ public async Task ExportFileAsync(string token, string record, string fi /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'. /// File path which the file will be saved. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// the file name that was exported public async Task ExportFileAsync(string token, Content content, RedcapAction action, string record, string field, string eventName, string repeatInstance = "1", RedcapReturnFormat onErrorFormat = RedcapReturnFormat.json, string filePath = null, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1255,14 +1254,14 @@ public async Task ExportFileAsync(string token, Content content, RedcapA { this.CheckToken(token); - if (IsNullOrEmpty(filePath)) + if(IsNullOrEmpty(filePath)) { throw new ArgumentNullException($"Must contain a file path to save the file."); } /* * FilePath check.. */ - if (!Directory.Exists(filePath) && !IsNullOrEmpty(filePath)) + if(!Directory.Exists(filePath) && !IsNullOrEmpty(filePath)) { Log.Warning($"The directory provided does not exist! Creating a folder for you."); Directory.CreateDirectory(filePath); @@ -1279,13 +1278,13 @@ public async Task ExportFileAsync(string token, Content content, RedcapA { "filePath", $@"{filePath}" } }; // Optional - if (!IsNullOrEmpty(repeatInstance)) + if(!IsNullOrEmpty(repeatInstance)) { payload.Add("repeat_instance", repeatInstance); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1309,7 +1308,7 @@ public async Task ExportFileAsync(string token, Content content, RedcapA /// the path where the file is located /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. public async Task ImportFileAsync(string token, string record, string field, string eventName, string repeatInstance, string fileName, string filePath, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1331,7 +1330,7 @@ public async Task ImportFileAsync(string token, string record, string fi {new StringContent(eventName), "event" }, {new StringContent(returnFormat.GetDisplayName()), "returnFormat" } }; - if (!IsNullOrEmpty(repeatInstance)) + if(!IsNullOrEmpty(repeatInstance)) { // add repeat instrument params if available payload.Add(new StringContent(repeatInstance), "repeat_instance"); @@ -1341,7 +1340,7 @@ public async Task ImportFileAsync(string token, string record, string fi repeatInstance = "1"; payload.Add(new StringContent(repeatInstance), "repeat_instance"); } - if (IsNullOrEmpty(_fileName) || IsNullOrEmpty(_filePath)) + if(IsNullOrEmpty(_fileName) || IsNullOrEmpty(_filePath)) { throw new InvalidOperationException($"file can not be empty or null"); } @@ -1354,7 +1353,7 @@ public async Task ImportFileAsync(string token, string record, string fi } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1380,7 +1379,7 @@ public async Task ImportFileAsync(string token, string record, string fi /// the path where the file is located /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'xml'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. public async Task ImportFileAsync(string token, Content content, RedcapAction action, string record, string field, string eventName, string repeatInstance, string fileName, string filePath, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1402,7 +1401,7 @@ public async Task ImportFileAsync(string token, Content content, RedcapA {new StringContent(eventName), "event" }, {new StringContent(returnFormat.GetDisplayName()), "returnFormat" } }; - if (!IsNullOrEmpty(repeatInstance)) + if(!IsNullOrEmpty(repeatInstance)) { // add repeat instrument params if available payload.Add(new StringContent(repeatInstance), "repeat_instance"); @@ -1413,7 +1412,7 @@ public async Task ImportFileAsync(string token, Content content, RedcapA payload.Add(new StringContent(repeatInstance), "repeat_instance"); } - if (IsNullOrEmpty(_fileName) || IsNullOrEmpty(_filePath)) + if(IsNullOrEmpty(_fileName) || IsNullOrEmpty(_filePath)) { throw new InvalidOperationException($"file can not be empty or null"); @@ -1427,7 +1426,7 @@ public async Task ImportFileAsync(string token, Content content, RedcapA } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1448,7 +1447,7 @@ public async Task ImportFileAsync(string token, Content content, RedcapA /// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// String public async Task DeleteFileAsync(string token, string record, string field, string eventName, string repeatInstance, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1466,7 +1465,7 @@ public async Task DeleteFileAsync(string token, string record, string fi {new StringContent(eventName), "event" }, {new StringContent(returnFormat.GetDisplayName()), "returnFormat" } }; - if (!IsNullOrEmpty(repeatInstance)) + if(!IsNullOrEmpty(repeatInstance)) { // add repeat instrument params if available payload.Add(new StringContent(repeatInstance), "repeat_instance"); @@ -1479,7 +1478,7 @@ public async Task DeleteFileAsync(string token, string record, string fi } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1502,7 +1501,7 @@ public async Task DeleteFileAsync(string token, string record, string fi /// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// String public async Task DeleteFileAsync(string token, Content content, RedcapAction action, string record, string field, string eventName, string repeatInstance, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1520,7 +1519,7 @@ public async Task DeleteFileAsync(string token, Content content, RedcapA {new StringContent(eventName), "event" }, {new StringContent(returnFormat.GetDisplayName()), "returnFormat" } }; - if (!IsNullOrEmpty(repeatInstance)) + if(!IsNullOrEmpty(repeatInstance)) { // add repeat instrument params if available payload.Add(new StringContent(repeatInstance), "repeat_instance"); @@ -1533,7 +1532,7 @@ public async Task DeleteFileAsync(string token, Content content, RedcapA } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1566,7 +1565,7 @@ public async Task DeleteFileAsync(string token, Content content, RedcapA /// the role_id of the User Role to which you wish to restrict access for this folder. If none is provided, the folder will accessible to users in all User Roles and users in no User Roles. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The folder_id of the new folder created in the specified format.
For example, if using format=json, the output would look similar to this: [{folder_id:45}].
public async Task CreateFolderFileRepositoryAsync(string token, Content content, RedcapAction action, string name, RedcapFormat format, string folderId = default, string dagId = default, string roleId = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1574,7 +1573,7 @@ public async Task CreateFolderFileRepositoryAsync(string token, Content { this.CheckToken(token); - if (IsNullOrEmpty(name)) + if(IsNullOrEmpty(name)) { throw new ArgumentNullException("Please provide a valid name for the folder to create in the Repository."); } @@ -1587,21 +1586,21 @@ public async Task CreateFolderFileRepositoryAsync(string token, Content { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (!IsNullOrEmpty(folderId)) + if(!IsNullOrEmpty(folderId)) { payload.Add("folder_id", folderId); } - if (!IsNullOrEmpty(dagId)) + if(!IsNullOrEmpty(dagId)) { payload.Add("dag_id", dagId); } - if (!IsNullOrEmpty(roleId)) + if(!IsNullOrEmpty(roleId)) { payload.Add("role_id", roleId); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1624,7 +1623,7 @@ public async Task CreateFolderFileRepositoryAsync(string token, Content /// the folder_id of a specific folder in the File Repository for which you wish to export a list of its files and sub-folders. If none is provided, the top-level directory of the File Repository will be used. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The list of all files and folders within a given sub-folder in the File Repository in the format specified. public async Task ExportFilesFoldersFileRepositoryAsync(string token, Content content = Content.FileRepository, RedcapAction action = RedcapAction.List, RedcapFormat format = RedcapFormat.json, string folderId = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1641,14 +1640,14 @@ public async Task ExportFilesFoldersFileRepositoryAsync(string token, Co { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (!IsNullOrEmpty(folderId)) + if(!IsNullOrEmpty(folderId)) { payload.Add("folder_id", folderId); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1668,7 +1667,7 @@ public async Task ExportFilesFoldersFileRepositoryAsync(string token, Co /// the doc_id of the file in the File Repository /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// the contents of the file public async Task ExportFileFileRepositoryAsync(string token, Content content, RedcapAction action, string docId = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1684,14 +1683,14 @@ public async Task ExportFileFileRepositoryAsync(string token, Content co { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (!IsNullOrEmpty(docId)) + if(!IsNullOrEmpty(docId)) { payload.Add("doc_id", docId); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1713,7 +1712,7 @@ public async Task ExportFileFileRepositoryAsync(string token, Content co /// the folder_id of a specific folder in the File Repository where you wish to store the file. If none is provided, the file will be stored in the top-level directory of the File Repository. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// string public async Task ImportFileRepositoryAsync(string token, Content content = Content.FileRepository, RedcapAction action = RedcapAction.Import, string file = null, string folderId = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1721,7 +1720,7 @@ public async Task ImportFileRepositoryAsync(string token, Content conten { this.CheckToken(token); - if (IsNullOrEmpty(file)) + if(IsNullOrEmpty(file)) { throw new ArgumentNullException("Please provide a file to import."); } @@ -1733,13 +1732,13 @@ public async Task ImportFileRepositoryAsync(string token, Content conten { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (!IsNullOrEmpty(folderId)) + if(!IsNullOrEmpty(folderId)) { payload.Add("folder_id", folderId); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1760,7 +1759,7 @@ public async Task ImportFileRepositoryAsync(string token, Content conten /// the doc_id of the file in the File Repository /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// string public async Task DeleteFileRepositoryAsync(string token, Content content = Content.FileRepository, RedcapAction action = RedcapAction.Delete, string docId = null, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1768,7 +1767,7 @@ public async Task DeleteFileRepositoryAsync(string token, Content conten { this.CheckToken(token); - if (IsNullOrEmpty(docId)) + if(IsNullOrEmpty(docId)) { throw new ArgumentNullException("Please provide a document id to delete."); } @@ -1781,7 +1780,7 @@ public async Task DeleteFileRepositoryAsync(string token, Content conten }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1801,7 +1800,7 @@ public async Task DeleteFileRepositoryAsync(string token, Content conten /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project. /// csv, json [default], xml /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Instruments for the project in the format specified and will be ordered according to their order in the project. public async Task ExportInstrumentsAsync(string token, RedcapFormat format = RedcapFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1817,7 +1816,7 @@ public async Task ExportInstrumentsAsync(string token, RedcapFormat form }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1836,7 +1835,7 @@ public async Task ExportInstrumentsAsync(string token, RedcapFormat form /// instrument /// csv, json [default], xml /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Instruments for the project in the format specified and will be ordered according to their order in the project. public async Task ExportInstrumentsAsync(string token, Content content = Content.Instrument, RedcapFormat format = RedcapFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1852,7 +1851,7 @@ public async Task ExportInstrumentsAsync(string token, Content content = }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1876,7 +1875,7 @@ public async Task ExportInstrumentsAsync(string token, Content content = /// [The value of this parameter does not matter and is ignored.] If this parameter is passed with any value, it will export all instruments (and all events, if longitudinal) with data from all records. Note: If this parameter is passed, the parameters record, event, and instrument will be ignored. /// csv, json [default] , xml- The returnFormat is only used with regard to the format of any error messages that might be returned. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// A PDF file containing one or all data collection instruments from the project, in which the instruments will be blank (no data), contain data from a single record, or contain data from all records in the project, depending on the parameters passed in the API request. public async Task ExportPDFInstrumentsAsync(string token, string recordId = default, string eventName = default, string instrument = default, bool allRecord = false, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1891,25 +1890,25 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI { "returnFormat", returnFormat.GetDisplayName() } }; // Add all optional parameters - if (!IsNullOrEmpty(recordId)) + if(!IsNullOrEmpty(recordId)) { payload.Add("record", recordId); } - if (!IsNullOrEmpty(eventName)) + if(!IsNullOrEmpty(eventName)) { payload.Add("event", eventName); } - if (!IsNullOrEmpty(instrument)) + if(!IsNullOrEmpty(instrument)) { payload.Add("instrument", instrument); } - if (allRecord) + if(allRecord) { payload.Add("allRecords", allRecord.ToString()); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1935,7 +1934,7 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI /// Set to TRUE to return a compact-formatted PDF that excludes fields that have no data saved and excludes unselected multiple choice options, thus producing a smaller PDF file. If set to FALSE, all fields will be displayed normally. /// csv, json [default] , xml- The returnFormat is only used with regard to the format of any error messages that might be returned. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// A PDF file containing one or all data collection instruments from the project, in which the instruments will be blank (no data), contain data from a single record, or contain data from all records in the project, depending on the parameters passed in the API request. public async Task ExportPDFInstrumentsAsync(string token, Content content = Content.Pdf, string recordId = default, string eventName = default, string instrument = default, bool allRecords = false, bool compactDisplay = false, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -1950,29 +1949,29 @@ public async Task ExportPDFInstrumentsAsync(string token, Content conten { "returnFormat", returnFormat.GetDisplayName() } }; // Add all optional parameters - if (!IsNullOrEmpty(recordId)) + if(!IsNullOrEmpty(recordId)) { payload.Add("record", recordId); } - if (!IsNullOrEmpty(eventName)) + if(!IsNullOrEmpty(eventName)) { payload.Add("event", eventName); } - if (!IsNullOrEmpty(instrument)) + if(!IsNullOrEmpty(instrument)) { payload.Add("instrument", instrument); } - if (allRecords) + if(allRecords) { payload.Add("allRecords", allRecords.ToString()); } - if (compactDisplay) + if(compactDisplay) { payload.Add("compactDisplay", compactDisplay.ToString()); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -1998,7 +1997,7 @@ public async Task ExportPDFInstrumentsAsync(string token, Content conten /// the path where the file is located /// csv, json [default] , xml- The returnFormat is only used with regard to the format of any error messages that might be returned. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// A PDF file containing one or all data collection instruments from the project, in which the instruments will be blank (no data), contain data from a single record, or contain data from all records in the project, depending on the parameters passed in the API request. public async Task ExportPDFInstrumentsAsync(string token, string recordId = default, string eventName = default, string instrument = default, bool allRecord = false, string filePath = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2009,7 +2008,7 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI /* * FilePath check.. */ - if (!Directory.Exists(filePath) && !IsNullOrEmpty(filePath)) + if(!Directory.Exists(filePath) && !IsNullOrEmpty(filePath)) { Log.Warning($"The directory provided does not exist! Creating a folder for you."); Directory.CreateDirectory(filePath); @@ -2022,25 +2021,25 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI { "filePath", $@"{filePath}" } }; // Add all optional parameters - if (!IsNullOrEmpty(recordId)) + if(!IsNullOrEmpty(recordId)) { payload.Add("record", recordId); } - if (!IsNullOrEmpty(eventName)) + if(!IsNullOrEmpty(eventName)) { payload.Add("event", eventName); } - if (!IsNullOrEmpty(instrument)) + if(!IsNullOrEmpty(instrument)) { payload.Add("instrument", instrument); } - if (allRecord) + if(allRecord) { payload.Add("allRecords", allRecord.ToString()); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2062,7 +2061,7 @@ public async Task ExportPDFInstrumentsAsync(string token, string recordI /// an array of arm numbers that you wish to pull events for (by default, all events are pulled) /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Instrument-event mappings for the project in the format specified public async Task ExportInstrumentMappingAsync(string token, RedcapFormat format = RedcapFormat.json, string[] arms = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2078,16 +2077,16 @@ public async Task ExportInstrumentMappingAsync(string token, RedcapForma { "returnFormat", returnFormat.GetDisplayName() } }; // Add all optional parameters - if (arms?.Length > 0) + if(arms?.Length > 0) { - for (var i = 0; i < arms.Length; i++) + for(var i = 0; i < arms.Length; i++) { payload.Add($"arms[{i}]", arms[i]); } } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2110,7 +2109,7 @@ public async Task ExportInstrumentMappingAsync(string token, RedcapForma /// an array of arm numbers that you wish to pull events for (by default, all events are pulled) /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Instrument-event mappings for the project in the format specified public async Task ExportInstrumentMappingAsync(string token, Content content, RedcapFormat format, string[] arms = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2126,16 +2125,16 @@ public async Task ExportInstrumentMappingAsync(string token, Content con { "returnFormat", returnFormat.GetDisplayName() } }; // Add all optional parameters - if (arms?.Length > 0) + if(arms?.Length > 0) { - for (var i = 0; i < arms.Length; i++) + for(var i = 0; i < arms.Length; i++) { payload.Add($"arms[{i}]", arms[i]); } } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2163,7 +2162,7 @@ public async Task ExportInstrumentMappingAsync(string token, Content con /// /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of Instrument-Event Mappings imported public async Task ImportInstrumentMappingAsync(string token, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2182,7 +2181,7 @@ public async Task ImportInstrumentMappingAsync(string token, RedcapFo }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2211,7 +2210,7 @@ public async Task ImportInstrumentMappingAsync(string token, RedcapFo /// /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of Instrument-Event Mappings imported public async Task ImportInstrumentMappingAsync(string token, Content content, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2230,7 +2229,7 @@ public async Task ImportInstrumentMappingAsync(string token, Content }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2259,7 +2258,7 @@ public async Task ImportInstrumentMappingAsync(string token, Content /// To return only records that have been logged *before* a given date/time, provide a timestamp in the format YYYY-MM-DD HH:MM (e.g., '2017-01-01 17:00' for January 1, 2017 at 5:00 PM server time). If not specified, it will use the current server time. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// List of all changes made to this project, including data exports, data changes, and the creation or deletion of users. public async Task ExportLoggingAsync(string token, Content content, RedcapFormat format = RedcapFormat.json, LogType logType = LogType.All, string user = default, string record = default, string dag = default, string beginTime = default, string endTime = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2278,30 +2277,30 @@ public async Task ExportLoggingAsync(string token, Content content, Redc }; // Optional - if (!IsNullOrEmpty(user)) + if(!IsNullOrEmpty(user)) { payload.Add("user", user); } - if (!IsNullOrEmpty(record)) + if(!IsNullOrEmpty(record)) { payload.Add("record", record); } - if (!IsNullOrEmpty(dag)) + if(!IsNullOrEmpty(dag)) { payload.Add("dag", dag); } - if (!IsNullOrEmpty(beginTime)) + if(!IsNullOrEmpty(beginTime)) { payload.Add("beginTime", beginTime); } - if (!IsNullOrEmpty(endTime)) + if(!IsNullOrEmpty(endTime)) { payload.Add("endTime", endTime); } exportLoggingResults = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return exportLoggingResults; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return exportLoggingResults; @@ -2325,7 +2324,7 @@ public async Task ExportLoggingAsync(string token, Content content, Redc /// an array of form names specifying specific data collection instruments for which you wish to pull metadata (by default, all metadata is pulled). NOTE: These 'forms' are not the form label values that are seen on the webpages, but instead they are the unique form names seen in Column B of the data dictionary. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Metadata from the project (i.e. Data Dictionary values) in the format specified ordered by the field order public async Task ExportMetaDataAsync(string token, Content content, RedcapFormat format, string[] fields = default, string[] forms = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2341,23 +2340,23 @@ public async Task ExportMetaDataAsync(string token, Content content, Red { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (fields?.Length > 0) + if(fields?.Length > 0) { - for (var i = 0; i < fields.Length; i++) + for(var i = 0; i < fields.Length; i++) { payload.Add($"fields[{i}]", fields[i]); } } - if (forms?.Length > 0) + if(forms?.Length > 0) { - for (var i = 0; i < forms.Length; i++) + for(var i = 0; i < forms.Length; i++) { payload.Add($"forms[{i}]", forms[i]); } } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2378,7 +2377,7 @@ public async Task ExportMetaDataAsync(string token, Content content, Red /// an array of form names specifying specific data collection instruments for which you wish to pull metadata (by default, all metadata is pulled). NOTE: These 'forms' are not the form label values that are seen on the webpages, but instead they are the unique form names seen in Column B of the data dictionary. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Metadata from the project (i.e. Data Dictionary values) in the format specified ordered by the field order public async Task ExportMetaDataAsync(string token, RedcapFormat format = RedcapFormat.json, string[] fields = default, string[] forms = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2394,23 +2393,23 @@ public async Task ExportMetaDataAsync(string token, RedcapFormat format { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (fields?.Length > 0) + if(fields?.Length > 0) { - for (var i = 0; i < fields.Length; i++) + for(var i = 0; i < fields.Length; i++) { payload.Add($"fields[{i}]", fields[i]); } } - if (forms?.Length > 0) + if(forms?.Length > 0) { - for (var i = 0; i < forms.Length; i++) + for(var i = 0; i < forms.Length; i++) { payload.Add($"forms[{i}]", forms[i]); } } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2433,7 +2432,7 @@ public async Task ExportMetaDataAsync(string token, RedcapFormat format /// The formatted data to be imported. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of fields imported public async Task ImportMetaDataAsync(string token, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2452,7 +2451,7 @@ public async Task ImportMetaDataAsync(string token, RedcapFormat form }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2476,7 +2475,7 @@ public async Task ImportMetaDataAsync(string token, RedcapFormat form /// The formatted data to be imported. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of fields imported public async Task ImportMetaDataAsync(string token, Content content, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, @@ -2497,7 +2496,7 @@ public async Task ImportMetaDataAsync(string token, Content content, }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2531,7 +2530,7 @@ public async Task ImportMetaDataAsync(string token, Content content, /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// default: NULL - The 'odm' parameter must be an XML string in CDISC ODM XML format that contains project metadata (fields, forms, events, arms) and might optionally contain data to be imported as well. The XML contained in this parameter can come from a REDCap Project XML export file from REDCap itself, or may come from another system that is capable of exporting projects and data in CDISC ODM format. If the 'odm' parameter is included in the API request, it will use the XML to import its contents into the newly created project. This will allow you not only to create the project with the API request, but also to import all fields, forms, and project attributes (and events and arms, if longitudinal) as well as record data all at the same time. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// When a project is created, a 32-character project-level API Token is returned (associated with both the project and user creating the project). This token could then ostensibly be used to make subsequent API calls to this project, such as for adding new events, fields, records, etc. public async Task CreateProjectAsync(string token, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, string odm = null, @@ -2550,13 +2549,13 @@ public async Task CreateProjectAsync(string token, RedcapFormat forma { "returnFormat", returnFormat.GetDisplayName() }, { "data", _serializedData } }; - if (!IsNullOrEmpty(odm)) + if(!IsNullOrEmpty(odm)) { payload.Add("odm", odm); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2590,7 +2589,7 @@ public async Task CreateProjectAsync(string token, RedcapFormat forma /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// default: NULL - The 'odm' parameter must be an XML string in CDISC ODM XML format that contains project metadata (fields, forms, events, arms) and might optionally contain data to be imported as well. The XML contained in this parameter can come from a REDCap Project XML export file from REDCap itself, or may come from another system that is capable of exporting projects and data in CDISC ODM format. If the 'odm' parameter is included in the API request, it will use the XML to import its contents into the newly created project. This will allow you not only to create the project with the API request, but also to import all fields, forms, and project attributes (and events and arms, if longitudinal) as well as record data all at the same time. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// When a project is created, a 32-character project-level API Token is returned (associated with both the project and user creating the project). This token could then ostensibly be used to make subsequent API calls to this project, such as for adding new events, fields, records, etc. public async Task CreateProjectAsync(string token, Content content, RedcapFormat format, List data, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, string odm = null, @@ -2609,13 +2608,13 @@ public async Task CreateProjectAsync(string token, Content content, R { "returnFormat", returnFormat.GetDisplayName() }, { "data", _serializedData } }; - if (!IsNullOrEmpty(odm)) + if(!IsNullOrEmpty(odm)) { payload.Add("odm", odm); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2637,7 +2636,7 @@ public async Task CreateProjectAsync(string token, Content content, R /// project_title, project_language, purpose, purpose_other, project_notes, custom_record_label, secondary_unique_field, is_longitudinal, surveys_enabled, scheduling_enabled, record_autonumbering_enabled, randomization_enabled, project_irb_number, project_grant_number, project_pi_firstname, project_pi_lastname, display_today_now_button /// /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns the number of values accepted to be updated in the project settings (including values which remained the same before and after the import). public async Task ImportProjectInfoAsync(string token, Content content, RedcapFormat format, RedcapProjectInfo projectInfo, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2655,7 +2654,7 @@ public async Task ImportProjectInfoAsync(string token, Content content, }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2676,7 +2675,7 @@ public async Task ImportProjectInfoAsync(string token, Content content, /// project_title, project_language, purpose, purpose_other, project_notes, custom_record_label, secondary_unique_field, is_longitudinal, surveys_enabled, scheduling_enabled, record_autonumbering_enabled, randomization_enabled, project_irb_number, project_grant_number, project_pi_firstname, project_pi_lastname, display_today_now_button /// /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns the number of values accepted to be updated in the project settings (including values which remained the same before and after the import). public async Task ImportProjectInfoAsync(string token, RedcapFormat format, RedcapProjectInfo projectInfo, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2694,7 +2693,7 @@ public async Task ImportProjectInfoAsync(string token, RedcapFormat form }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2714,7 +2713,7 @@ public async Task ImportProjectInfoAsync(string token, RedcapFormat form /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// /// Attributes for the project in the format specified. For any values that are boolean, they will be represented as either a '0' (no/false) or '1' (yes/true). Also, all date/time values will be returned in Y-M-D H:M:S format. The following attributes will be returned: /// project_id, project_title, creation_time, production_time, in_production, project_language, purpose, purpose_other, project_notes, custom_record_label, secondary_unique_field, is_longitudinal, surveys_enabled, scheduling_enabled, record_autonumbering_enabled, randomization_enabled, ddp_enabled, project_irb_number, project_grant_number, project_pi_firstname, project_pi_lastname, display_today_now_button @@ -2734,7 +2733,7 @@ public async Task ExportProjectInfoAsync(string token, Content content = }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2753,7 +2752,7 @@ public async Task ExportProjectInfoAsync(string token, Content content = /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// /// Attributes for the project in the format specified. For any values that are boolean, they will be represented as either a '0' (no/false) or '1' (yes/true). Also, all date/time values will be returned in Y-M-D H:M:S format. The following attributes will be returned: /// project_id, project_title, creation_time, production_time, in_production, project_language, purpose, purpose_other, project_notes, custom_record_label, secondary_unique_field, is_longitudinal, surveys_enabled, scheduling_enabled, record_autonumbering_enabled, randomization_enabled, ddp_enabled, project_irb_number, project_grant_number, project_pi_firstname, project_pi_lastname, display_today_now_button @@ -2773,7 +2772,7 @@ public async Task ExportProjectInfoAsync(string token, RedcapFormat form }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2803,7 +2802,7 @@ public async Task ExportProjectInfoAsync(string token, RedcapFormat form /// String of logic text (e.g., [age] > 30) for filtering the data to be returned by this API method, in which the API will only return the records (or record-events, if a longitudinal project) where the logic evaluates as TRUE. This parameter is blank/null by default unless a value is supplied. Please note that if the filter logic contains any incorrect syntax, the API will respond with an error message. /// true, false [default] - TRUE will cause the XML returned to include all files uploaded for File Upload and Signature fields for all records in the project, whereas FALSE will cause all such fields not to be included. NOTE: Setting this option to TRUE can make the export very large and may prevent it from completing if the project contains many files or very large files. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The entire REDCap project's metadata (and data, if specified) will be returned in CDISC ODM format as a single XML string. public async Task ExportProjectXmlAsync(string token, Content content, bool returnMetadataOnly = false, string[] records = default, string[] fields = default, string[] events = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = default, bool exportFiles = false, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2818,37 +2817,37 @@ public async Task ExportProjectXmlAsync(string token, Content content, b { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (returnMetadataOnly) + if(returnMetadataOnly) { payload.Add("returnMetadataOnly", returnMetadataOnly.ToString()); } - if (records?.Length > 0) + if(records?.Length > 0) { payload.Add("records", await this.ConvertArraytoString(records)); } - if (events?.Length > 0) + if(events?.Length > 0) { payload.Add("events", await this.ConvertArraytoString(events)); } - if (exportSurveyFields) + if(exportSurveyFields) { payload.Add("exportSurveyFields", exportSurveyFields.ToString()); } - if (exportDataAccessGroups) + if(exportDataAccessGroups) { payload.Add("exportDataAccessGroups", exportDataAccessGroups.ToString()); } - if (!IsNullOrEmpty(filterLogic)) + if(!IsNullOrEmpty(filterLogic)) { payload.Add("filterLogic", filterLogic); } - if (exportFiles) + if(exportFiles) { payload.Add("exportFiles", exportFiles.ToString()); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2877,7 +2876,7 @@ public async Task ExportProjectXmlAsync(string token, Content content, b /// String of logic text (e.g., [age] > 30) for filtering the data to be returned by this API method, in which the API will only return the records (or record-events, if a longitudinal project) where the logic evaluates as TRUE. This parameter is blank/null by default unless a value is supplied. Please note that if the filter logic contains any incorrect syntax, the API will respond with an error message. /// true, false [default] - TRUE will cause the XML returned to include all files uploaded for File Upload and Signature fields for all records in the project, whereas FALSE will cause all such fields not to be included. NOTE: Setting this option to TRUE can make the export very large and may prevent it from completing if the project contains many files or very large files. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The entire REDCap project's metadata (and data, if specified) will be returned in CDISC ODM format as a single XML string. public async Task ExportProjectXmlAsync(string token, bool returnMetadataOnly = false, string[] records = default, string[] fields = default, string[] events = default, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = default, bool exportFiles = false, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2891,37 +2890,37 @@ public async Task ExportProjectXmlAsync(string token, bool returnMetadat { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (returnMetadataOnly) + if(returnMetadataOnly) { payload.Add("returnMetadataOnly", returnMetadataOnly.ToString()); } - if (records?.Length > 0) + if(records?.Length > 0) { payload.Add("records", await this.ConvertArraytoString(records)); } - if (events?.Length > 0) + if(events?.Length > 0) { payload.Add("events", await this.ConvertArraytoString(events)); } - if (exportSurveyFields) + if(exportSurveyFields) { payload.Add("exportSurveyFields", exportSurveyFields.ToString()); } - if (exportDataAccessGroups) + if(exportDataAccessGroups) { payload.Add("exportDataAccessGroups", exportDataAccessGroups.ToString()); } - if (!IsNullOrEmpty(filterLogic)) + if(!IsNullOrEmpty(filterLogic)) { payload.Add("filterLogic", filterLogic); } - if (exportFiles) + if(exportFiles) { payload.Add("exportFiles", exportFiles.ToString()); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2945,7 +2944,7 @@ public async Task ExportProjectXmlAsync(string token, bool returnMetadat /// /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The maximum integer record ID + 1. public async Task GenerateNextRecordNameAsync(string token, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2960,7 +2959,7 @@ public async Task GenerateNextRecordNameAsync(string token, Cancellation }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -2982,7 +2981,7 @@ public async Task GenerateNextRecordNameAsync(string token, Cancellation /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project. /// generateNextRecordName /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The maximum integer record ID + 1. public async Task GenerateNextRecordNameAsync(string token, Content content, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -2997,7 +2996,7 @@ public async Task GenerateNextRecordNameAsync(string token, Content cont }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3033,7 +3032,7 @@ public async Task GenerateNextRecordNameAsync(string token, Content cont /// If specified, force all numbers into same decimal format. You may choose to force all data values containing a decimal to have the same decimal character, which will be applied to all calc fields and number-validated text fields. Options include comma ',' or dot/full stop '.', but if left blank/null, then it will export numbers using the fields' native decimal format. Simply provide the value of either ',' or '.' for this parameter. /// true, false [default] - specifies whether or not to export blank values for instrument complete status fields that have a gray status icon. All instrument complete status fields having a gray icon can be exported either as a blank value or as "0" (Incomplete). Blank values are recommended in a data export if the data will be re-imported into a REDCap project. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Data from the project in the format and type specified ordered by the record (primary key of project) and then by event id public async Task ExportRecordsAsync(string token, RedcapFormat format = RedcapFormat.json, RedcapDataType redcapDataType = RedcapDataType.flat, string[] records = default, string[] fields = default, string[] forms = default, string[] events = default, RawOrLabel rawOrLabel = RawOrLabel.raw, RawOrLabelHeaders rawOrLabelHeaders = RawOrLabelHeaders.raw, bool exportCheckboxLabel = false, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = null, DateTime? dateRangeBegin = default, DateTime? dateRangeEnd = default, CsvDelimiter csvDelimiter = CsvDelimiter.comma, DecimalCharacter decimalCharacter = DecimalCharacter.none, bool exportBlankForGrayFormStatus = false, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3052,68 +3051,68 @@ public async Task ExportRecordsAsync(string token, RedcapFormat format = }; // Optional - if (records?.Length > 0) + if(records?.Length > 0) { payload.Add("records", await this.ConvertArraytoString(records)); } - if (fields?.Length > 0) + if(fields?.Length > 0) { payload.Add("fields", await this.ConvertArraytoString(fields)); } - if (forms?.Length > 0) + if(forms?.Length > 0) { payload.Add("forms", await this.ConvertArraytoString(forms)); } - if (events?.Length > 0) + if(events?.Length > 0) { payload.Add("events", await this.ConvertArraytoString(events)); } // Pertains to CSV data only var _rawOrLabel = rawOrLabel.ToString(); - if (!IsNullOrEmpty(_rawOrLabel)) + if(!IsNullOrEmpty(_rawOrLabel)) { payload.Add("rawOrLabel", _rawOrLabel); } // Optional (defaults to false) - if (exportCheckboxLabel) + if(exportCheckboxLabel) { payload.Add("exportCheckboxLabel", exportCheckboxLabel.ToString()); } // Optional (defaults to false) - if (exportSurveyFields) + if(exportSurveyFields) { payload.Add("exportSurveyFields", exportSurveyFields.ToString()); } // Optional (defaults to false) - if (exportDataAccessGroups) + if(exportDataAccessGroups) { payload.Add("exportDataAccessGroups", exportDataAccessGroups.ToString()); } // Optional (defaults to empty) - if (!IsNullOrEmpty(filterLogic)) + if(!IsNullOrEmpty(filterLogic)) { payload.Add("filterLogic", filterLogic); } - if (dateRangeBegin.HasValue) + if(dateRangeBegin.HasValue) { payload.Add("dateRangeBegin", dateRangeBegin.Value.ToString("yyyy-MM-dd hh:mm:ss")); } - if (dateRangeEnd.HasValue) + if(dateRangeEnd.HasValue) { payload.Add("dateRangeEnd", dateRangeEnd.Value.ToString("yyyy-MM-dd hh:mm:ss")); } - if (format == RedcapFormat.csv) + if(format == RedcapFormat.csv) { payload.Add("csvDelimiter", csvDelimiter.ToString()); } - if (decimalCharacter != DecimalCharacter.none) + if(decimalCharacter != DecimalCharacter.none) { payload.Add("decimalCharacter", decimalCharacter.ToString()); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3150,7 +3149,7 @@ public async Task ExportRecordsAsync(string token, RedcapFormat format = /// If specified, force all numbers into same decimal format. You may choose to force all data values containing a decimal to have the same decimal character, which will be applied to all calc fields and number-validated text fields. Options include comma ',' or dot/full stop '.', but if left blank/null, then it will export numbers using the fields' native decimal format. Simply provide the value of either ',' or '.' for this parameter. /// true, false [default] - specifies whether or not to export blank values for instrument complete status fields that have a gray status icon. All instrument complete status fields having a gray icon can be exported either as a blank value or as "0" (Incomplete). Blank values are recommended in a data export if the data will be re-imported into a REDCap project. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Data from the project in the format and type specified ordered by the record (primary key of project) and then by event id public async Task ExportRecordsAsync(string token, Content content, RedcapFormat format = RedcapFormat.json, RedcapDataType redcapDataType = RedcapDataType.flat, string[] records = null, string[] fields = null, string[] forms = null, string[] events = null, RawOrLabel rawOrLabel = RawOrLabel.raw, RawOrLabelHeaders rawOrLabelHeaders = RawOrLabelHeaders.raw, bool exportCheckboxLabel = false, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = null, DateTime? dateRangeBegin = null, DateTime? dateRangeEnd = null, CsvDelimiter csvDelimiter = CsvDelimiter.comma, DecimalCharacter decimalCharacter = DecimalCharacter.none, bool exportBlankForGrayFormStatus = false, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3169,58 +3168,58 @@ public async Task ExportRecordsAsync(string token, Content content, Redc }; // Optional - if (records?.Length > 0) + if(records?.Length > 0) { payload.Add("records", await this.ConvertArraytoString(records)); } - if (fields?.Length > 0) + if(fields?.Length > 0) { payload.Add("fields", await this.ConvertArraytoString(fields)); } - if (forms?.Length > 0) + if(forms?.Length > 0) { payload.Add("forms", await this.ConvertArraytoString(forms)); } - if (events?.Length > 0) + if(events?.Length > 0) { payload.Add("events", await this.ConvertArraytoString(events)); } // Pertains to CSV data only var _rawOrLabel = rawOrLabel.ToString(); - if (!IsNullOrEmpty(_rawOrLabel)) + if(!IsNullOrEmpty(_rawOrLabel)) { payload.Add("rawOrLabel", _rawOrLabel); } // Optional (defaults to false) - if (exportCheckboxLabel) + if(exportCheckboxLabel) { payload.Add("exportCheckboxLabel", exportCheckboxLabel.ToString()); } // Optional (defaults to false) - if (exportSurveyFields) + if(exportSurveyFields) { payload.Add("exportSurveyFields", exportSurveyFields.ToString()); } // Optional (defaults to false) - if (exportDataAccessGroups) + if(exportDataAccessGroups) { payload.Add("exportDataAccessGroups", exportDataAccessGroups.ToString()); } // Optional (defaults to empty) - if (!IsNullOrEmpty(filterLogic)) + if(!IsNullOrEmpty(filterLogic)) { payload.Add("filterLogic", filterLogic); } - if (dateRangeBegin.HasValue) + if(dateRangeBegin.HasValue) { payload.Add("dateRangeBegin", dateRangeBegin.Value.ToString("yyyy-MM-dd hh:mm:ss")); } - if (dateRangeEnd.HasValue) + if(dateRangeEnd.HasValue) { payload.Add("dateRangeEnd", dateRangeEnd.Value.ToString("yyyy-MM-dd hh:mm:ss")); } - if (format == RedcapFormat.csv) + if(format == RedcapFormat.csv) { payload.Add("csvDelimiter", csvDelimiter.ToString()); } @@ -3231,7 +3230,7 @@ public async Task ExportRecordsAsync(string token, Content content, Redc return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3268,7 +3267,7 @@ public async Task ExportRecordsAsync(string token, Content content, Redc /// dot [default] If specified, force all numbers into same decimal format. You may choose to force all data values containing a decimal to have the same decimal character, which will be applied to all calc fields and number-validated text fields. Options include comma ',' or dot/full stop '.', but if left blank/null, then it will export numbers using the fields' native decimal format. Simply provide the value of either ',' or '.' for this parameter. /// true, false [default] - specifies whether or not to export blank values for instrument complete status fields that have a gray status icon. All instrument complete status fields having a gray icon can be exported either as a blank value or as "0" (Incomplete). Blank values are recommended in a data export if the data will be re-imported into a REDCap project. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Data from the project in the format and type specified ordered by the record (primary key of project) and then by event id public async Task ExportRecordAsync(string token, Content content, string record, RedcapFormat format = RedcapFormat.json, RedcapDataType redcapDataType = RedcapDataType.flat, string[] fields = null, string[] forms = null, string[] events = null, RawOrLabel rawOrLabel = RawOrLabel.raw, RawOrLabelHeaders rawOrLabelHeaders = RawOrLabelHeaders.raw, bool exportCheckboxLabel = false, RedcapReturnFormat onErrorFormat = RedcapReturnFormat.json, bool exportSurveyFields = false, bool exportDataAccessGroups = false, string filterLogic = null, DateTime? dateRangeBegin = default, DateTime? dateRangeEnd = default, CsvDelimiter csvDelimiter = CsvDelimiter.comma, DecimalCharacter decimalCharacter = DecimalCharacter.none, bool exportBlankForGrayFormStatus = false, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3287,15 +3286,15 @@ public async Task ExportRecordAsync(string token, Content content, strin }; // Optional - if (fields?.Length > 0) + if(fields?.Length > 0) { payload.Add("fields", await this.ConvertArraytoString(fields)); } - if (forms?.Length > 0) + if(forms?.Length > 0) { payload.Add("forms", await this.ConvertArraytoString(forms)); } - if (events?.Length > 0) + if(events?.Length > 0) { payload.Add("events", await this.ConvertArraytoString(events)); } @@ -3303,63 +3302,62 @@ public async Task ExportRecordAsync(string token, Content content, strin * Pertains to CSV data only */ var _rawOrLabel = rawOrLabel.ToString(); - if (!IsNullOrEmpty(_rawOrLabel)) + if(!IsNullOrEmpty(_rawOrLabel)) { payload.Add("rawOrLabel", _rawOrLabel); } // Optional (defaults to false) - if (exportCheckboxLabel) + if(exportCheckboxLabel) { payload.Add("exportCheckboxLabel", exportCheckboxLabel.ToString()); } // Optional (defaults to false) - if (exportSurveyFields) + if(exportSurveyFields) { payload.Add("exportSurveyFields", exportSurveyFields.ToString()); } // Optional (defaults to false) - if (exportDataAccessGroups) + if(exportDataAccessGroups) { payload.Add("exportDataAccessGroups", exportDataAccessGroups.ToString()); } // Optional (defaults to empty) - if (!IsNullOrEmpty(filterLogic)) + if(!IsNullOrEmpty(filterLogic)) { payload.Add("filterLogic", filterLogic); } - if (dateRangeBegin.HasValue) + if(dateRangeBegin.HasValue) { payload.Add("dateRangeBegin", dateRangeBegin.Value.ToString("yyyy-MM-dd hh:mm:ss")); } - if (dateRangeEnd.HasValue) + if(dateRangeEnd.HasValue) { payload.Add("dateRangeEnd", dateRangeEnd.Value.ToString("yyyy-MM-dd hh:mm:ss")); } - if (format == RedcapFormat.csv) + if(format == RedcapFormat.csv) { payload.Add("csvDelimiter", csvDelimiter.ToString()); } - if (decimalCharacter != DecimalCharacter.none) + if(decimalCharacter != DecimalCharacter.none) { payload.Add("decimalCharacter", decimalCharacter.ToString()); } // Optional (defaults to false) - if (exportBlankForGrayFormStatus) + if(exportBlankForGrayFormStatus) { payload.Add("exportBlankForGrayFormStatus", exportBlankForGrayFormStatus.ToString()); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; } } - /// /// From Redcap version with version 10.3.0
/// Import Records
@@ -3392,7 +3390,7 @@ public async Task ExportRecordAsync(string token, Content content, strin /// count [default] - the number of records imported, ids - a list of all record IDs that were imported, auto_ids = (used only when forceAutoNumber=true) a list of pairs of all record IDs that were imported, includes the new ID created and the ID value that was sent in the API request (e.g., 323,10). /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// the content specified by returnContent public async Task ImportRecordsAsync(string token, RedcapFormat format, RedcapDataType redcapDataType, OverwriteBehavior overwriteBehavior, bool forceAutoNumber, bool backgroundProcess, List data, string dateFormat = default, CsvDelimiter csvDelimiter = CsvDelimiter.tab, ReturnContent returnContent = ReturnContent.count, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3415,17 +3413,17 @@ public async Task ImportRecordsAsync(string token, RedcapFormat forma { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (!IsNullOrEmpty(dateFormat)) + if(!IsNullOrEmpty(dateFormat)) { payload.Add("dateFormat", dateFormat); } - if (!IsNullOrEmpty(returnContent.ToString())) + if(!IsNullOrEmpty(returnContent.ToString())) { payload.Add("returnContent", returnContent.ToString()); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3463,7 +3461,7 @@ public async Task ImportRecordsAsync(string token, RedcapFormat forma /// count [default] - the number of records imported, ids - a list of all record IDs that were imported, auto_ids = (used only when forceAutoNumber=true) a list of pairs of all record IDs that were imported, includes the new ID created and the ID value that was sent in the API request (e.g., 323,10). /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// the content specified by returnContent public async Task ImportRecordsAsync(string token, Content content, RedcapFormat format, RedcapDataType redcapDataType, OverwriteBehavior overwriteBehavior, bool forceAutoNumber, bool backgroundProcess, List data, string dateFormat = "", CsvDelimiter csvDelimiter = CsvDelimiter.tab, ReturnContent returnContent = ReturnContent.count, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3487,18 +3485,18 @@ public async Task ImportRecordsAsync(string token, Content content, R { "returnFormat", returnFormat.GetDisplayName() } }; // Optional - if (!IsNullOrEmpty(dateFormat)) + if(!IsNullOrEmpty(dateFormat)) { payload.Add("dateFormat", dateFormat); } - if (!IsNullOrEmpty(returnContent.ToString())) + if(!IsNullOrEmpty(returnContent.ToString())) { payload.Add("returnContent", returnContent.ToString()); } importRecordsResults = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return importRecordsResults; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return importRecordsResults; @@ -3518,7 +3516,7 @@ public async Task ImportRecordsAsync(string token, Content content, R /// the arm number of the arm in which the record(s) should be deleted. /// (This can only be used if the project is longitudinal with more than one arm.) NOTE: If the arm parameter is not provided, the specified records will be deleted from all arms in which they exist. Whereas, if arm is provided, they will only be deleted from the specified arm. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// the number of records deleted or (if instrument, event, and/or instance are provided) the number of items deleted over the total records specified. public async Task DeleteRecordsAsync(string token, string[] records, int? arm, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3526,7 +3524,7 @@ public async Task DeleteRecordsAsync(string token, string[] records, int { this.CheckToken(token); - if (records?.Length < 1) + if(records?.Length < 1) { throw new ArgumentNullException("Please provide the records you would like to remove."); } @@ -3537,7 +3535,7 @@ public async Task DeleteRecordsAsync(string token, string[] records, int { "action", RedcapAction.Delete.GetDisplayName() } }; // Required - for (var i = 0; i < records.Length; i++) + for(var i = 0; i < records.Length; i++) { payload.Add($"records[{i}]", records[i]); } @@ -3546,7 +3544,7 @@ public async Task DeleteRecordsAsync(string token, string[] records, int payload.Add("arm", arm?.ToString()); return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3568,7 +3566,7 @@ public async Task DeleteRecordsAsync(string token, string[] records, int /// the arm number of the arm in which the record(s) should be deleted. /// (This can only be used if the project is longitudinal with more than one arm.) NOTE: If the arm parameter is not provided, the specified records will be deleted from all arms in which they exist. Whereas, if arm is provided, they will only be deleted from the specified arm. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// the number of records deleted or (if instrument, event, and/or instance are provided) the number of items deleted over the total records specified. public async Task DeleteRecordsAsync(string token, Content content, RedcapAction action, string[] records, int? arm, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3576,7 +3574,7 @@ public async Task DeleteRecordsAsync(string token, Content content, Redc { this.CheckToken(token); - if (records?.Length < 1) + if(records?.Length < 1) { throw new ArgumentNullException("Please provide the records you would like to remove."); } @@ -3586,7 +3584,7 @@ public async Task DeleteRecordsAsync(string token, Content content, Redc { "content", content.GetDisplayName() }, { "action", action.GetDisplayName() } }; - for (var i = 0; i < records.Length; i++) + for(var i = 0; i < records.Length; i++) { payload.Add($"records[{i}]", records[i]); } @@ -3595,7 +3593,7 @@ public async Task DeleteRecordsAsync(string token, Content content, Redc payload.Add("arm", arm?.ToString()); return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3621,7 +3619,7 @@ public async Task DeleteRecordsAsync(string token, Content content, Redc /// the unique event name - only for longitudinal projects. NOTE: If instrument is provided for a longitudinal project, the event parameter is mandatory. /// the repeating instance number for a repeating instrument or repeating event. NOTE: If project has repeating instruments/events, it will remove only the data for that repeating instance /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// the number of records deleted or (if instrument, event, and/or instance are provided) the number of items deleted over the total records specified. public async Task DeleteRecordsAsync(string token, Content content, RedcapAction action, string[] records, int? arm, RedcapInstrument instrument, RedcapEvent redcapEvent, RedcapRepeatInstance repeatInstance, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3629,7 +3627,7 @@ public async Task DeleteRecordsAsync(string token, Content content, Redc { this.CheckToken(token); - if (records?.Length < 1) + if(records?.Length < 1) { throw new ArgumentNullException("Please provide the records you would like to remove."); } @@ -3640,7 +3638,7 @@ public async Task DeleteRecordsAsync(string token, Content content, Redc { "action", action.GetDisplayName() } }; // Required - for (var i = 0; i < records.Length; i++) + for(var i = 0; i < records.Length; i++) { payload.Add($"records[{i}]", records[i]); } @@ -3653,7 +3651,7 @@ public async Task DeleteRecordsAsync(string token, Content content, Redc return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3677,7 +3675,7 @@ public async Task DeleteRecordsAsync(string token, Content content, Redc /// new record name to which you want to rename current record. /// specific arm number in which current record exists. If null, then all records with same name across all arms on which it exists (if longitudinal with multiple arms) will be renamed to new record name, otherwise it will rename the record only in the specified arm. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns "1" if record is renamed or error message if any. public async Task RenameRecordAsync(string token, Content content, RedcapAction action, string record, string newRecordName, int? arm, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3696,12 +3694,59 @@ public async Task RenameRecordAsync(string token, Content content, Redca payload.Add("arm", arm?.ToString()); return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; } } + + /// + /// From Redcap 14.7.0
+ /// Randomize Record
+ /// This method allows the current API user to randomize a record. + ///
+ /// + /// To use this method you must have the Randomize privilege in the project. + /// + /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project. + /// record + /// randomize + /// The record name (id) of the record to randomize. The record must already exist and contain all necessary stratification information. + /// The unique id of the randomization (viewable on the Randomization page for users with Design permissions, or on the API Playground page). Corresponds to a specific target field and event. + /// csv, json [default], xml, odm ('odm' refers to CDISC ODM XML format, specifically ODM version 1.3.1) + /// csv, json [default], xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. + /// false [default], true - return the value for the alternative target field, i.e. the randomization number for open allocations. Note: with concealed allocations only the value '*' will be returned, not the real allocation group (which would break the blinding). + /// + /// Number of seconds before the http request times out. + /// Performs the specified randomization for the record and returns the value for the target randomization field (plus optionally the alternative target value), or an error message on failure (such as if the record does not exist or if stratification information is missing). + public async Task RandomizeRecord(string token, Content content, RedcapAction action, string record, string randomizationId, RedcapFormat format, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, bool returnAlt = false, CancellationToken cancellationToken = default, long timeOutSeconds = 100) + { + try + { + this.CheckToken(token); + + var payload = new Dictionary + { + { "token", token }, + { "action", action.GetDisplayName() }, + { "content", Content.Record.GetDisplayName() }, + { "record", record }, + { "randomization_id", randomizationId }, + { "format", format.GetDisplayName() }, + { "returnFormat", returnFormat.GetDisplayName() }, + { "returnAlt", returnAlt.ToString() }, + }; + var res = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); + return res; + } + catch(Exception Ex) + { + Log.Error($"{Ex.Message}"); + return Ex.Message; + } + } + #endregion Records #region Repeating Instruments and Events @@ -3715,7 +3760,7 @@ public async Task RenameRecordAsync(string token, Content content, Redca /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project. /// csv, json [default], xml odm ('odm' refers to CDISC ODM XML format, specifically ODM version 1.3.1) /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Repeated instruments and events for the project in the format specified and will be ordered according to their order in the project. public async Task ExportRepeatingInstrumentsAndEvents(string token, RedcapFormat format = RedcapFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3731,7 +3776,7 @@ public async Task ExportRepeatingInstrumentsAndEvents(string token, Redc }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3749,7 +3794,7 @@ public async Task ExportRepeatingInstrumentsAndEvents(string token, Redc /// repeatingFormsEvents /// csv, json [default], xml odm ('odm' refers to CDISC ODM XML format, specifically ODM version 1.3.1) /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Repeated instruments and events for the project in the format specified and will be ordered according to their order in the project. public async Task ExportRepeatingInstrumentsAndEvents(string token, Content content, RedcapFormat format = RedcapFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3765,7 +3810,7 @@ public async Task ExportRepeatingInstrumentsAndEvents(string token, Cont }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3784,7 +3829,7 @@ public async Task ExportRepeatingInstrumentsAndEvents(string token, Cont /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Repeated instruments and events for the project in the format specified and will be ordered according to their order in the project. public async Task ImportRepeatingInstrumentsAndEvents(string token, List data, Content content = Content.RepeatingFormsEvents, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3803,7 +3848,7 @@ public async Task ImportRepeatingInstrumentsAndEvents(string token, L }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3832,7 +3877,7 @@ public async Task ImportRepeatingInstrumentsAndEvents(string token, L /// /// /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Data from the project in the format and type specified ordered by the record (primary key of project) and then by event id public async Task ExportReportsAsync(string token, int reportId, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, RawOrLabel rawOrLabel = RawOrLabel.raw, RawOrLabelHeaders rawOrLabelHeaders = RawOrLabelHeaders.raw, bool exportCheckboxLabel = false, string csvDelimiter = default, string decimalCharacter = default, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3850,30 +3895,30 @@ public async Task ExportReportsAsync(string token, int reportId, RedcapF }; // Optional var _rawOrLabel = rawOrLabel.ToString(); - if (!IsNullOrEmpty(_rawOrLabel)) + if(!IsNullOrEmpty(_rawOrLabel)) { payload.Add("rawOrLabel", _rawOrLabel); } var _rawOrLabelHeaders = rawOrLabelHeaders.ToString(); - if (!IsNullOrEmpty(_rawOrLabelHeaders)) + if(!IsNullOrEmpty(_rawOrLabelHeaders)) { payload.Add("rawOrLabelHeaders", _rawOrLabelHeaders); } - if (exportCheckboxLabel) + if(exportCheckboxLabel) { payload.Add("exportCheckboxLabel", exportCheckboxLabel.ToString()); } - if (!IsNullOrEmpty(csvDelimiter)) + if(!IsNullOrEmpty(csvDelimiter)) { payload.Add("csvDelimiter", csvDelimiter); } - if (!IsNullOrEmpty(decimalCharacter)) + if(!IsNullOrEmpty(decimalCharacter)) { payload.Add("decimalCharacter", decimalCharacter); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3900,7 +3945,7 @@ public async Task ExportReportsAsync(string token, int reportId, RedcapF /// /// /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Data from the project in the format and type specified ordered by the record (primary key of project) and then by event id public async Task ExportReportsAsync(string token, Content content, int reportId, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, RawOrLabel rawOrLabel = RawOrLabel.raw, RawOrLabelHeaders rawOrLabelHeaders = RawOrLabelHeaders.raw, bool exportCheckboxLabel = false, string csvDelimiter = default, string decimalCharacter = default, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3918,30 +3963,30 @@ public async Task ExportReportsAsync(string token, Content content, int }; // Optional var _rawOrLabel = rawOrLabel.ToString(); - if (!IsNullOrEmpty(_rawOrLabel)) + if(!IsNullOrEmpty(_rawOrLabel)) { payload.Add("rawOrLabel", _rawOrLabel); } var _rawOrLabelHeaders = rawOrLabelHeaders.ToString(); - if (!IsNullOrEmpty(_rawOrLabelHeaders)) + if(!IsNullOrEmpty(_rawOrLabelHeaders)) { payload.Add("rawOrLabelHeaders", _rawOrLabelHeaders); } - if (exportCheckboxLabel) + if(exportCheckboxLabel) { payload.Add("exportCheckboxLabel", exportCheckboxLabel.ToString()); } - if (!IsNullOrEmpty(csvDelimiter)) + if(!IsNullOrEmpty(csvDelimiter)) { payload.Add("csvDelimiter", csvDelimiter); } - if (!IsNullOrEmpty(decimalCharacter)) + if(!IsNullOrEmpty(decimalCharacter)) { payload.Add("decimalCharacter", decimalCharacter); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3962,7 +4007,7 @@ public async Task ExportReportsAsync(string token, Content content, int /// version /// csv, json [default], xml /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The current REDCap version number (three numbers delimited with two periods) as plain text - e.g., 4.13.18, 5.12.2, 6.0.0 public async Task ExportRedcapVersionAsync(string token, Content content = Content.Version, RedcapFormat format = RedcapFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -3979,7 +4024,7 @@ public async Task ExportRedcapVersionAsync(string token, Content content return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -3997,7 +4042,7 @@ public async Task ExportRedcapVersionAsync(string token, Content content /// The API token specific to your REDCap project and username (each token is unique to each user for each project). See the section on the left-hand menu for obtaining a token for a given project. /// csv, json [default], xml /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The current REDCap version number (three numbers delimited with two periods) as plain text - e.g., 4.13.18, 5.12.2, 6.0.0 public async Task ExportRedcapVersionAsync(string token, RedcapFormat format = RedcapFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4014,7 +4059,7 @@ public async Task ExportRedcapVersionAsync(string token, RedcapFormat fo return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4039,7 +4084,7 @@ public async Task ExportRedcapVersionAsync(string token, RedcapFormat fo /// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'. /// csv, json [default], xml - The returnFormat is only used with regard to the format of any error messages that might be returned. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns a unique survey link (i.e., a URL) in plain text format for the specified record and instrument (and event, if longitudinal). public async Task ExportSurveyLinkAsync(string token, string record, string instrument, string eventName, int repeatInstance, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4060,7 +4105,7 @@ public async Task ExportSurveyLinkAsync(string token, string record, str return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4084,7 +4129,7 @@ public async Task ExportSurveyLinkAsync(string token, string record, str /// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'. /// csv, json [default], xml - The returnFormat is only used with regard to the format of any error messages that might be returned. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns a unique survey link (i.e., a URL) in plain text format for the specified record and instrument (and event, if longitudinal). public async Task ExportSurveyLinkAsync(string token, Content content, string record, string instrument, string eventName, int repeatInstance, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4105,7 +4150,7 @@ public async Task ExportSurveyLinkAsync(string token, Content content, s return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4126,7 +4171,7 @@ public async Task ExportSurveyLinkAsync(string token, Content content, s /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns the list of all participants for the specified survey instrument [and event] in the desired format. The following fields are returned: email, email_occurrence, identifier, invitation_sent_status, invitation_send_time, response_status, survey_access_code, survey_link. The attribute 'email_occurrence' represents the current count that the email address has appeared in the list (because emails can be used more than once), thus email + email_occurrence represent a unique value pair. 'invitation_sent_status' is '0' if an invitation has not yet been sent to the participant, and is '1' if it has. 'invitation_send_time' is the date/time in which the next invitation will be sent, and is blank if there is no invitation that is scheduled to be sent. 'response_status' represents whether the participant has responded to the survey, in which its value is 0, 1, or 2 for 'No response', 'Partial', or 'Completed', respectively. Note: If an incorrect event_id or instrument name is used or if the instrument has not been enabled as a survey, then an error will be returned. public async Task ExportSurveyParticipantsAsync(string token, string instrument, string eventName, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4146,7 +4191,7 @@ public async Task ExportSurveyParticipantsAsync(string token, string ins return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4168,7 +4213,7 @@ public async Task ExportSurveyParticipantsAsync(string token, string ins /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns the list of all participants for the specified survey instrument [and event] in the desired format. The following fields are returned: email, email_occurrence, identifier, invitation_sent_status, invitation_send_time, response_status, survey_access_code, survey_link. The attribute 'email_occurrence' represents the current count that the email address has appeared in the list (because emails can be used more than once), thus email + email_occurrence represent a unique value pair. 'invitation_sent_status' is '0' if an invitation has not yet been sent to the participant, and is '1' if it has. 'invitation_send_time' is the date/time in which the next invitation will be sent, and is blank if there is no invitation that is scheduled to be sent. 'response_status' represents whether the participant has responded to the survey, in which its value is 0, 1, or 2 for 'No response', 'Partial', or 'Completed', respectively. Note: If an incorrect event_id or instrument name is used or if the instrument has not been enabled as a survey, then an error will be returned. public async Task ExportSurveyParticipantsAsync(string token, Content content, string instrument, string eventName, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4187,7 +4232,7 @@ public async Task ExportSurveyParticipantsAsync(string token, Content co return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4207,7 +4252,7 @@ public async Task ExportSurveyParticipantsAsync(string token, Content co /// the record ID. The name of the record in the project. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns a unique Survey Queue link (i.e., a URL) in plain text format for the specified record in the project. public async Task ExportSurveyQueueLinkAsync(string token, string record, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4225,7 +4270,7 @@ public async Task ExportSurveyQueueLinkAsync(string token, string record return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4246,7 +4291,7 @@ public async Task ExportSurveyQueueLinkAsync(string token, string record /// the record ID. The name of the record in the project. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns a unique Survey Queue link (i.e., a URL) in plain text format for the specified record in the project. public async Task ExportSurveyQueueLinkAsync(string token, Content content, string record, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4264,7 +4309,7 @@ public async Task ExportSurveyQueueLinkAsync(string token, Content conte return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4286,7 +4331,7 @@ public async Task ExportSurveyQueueLinkAsync(string token, Content conte /// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns a unique Return Code in plain text format for the specified record and instrument (and event, if longitudinal). public async Task ExportSurveyReturnCodeAsync(string token, string record, string instrument, string eventName, string repeatInstance, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4307,7 +4352,7 @@ public async Task ExportSurveyReturnCodeAsync(string token, string recor return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4330,7 +4375,7 @@ public async Task ExportSurveyReturnCodeAsync(string token, string recor /// (only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal). Default value is '1'. /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Returns a unique Return Code in plain text format for the specified record and instrument (and event, if longitudinal). public async Task ExportSurveyReturnCodeAsync(string token, Content content, string record, string instrument, string eventName, string repeatInstance, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4349,7 +4394,7 @@ public async Task ExportSurveyReturnCodeAsync(string token, Content cont }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4374,7 +4419,7 @@ public async Task ExportSurveyReturnCodeAsync(string token, Content cont /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The method will return all the attributes below with regard to user privileges in the format specified. Please note that the 'forms' attribute is the only attribute that contains sub-elements (one for each data collection instrument), in which each form will have its own Form Rights value (see the key below to learn what each numerical value represents). Most user privilege attributes are boolean (0=No Access, 1=Access). Attributes returned: /// username, email, firstname, lastname, expiration, data_access_group, design, user_rights, data_access_groups, data_export, reports, stats_and_charts, manage_survey_participants, calendar, data_import_tool, data_comparison_tool, logging, file_repository, data_quality_create, data_quality_execute, api_export, api_import, mobile_app, mobile_app_download_data, record_create, record_rename, record_delete, lock_records_customization, lock_records, lock_records_all_forms, forms public async Task ExportUsersAsync(string token, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) @@ -4391,7 +4436,7 @@ public async Task ExportUsersAsync(string token, RedcapFormat format = R }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4415,7 +4460,7 @@ public async Task ExportUsersAsync(string token, RedcapFormat format = R /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The method will return all the attributes below with regard to user privileges in the format specified. Please note that the 'forms' attribute is the only attribute that contains sub-elements (one for each data collection instrument), in which each form will have its own Form Rights value (see the key below to learn what each numerical value represents). Most user privilege attributes are boolean (0=No Access, 1=Access). Attributes returned: /// username, email, firstname, lastname, expiration, data_access_group, design, user_rights, data_access_groups, data_export, reports, stats_and_charts, manage_survey_participants, calendar, data_import_tool, data_comparison_tool, logging, file_repository, data_quality_create, data_quality_execute, api_export, api_import, mobile_app, mobile_app_download_data, record_create, record_rename, record_delete, lock_records_customization, lock_records, lock_records_all_forms, forms /// @@ -4435,7 +4480,7 @@ public async Task ExportUsersAsync(string token, Content content = Conte return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4482,7 +4527,7 @@ public async Task ExportUsersAsync(string token, Content content = Conte /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of users added or updated public async Task ImportUsersAsync(string token, List data, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4501,7 +4546,7 @@ public async Task ImportUsersAsync(string token, List data, Redcap }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4549,7 +4594,7 @@ public async Task ImportUsersAsync(string token, List data, Redcap /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of users added or updated public async Task ImportUsersAsync(string token, Content content, List data, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4569,7 +4614,7 @@ public async Task ImportUsersAsync(string token, Content content, Lis return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4590,7 +4635,7 @@ public async Task ImportUsersAsync(string token, Content content, Lis /// user /// delete /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of Users deleted public async Task DeleteUsersAsync(string token, List users, Content content = Content.User, RedcapAction action = RedcapAction.Delete, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4604,13 +4649,13 @@ public async Task DeleteUsersAsync(string token, List users, Con { "action", action.GetDisplayName() } }; // Required - for (var i = 0; i < users.Count; i++) + for(var i = 0; i < users.Count; i++) { payload.Add($"users[{i}]", users[i]); } return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4635,7 +4680,7 @@ public async Task DeleteUsersAsync(string token, List users, Con /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// The method will return all the attributes below with regard to user roles privileges in the format specified. Please note that the 'forms' attribute is the only attribute that contains sub-elements (one for each data collection instrument), in which each form will have its own Form Rights value (see the key below to learn what each numerical value represents). /// Most user role privilege attributes are boolean (0=No Access, 1=Access). Attributes returned: /// unique_role_name, role_label, design, user_rights, data_access_groups, data_export, reports, stats_and_charts, manage_survey_participants, calendar, data_import_tool, data_comparison_tool, logging, file_repository, data_quality_create, data_quality_execute, api_export, api_import, mobile_app, mobile_app_download_data, record_create, record_rename, record_delete, lock_records_customization, lock_records, lock_records_all_forms, forms @@ -4671,7 +4716,7 @@ public async Task ExportUserRolesAsync(string token, Content content = C }; return await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return Ex.Message; @@ -4700,7 +4745,7 @@ public async Task ExportUserRolesAsync(string token, Content content = C /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of user roles added or updated public async Task ImportUserRolesAsync(string token, List data, Content content = Content.UserRole, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat returnFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4721,7 +4766,7 @@ public async Task ImportUserRolesAsync(string token, List data, Co importUserRolesResult = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return importUserRolesResult; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return importUserRolesResult; @@ -4742,7 +4787,7 @@ public async Task ImportUserRolesAsync(string token, List data, Co /// userRole /// delete /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of User Roles deleted public async Task DeleteUserRolesAsync(string token, List roles, Content content = Content.UserRole, RedcapAction action = RedcapAction.Delete, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4758,7 +4803,7 @@ public async Task DeleteUserRolesAsync(string token, List roles, { "action", action.GetDisplayName() } }; // Required - for (var i = 0; i < roles.Count; i++) + for(var i = 0; i < roles.Count; i++) { payload.Add($"roles[{i}]", roles[i]); } @@ -4766,7 +4811,7 @@ public async Task DeleteUserRolesAsync(string token, List roles, deleteUserRolesResult = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return deleteUserRolesResult; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return deleteUserRolesResult; @@ -4787,7 +4832,7 @@ public async Task DeleteUserRolesAsync(string token, List roles, /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// User-Role assignments for the project in the format specified public async Task ExportUserRoleAssignmentAsync(string token, Content content = Content.UserRoleMapping, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat onErrorFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4807,7 +4852,7 @@ public async Task ExportUserRoleAssignmentAsync(string token, Content co exportUserRolesAssignmentResult = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return exportUserRolesAssignmentResult; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return exportUserRolesAssignmentResult; @@ -4836,7 +4881,7 @@ public async Task ExportUserRoleAssignmentAsync(string token, Content co /// csv, json [default], xml /// csv, json, xml - specifies the format of error messages. If you do not pass in this flag, it will select the default format for you passed based on the 'format' flag you passed in or if no format flag was passed in, it will default to 'json'. /// - /// Number of seconds before the http request tiems out. + /// Number of seconds before the http request times out. /// Number of User-Role assignments added or updated public async Task ImportUserRoleAssignmentAsync(string token, List data, Content content = Content.UserRoleMapping, RedcapAction action = RedcapAction.Import, RedcapFormat format = RedcapFormat.json, RedcapReturnFormat onErrorFormat = RedcapReturnFormat.json, CancellationToken cancellationToken = default, long timeOutSeconds = 100) { @@ -4858,7 +4903,7 @@ public async Task ImportUserRoleAssignmentAsync(string token, List importUserRoleAssignmentResult = await this.SendPostRequestAsync(payload, _uri, cancellationToken: cancellationToken, timeOutSeconds); return importUserRoleAssignmentResult; } - catch (Exception Ex) + catch(Exception Ex) { Log.Error($"{Ex.Message}"); return importUserRoleAssignmentResult; diff --git a/RedcapApi/Models/RedcapAction.cs b/RedcapApi/Models/RedcapAction.cs index 37d0d43..7f06398 100644 --- a/RedcapApi/Models/RedcapAction.cs +++ b/RedcapApi/Models/RedcapAction.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Text; +using System.ComponentModel.DataAnnotations; namespace Redcap.Models { @@ -51,6 +47,12 @@ public enum RedcapAction /// Rename ///
[Display(Name = "rename")] - Rename + Rename, + + /// + /// Randomize + /// + [Display(Name = "randomize")] + Randomize } } diff --git a/RedcapApi/Redcap.csproj b/RedcapApi/Redcap.csproj index b103f78..ecf45fe 100644 --- a/RedcapApi/Redcap.csproj +++ b/RedcapApi/Redcap.csproj @@ -11,20 +11,20 @@ This library allows applications on the .NET platform to make http calls to REDCap instances. Redcap Api Library RedcapAPI - 1.3.6 - 1.3.6 + 1.3.7 + 1.3.7 redcap api library vcu Library en - 1.3.6 + 1.3.7 https://github.com/cctrbic/redcap-api/blob/master/LICENSE.md https://vortex.cctr.vcu.edu/images/ram_crest_160.png vcu.png Redcap Api - - -Enhancements: Provide the ability to pass a timeout argument to individual http requests, - -multiple bug fixes + Add support for new API Method: +- RandomizeRecord - This method allows the current API user to randomize a record. This follows the Randomization 2.0 Update in REDCap v14.7.0 + README.md True @@ -49,6 +49,6 @@ - + \ No newline at end of file diff --git a/RedcapApiDemo/Program.cs b/RedcapApiDemo/Program.cs index c319ec5..cc542e0 100644 --- a/RedcapApiDemo/Program.cs +++ b/RedcapApiDemo/Program.cs @@ -2,7 +2,9 @@ using Redcap; using Redcap.Models; + using RedcapApiDemo.Models; + using System; using System.Collections.Generic; using System.IO; @@ -138,7 +140,7 @@ static async Task InitializeDemo() Console.WriteLine("Please make sure you include a working redcap api token."); Console.WriteLine("Enter your redcap instance uri, example: http://localhost/redcap"); _uri = Console.ReadLine(); - if (string.IsNullOrEmpty(_uri)) + if(string.IsNullOrEmpty(_uri)) { // provide a default one here.. _uri = "http://localhost/redcap"; @@ -147,9 +149,9 @@ static async Task InitializeDemo() Console.WriteLine("Enter your api token for the project to test: "); var token = Console.ReadLine(); - if (string.IsNullOrEmpty(token)) + if(string.IsNullOrEmpty(token)) { - _token = "DF70F2EC94AE05021F66423B386095BD"; + _token = "BFB6C6194FCEA7300170D076903B3EC7"; } else { @@ -163,13 +165,13 @@ static async Task InitializeDemo() Console.ReadLine(); Console.WriteLine("Creating a new instance of RedcapApi"); - var redcap_api_2_0_0 = new RedcapApi(_uri); + var redcap_api = new RedcapApi(_uri); Console.WriteLine($"Using {_uri.ToString()} for redcap api endpoint."); #region ExportLoggingAsync() Console.WriteLine("Calling ExportLoggingAsync() . . ."); Console.WriteLine($"Exporting logs for User . . ."); - var ExportLoggingAsync = await redcap_api_2_0_0.ExportLoggingAsync(_token, Content.Log, RedcapFormat.json, LogType.User); + var ExportLoggingAsync = await redcap_api.ExportLoggingAsync(_token, Content.Log, RedcapFormat.json, LogType.User); Console.WriteLine($"ExportLoggingAsync Results: {JsonConvert.DeserializeObject(ExportLoggingAsync)}"); Console.WriteLine("----------------------------Press Enter to Continue-------------"); Console.ReadLine(); @@ -180,7 +182,7 @@ static async Task InitializeDemo() Console.WriteLine("Calling ImportDagsAsync() . . ."); Console.WriteLine($"Importing Dags . . ."); var dags = CreateDags(5); - var ImportDagsAsyncResult = await redcap_api_2_0_0.ImportDagsAsync(_token, Content.Dag, RedcapAction.Import, RedcapFormat.json, dags); + var ImportDagsAsyncResult = await redcap_api.ImportDagsAsync(_token, Content.Dag, RedcapAction.Import, RedcapFormat.json, dags); Console.WriteLine($"ImportDagsAsync Results: {JsonConvert.DeserializeObject(ImportDagsAsyncResult)}"); Console.WriteLine("----------------------------Press Enter to Continue-------------"); Console.ReadLine(); @@ -190,7 +192,7 @@ static async Task InitializeDemo() #region ExportDagsAsync() Console.WriteLine("Calling ExportDagsAsync() . . ."); Console.WriteLine($"Exporting Dags . . ."); - var ExportDagsAsyncResult = await redcap_api_2_0_0.ExportDagsAsync(_token, Content.Dag, RedcapFormat.json); + var ExportDagsAsyncResult = await redcap_api.ExportDagsAsync(_token, Content.Dag, RedcapFormat.json); Console.WriteLine($"ExportDagsAsync Results: {JsonConvert.DeserializeObject(ExportDagsAsyncResult)}"); Console.WriteLine("----------------------------Press Enter to Continue-------------"); Console.ReadLine(); @@ -200,7 +202,7 @@ static async Task InitializeDemo() Console.WriteLine("Calling DeleteDagsAsync() . . ."); Console.WriteLine($"Deleting Dags . . ."); var dagsToDelete = JsonConvert.DeserializeObject>(ExportDagsAsyncResult).Select(x => x.UniqueGroupName).ToArray(); - var DeleteDagsAsyncResult = await redcap_api_2_0_0.DeleteDagsAsync(_token, Content.Dag, RedcapAction.Delete, dagsToDelete); + var DeleteDagsAsyncResult = await redcap_api.DeleteDagsAsync(_token, Content.Dag, RedcapAction.Delete, dagsToDelete); Console.WriteLine($"DeleteDagsAsync Results: {JsonConvert.DeserializeObject(DeleteDagsAsyncResult)}"); Console.WriteLine("----------------------------Press Enter to Continue-------------"); Console.ReadLine(); @@ -212,7 +214,7 @@ static async Task InitializeDemo() var importDemographicsData = CreateDemographics(includeBio: true, 5); Console.WriteLine("Serializing the data . . ."); Console.WriteLine($"Importing record {string.Join(",", importDemographicsData.Select(x => x.RecordId).ToList())} . . ."); - var ImportRecordsAsync = await redcap_api_2_0_0.ImportRecordsAsync(_token, Content.Record, RedcapFormat.json, RedcapDataType.flat, OverwriteBehavior.normal, forceAutoNumber: true, backgroundProcess: true, importDemographicsData, "MDY", CsvDelimiter.tab, ReturnContent.count, RedcapReturnFormat.json); + var ImportRecordsAsync = await redcap_api.ImportRecordsAsync(_token, Content.Record, RedcapFormat.json, RedcapDataType.flat, OverwriteBehavior.normal, forceAutoNumber: true, backgroundProcess: true, importDemographicsData, "MDY", CsvDelimiter.tab, ReturnContent.count, RedcapReturnFormat.json); var ImportRecordsAsyncData = JsonConvert.DeserializeObject(ImportRecordsAsync); Console.WriteLine($"ImportRecordsAsync Result: {ImportRecordsAsyncData}"); Console.WriteLine("----------------------------Press Enter to Continue-------------"); @@ -224,7 +226,7 @@ static async Task InitializeDemo() Console.WriteLine($"Using records from the imported method.."); var recordsToExport = importDemographicsData.Select(x => x.RecordId).ToArray(); var instrumentName = new string[] { "demographics" }; - var ExportRecordsAsyncResult = await redcap_api_2_0_0.ExportRecordsAsync(_token, Content.Record, RedcapFormat.json, RedcapDataType.flat, recordsToExport, null, instrumentName); + var ExportRecordsAsyncResult = await redcap_api.ExportRecordsAsync(_token, Content.Record, RedcapFormat.json, RedcapDataType.flat, recordsToExport, null, instrumentName); Console.WriteLine($"ExportRecordsAsyncResult: {ExportRecordsAsyncResult}"); Console.WriteLine("----------------------------Press Enter to Continue-------------"); Console.ReadLine(); @@ -234,7 +236,7 @@ static async Task InitializeDemo() Console.WriteLine("Calling DeleteRecordsAsync() . . ."); var records = importDemographicsData.Select(x => x.RecordId).ToArray(); Console.WriteLine($"Deleting record {string.Join(",", recordsToExport)} . . ."); - var DeleteRecordsAsync = await redcap_api_2_0_0.DeleteRecordsAsync(_token, Content.Record, RedcapAction.Delete, recordsToExport, 1); + var DeleteRecordsAsync = await redcap_api.DeleteRecordsAsync(_token, Content.Record, RedcapAction.Delete, recordsToExport, 1); var DeleteRecordsAsyncData = JsonConvert.DeserializeObject(DeleteRecordsAsync); Console.WriteLine($"DeleteRecordsAsync Result: {DeleteRecordsAsyncData}"); @@ -247,7 +249,7 @@ static async Task InitializeDemo() var recordToRename = importDemographicsData.Select(x => x.RecordId).SingleOrDefault(); Console.WriteLine($"Renaming record {recordToRename} . . ."); var newRecordName = "2"; - var RenameRecordAsyncResult = await redcap_api_2_0_0.RenameRecordAsync(_token, Content.Record, RedcapAction.Rename,recordToRename, newRecordName, 1); + var RenameRecordAsyncResult = await redcap_api.RenameRecordAsync(_token, Content.Record, RedcapAction.Rename,recordToRename, newRecordName, 1); var RenameRecordAsyncData = JsonConvert.DeserializeObject(RenameRecordAsyncResult); Console.WriteLine($"RenameRecordAsync Result: {DeleteRecordsAsyncData}"); @@ -255,6 +257,18 @@ static async Task InitializeDemo() Console.ReadLine(); #endregion RenameRecordAsync() + #region RandomizeRecord + Console.WriteLine("Calling RandomizeRecord() Make sure project is randomization ready with tables etc. . . ."); + var record = "3"; + var randomizationId = "2"; + var randomizationResult = await redcap_api.RandomizeRecord(_token, Content.Record, RedcapAction.Randomize, record, randomizationId, RedcapFormat.json, RedcapReturnFormat.json); + var randomizationData = JsonConvert.DeserializeObject(randomizationResult); + Console.WriteLine($"RandomizeRecord Result: {randomizationData}"); + Console.WriteLine("----------------------------Press Enter to Continue-------------"); + Console.ReadLine(); + + #endregion RandomizeRecord + #region Users & User Priveleges @@ -265,7 +279,7 @@ static async Task InitializeDemo() redcapUsers.Add(redcapUser1); redcapUsers.Add(redcapUser2); Console.WriteLine($"Importing {redcapUsers.Count} user. . ."); - var ImportUsersAsyncResult = await redcap_api_2_0_0.ImportUsersAsync(_token, redcapUsers, RedcapFormat.json, RedcapReturnFormat.json); + var ImportUsersAsyncResult = await redcap_api.ImportUsersAsync(_token, redcapUsers, RedcapFormat.json, RedcapReturnFormat.json); var ImportUsersAsyncData = JsonConvert.DeserializeObject(ImportUsersAsyncResult); Console.WriteLine($"ImportUsersAsync Result: {ImportUsersAsyncData}"); Console.WriteLine("----------------------------Press Enter to Continue-------------"); @@ -276,7 +290,7 @@ static async Task InitializeDemo() #region ExportArmsAsync() var arms = new string[] { }; Console.WriteLine("Calling ExportArmsAsync()"); - var ExportArmsAsyncResult = await redcap_api_2_0_0.ExportArmsAsync(_token, Content.Arm, RedcapFormat.json, arms, RedcapReturnFormat.json); + var ExportArmsAsyncResult = await redcap_api.ExportArmsAsync(_token, Content.Arm, RedcapFormat.json, arms, RedcapReturnFormat.json); Console.WriteLine($"ExportArmsAsyncResult: {JsonConvert.DeserializeObject(ExportArmsAsyncResult)}"); #endregion ExportArmsAsync() @@ -286,7 +300,7 @@ static async Task InitializeDemo() #region ImportArmsAsync() var ImportArmsAsyncData = CreateArms(count: 3); Console.WriteLine("Calling ImportArmsAsync()"); - var ImportArmsAsyncResult = await redcap_api_2_0_0.ImportArmsAsync(_token, Content.Arm, Override.False, RedcapAction.Import, RedcapFormat.json, ImportArmsAsyncData, RedcapReturnFormat.json); + var ImportArmsAsyncResult = await redcap_api.ImportArmsAsync(_token, Content.Arm, Override.False, RedcapAction.Import, RedcapFormat.json, ImportArmsAsyncData, RedcapReturnFormat.json); Console.WriteLine($"ImportArmsAsyncResult: {JsonConvert.DeserializeObject(ImportArmsAsyncResult)}"); #endregion ImportArmsAsync() @@ -296,7 +310,7 @@ static async Task InitializeDemo() #region DeleteArmsAsync() var DeleteArmsAsyncData = ImportArmsAsyncData.Select(x => x.ArmNumber).ToArray(); Console.WriteLine("Calling DeleteArmsAsync()"); - var DeleteArmsAsyncResult = await redcap_api_2_0_0.DeleteArmsAsync(_token, Content.Arm, RedcapAction.Delete, DeleteArmsAsyncData); + var DeleteArmsAsyncResult = await redcap_api.DeleteArmsAsync(_token, Content.Arm, RedcapAction.Delete, DeleteArmsAsyncData); Console.WriteLine($"DeleteArmsAsyncResult: {JsonConvert.DeserializeObject(DeleteArmsAsyncResult)}"); #endregion DeleteArmsAsync() @@ -306,7 +320,7 @@ static async Task InitializeDemo() #region ExportEventsAsync() var ExportEventsAsyncData = new string[] { "1" }; Console.WriteLine("Calling ExportEventsAsync()"); - var ExportEventsAsyncResult = await redcap_api_2_0_0.ExportEventsAsync(_token, Content.Event, RedcapFormat.json, ExportEventsAsyncData, RedcapReturnFormat.json); + var ExportEventsAsyncResult = await redcap_api.ExportEventsAsync(_token, Content.Event, RedcapFormat.json, ExportEventsAsyncData, RedcapReturnFormat.json); Console.WriteLine($"ExportEventsAsyncResult: {JsonConvert.DeserializeObject(ExportEventsAsyncResult)}"); #endregion ExportEventsAsync() @@ -335,7 +349,7 @@ static async Task InitializeDemo() CustomEventLabel = "hello clinical" } }; - var ImportEventsAsyncResult = await redcap_api_2_0_0.ImportEventsAsync(_token, Content.Event, RedcapAction.Import, Override.False, RedcapFormat.json, eventList, RedcapReturnFormat.json); + var ImportEventsAsyncResult = await redcap_api.ImportEventsAsync(_token, Content.Event, RedcapAction.Import, Override.False, RedcapFormat.json, eventList, RedcapReturnFormat.json); Console.WriteLine($"ImportEventsAsyncResult: {ImportEventsAsyncResult}"); #endregion ImportEventsAsync() @@ -346,7 +360,7 @@ static async Task InitializeDemo() #region DeleteEventsAsync() var DeleteEventsAsyncData = new string[] { "baseline_arm_1" }; Console.WriteLine("Calling DeleteEventsAsync()"); - var DeleteEventsAsyncResult = await redcap_api_2_0_0.DeleteEventsAsync(_token, Content.Event, RedcapAction.Delete, DeleteEventsAsyncData); + var DeleteEventsAsyncResult = await redcap_api.DeleteEventsAsync(_token, Content.Event, RedcapAction.Delete, DeleteEventsAsyncData); Console.WriteLine($"DeleteEventsAsyncResult: {DeleteEventsAsyncResult}"); #endregion DeleteEventsAsync() @@ -357,7 +371,7 @@ static async Task InitializeDemo() #region SwitchDagAsync() var SwitchDagAsyncData = new RedcapDag { GroupName = "testGroup", UniqueGroupName = "unique_name" }; Console.WriteLine("Calling SwitchDagAsync()"); - var SwitchDagAsyncResult = await redcap_api_2_0_0.SwitchDagAsync(_token, SwitchDagAsyncData, Content.Dag, RedcapAction.Switch); + var SwitchDagAsyncResult = await redcap_api.SwitchDagAsync(_token, SwitchDagAsyncData, Content.Dag, RedcapAction.Switch); Console.WriteLine($"SwitchDagAsyncResult: {SwitchDagAsyncResult}"); #endregion SwitchDagAsync() @@ -368,7 +382,7 @@ static async Task InitializeDemo() #region ExportFieldNamesAsync() Console.WriteLine("Calling ExportFieldNamesAsync(), first_name"); - var ExportFieldNamesAsyncResult = await redcap_api_2_0_0.ExportFieldNamesAsync(_token, Content.ExportFieldNames, RedcapFormat.json, "first_name", RedcapReturnFormat.json); + var ExportFieldNamesAsyncResult = await redcap_api.ExportFieldNamesAsync(_token, Content.ExportFieldNames, RedcapFormat.json, "first_name", RedcapReturnFormat.json); Console.WriteLine($"ExportFieldNamesAsyncResult: {ExportFieldNamesAsyncResult}"); #endregion ExportFieldNamesAsync() @@ -384,7 +398,7 @@ static async Task InitializeDemo() var parent = Directory.GetParent(parentDirectory).FullName; var filePath = Directory.GetParent(parent).FullName + @"\Docs\"; Console.WriteLine($"Calling ImportFileAsync(), {fileName}"); - var ImportFileAsyncResult = await redcap_api_2_0_0.ImportFileAsync(_token, Content.File, RedcapAction.Import, recordId, fieldName, eventName, null, fileName, filePath, RedcapReturnFormat.json); + var ImportFileAsyncResult = await redcap_api.ImportFileAsync(_token, Content.File, RedcapAction.Import, recordId, fieldName, eventName, null, fileName, filePath, RedcapReturnFormat.json); Console.WriteLine($"ImportFileAsyncResult: {ImportFileAsyncResult}"); #endregion ImportFileAsync() @@ -394,7 +408,7 @@ static async Task InitializeDemo() #region ExportFileAsync() Console.WriteLine($"Calling ExportFileAsync(), {fileName} for field name {fieldName}, not save the file."); - var ExportFileAsyncResult = await redcap_api_2_0_0.ExportFileAsync(_token, Content.File, RedcapAction.Export, recordId, fieldName, eventName, null, RedcapReturnFormat.json); + var ExportFileAsyncResult = await redcap_api.ExportFileAsync(_token, Content.File, RedcapAction.Export, recordId, fieldName, eventName, null, RedcapReturnFormat.json); Console.WriteLine($"ExportFileAsyncResult: {ExportFileAsyncResult}"); #endregion ExportFileAsync() @@ -404,7 +418,7 @@ static async Task InitializeDemo() #region ExportFileAsync() var filedDownloadPath = @"C:\redcap_download_files"; Console.WriteLine($"Calling ExportFileAsync(), {fileName} for field name {fieldName}, saving the file."); - var ExportFileAsyncResult2 = await redcap_api_2_0_0.ExportFileAsync(_token, Content.File, RedcapAction.Export, recordId, fieldName, eventName, null, RedcapReturnFormat.json, filedDownloadPath); + var ExportFileAsyncResult2 = await redcap_api.ExportFileAsync(_token, Content.File, RedcapAction.Export, recordId, fieldName, eventName, null, RedcapReturnFormat.json, filedDownloadPath); Console.WriteLine($"ExportFileAsyncResult2: {ExportFileAsyncResult2}"); #endregion ExportFileAsync() @@ -413,7 +427,7 @@ static async Task InitializeDemo() #region DeleteFileAsync() Console.WriteLine($"Calling DeleteFileAsync(), deleting file: {fileName} for field: {fieldName}"); - var DeleteFileAsyncResult = await redcap_api_2_0_0.DeleteFileAsync(_token, Content.File, RedcapAction.Delete, recordId, fieldName, eventName, "1", RedcapReturnFormat.json); + var DeleteFileAsyncResult = await redcap_api.DeleteFileAsync(_token, Content.File, RedcapAction.Delete, recordId, fieldName, eventName, "1", RedcapReturnFormat.json); Console.WriteLine($"DeleteFileAsyncResult: {DeleteFileAsyncResult}"); #endregion DeleteFileAsync() @@ -422,7 +436,7 @@ static async Task InitializeDemo() #region ExportInstrumentsAsync() Console.WriteLine($"Calling DeleteFileAsync()"); - var ExportInstrumentsAsyncResult = await redcap_api_2_0_0.ExportInstrumentsAsync(_token, Content.Instrument, RedcapFormat.json); + var ExportInstrumentsAsyncResult = await redcap_api.ExportInstrumentsAsync(_token, Content.Instrument, RedcapFormat.json); Console.WriteLine($"ExportInstrumentsAsyncResult: {ExportInstrumentsAsyncResult}"); #endregion ExportInstrumentsAsync() @@ -431,7 +445,7 @@ static async Task InitializeDemo() #region ExportPDFInstrumentsAsync() Console.WriteLine($"Calling ExportPDFInstrumentsAsync(), returns raw"); - var ExportPDFInstrumentsAsyncResult = await redcap_api_2_0_0.ExportPDFInstrumentsAsync(_token, Content.Pdf, recordId, eventName, "demographics", true); + var ExportPDFInstrumentsAsyncResult = await redcap_api.ExportPDFInstrumentsAsync(_token, Content.Pdf, recordId, eventName, "demographics", true); Console.WriteLine($"ExportInstrumentsAsyncResult: {JsonConvert.SerializeObject(ExportPDFInstrumentsAsyncResult)}"); #endregion ExportPDFInstrumentsAsync() @@ -440,7 +454,7 @@ static async Task InitializeDemo() #region ExportPDFInstrumentsAsync() Console.WriteLine($"Calling ExportPDFInstrumentsAsync(), saving pdf file to {filedDownloadPath}"); - var ExportPDFInstrumentsAsyncResult2 = await redcap_api_2_0_0.ExportPDFInstrumentsAsync(_token, recordId, eventName, "demographics", true, filedDownloadPath, RedcapReturnFormat.json); + var ExportPDFInstrumentsAsyncResult2 = await redcap_api.ExportPDFInstrumentsAsync(_token, recordId, eventName, "demographics", true, filedDownloadPath, RedcapReturnFormat.json); Console.WriteLine($"ExportPDFInstrumentsAsyncResult2: {ExportPDFInstrumentsAsyncResult2}"); #endregion ExportPDFInstrumentsAsync() @@ -460,7 +474,7 @@ static async Task InitializeDemo() #region ImportInstrumentMappingAsync() var importInstrumentMappingData = new List { new FormEventMapping { arm_num = "1", unique_event_name = "clinical_arm_1", form = "demographics" } }; Console.WriteLine($"Calling ImportInstrumentMappingAsync()"); - var ImportInstrumentMappingAsyncResult = await redcap_api_2_0_0.ImportInstrumentMappingAsync(_token, Content.FormEventMapping, RedcapFormat.json, importInstrumentMappingData, RedcapReturnFormat.json); + var ImportInstrumentMappingAsyncResult = await redcap_api.ImportInstrumentMappingAsync(_token, Content.FormEventMapping, RedcapFormat.json, importInstrumentMappingData, RedcapReturnFormat.json); Console.WriteLine($"ImportInstrumentMappingAsyncResult: {ImportInstrumentMappingAsyncResult}"); #endregion ImportInstrumentMappingAsync() @@ -469,7 +483,7 @@ static async Task InitializeDemo() #region ExportMetaDataAsync() Console.WriteLine($"Calling ExportMetaDataAsync()"); - var ExportMetaDataAsyncResult = await redcap_api_2_0_0.ExportMetaDataAsync(_token, Content.MetaData, RedcapFormat.json, null, null, RedcapReturnFormat.json); + var ExportMetaDataAsyncResult = await redcap_api.ExportMetaDataAsync(_token, Content.MetaData, RedcapFormat.json, null, null, RedcapReturnFormat.json); Console.WriteLine($"ExportMetaDataAsyncResult: {ExportMetaDataAsyncResult}"); #endregion ExportMetaDataAsync() @@ -493,7 +507,7 @@ static async Task InitializeDemo() var projectData = new List { new RedcapProject { project_title = "Amazing Project ", purpose = ProjectPurpose.Other, purpose_other = "Test" } }; Console.WriteLine($"Calling CreateProjectAsync(), creating a new project with Amazing Project as title, purpose 1 (other) "); Console.WriteLine($"-----------------------Notice the use of SUPER TOKEN------------------------"); - var CreateProjectAsyncResult = await redcap_api_2_0_0.CreateProjectAsync(_superToken, Content.Project, RedcapFormat.json, projectData, RedcapReturnFormat.json, null); + var CreateProjectAsyncResult = await redcap_api.CreateProjectAsync(_superToken, Content.Project, RedcapFormat.json, projectData, RedcapReturnFormat.json, null); Console.WriteLine($"CreateProjectAsyncResult: {CreateProjectAsyncResult}"); #endregion CreateProjectAsync() Console.WriteLine("----------------------------Press Enter to Continue-------------"); @@ -502,7 +516,7 @@ static async Task InitializeDemo() #region ImportProjectInfoAsync() var projectInfo = new RedcapProjectInfo { ProjectTitle = "Updated Amazing Project ", Purpose = ProjectPurpose.QualityImprovement, SurveysEnabled = 1 }; Console.WriteLine($"Calling ImportProjectInfoAsync()"); - var ImportProjectInfoAsyncResult = await redcap_api_2_0_0.ImportProjectInfoAsync(_token, Content.ProjectSettings, RedcapFormat.json, projectInfo); + var ImportProjectInfoAsyncResult = await redcap_api.ImportProjectInfoAsync(_token, Content.ProjectSettings, RedcapFormat.json, projectInfo); Console.WriteLine($"ImportProjectInfoAsyncResult: {ImportProjectInfoAsyncResult}"); #endregion ImportProjectInfoAsync() Console.WriteLine("----------------------------Press Enter to Continue-------------"); @@ -510,7 +524,7 @@ static async Task InitializeDemo() #region ExportProjectInfoAsync() Console.WriteLine($"Calling ExportProjectInfoAsync()"); - var ExportProjectInfoAsyncResult = await redcap_api_2_0_0.ExportProjectInfoAsync(_token, Content.ProjectSettings, RedcapFormat.json); + var ExportProjectInfoAsyncResult = await redcap_api.ExportProjectInfoAsync(_token, Content.ProjectSettings, RedcapFormat.json); Console.WriteLine($"ExportProjectInfoAsyncResult: {ExportProjectInfoAsyncResult}"); #endregion ExportProjectInfoAsync() @@ -524,7 +538,7 @@ public static Demographic GetRandomPerson(string id, bool includeBio = false) person.RecordId = id; person.FirstName = Names[rand.Next(Names.Length)]; person.LastName = Places[rand.Next(Places.Length)]; - if (includeBio) + if(includeBio) { person.Bio = VeryLargeText; } @@ -533,13 +547,13 @@ public static Demographic GetRandomPerson(string id, bool includeBio = false) public static List CreateDemographics(bool includeBio = false, int count = 1) { var demographics = new List(); - for (var i = 1; i <= count; i++) + for(var i = 1; i <= count; i++) { var _demographicFiller = new Filler(); - + _demographicFiller.Setup().OnProperty(x => x.RecordId).Use(i.ToString()); var _demographic = _demographicFiller.Create(); - if (includeBio) + if(includeBio) { _demographic.Bio = VeryLargeText; } @@ -552,7 +566,7 @@ public static List CreateArms(int count = 1) { var arms = new List(); - for (var i = 0; i < count; i++) + for(var i = 0; i < count; i++) { var _demographicFiller = new Filler(); _demographicFiller.Setup().OnProperty(x => x.ArmNumber).Use(i.ToString()); @@ -561,7 +575,8 @@ public static List CreateArms(int count = 1) } return arms; } - public static List CreateDags(int count = 1){ + public static List CreateDags(int count = 1) + { var dags = new List(); for(var i = 0; i < count; i++) diff --git a/RedcapApiDemo/RedcapApiDemo.csproj b/RedcapApiDemo/RedcapApiDemo.csproj index 97f21c1..c0eacd9 100644 --- a/RedcapApiDemo/RedcapApiDemo.csproj +++ b/RedcapApiDemo/RedcapApiDemo.csproj @@ -7,8 +7,8 @@ - - + +