Skip to content

Commit

Permalink
Merge pull request #28 from tranpl/master
Browse files Browse the repository at this point in the history
impliment apis and more tests
  • Loading branch information
tranpl authored Sep 15, 2017
2 parents d5d8102 + bfcbeea commit b3a9d65
Show file tree
Hide file tree
Showing 16 changed files with 1,045 additions and 253 deletions.
716 changes: 579 additions & 137 deletions RedcapApi/Api/Redcap.cs

Large diffs are not rendered by default.

348 changes: 257 additions & 91 deletions RedcapApi/Interfaces/IRedcap.cs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions RedcapApi/Models/Override.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
namespace Redcap.Models
{
/// <summary>
/// Used to erase existing arms in the project or only add new ones
/// </summary>
public enum Override
{
/// <summary>
/// true — You may use override=1 as a 'delete all + import' action in order to erase all existing Arms in the project while importing new Arms.
/// </summary>
True = 1,
/// <summary>
/// false [default] If override=0, then you can only add new Arms or rename existing ones.
/// </summary>
False = 0
}
}
6 changes: 6 additions & 0 deletions RedcapApi/Models/OverwriteBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
/// </summary>
public enum OverwriteBehavior
{
/// <summary>
/// blank/empty values will be ignored [default]
/// </summary>
normal = 0,
/// <summary>
/// blank/empty values are valid and will overwrite data
/// </summary>
overwrite = 1
}
}
6 changes: 6 additions & 0 deletions RedcapApi/Models/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@

namespace Redcap.Models
{
/// <summary>
/// A record should contain a set of key/value pair.
/// </summary>
public class Record
{
/// <summary>
/// A record value contains a key and its associated value.
/// </summary>
public KeyValuePair<string, string> Value { get; set; }
}
}
9 changes: 9 additions & 0 deletions RedcapApi/Models/RedcapArm.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
namespace Redcap.Models
{
/// <summary>
/// Arms are only available for longitudinal projects.
/// </summary>
public class RedcapArm
{
/// <summary>
/// Number associated with the event, e.g "1"
/// </summary>
public string arm_num { get; set; }
/// <summary>
/// Name of the event. e.g "event1_arm_1"
/// </summary>
public string name { get; set; }
}
}
14 changes: 0 additions & 14 deletions RedcapApi/Models/RedcapConfigurations.cs

This file was deleted.

12 changes: 12 additions & 0 deletions RedcapApi/Models/RedcapDataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@
/// </summary>
public enum RedcapDataType
{
/// <summary>
/// output as one record per row [default]
/// </summary>
flat = 0,
/// <summary>
/// input as one data point per row
/// </summary>
eav = 1,
/// <summary>
/// EAV: Non-longitudinal: Will have the fields - record*, field_name, value
/// </summary>
nonlongitudinal = 2,
/// <summary>
/// EAV: Longitudinal: Will have the fields - record*, field_name, value, redcap_event_name
/// </summary>
longitudinal = 3
}
}
9 changes: 9 additions & 0 deletions RedcapApi/Models/RedcapFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@
/// </summary>
public enum InputFormat
{
/// <summary>
/// Default Javascript Notation
/// </summary>
json = 0,
/// <summary>
/// Comma Seperated Values
/// </summary>
csv = 1,
/// <summary>
/// Extensible Markup Language
/// </summary>
xml = 2
}
}
6 changes: 6 additions & 0 deletions RedcapApi/Models/ReturnContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
/// </summary>
public enum ReturnContent
{
/// <summary>
/// ids - a list of all record IDs that were imported
/// </summary>
ids = 0,
/// <summary>
/// count [default] - the number of records imported
/// </summary>
count = 1
}
}
9 changes: 9 additions & 0 deletions RedcapApi/Models/ReturnFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@
/// </summary>
public enum ReturnFormat
{
/// <summary>
/// Default Javascript Notation
/// </summary>
json = 0,
/// <summary>
/// Comma Seperated Values
/// </summary>
csv = 1,
/// <summary>
/// Extensible Markup Language
/// </summary>
xml = 2
}
}
9 changes: 7 additions & 2 deletions RedcapApi/Redcap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<Description>This library allows external applications to connect to REDCap remotely and is used to programmatically retrieve or modify data or settings within REDCap, e.g Import/Export records into Redcap</Description>
<Product>Redcap Api Library</Product>
<PackageId>RedcapAPI</PackageId>
<Version>0.2.9-alpha</Version>
<AssemblyVersion>0.2.9.0</AssemblyVersion>
<Version>0.3.0-alpha</Version>
<AssemblyVersion>0.3.0.0</AssemblyVersion>
<PackageTags>redcap</PackageTags>
<PackageReleaseNotes>alpha release</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand All @@ -22,6 +22,11 @@

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>True</Optimize>
<DocumentationFile>bin\Debug\netcoreapp1.1\Redcap.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp1.1\Redcap.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand Down
12 changes: 10 additions & 2 deletions RedcapApiDemo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Redcap;
using Redcap.Models;
Expand All @@ -9,9 +10,11 @@ class Program
{
static void Main(string[] args)
{

Console.WriteLine("Redcap Api Demo Started!");

var redcap_api = new RedcapApi("3D57A7FA57C8A43F6C8803A84BB3957B", "http://localhost/redcap/api/");
var _apiToken = "3D57A7FA57C8A43F6C8803A84BB3957B";
if (true) _apiToken = "BCC9D1F214B8BE2AA4F24C56ED7674E4";
var redcap_api = new RedcapApi(_apiToken, "http://localhost/redcap/api/");

Console.WriteLine("Calling GetRecordAsync() . . .");
var GetRecordAsync = redcap_api.GetRecordAsync("1", InputFormat.json, RedcapDataType.flat, ReturnFormat.json, null, null, null, null).Result;
Expand Down Expand Up @@ -51,6 +54,11 @@ static void Main(string[] args)
var ExportRecordsAsyncData = JsonConvert.DeserializeObject(ExportRecordsAsync);
Console.WriteLine($"ExportRecordsAsync Result: {ExportRecordsAsyncData}");

Console.WriteLine("Calling ExportArmsAsync() . . .");
var ExportArmsAsync = redcap_api.ExportArmsAsync(InputFormat.json, ReturnFormat.json, new List<string> { }).Result;
var ExportArmsAsyncData = JsonConvert.DeserializeObject(ExportArmsAsync);
Console.WriteLine($"ExportArmsAsync Result: {ExportArmsAsyncData}");


Console.ReadLine();

Expand Down
2 changes: 1 addition & 1 deletion RedcapApiDemo/RedcapApiDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<Reference Include="Redcap">
<HintPath>..\RedcapApi\bin\Release\netcoreapp1.1\Redcap.dll</HintPath>
<HintPath>..\RedcapApi\bin\Debug\netcoreapp1.1\Redcap.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
Loading

0 comments on commit b3a9d65

Please sign in to comment.