Building a Standard Interface Template

Overriding functions in your standard module

Lua makes it very elegant to over ride functions defined within your standard template. It’s a very important concept to grasp if you want to make a standard template. Say you had a function called “MapPIDName2Patient” in your standard template and you wanted to over-ride it. All you have to do is define a new version of this function within your main file and this will replace the usage of the function defined in the standard template. Furthermore annotations make it clear which implementation is being followed since the annotation block only appears beside the function which is actually called. This will really pay off if you have taken the time to break your template into small well defined functions that handle small parts of the mapping. Here’s an example using the fuzzy date/time parser we supply: Here we can see the default implementation of the node.D time conversion function translating the format “19980210” to “1998-02-10 00:00:00”. Say we wanted to the D method to format as dd-mmm-YYYY, i.e., 10-Feb-1998 then we just copy paste the above implementation into our main module and tweak it to have the new strftime formatting code like so: We can see that the new implementation is being invoked since it has the annotation block appearing on the right. If we go back to the dateparse module we can see that it is not being invoked any more:

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.