More Billing Improvements

sunsetsystems wrote on Monday, July 09, 2007:

I have checked in some important changes to correct a couple of deficiencies in OpenEMR:

(1) OpenEMR was not keeping track of changes to patient insurance.  So for example if you submitted a primary claim, and then the patient came in for another visit with new secondary insurance, and then the primary EOB comes back and you submit a secondary claim, it would go to the new (and incorrect) payer.  This has been fixed with new logic that accepts an "effective date" for each insurance plan, and refers to the correct insurance based on that date and the encounter date.  You will also notice a full list of current and previous insurances in the patient demographics summary.

(2) There was no reasonable tracking of claim history.  This is now addressed with the addition of a "claims" table and a list of relevant events for claims on the Billing page.  This also lays some groundwork for future addition of accounting events (payments and adjustments), with a goal of eliminating the need for SQL-Ledger.

Quite a lot of code needed changing.  I have updated the following in CVS:

  custom/BillingExport.csv.php
  custom/export_labworks.php
  custom/export_xml.php
  interface/billing/billing_process.php
  interface/billing/billing_report.php
  interface/patient_file/deleter.php
  interface/patient_file/front_payment.php
  interface/patient_file/pos_checkout.php
  interface/patient_file/encounter/copay.php
  interface/patient_file/summary/demographics.php
  interface/patient_file/summary/demographics_full.php
  interface/patient_file/summary/demographics_save.php
  interface/reports/insurance_allocation_report.php
  interface/reports/patient_list.php
  interface/reports/unique_seen_patients_report.php
  library/Claim.class.php
  library/billing.inc
  library/billrep.inc
  library/patient.inc
  library/sl_eob.inc.php
  library/classes/Prescription.class.php
  library/classes/WSClaim.class.php
  library/freeb/ClearingHouse.class.php
  library/freeb/Patient.class.php
  library/freeb/Procedure.class.php
  library/freeb/process_bills.php
  sql/2_8_2-to-2_8_3_upgrade.sql
  sql/database.sql

I have done basic testing, but it’s impossible to check all cases so of course please notify me of any related problems.

Rod
www.sunsetsystems.com

markleeds wrote on Monday, July 09, 2007:

This will probably break my zirmed.php script, but no big deal.  I am probably the only one using it and it would be easy to fix.

I have dealt with this problem by telling my small staff not to update a patient’s insurance data until claims are submitted.  If something has to be resubmitted, it is handled through Zirmed.

sunsetsystems wrote on Monday, July 09, 2007:

Mark, you may want to look at the new X12 claim generator as it no longer requires FreeB, and also deals with secondary payers.  Alternatively, consider using library/Claim.class.php as the data source for your own script, as it already solves many problems such as matching insurance with encounters.

Rod
www.sunsetsystems.com

andres_paglayan wrote on Monday, July 09, 2007:

That’s a huge step in the right direction,
Thank you Rod,

markleeds wrote on Monday, July 09, 2007:

Rod,

Thanks, I’m going to look at those files.  I should have asked before doing it the hard way.

Also, thanks for fixing the problem.  I can see how it could be a big problem for a busy practice doing all of its own billing.  It is especially a problem for us when patients join a medicare HMO and claims were not submitted from before the change.  If our practice were bigger, we would likely have lost some of those claims.

sunsetsystems wrote on Monday, July 09, 2007:

Actually Claim.class.php is brand new, so you didn’t miss anything when you created your script.  :slight_smile:

Rod
www.sunsetsystems.com

rpl122 wrote on Sunday, July 22, 2007:

Rod, I’m quite impressed by your work on improving the billing features of OpenEMR.  After seeing your recent post on this matter, I did a fresh cvs installation of openemr on a Debian machine just to see how this works.  (I did NOT install SQL Ledger, freeb, phpgacl.)  The installation seemed to go flawlessly.  It included your new billing scripts dated July 8, 2007.

I put in some transactions with insurance data and clicked the ProcessX12 button for a selected transaction.  Messages on the transaction line included "transaction coded" and "queued for primary standard billing to Medicare."

However, it didn’t produce an *.edi output file.  The error log showed this:

ERROR: query failed: SELECT fpa.* FROM forms JOIN form_misc_billing_options AS fpa ON fpa.id = forms.form_id WHERE forms.encounter = ‘8’ AND formspid = ‘1’ and forms.formdir = ‘misc_billing_opetions’ ORDER BY formsdate

