Default values for distinct objects

Post author
Eliezer Bauer

I'm trying to figure out if there is a built in way to set default variables for distinct object types. 

For example in an 837I in the 2300 loop there is the DTP segment:

loop2300.AllDTP = new All_DTP_837I();

This has statement dates and admission dates. 

The admission date is always defined like so:

DTP*435*DT*201707071615~

So why do I have to set the first two fields if they are always the same?

loop2300.AllDTP.DTP_AdmissionDate_Hour = new DTP_AdmissionDate();
loop2300.AllDTP.DTP_AdmissionDate_Hour.DateTimeQualifier_01 = "435";
loop2300.AllDTP.DTP_AdmissionDate_Hour.DateTimePeriodFormatQualifier_02 = "DT";
loop2300.AllDTP.DTP_AdmissionDate_Hour.AccidentDate_03 = "201707071615";

When parsing a file, the parse knows that when it comes to this: DTP*435*DT*, it's an admission date. So why do I have to set the first two properties? Should I be able to do something like this:

loop2300.AllDTP.DTP_AdmissionDate_Hour = new DTP_AdmissionDate();
loop2300.AllDTP.DTP_AdmissionDate_Hour.AccidentDate_03 = "201707071615";

or like so:

loop2300.AllDTP.DTP_AdmissionDate_Hour = new DTP_AdmissionDate("201707071615");

 

Thank you!

Comments

1 comment

  • Comment author
    Admin

    Hello,

    The parser "knows" nothing. It is transaction-agnostic. Everything is driven by the attributes and in effect you don't even need the templates because you can apply the attributes to any .NET class.

    The templates represent EDI transactions according to the guidelines of the official X12 standard and are intentionally provided in their simplest and raw form. There is intentionally no automation (both for setters and getters) and never will be as part of the core product. The templates are meant to be "live" classes that "are highly likely" to be amended to match:

    1. Partner specific customization

    2. Custom extension

    Following from the above - you can add whatever extra code you need to your template (in the DTP constructor or elsewhere) that would set whatever values you need automatically populated. At the end of the day, the template is simply a hierarchy of C# classes which you can amend at will, just like you would have with the rest of your C# classes.

    0

Please sign in to leave a comment.