Index>
20140728-print-prescription-with-qrcode
Summary
- add a qrinfo file when printing a prescription
Commits
in branch qrcode
Index
- Keep in Mind
-
- Fix dojo error http://www.sitepen.com/blog/2012/10/31/debugging-dojo-common-error-messages/#forgot-dom-ready
- I removed on May-27 tests for ix_registrationss, fix_sequences, fix_compositions, fix_packages from test/test_plugin/swissmedic.rb,as he could not find any references for them in the src code. Did I erroneously remove stuff when cleaning up the swissmedic import earlier?
- The whole test for older/newer Packages must be adapted to xlsx. One must compare the rows (e.g. by creating csv files) and do the same stuff in xlsx!
- One unit-test for searchbar fails and might be a clue why searching does not work correctly.
- Added two skip in test/test_plugin/rss.rb. Why does the mocking not work there anymore?
- Make ext/swissindex/test/test_swissindex.rb and skipping tests in migel-gem pass.
---
Test combining ruby and javascript to generate a qrcode-png
Decided we Zeno to implement a spike on a separate branch ob oddb.org to solve interaction between javascript and ruby code using the following sequence
- javascript make AJAX POST request to Ruby (this is e.g. done with the print button in prescription.rb
- Ruby generates image
- ruby replies with a JSON object containing a URL to the QR image
- JS displays img
Ruby can only generate the image if it has each of the following elements
- ZSR number of the doctor (this will need a new field, which could be added to the url like /zsr=<id>. For the moment we only use a fix id.
- EAN13 of the selected drugs. Available now via persistent_user_input(:drugs) and/or URL
- comments (+ eventually exact posology) of the prescription
After (background) medating the last few days about the problem I think the solutions must look like the following.
- When creating a new prescription, create a unique ID and go to URL (after usual prefix like ch.oddb.org/de/gcc) prescription/<id>/new
- prescription/<id>/new creates a new Ruby variable persistent_user_input and save it as persistent_user_input named :prescription
- After adding/deleting a drug
- Save selected drugs in persistent_user_input(:drugs) (same mechanism as today) and go (via on_click javascript handler) to URL prescription/<id>/ean/ean1,ean2,...,eanx
Pending problem is howto handle the comment. The problem with the current implementation is, that it not stored in a field of the enclosing model drug.
add a qrinfo file when printing a prescription
After some serious discussions with Zeno decided to use JavaScript as much as possible to offload work from the server to the client.
Tried creating a simple QRCode using http://davidshimjs.github.io/qrcodejs/. See Attach:tst_qr.html which resulted in
Next step is using an already generated print-presciption html to assemble the qrcode-string(various fields, checksum) using JavaScript. Maybe we should also find a way to add a unit test for this javascript.
Using nodejs I can test javascripts using something like nodejs -e "console.log('testing');"
Therefore transforming my (not yet committed) ruby class prescription into a javascript class and adding it as src/view/prescription.js. Made a simple unittest which calculates the checksum of the example presction. Works now. Pushed this with commit Javascript for generating qrcode added for new branch qrcode.
Now I will rework the javascripts in view/drugs/prescription.rb to use the newly created file prescription.js and pushing most JS-functions into this file. This will allow me to run the unit test to catch javascript errors and helps decoupling ruby and javascript code.
Running the watir test for prescription did not show two regressions to the state before. But still pushing the changes to the experimental branch qr_code with commit Move javascript functions to separate file for view/drugs/prescription. Will continue tomorrow by fixing this problem first.