hmis-tools / hmis-api-server

Version 2 of OpenHMIS
Mozilla Public License 2.0
15 stars 11 forks source link

How to initiate a session to OpenHMIS API server? #41

Closed kfogel closed 8 years ago

kfogel commented 8 years ago

(Moving private email thread to public support ticket thread, with permission from @taylordowns2000.)

I'm trying to build a generic adaptor for OpenHMIS, so that users of front-end tools like Ona, CommCare, MedicMobile, ODK, SurveyCTO, etc., can set up a data integration to OpenHMIS in a few clicks.

Right now I'm playing around with POST and PUT on the /clients/ api, but getting no love! The example CURL on your github returns:

org.openmrs.api.APIException:                                           \
A user context must first be passed to setUserContext()                 \
...                                                                     \
use Context.openSession() (and closeSession() to prevent memory leaks!) \
before using the API`

...when I post to http://build.openhmisafrica.org/openmrs2/api/v3/clients/ using basic AUTH (demo/Demo1234).

How do I initiate a session? Is there any way to POST or PUT data that doesn't require initiating a session? Thanks in advance for your help!

(For more info about what we're up to, check out http://openfn.org/ and my recent PopTech talk.)

kfogel commented 8 years ago

Hi, @taylordowns2000. First question: what version (commit) of the code are you running on the server side? Are you on the HEAD of the master branch or the feature-xml branch?

kfogel commented 8 years ago

By the way, @taylordowns2000: There's a project in Africa called OpenHMIS, which is an open source EMR system that's pretty widely used in that part of the world... Did you mean to be trying that one? (Just wanted to sanity check.)

taylordowns2000 commented 8 years ago

@kfogel , you're absolutely right. Maybe it was wishful thinking, because you've got such nice clean API documentation. At some point, while searching for "OpenHMIS API" I came across your project instead of "OpenHMIS Africa" here.

I'm so sorry to have wasted your time, but maybe there is a silver lining: is it possible that users of your platform would benefit from being able to register new clients via SMS, IVR, or some sort of lightweight mobile survey capture application? If so, https://github.com/OpenFn might be useful. (Think Zapier, but open-source and able to do updates and more complex mappings.) Glancing at your documentation, it wouldn't be hard to do. Please let me know if that would help you guys in any way and I'll point you to the right place!

kfogel commented 8 years ago

Hey, thanks @taylordowns2000. No worries about the misunderstanding; it's actually a nice coincidence for me that you mentioned OpenFn, as I had other reasons to look more closely at them recently and this is a good reminder, from an independent source, about doing so!

Best of luck with the "other" OpenHMIS!