Pharmacists are required to determine calcium and phosphate compatibility in TPN solutions. The most reliable method is to visually evaluate compatibility with a solubility curve. Solubility curves are incorporated into the TPNassist program, and I wanted to see if I could duplicate that in a web page. After playing around with google chart wizard for a couple of hours I was able to produce a good looking graph.
The next step was to break down and reassemble the URL generated by chart wizard in order to create a curve with a marker for specific calcium and phosphorous concentrations. The result of this effort is found on the web site’s TPN osmolarity calculator.
In other news, all versions of AbPK that were submitted in the last month have been approved at various online “stores”. But the reality is, I have given these multimillion dollar corporations a license to steal from what little money I make from this low selling niche app. All of these stores take 25-30% right off the top of the retail price. Amazon also charges $100 per year just for the “privilege” of hosting an app. They (and Apple) don’t even attempt to disguise the fact that they are picking the pockets of app developers.
At least Blackberry was giving away a free Playbook if your app was approved. Of course they drug their feet for weeks, and didn’t approve the app until after their giveaway expired. But according to the terms of their giveaway offer, the app had to be submitted before March 2, which it was. So, we’ll see if they actually follow through.
This week was spent working in Eclipse/Java on the Android platform. After finishing the Nook and Playbook apps, work was completed on much needed updates to AbPk for Android, including the following
Added IDMS SrCr adjustment to preferences screen
Added support for multiple size screens (including tablets)
Added T90%/T95% calculation to model display and consult email function
Added mg/kg calculation
Allow single point Bayesian outside dosing interval
Also did some sprucing up of the screen layouts, and added a custom Toast layout for the information dialogs.
TextView text = (TextView) toastlayout.findViewById(R.id.toastText);
text.setText(message);
Toast toast = new Toast(this);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(toastlayout);
toast.show();
}
Also changed the formatting on the preferences layout, which has been broken since Android 2.3 (section heading font is smaller than the sub element). Here is the customized preference screen:
Preferences layout
XML for preference screen
The biggest roadblock I ran into was resetting an out of range preference. The check code is within the onSharedPreference change listener. If a value entered by the user is out of range, then the preference is reset to the default value with this code:
// Min SrCr text change
if (key.equals("editTextMinSrCr")) {
String MinSrCr = sharedPreferences.getString(key, defaultMinSrCr);
// Save or Reset w/error
if(CheckMinSrCr(MinSrCr)){
prefMinSrCr.setSummary(MinSrCr);
}else{
// Reset to default
prefEditor.putString(key, defaultMinSrCr);
prefEditor.commit();
getCustomToast(errMessage);
}
}
However, the editor continues to display the new (wrong) value. It was about to drive me crazy, I checked every post on Stack Overflow to no avail. The people who answer questions there work in Java all the time and argue about whose code is more “elegant”, I just want some practical advice. Google’s Android dev site is a comprehensive encyclopedia, but it gives absolutely no examples. After searching for two days I finally ran across this page on the Android Cookbook web site: Default shared preferences consistency check
The article contained this revelation: “even if the SharedPreferences contains the right value, you won’t see it displayed correctly. For this reason, you need to reload the preferences activity.”
And that was it, added a reload procedure, and it worked.
if(CheckMinSrCr(MinSrCr)){
prefMinSrCr.setSummary(MinSrCr);
}else{
// Reset to default
prefEditor.putString(key, defaultMinSrCr);
prefEditor.commit();
reload();
getCustomToast(errMessage);
}
Apparently the blog importer I was using is no longer supported by Facebook, so hopefully this one (NetworkedBlogs) will work. I decided to play around with the layout theme, and added a photo I took of the beautiful Flint Hills area around Emporia, Kansas.
Well, I started out the week attempting to update the rxkinetics.net web app. My plan is to add the ability to change and save settings and pk models, using the localStorage functionality in HTML5. But, localStorage is via JavaScript on the client side (web browser), whereas the web app is ASP.NET server side. And neither the twain shall meet.
Since this is a working site, I had to copy the abpk.aspx to a test page. Then I added a settings page for changing creatinine clearance options, and attempted to save and retrieve the settings and populate the screen.
I wanted to use JSON, because that is what I will need to use when I add local pk model storage. But, after screwing around with JSON for a day and failing, I gave up and put each setting into its’ own row.
Since I’m working in Visual studio 2005, there is no native support for JavaScript, no Intellisense, no syntax checking, no real time debugging. Just blind coding followed
by trial and error. The only debugging I could do was to put alerts at various points within the JavaScript to display the progress.
Then I had no idea where to put the JavaScript, and when to trigger it. Putting the code in head element and triggering the JavaScript on the page onload event did nothing because the page isn’t fully rendered yet. Placing the script in the body “sort of” worked, but the CheckBox.checked value didn’t change. I ended up adding some hidden elements to store the settings so the server side app could read them.
It took three days of beating my head against the wall to figure out this trivial stuff. So, having had enough of this frustration, I switched to working on the Nook Color version of the Android app.
The first problem I ran into was error after unexplained error in Eclipse. It kept showing errors from google tools, which aren’t even used in this app. I eventually figured out that these were red herrings, the real problem was the target platform was not set.
Next problem was the layout editor throwing an XML error on some of the layouts, for no reason whatsoever. Eventually discovered that this is a known bug in the Android layout editor.
Finally I was able to run the app in the emulator, but, as any developer knows there is no substitute for debugging the app on the actual target device.
And that’s when the real nightmare began.
B&N has the Nook Color totally locked down. It will not allow installation of “non-market” apps. Nor does it allow connection to the Android Debug Bridge, and there is no Development setting on the Nook as there is on a standard Android device.
I tried following the cryptic instructions on the Nook developer site to allow ADB access, to no avail.
Then I tried various methods from the internet to soft root it. One suggestion was to attempt to crash the browser by going to certain web site. It said to try it up to twelve times. Good grief, once upon a time google was useful for finding information, now it only brings up page after page of irrelevant useless crap.
Eventually I resorted to rooting the Nook, and, after uninstalling and reinstalling the ADB USB driver umpteen times, I was finally able to connect the Nook to Eclipse and debug the app. I started this at 5 AM and finally, at noon, got the app to run on the Nook.
Since I had copied the layouts from the Android phone version, I’ll need to change all of them, increasing the size and color of all the elements. But at least I can see some light at the end of the tunnel.
As for the web app, I’ll have to mull it over, my brain is just too tired now. I think I’m getting too old for all this switching between languages, my mind is not as agile as it used to be.
The update parade continues, adding new features to APK and Kinetics. Unfortunately I’ve had to spend a lot of time in the last two years learning and developing Android and web apps. But I’ve resolved to spend more time maintaining these traditional desktop apps, as a result there has been much catching up to do. Most of the new non-database functions were first implemented in Antibiotic Kinetics. It has a much smaller code base, making it easier to add and test new features without worrying about their impact on existing functionality. Although it takes more time to add new features to APK and Kinetics, the kinks have usually been worked out because of this “pre-testing” within the Antibiotic Kinetics code base.
APK 3.5.6 Features added/bugs fixed:
Added form position save to profile ini.
Added free text infusion time option.
Added real-time x,y graph scaling.
Added last used CrCl method saved.
Updated Bayesian routine.
Updated the updater stub.
Kinetics 2.3.3 – Features added/bugs fixed:
Added Adjust CL to LBW option on prospective clearance model.
Updated single point Bayesian analysis to allow level outside of dosing interval.
Fixed Clearance label on consult print-out.
Added max length to Sr Cr fields.
Fixed duplicate levels save.
Because there has been a fundamental change in how APK and Kinetics are accessed, I decided to make some screencasts demonstrating the changes, posting them to youtube.
Spent the first day making some improvements to the RxInterventions program:
Changed the export function to run independently of Excel
Fixed a bug with the archive routine
Added an info dialog to the input routine
Then spent the rest of the week simultaneously updating APK and Antibiotic Kinetics. Both programs use the same code base for the calculations, while APK adds database functionality.
For Antibiotic Kinetics and APK added the following calculation related changes:
Adjust CL to LBW option to correct clearance for obesity.
Changed single point Bayesian to allow analysis of level outside of dosing interval.
Added SrCr adjustment settings for IDMS SrCr and for minium SrCr. Adjust settings are found on the Other CrCl methods screen.
APK received a complete makeover in version 3.5.4. The most apparent change is the patient database interface. The program now starts with a simple search box. Type in a patient name to find matching records, or press Enter to list all patients. The user cannot add a new patient until record search has been performed. The intent is to cut down on entry of duplicate records for the same patient.
Start screen:
APK start
Search results:
APK search list
MRU drop down:
APK MRU list
Complete APK 3.5.4 change listing:
Added Overlay to patient tab with search as the default start up point.
Added Most recent used patient list.
Added Search listing.
Updated SrCr fields to allow 2 decimal places.
Added Print T90% and T95% to consult report.
Added BMI to patient data tab.
Added mouse hover to view dose in mg/kg.
P.S. this new version of WordPress is buggy, the picture upload feature is broken. When I click to add a pic, it blackens the screen and… nothing. Had to add pix via pain-in-the-ass HTML code. Also, the code formatting plug-in does the same thing, blacks out the screen completely without any functionality, so I could not post the Adjust CL to IBW code. Found this on the wordpress forums: I think we can confirm that it is a mistake of the last update of wordpress
I ran some final tests from a USB stick on Vista and Win7, everything worked great. But when I tested it on a virgin XP system, it threw error 713 “MSSTDFMT.DLL is not registered on this computer.” I looked in the project references and noticed that the data formatter dll was listed, so I unchecked it and recompiled. Same error. Closed the IDE, reloaded the project, made sure the dll was no longer referenced in the project. Recompiled, continued to error-out on the test machine.
I remembered playing around with the DataFormat property on one text box on the main form. I had wanted to see if this property could be used for a time formatter, instead of having to use that awful Microsoft date/time control. It wasn’t useful at all, so I deleted the DataFormat property from the text box. But the compiled exe is still looking for the dll. WTF was going on? I finally loaded the form into a text editor and found this:
Even though I had deleted all reference to this in the IDE, it was still showing up in the form code. I deleted this code block in the text editor, saved the file and recompiled. Finally, it ran without error on all 3 test platforms. Testing completed, I posted the update to the web site. So glad to get this over with, I hate VB and can’t wait to get back to working in Delphi.