*****(Table ‘openemr:form_misc.billing_options’ doesn’t exist.)

I checked my openemr database from the mysql command line.  Indeed a table by that name was not present.

Seems to me we’ll need the specifications for this table and perhaps a way to insert it into the database.

Maybe I’m running it improperly.  Or perhaps, you put your table in manually and the cvs tree doesn’t generate it.

Any ideas on this?

rpl122 wrote on Sunday, July 22, 2007:

Regarding the database changes required as a result of Rod’s upgrades of July 8, 2007 – I missed the obvious sql file named database.sql – also with a data of July 8, 2007.

I "sourced" that file on the mysql command line and it changed my database to a new format.  In the process it appears to have removed a lot of information including all passwords.  Well, I then ran the setup.php script again and things worked with the new database configuration.

However, most of my data were gone.  I started re-entering users, passwords, groups etc.  When it cam to entering a new facility I got this error:

ERROR:  query failed insert into facility …  
                (Unknown column ‘specialty’ in ‘field list’)

I’ll keep playing around with this, Rod.

sunsetsystems wrote on Sunday, July 22, 2007:

Ronald, database.sql is loaded as part of the install process, you don’t want to run it again after installation.

Regarding your original SQL eror, what you do want to do is enable the misc_biling_options encounter form.  This replaces the old prior_auth form.

Rod
www.sunsetsystems.com

rpl122 wrote on Sunday, July 22, 2007:

That did the trick, Rod.  Next week, back at the office, I’ll do another fresh cvs installation and put data in right and actually try sending some X12 files to Medicare, Blue Shield and to Anvicare.

drbowen wrote on Saturday, July 28, 2007:

Rod,

Why don’t you enable the

misc_biling_options encounter form

and the

fee sheet

by default in the distribution?

Sam Bowen, MD

sunsetsystems wrote on Saturday, July 28, 2007:

Good idea.  Done (in CVS).

Rod
www.sunsetsystems.com

rpl122 wrote on Thursday, August 16, 2007:

I’m continuing to play around with the latest cvs (08/15/2007) for openemr along with a 2.6 version of sql-ledger. 

On both Debian (latest – etch or whatever) and Ubuntu (Feisty Fawn) I was able to put together packages that made the two programs work together for the most part.  I did not put in freeb because my impression was that it should not be necessary.  I am hoping to be able to write up step by step and specific instructions for installation of this pair of programs on Debian and/or Ubuntu.

First, openemr seems itself to work without a hitch.
Second, sql-ledger seems to work great when I log in to it directly.
Third, the [Sql-Ledger] [Reports] and [EOBs] buttons pull up appropriate menus.

When I “Process X12” on a transaction, however, I get this content (pasted below)  on screen just before seeing what looks like a good X12 transaction file, which is saved somewhere in text form.  Furthermore, the transactions don’t carry over into sql-ledger as they should.

I have to admit that I entered openemr transactions before actually getting sql-ledger up and running, so maybe things are of of sync somehow.  Any ideas on what this means?

===============================================================================

Warning: pg_fetch_array() [function.pg-fetch-array]: Unable to jump to row 0 on PostgreSQL result index 73 in /var/www/openemr/library/sql-ledger.inc on line 63
Entry has not been previously sent to external system or no entry was found for them in the integration mapping, could not send claim. Patient: ‘1’

Warning: Cannot modify header information - headers already sent by (output started at /var/www/openemr/library/sql-ledger.inc:63) in /var/www/openemr/interface/billing/billing_process.php on line 102

Warning: Cannot modify header information - headers already sent by (output started at /var/www/openemr/library/sql-ledger.inc:63) in /var/www/openemr/interface/billing/billing_process.php on line 103

Warning: Cannot modify header information - headers already sent by (output started at /var/www/openemr/library/sql-ledger.inc:63) in /var/www/openemr/interface/billing/billing_process.php on line 104

Warning: Cannot modify header information - headers already sent by (output started at /var/www/openemr/library/sql-ledger.inc:63) in /var/www/openemr/interface/billing/billing_process.php on line 105

Warning: Cannot modify header information - headers already sent by (output started at /var/www/openemr/library/sql-ledger.inc:63) in /var/www/openemr/interface/billing/billing_process.php on line 106

Warning: Cannot modify header information - headers already sent by (output started at /var/www/openemr/library/sql-ledger.inc:63) in /var/www/openemr/interface/billing/billing_process.php on line 107

