title: EDI X12 Templates in Python (Most likely django or jinja) (w/ sqlalchemy)
body: <p><strong>My Case:</strong></p>
  
  <p>I'm working on a system that will need to create various X12 files for health care (insurance)  transactions and inquiries (Specifically 270 Eligibility and 837 Claim).</p>
  
  <p>I know there are good tools out there (pyx12 specifically) for converting between XML and X12, and actually I've gone as far as importing some components from pyx12 to actually create/manipulate x12 data.</p>
  
  <p>Even considering that, after researching the formats a bit, I'm starting to believe that I could have an easier time generating these formats using a template language.  I think that it would be a matter of defining <code>for</code> loops for any segments&amp;loops that need to be repeated per portion claim/inquiry, and the header regions are going to be somewhat static besides whatever element values that could be easily updated by my context.</p>
  
  <p>Almost all of my records are coming out from sqlalchemy so it should be easy enough to loop through my records in the database where relations are very well defined and mapped.</p>
  
  <p><strong>My questions:</strong></p>
  
  <ol>
  <li>I suppose this is less of a question and more of a quest for advice &amp; insight, so feel free to shoot with all of that.  IE, Do you think this is a good idea or a waste of time?</li>
  <li>For any die-hard x12 people, what kind of problems have you run into building x12 from scratch? What should I watch out for?</li>
  <li>Has this style of implementation been done before? Are there examples of specific X12 format templates available, from any language? (I did look with little success)</li>
  </ol>
  
  <p><em>Just a side note:</em></p>
  
  <p>We're already working with python and django, so that template language is available to us.  If we need to do these things as a background process we'll either do the hacky config environment tricks to get django templates to work outside of our django project or else use jinja instead--which is nearly interchangeable.</p>