Update: 2023-04-22
General Operations
- Initializing and cleanup of the SDK
- Working with the 837 transaction set
- Working with the 835 transaction set
- Working with the 277 transaction set
- Working with the 999 transaction set
Initializing the SDK
Important
Initialization should be called only once at the start of your application and clean up should be called only once at the end or termination of your application.
You must first initialize the SDK to process transactions.
This step is responsible for loading the necessary X12 resources before you can process any transactions. It also provides the SDK with information about your company as the originator (sender, submitter, or source) for processing outbound transactions.
Set Default Settings
First, set X12Config to define default settings about you as the source, sender or submitter of EDI transactions.
The SDK uses these settings to populate appropriate loops and segments in various transactions that your application creates.
// Sample config file.
var cfg = new X12Config()
{
// Required. Default:Clearinghouse. Used during creation of transactions by your system.
// Uncomment if you are a Payer
// EntityCode = X12EntityCode.Payer,
// Required. Default:NonPerson. Identifies the type of entity you or your organization (i.e., a Person or a None person)
// Uncomment if you are a person (an individual)
// EntityType = X12EntityType.Person,
// Required. No Default. This is a short 3-4 letter alias for your organization. Used internally on file naming operations to distinguish you
// as originating files for others. It is also used by the SDK to create unique originating document control numbers that reference transactions.
Alias = "BHT",
// Required. No Default. This is your organization name or if an individual the person's last name. This value is inserted as the source
// in your transactions
LastOrOrgName = "Bishop Healthcare Technologies",
// Required. Default:ZZ. This is the type of number you are using for your Electronic Transaction Identification Number (ETIN).
// Uncomment if you want to change this to one of other codes that identifies your ETIN
// IdQualifier = "ZZ",
// Required. No Default. This is your Electronic Trader Identification Number; the SDK will use this value as the sender of your transactions and
// as the receiver of inbound transactions
ETIN = "113766",
// Required. No Default. This can be a person or department name. This the name the receivers of your transactions will contact at your organization
// when they have issues or questions with your transactions.
SupportContactName = "BHT Support",
// Required. No Default. Set your default support phone number. This is the phone number the receivers of your transactions should use to contact
// SupportContactName (see above) with questions or issues with your transaction.
SupportPhone = "9045551212",
// Optional. No Default. Enter your phone extension as part of SupportPhone (see above).
// SupportPhoneExt = "101",
// Required. No Default. This is the support e-mail address that receivers of your transactions should use to contact you about your transactions.
SupportEMail = "support@bishopht.com",
};
Next, call X12Api.Init() passing to it your credentials (sid and auth), the path to the SDK installation where supporting files are located, and an instance of the X12Config object.
Warning
Upon exiting your applicaton you must call X12Api.Finish() to free up allocated resources.
var cfg = new X12Config()
{
... // See example above how to defined your configuration
};
// Initialize the SDK with an on progress delegate to receive status updates during long running operations. Alternatively
// you can pass in an onx12progress delegate to recieve events during long running operations like batching and splitting.
if (!(await X12Api.InitAsync(uid, pwd, sid, aid, cfg)))
throw new Exception("Failed to initialize X12Api!");
... // your code here
// Free up resources
X12Api.Finish();
Implementation Suggestion
You might consider implementing a wrapper class for the SDK to ensure proper resource allocation and resource cleanup.
namespace X12Sandbox;
public class X12Samples : IDisposable
{
private bool disposed = false;
X12Samples()
{
}
public static async Task<X12Samples> CreateAsync(string uid, string pwd, string sid, string aid)
{
var cfg = new X12Config()
{
Alias = "MBC",
LastOrOrgName = "My Billing Company Inc.",
IdQualifier = "ZZ",
ETIN = "1234567890",
SupportContactName = "MBC Support",
SupportPhone = "9045551212",
SupportEMail = "support@mbc.com",
};
X12Samples sample = new();
// Initialize the SDK with an on progress delegate to receive status updates during long running operations. Alternatively
// you can pass in an onx12progress delegate to receive events during long running operations like batching and splitting.
if (!(await X12Api.InitAsync(uid, pwd, sid, aid, cfg)))
throw new Exception("Failed to initialize X12Api!");
return sample;
}
~X12Samples()
{
Dispose(false);
}
protected void Dispose(bool disposing)
{
if (disposed)
return;
if (disposing)
{
// Free up resources
X12Api.Finish();
disposed = true;
}
}
/// <summary>
/// Disposes the current derived X12 SDK object freeing up allocated resources
/// </summary>
public void Dispose()
{
Dispose(true);
disposed = true;
GC.SuppressFinalize(this);
}
// Implement your event delegates
// Example: Install an on progress delegate to get updates during long running operations
public void OnX12Progress(int totalItems, int currentItem)
{
...
}
// Implement your methods
public void Create837P()
{
...
}
}
Within your application program.cs file you might create an instance of the X12Samples class and perform your operations and it will automatically cleanup and free resources upon exit.
using X12Sandbox;
string uid = "your bishop registered user id";
string pwd = "your user password";
string sid = "security identifier";
string aid = "authorization identifier";
using X12Samples x12 = await X12Samples.CreateAsync(uid, pwd, sid, aid);
x12.Create837P();
return;