Warning: Cannot modify header information - headers already sent by (output started at /var/www/openemr/library/sql-ledger.inc:63) in /var/www/openemr/interface/billing/billing_process.php on line 108
ISA*00* *00* *ZZ*SENDERID *ZZ*RECEIVERID *070815*2042*U*00401*019787083*0*T*:~GS*HC*SENDERID*RECEIVERID*20070815*2042*1*X*004010X098A1~ST*837*0001~BHT*0019*00*0123*20070815*1023*CH~REF*87*004010X098A1~NM1*41*2*MID ERIE FAMILY PRACTICE LLC*****46*251843481~PER*IC*RONALD LEEMHUIS*TE*8144562003~NM1*40*2*MEDICARE*****46*ETIN~HL*1**20*1~NM1*85*2*MID ERIE FAMILY PRACTICE LLC*****24*251843481~N3*1611 PEACH ST SUITE 320~N4*ERIE*PA*16501-2122~REF**~NM1*87*2*MID ERIE FAMILY PRACTICE LLC*****24*251843481~N3*1611 PEACH ST SUITE 320~N4*ERIE*PA*16501-2122~HL*2*1*22*0~SBR*S****12****MB~NM1*IL*1******MI*987654321B~N3*~N4***~DMG*D8*00000000*F~NM1*PR*2*MEDICARE*****PI*CMSID~N3*~N4***~HL*3*2*23*0~PAT*~NM1*QC*1*PATIENT*TEST*E~N3*~N4***~DMG*D8*19730702*F~CLM*1-6*500.00***11::1*Y*A*Y*Y*C~DTP*431*D8*20070813~HI*BK:25003~NM1*DN*1*LEEMHUIS MD*RONALD*PAUL***34*251843481~REF*1G*B36639~NM1*82*1*LEEMHUIS MD*RONALD*PAUL***34*251843481~PRV*PE*ZZ*207Q00000X~NM1*77*2*MID ERIE FAMILY PRACTICE LLC*****24*251843481~N3*1611 PEACH ST SUITE 320~N4*ERIE*PA*16501-2122~SBR*P*18*******MB~AMT*D*0.00~AMT*F2*500.00~DMG*D8*19730702*F~OI***Y*B**Y~NM1*IL*1*PATIENT*TEST*E***MI*1234567879A~NM1*PR*2*MEDICARE*****PI*CMSID~LX*1~SV1*HC:99212*500.00*UN*1***1~DTP*472*D8*20070813~SE*50*0001~GE*1*1~IEA*1*019787083~

sunsetsystems wrote on Thursday, August 16, 2007:

Right.  The message “Entry has not been previously sent to external system or no entry was found for them in the integration mapping, could not send claim. Patient: ‘1’” indicates that you set up the patient while SQL-Ledger was not hooked in.  All you have to do is go into the patient’s demographics and save them again.

A similar thing can happen with providers, with a similar solution.

Rod
www.sunsetsystems.com

rpl122 wrote on Thursday, August 16, 2007:

That did the trick.  Now the latest cvs version of OpenEMR is working smoothly and correctly with SQL-Ledger on Ubuntu.  It creates X12 files without error messages and puts transactions into SQL-Ledger.  I can apply insurance payments using the [EOBs] button/menu.

I’m going to keep this installation up and running and document the Debian and/or Ubuntu installations clearly, accurately and step by step for others who are interested.  Thank you, Rod.

rpl122 wrote on Friday, August 17, 2007:

The latest cvs version of OpenEMR plays well with SQL-Ledger and Ubuntu on my home computer and with SQL-Ledger and Debian on the office computer.  I have recorded step by step instructions for the Debian instruction and plan to put them together for the community.

I figure at this point it will be more productive to test out the primary and secondary insurance billing features than to worry about installing the phpgacl access control features.

rpl122 wrote on Thursday, August 23, 2007:

With some encouragement and direction from Rod Roark, I have been putting together a detailed step by step set of instructions for building a Debian system that includes the latest cvs version of OpenEMR, SQL-Ledger-2.6, phpgacl, freeB and SSL.  So far I have written up the first three of the five and gotten that much working well on Ubuntu and "almost" on Debian.

If anybody wants to try it out step by step and offer feedback, I’d be grateful.  My hope is to make a clear set of instructions on how to build a cutting edge development installation on Debian so it can be contributed to the OpenEMR community.