OCL subscription using openmrs-module-openconceptlab

As I am not able bring up the UI of openconceptlab, trying to see how the module works by making REST calls from different tool like Postman. Based on the code flow, sending the below POST request:

https://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/subscription I see that we need to give url and token in the body of this request. I have created a subscription in the OCL module and created a collection. The token I gave is the API token in OCL module. What should be the url? If the url is empty string, I don’t see any response. Also, should we give the uuid also?

The URL would be the URL of the source or collection that you’re subscribing to. You’re going to need to create a test one on openconceptlab.org. (Eventually you might use something like https://openconceptlab.org/orgs/Bahmni/collections/SSS/ which I just created, but haven’t populated, but for now you can create one in your own user account.)

For the URL I’m not sure of the exact format, e.g. maybe it’s https://api.openconceptlab.org/orgs/Bahmni/collections/SSS/ in that case.

Cool. https://openconceptlab.org/orgs/Bahmni/collections/SSS/ worked. Similarly, I created a collection and used the url: https://openconceptlab.org/users/pramidat/collections/c1/. I got a response with uuid and links

Looking at the code, in

the URL would be something like http://api.openconceptlab.com/orgs/CIEL/sources/CIEL/

You’ve set it right. “api.” at the beginning of the url is optional.

You can trigger the import by posting to openconceptlab/import (empty body). You can check the status by getting openconceptlab/import.

For both POST and GET of openconceptlab/import, I am getting the response as { “results”: [] } If the import is done, will the concepts be saved in the openmrs concept table? (I should be able to search the concept name in openmrs dictionary)

@pramidat, yes, they should have been saved in the openmrs concept table and you should be able to search for them. However, it’s strange you get no results after posting. What results do you get for the GET request to openconceptlab/subscription?

I am getting the below response for GET request to openconceptlab/subscription

{ “results”: [ { “uuid”: “61a5fdc0-f44d-3498-b427-11ad5d62877b”, “url”: “https://api.openconceptlab.org/users/pramidat/collections/c1”, “links”: [ { “rel”: “self”, “uri”: “http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/subscription/61a5fdc0-f44d-3498-b427-11ad5d62877b” } ] } ] }

I tried

POST https://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import
{}

And the response I got back was:

{
    "uuid": "260e7a82-1dae-4a5e-a6fd-77082ce97e76",
    "localDateStarted": "2017-12-13T15:15:00.000+0000",
    "localDateStopped": null,
    "links": [
        {
            "rel": "full",
            "uri": "http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/260e7a82-1dae-4a5e-a6fd-77082ce97e76?v=full"
        },
        {
            "rel": "ref",
            "uri": "http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/260e7a82-1dae-4a5e-a6fd-77082ce97e76?v=ref"
        },
        {
            "rel": "self",
            "uri": "http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/260e7a82-1dae-4a5e-a6fd-77082ce97e76"
        }
    ],
    "resourceVersion": "1.8"
}

In other words it is working for me. Woohoo!

@darius what was the subscription URL and Token you have used. I did the following steps:

  1. POST https://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/subscription with body {“url”:“https://openconceptlab.org/users/pramidat/collections/c1",“token”:"”} Getting the below response:

  2. POST http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import with empty body Getting the below result: { “results”: [] }

  3. GET http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import Getting the below result: { “results”: [] }

Am I missing something? I am trying using Postman

I used postman also. I used basic auth with superman:Admin123

POST https://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/subscription with body:

{
	"url": "https://openconceptlab.org/users/djazayeri/collections/TEST/",
	"token": "what I got from my user page in OCL"
}

and got a similar response to yours.

Then POST https://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import with body:

{}

Response is

{
    "uuid": "18f395ee-6cb9-4d6c-ae1e-865688fccc49",
    "localDateStarted": "2017-12-15T07:14:10.000+0000",
    "localDateStopped": null,
    "links": [
        {
            "rel": "full",
            "uri": "http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/18f395ee-6cb9-4d6c-ae1e-865688fccc49?v=full"
        },
        {
            "rel": "ref",
            "uri": "http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/18f395ee-6cb9-4d6c-ae1e-865688fccc49?v=ref"
        },
        {
            "rel": "self",
            "uri": "http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/18f395ee-6cb9-4d6c-ae1e-865688fccc49"
        }
    ],
    "resourceVersion": "1.8"
}

I don’t know for sure why you’re getting empty results, but maybe you need to post {} instead of just empty body. The response you get seems to me like the server is interpreting it as a search…

Afterwards using the UUID that came back from the POST I can do:

GET https://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/18f395ee-6cb9-4d6c-ae1e-865688fccc49

and the response is

{
    "uuid": "18f395ee-6cb9-4d6c-ae1e-865688fccc49",
    "localDateStarted": "2017-12-15T07:14:10.000+0000",
    "localDateStopped": "2017-12-15T07:14:34.000+0000",
    "links": [
        {
            "rel": "full",
            "uri": "http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/18f395ee-6cb9-4d6c-ae1e-865688fccc49?v=full"
        },
        {
            "rel": "ref",
            "uri": "http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/18f395ee-6cb9-4d6c-ae1e-865688fccc49?v=ref"
        },
        {
            "rel": "self",
            "uri": "http://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/18f395ee-6cb9-4d6c-ae1e-865688fccc49"
        }
    ],
    "resourceVersion": "1.8"
}

I tried POST of import with {} also. Still, I am seeing the same issue (empty results)

Got it!!! I was using http:// for POSTing import instead of https:// (Was using some already stored messages) Now, I am getting the same response as yours for import now. But, I don’t see the concepts being saved in Openmrs :slight_smile:

The below is the response I am getting for GET https://192.168.33.10/openmrs/ws/rest/v1/openconceptlab/import/f4e39c12-1839-4998-81cc-6d17dffd4af6

@pramidat, the import took only 3 seconds so it most likely failed. Please try getting the full representation from the links section to see details.

The problem was that the concept collection I created in OCL was not released. I have created a release version for that and now I could see the concepts saved in openmrs after the import. import should be posted only with {}.

Thanks for the suggestions. I didn’t see instructions, but the suggestions here helpful.

These were my steps for subscribing to the CIEL dictionary:

  1. Install OpenMRS module “Open Concept Lab Module” (Administration -> Modules -> Manage Modules)
  2. Navigate to Administration -> Open Concept Lab -> Configuration Page
  3. Add Subscription URL (for CIEL, use http://api.openconceptlab.org/orgs/CIEL/sources/CIEL)
  4. Add Token which you can find on your user page on openconceptlab.com (which requires that you have a user account for OCL)

Hopefully that works. I’ll know soon.