lcmaas3 wrote on Monday, February 11, 2013:
Ok, round 2 of Direct Support is done. This task was quite involved. There are 4 major components:
1. Implementation of the actual message status and message receive functions of the phiMail API. Straightforward, all within library/direct_message_check.inc. OpenEMR can now receive status messages on previously sent CCDs and receive messages from any trusted Direct sender, including messages with CCDA, XML, JPG, PDF, or other attachments.
2. Extensible and robust mechanism for executing background services in a rate-limited manner. Building from Brady’s idea, we currently piggy-back on the existing left_nav timer. This calls the manager script library/ajax/execute_background_services.php that iterates through a list of known background service function calls and executes them no more frequently than specified. We use the built in locking of tables in mysql to prevent race conditions. Care was taken to prevent the “is_running” flag from being left set if the background service function crashes or throws an exception. (The mechanism may need to be reset manually after a server failure or restart though.) Other services can be easily added to this framework.
3. Storage mechanism for received attachments and non-text documents. We leverage the existing framework for Documents with some changes to the Controller class and C_Document class to extend the “upload” function so it will also accept documents received through Direct messaging. Also, new messages (for now at least) are assigned to PID=0 but can later be assigned to the correct patient through the usual interfaces. Would be nice if HTML files were as nicely integrated as PDFs and JPGs in the document viewer, since some Direct services use HTML.
4. Alert mechanism for received messages. Again, we have extended the pnotes features to allow the phiMail service to inject messages into the existing message framework. Currently these are routed to user “admin” and the patient is set to 0. The patient can be set (once) by the admin who can then forward the message to the correct party. The message shows the details of the incoming Direct message, including any associated Documents. If the main message text was plaintext (text/plain) it is also included in the message, otherwise it is stored as a Document and referenced in the message.
Few other minor things, few new tables, should add a NoLogin Inactive user with username “phimail-service” for best operation. And, of course, one would need a Direct Messaging account to fully test this, which I can gladly set anyone up with (well, technically, our CA can only issue to US residents at this time.)
Comments and questions are welcome.
-Luis