FreeB Syntax
The FreeB language is written in XML. It is a compiled language and compiles to Perl. Instead of using lex and yakk, perl is also the compiler, using the very useful Recdescent Module which has several good tutorials
FreeB files are opend and closed with the following tags
Inside those tags there are only five (currently) program structures. These are..
Here is what each one does...
command
The put command is for filling out paper forms. It starts at the top of a file and will place the correct text in the correct slots. Essentially it uses a column and line number to fill out the form left to right and then top to bottom. You must use put commands sequentially, starting at the top left and ending bottom left. The rest of the syntax will serve to illustrate
Those of you who are perl savvy can immediately see how I cheated... I simply put a line of perl code directly into the tag... The underlying functions simply place the $data variable into the space alloted. In the future this might change, but for now I wanted to be certain that my system could handle ANY formating needs. By using perl directly I can guarentee that anything can be munged correctly. NOTE: The ways that I do this are TOTALLY INCONSISTENT. That is the perl code that will fit in a tag will be incorrectly syntaxed for another section of my system say .
This means that bears more comphrensive examination. Here are the rules.
For those of you who are programers this gives you some idea of what is possible. For those of you who are NOT programmers stick to the following format.
The "^" marketed sections are ALWAYS the same... and "getFunctionOfSomeKind" changes depending on what you want to put into the slot. The "get" style functions are documented in the api documentation, or they will be when I figure them out completely. 99% of the time making this statement will be the limit of the "programming" that you need to do.
NOTE: Currently put statements are all left justified, I am thinking of adding another tag to control this, and will do this when there is a serious need for a format that is centered.
command
This was an outright act of cowardice... I had not idea how a parser capable of using "if" statements, and a compiled syntax that also needed to use "if" statments would respond to having an tag. So I used ... it is just my way of using a conditional.
The tricky part of filling out paper forms is when one check box needs to be check if the gender of the patient/client is male and another if the patient/client is female. So you simple embed statments inside statements. The whole syntax follows...
The Syntax for the tag works just like the . You can do complicated perl work here, but it is better to just use the "is" API functions.
command
The command is what makes FreeB Turing complete. It only has two functions, and . But is simply an opportunity to write a bunch of perl code. This is where I create and modify dynamic data, so that in my put and edi commands I will be able to use arrays and such.
This is most definately cheating, however its worth it, because it ensures that I will be able to support any format, without totally redesigning the system.
command
I am the least satisfied with the loop command. I will give the current syntax here, but ultimatley I want this to be far more simplified then it is. Right now it has too much in common with the cheater . I currently plan to have this work in conjunction with the limited Data modelling that FreeB will do of the Practice Management Data... but more on that later...
My hope is that core formats will be setup for each of the major formats, HCFAish, X12ish etc etc... and that someone will sort out what loops are needed in the template format and then everyone can just tweak using and ... This way only programmers are actually screwing with loops... Make it a point to over document here in any case.
command
I would like to thank Joe Thielen and his inital X12 Hacks on FreeMED-Yirc for giving me ideas on the format. I was pretty desperately needing some new ideas when I looked and his code, and some of his ideas severed to make my edi worldview adjust correctly. Thanks Joe!!
The first thing to understand about EDI is that it was never made to read by humans. It was made to be parsed by computers. It was designed back in the day when bandwidth was an issue, so it was designed pretty compact. These two things make it pretty darned hard to read... Here are some X12 examples...
Note that in the normal files it is even worse... it looks like this...
ST*837*0021~BHT*0019*00*0123*19981015*1023*RP~REF*87*004010X098~NM1*41*2*PREMIER BILLING SERVICE*****46*TGJ23~ and so on...
Pretty painful right? Anyways, anyone in there right mind would use an XML based technology now, but Medical IT is stuck twenty years in the past. So X12 it is.
The first thing is to note is that each line begins with a tag. These tags mean different things in different parts of the file. You can go buy a whole (massive) dictionary of these codes online... you will need to if you want to hack on X12. The second thing to note is that X12 uses the "*" character to seperate its fields and the "~" character to seperate its lines.
As a result a simple way to define these files is as follows
The item is the only function that canhave anabitrarily repeating inner tag. You can have (and have to have) any number of tags.. Note that the "perlness" of the tag works entirely differently than the other tags. You have to "make a string" inside the tag, with ending ";" characters. As a result your tags will start to look like this...
This is much more focused on the string building functionality in perl... Use the set command if you need more perl power...
Conclusion
This syntax will be in flux. But I want people to understand where I am going. I want to create a system that is simple to use, but powerful enough to totally handle medical billing. Using perl I will be able to cool things with Perl-expect module and other things like this... There is almost no means of talking between computers that perl cannot do. Hopefully this combination of flexibility and simplicity will solve the medical billing problem for the Free and Open Source community!
Thanks,
Fred Trotter