Yet another template engine - for Office documents

mdsupport wrote on Saturday, July 11, 2015:

Every installation of OpenEMR sooner or later comes up with requirement for professional reports/documents to be provided to other practices, patients, payors or even attorneys. Printing a browser page has its own limitation. Most importantly, every new report needs a developer to make changes that need to be reviewed with every new release and patch of standard release.

Template interface introduced in version 4.2.0 was a good start but our users have struggled to effectively use it. We are wrapping up a proof of concept project that uses OpenTBS plugin for TBS template framework.

Since the results so far look very useful, this is to check if the project would be interested in adding this feature to standard codebase in future and if anyone in the developer/user community would be interested in collaborating?

Although tbs has some interesting features, we plan on using 2 opentbs related library files solely for document interface.

Your thoughts are greatly appreciated.

Edit: Added attachments as follows -

  1. enc_sum1 is a MS Word document template that results in temp.docx output.

  2. docx_list1 is a MS Word document template that results in temp(1).docx report.

sunsetsystems wrote on Saturday, July 11, 2015:

I might be able to get a client interested, not sure.

Can it produce a PDF as the final report?

Rod
http://www.sunsetsystems.com/

mdsupport wrote on Saturday, July 11, 2015:

No native option to convert and output pdf. It does have option to save output to server rather than pushing to client (download). So a wrapper or post-processor can use unoconv command-line to output pdf which can then be pushed to client. That probably will be more reliable than html2pdf. Many of our recipients will gladly take MS Word format.

In either case (pdf or docx), recurring question is about adding digital signature and prevent any alterations. None of the tools seem to have that feature. So having the user open the document, insert signatures and then lock the document manually may be unavoidable.

mdsupport wrote on Saturday, July 11, 2015:

Although our POC was limited to SQL data sources, design is extensible to use of PHP functions that return data arrays. So users like the idea that once a developer configures a data source, someone good with MS Word can create templates incorporating various combinations of multiple data sources, including sub-blocks.

juggernautsei wrote on Monday, July 20, 2015:

This sound like what I was looking for and what a client was asking about.
I am sure I would like to collaborate on this project.

In a previous EMR the new office manager was using, she said they were able
to build reports by dragging and dropping blocks in place to build the
report.

In my mind, I knew that those blocks had to be connected to pieces of data
that was presented to the EU as a block to be assembled into a final
report.

mdsupport wrote on Saturday, July 25, 2015:

  1. Follow download instructions for OpenTBS plugin. Currently we do not have zlib enabled. After installation, note down location of tbs_class.php and tbs_plugin_opentbs.php files.

  2. Unzip attached file. Review temp.sql file. Create new list ‘otbsx’ manually and then use temp.sql to create table data_views and a list ‘otbsx’ with few test entries.

  3. Copy the sample MS Word (*.docx) files to doctemplates directory.

  4. Merge this commit.

  5. Update the location of tbs_class.php and tbs_plugin_opentbs.php files in zutil…template.php script to values noted in step 1. The script at commit expects these files in <>/addon/openTBS directory.

  6. Get merged output by accessing :
    <>/custom/zutil.merge.opentbs.template.php?form_filename=xxxx.docx

Design background:
Common/reusable data views are stored in table data_views. It is expected that a developer/analyst will ‘release’ these entries.

Based on the requirement, the ‘note’ in otbsx list sets data views to be provided to each template. For example: *pt:pt_curr*;*enc:pt_enc_last3* is interpreted as follows:

  • template will be filled in two passess
  • Pass 1 will fetch data view ‘pt_curr’ (all columns from patient_data for current $pid) and fill in specified columns (as pt.xxx) in the template.
  • Pass 2 will fetch data view ‘pt_enc_last_3’ (data about last 3 patient encounters for the current patient) and fill in a table with up to 3 rows.

Expert user or analyst will create and maintain this configuration.

Skilled MS Word user will create and maintain templates as required using available data views and the columns in each view.

teryhill wrote on Sunday, September 06, 2015:

I copied the pt_curr record in the data views table and called it pt_fee_sheet1. I added the record to otbsx and I created a template called pt_fee_sheet1.odt and it is outputting the file. If you have any more templates that you would share that would be great. Also where did you place the hooks so the user could run the reports.

Terry

mdsupport wrote on Sunday, September 06, 2015:

As mentioned in the original message, this is a proof of concept stage - though the basic design of reusable query definitions feeding document templates seems to be adequate. Based on the results, we have this in our development queue but ICD10 has taken up higher priority. So we do not have much to share at this point.

In your case of superbill output, your main design effort will be in identifying the data sources / queries that would give desired results. The hooks in your case would be :

  1. ‘Popup’ in left_nav for single encounter
  2. Either replace current or add new entry in reports section if you want users to be able to print superbills for all apointments for a day.
  3. OpenTBS supports output to server. So we plan on running many of our reports in background at night and have the output available at a shared location on network. In your case this could be all superbills for appointments for the day.

Some of the convenient things to remember when using of templates:

  1. Leave decision about practice information, formatting, logo, header/footer, font sizes etc to users though you could write a query that will provide globals through a query.
  2. The report gets filled in multiple passes so querries should be simple and allow for patient id or encounter number parameters.
  3. In our case, most users have Microsoft Office so Open Office is not a requirement.

teryhill wrote on Monday, September 07, 2015:

I need to add getting the appointment date and time. Any wisdom ?

Terry

teryhill wrote on Monday, September 07, 2015:

Never mind I got it.

teryhill wrote on Monday, September 07, 2015:

I have figured out most of it and have the fee sheet working. There are a few spots that I am still working on.

  1. opening the print dialog instead or in addition to the save.
  2. over writing the file so I don’t have 25 files accumulate on a daily bases.
  3. doing a date calculation in the template.

If you have any Ideas they will be welcomed.

Thanks

Terry