I wrote a couple of MEL functions that will be used in quicktext and they are longer than the maximum number of characters for quicktext.
I wanted to copy them out to libraries, but I am not sure which library is appropriate. Should I create a new library file and load it from another library? If so which other library should I load it from. I found the usrlib.txt which is where I put it for now but I am not sure if that is the appropriate place.(it seems to work)
It would also be nice to not have to merge changes all of the time after upgrades.
My rule of thumb for maintaining stability and performance is unless a function is needed outside of an active update (i.e. headers, letters, handouts, etc.), it goes into a function library (text component) and that text component gets added to the update via a form (typically).
When using the usrlib.txt file, I only add a load command to that file meaning I always create a separate file for the library of functions. While it is 'ok' to add directly to the usrlib file, I find it more organized to group custom code into their own sets and easier to update should the file become corrupt, replaced, or otherwise unusable. It is also a handy method to prevent specific workstations from having access to functions that they don't need/should not have access to.
With regard to stability and performance - understand that anything loaded from the usrlib.txt file is loaded into the global memory space when the EMR is started up and remains there until it is shut down. That can add up over time as your libraries grow. Because it is persistent and global, there could be issues related to recursive executions as well as the potential to cross data between charts, so code carefully.
Remember - if you go the usrlib route, you will need to copy the file(s) to each fat client workstation and thin client server either manually or via jobs.txt.
usrlib.txt vs function library in regards to performance for a function used in many encounters.
Function library - function would have to be loaded every time a new encounter is open. usrlib.txt the function has to be loaded just once.
Since usrlib.txt stays in the memory and it utilizes more RAM on average but wouldn't that make loading an encounter faster?
It would appear so, until you consider how a function library is handled. Text components load instantaneously without noticeable impact on the update. Once the update is placed on hold or otherwise ended, the memory it occupied is freed up. This allows a large variety of libraries to be loaded without impacting performance overall. I have forms that load in as many as 15 libraries without any noticeable delay in the update. Note that those libraries are typically near max size averaging 60K each.
I have tried those same libraries in the global space and the EMR is delayed at startup, is visibly slower overall and feels a bit sluggish in comparison, especially where obsterm utilization is involved. It might not seem like much until you evaluate the time spent starting/navigating the EMR for both update and non-update related tasks on a per user times the number of uses throughout the day.
To be clear, there is code that works well for globalization, but for more granular functionality, especially patient centric data management, I typically avoid the global space and use a library instead. It becomes a 'dead weight' vs. 'utility' argument, in my opinion. When in doubt, the real answer is found through testing and evaluating the impact of the code in both places and comparing the cumulative effect overall.
Thanks Lee for the explanation.