HIPAA Database

All HIPAA Templates are compliant with Entity Framework and are ready to be used as entity models. Due to the complexity of the templates, however, a DBContext is provided for each transaction. To further improve the performance of reading\writing to the database, please refer to Entity Framework's patterns and guides.

 

 

 


 

 

 

Create database per transaction

Example for 834 (example code here):

  • Create a ConsoleApp project in Visual Studio and set it to be the StartUp project
  • Locate all files in the Entity Framework\834 folder and add them to the project

mceclip0.png

  • Use Entity Framework migrations to create the database by
    • Install Entity Framework from NuGet
    • Run the Enable-Migrations command in Package Manager Console
    • Run the Add-Migration command in Package Manager Console
    • Run the Update-Database command in Package Manager Console
  • Ensure that a valid connection string exists in the App.config and the database name refers to the transaction (HIPAA_5010_834 by default):
<connectionStrings>
<add name="Hipaa5010837PConnectionString" connectionString="Data Source=.;Initial Catalog=HIPAA_5010_837P;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings> </configuration> </connectionStrings> 

The DbContext expects the following connection string:

mceclip5.png

A DB structure is created:

mceclip6.png

 

 

 


 

 

 

Entity Framework Specifics

  • All EDI Templates implement an interface and inherit from a base class. This allows all the derived segment and complex element classes to be represented with a single Entity Framework entity (and a single database table) following the Table Per Hierarchy Inheritance concept
  /// <summary>
  /// Organization Summary Remittance
  /// </summary>
  [Serializable()]
  [DataContract()]
  [Segment("ENT")]
  public class ENT_OrganizationSummaryRemittance : ENT, I_ENT
  • All EDI Templates use List<string> to represent repeatable data elements (in both segments or complex elements). Entity Framework, however, doesn't work with collections of primitive types. To work around this limitation, all occurrences of List<string> in the templates have been amended in the following way:

EQ segment defines a repeatable data element, ServiceTypeCode at position one:

  [Serializable()]
  [DataContract()]
  [Segment("EQ", typeof(X12_ID_1365_3), typeof(X12_ID_235_12))]
  public class EQ_DependentEligibilityorBenefitInquiry : 
EQ, I_EQ<C003_CompositeMedicalProcedureIdentifier, C004_CompositeDiagnosisCodePointer> { /// <summary> /// Service Type Code /// </summary> [DataMember] [RequiredAny(2)] [ListCount(99)] [DataElement("1365", typeof(X12_ID_1365_3))] [Pos(1)] public virtual List<string> ServiceTypeCode_01 { get { return _serviceTypeCode; } set { _serviceTypeCode = value; } }

The default getter and setter have been reworked to get\set a protected property from the base class, defined like this:

[Serializable()]
[DataContract()]
public class EQ
{ [XmlIgnore] [IgnoreDataMember] public int Id { get; set; } [DataMember] public virtual string CoverageLevelCode_03 { get; set; } [DataMember] public virtual string InsuranceTypeCode_04 { get; set; }
protected List<string> _serviceTypeCode { get; set; } public string ServiceTypeCode { get { if (_serviceTypeCode != null) return string.Join("^", _serviceTypeCode); return null; } set { if (!string.IsNullOrEmpty(value)) _serviceTypeCode = value.Split('^').ToList(); } } }
Was this article helpful?
2 out of 3 found this helpful