Fetch Patient data for HIU

Hi,
i have followed below step to fetch patient data.

Step 1: Getting access tocken by using below command

curl --location --request POST 'https://dev.ndhm.gov.in/gateway/v0.5/sessions' --header 'Content-Type: application/json' --data-raw '{
  "clientId": "clientId-you-received",
  "clientSecret": "secret-you-received"
}'

Step 2: Create bridge with access tocken

curl --location --request PATCH 'https://dev.ndhm.gov.in/devservice/v1/bridges' --header 'Content-Type: application/json' --header 'Authorization: Bearer xx-xxx-xxx-xx-xx' --data-raw '{
	"url": "https://localhost:44357/Test"
}'

Note: xx-xxx-xxx-xx-xx is what i receive in response of step 1. Also i have set url as localhost is it ok for development.

Step 3 : Register facility using below command

curl --location --request PUT 'https://dev.ndhm.gov.in/devservice/v1/bridges/services' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer xx-xxx-xxx-xx-xx' --data-raw '{"id":"unique-hiu-id","name":"Your-facility-name","type":"HIU","active":true,"alias":["EG"]}'


After completed all above 3 steps, now i assume and ready to get patient data,

First we have to create Consent request. using api https://dev.ndhm.gov.in/gateway/v0.5/consent-requests/init
Above url need below parameter.

  • Authorization : this is what we get from step 1.
  • X-CM-ID : from where we get CM-ID ?
  • Request Body: In request what is requestId (Can i give any unique id as requestID ?)

After calling api consent-request/init next do i need to call api consent-request/on-init, if yes, then what will be requestId, consentRequest.id , resp.requestId

Hi @satindersingh,

First and foremost thing, you cannot use localhost, you should use a https url with proper certificate,

and you won’t get the patient data directly unless there is a data for the given patient. next thing is X-CM-ID is sbx.

Last is you can follow the documentation to know how to build the HIU https://sandbox.ndhm.gov.in/docs/build_hiu

Hi @leelanakka,

I have followed the documentation to build HIU.

Now from gateway callback On-Fetch got below response

{
    "requestId": "5115f5e1-3d7d-4367-9503-8077f01a89fd",
    "timestamp": "2020-11-04T13:39:40.53504",
    "consent": {
        "status": "GRANTED",
        "consentDetail": {
            "schemaVersion": "v0.5",
            "consentId": "928f6d41-cb82-4ef9-a7c9-2d5aaaf7f8e7",
            "createdAt": "2020-11-04T13:18:04.515334",
            "patient": {
                "id": "satinder@sbx"
            },
            "careContexts": [
                {
                    "patientReference": "12660",
                    "careContextReference": "12660"
                }
            ],
            "purpose": {
                "text": "Care Management",
                "code": "CAREMGT",
                "refUri": ""
            },
            "hip": {
                "id": "139245-01"
            },
            "hiu": {
                "id": "115"
            },
            "consentManager": {
                "id": "sbx"
            },
            "requester": {
                "name": "Dr. Poonam",
                "identifier": {
                    "type": "REGNO",
                    "value": "MH1001",
                    "system": "https://www.mciindia.org"
                }
            },
            "hiTypes": [
                "OPConsultation"
            ],
            "permission": {
                "accessMode": "VIEW",
                "dateRange": {
                    "from": "2020-10-02T05:18:52.261",
                    "to": "2020-10-31T05:18:52.261"
                },
                "dataEraseAt": "2020-11-05T13:17:51.373",
                "frequency": {
                    "unit": "HOUR",
                    "value": 0,
                    "repeats": 0
                }
            }
        },
        "signature": "bYONklt81f8i095Fj9p+iwnio8VjJK6W7vrwj8JLD04aLXnWZ3F4RkARRlGg58vLE8vGeShHUMU5HRvkw5v6WnQwXZgk2/D/cyP2lCj7NLIcuLLnRQXjolDuaYsxEB8yKIHGdamHoXFM5wkBkvyQg69nQW0j1hKX6sWYjl5VehGr5lmxJmQobFe52sLezKyoGpQj0pQL17akdCOZaTjBTVMg3DtUUo6edGUE+g9/bdmNdVSgr4FbdBpDX77sstX7/X7S666K/4ZHZ9DY8Bd029AvmH1eOswox1+wykV6bBnvipfm10WSV+PgHhm2BdAwlGskzH2orFf1ULWFjlkSqw=="
    },
    "error": null,
    "resp": {
        "requestId": "b5c3ce5a-2741-4d7f-8639-1ba122b8533a"
    }
}

Now do i need to call api /v0.5/health-information/cm/request to get patient data ?
If yes then can you tell me about these parameter.

     "dataPushUrl": "string",
        "keyMaterial": {
          "cryptoAlg": "ECDH",
          "curve": "Curve25519",
          "dhPublicKey": {
            "expiry": "2020-11-04T13:53:13.232Z",
            "parameters": "Curve25519/32byte random key",
            "keyValue": "string"
          },
          "nonce": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
        }

What is dataPushUrl, dhpublickey, nonce or if you provide any reference link would be much appreciated

Hi @satindersingh,

Yes, for each care context you receive in on-fetch API you have to call /v0.5/health-information/cm/request.

Those parameters are required for HIP to encrypt the data and also for you (HIU) to decrypt the data received from HIP. To know about the parameters and data transfer please follow this link https://sandbox.ndhm.gov.in/docs/build_hiu. In the section 4 Data request and transfer you would find the relevant information.

Thanks

Hi @dheerajp
Am making HIU app using asp.net.
Am still not clear about this part

"keyMaterial": {
    "cryptoAlg": "ECDH",
    "curve": "Curve25519",
    "dhPublicKey": {
        "expiry": "2020-11-04T13:53:13.232Z",
        "parameters": "Curve25519/32byte random key",
        "keyValue": "string"
    },
    "nonce": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}

Is this


or

what i can use to have nonce,key value ?

Hi @satindersingh

I think you can follow this Gist https://gist.github.com/Nexengineer/23589d0e8eeab0ad0f50cffdf4be6bca, it is a sample implementation of Encryption/Decryption.

keyValue will be the receiverPublicKey on line number 38.
nonce will be the randomKeyReceiver on line number 46.

Thanks!

Ok will try with that, Also can you tell me about dataPushUrl .
For dataPushUrl can i use same endpoint (url which i use to register for HIU system),

dataPushUrl is the on which you want to receive the encrypted patient data sent by HIP.
The contract for the dataPushUrl is https://sandbox.ndhm.gov.in/swagger/ndhm-hiu.yaml --> /v0.5/health-information/transfer.

Note: The URL can be different from what is specified in the contract. You can have your own custom data push URL but the same should be sent with the /v0.5/health-information/cm/request .

Hi @dheerajp
Thanks for https://gist.github.com/Nexengineer/23589d0e8eeab0ad0f50cffdf4be6bca i tried that sample and its works.
Now I successfully able to get response from callback API v0.5/health-information/hiu/on-request is as below

{
  "requestId": "14d16ba2-7bb7-41a2-8c6e-57c89612eb4f",
  "timestamp": "2020-11-05T17:01:16.032758",
  "hiRequest": {
    "transactionId": "5583a927-eafb-4f48-bee1-3fb348397dc3",
    "sessionStatus": "REQUESTED"
  },
  "error": null,
  "resp": {
    "requestId": "678ef35e-a132-4281-a957-7872c1ba79b7"
  }
}

But datapushurl didnt callback any response.

So i tried to consume api https://dev.ndhm.gov.in/gateway/v0.5/health-information/cm/request with request body as below

{
  "requestId": "499a5a4a-7dda-4f20-9b67-e24589627061",
  "timestamp": "2020-11-05T16:52:05.107Z",
  "notification": {
    "consentId": "0a055851-778e-4d77-aad7-f1603b9f111b",
    "transactionId": "5583a927-eafb-4f48-bee1-3fb348397dc3",
    "doneAt": "2020-11-05T16:52:05.107Z",
    "notifier": {
      "type": "HIU",
      "id": "115"
    },
    "statusNotification": {
      "sessionStatus": "TRANSFERRED",
      "hipId": "139245-01",
      "statusResponses": [
        {
          "careContextReference": "12660",
          "hiStatus": "OK",
          "description": "string"
        }
      ]
    }
  }
}

Still no success to fetch patient data.

Hi @satindersingh,

Please follow the API contracts, you won’t get expected response if you call API with wrong body.
Also can you share the request body with which you called API v0.5/health-information/cm/request.
Since you got the /on-request callback we can check what could have been wrong.

Thanks

Hi @dheerajp

I have called api /v0.5/health-information/cm/request with below request body

{
  "requestId": "e9bdf43a-f5db-4221-a0d1-68784c73f044",
  "timestamp": "2020-11-06T07:43:05.099Z",
  "hiRequest": {
    "consent": {
      "id": "c0511065-af4c-4cdf-99ac-eb637f0297a0"
    },
    "dateRange": {
      "from": "2020-10-02T05:18:52.261Z",
      "to": "2020-10-31T05:18:52.261Z"
    },
    "dataPushUrl": "https://cldilstaffweb04.insurancearticlez.com/HIU/api/hiu/v0.5/health-information/transfer",
    "keyMaterial": {
      "cryptoAlg": "ECDH",
      "curve": "Curve25519",
      "dhPublicKey": {
        "expiry": "2020-11-06T07:43:05.099Z",
        "parameters": "Curve25519/32byte random key",
        "keyValue": "MIIBMTCB6gYHKoZIzj0CATCB3gIBATArBgcqhkjOPQEBAiB/////////////////////////////////////////7TBEBCAqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqYSRShRAQge0Je0Je0Je0Je0Je0Je0Je0Je0Je0Je0JgtenHcQyGQEQQQqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq0kWiCuGaG4oIa04B7dLHdI0UySPU1+bXxhsinpxaJ+ztPZAiAQAAAAAAAAAAAAAAAAAAAAFN753qL3nNZYEmMaXPXT7QIBCANCAAQBcFPsoaJSkQ7DsJ88l1vTURCE14+4o9cTFJ2DwYjNKHVWBsn/BBrzractjquL1DyqCigiNaje7RgeMubWj5Kn"
      },
      "nonce": "SOZVhijPRdmi94c1mfKpwj3jFPS5c1DhqrJbmnNfARQ="
    }
  }
}

Then i got below response from callback api health-information/hiu/on-request

{
  "requestId": "50f1d8e8-220c-4944-b15a-1022f1c003a2",
  "timestamp": "2020-11-06T07:43:05.33836",
  "hiRequest": {
"transactionId": "b75c0a12-7463-4e1c-8bce-dce5f46d1483",
"sessionStatus": "REQUESTED"
  },
  "error": null,
  "resp": {
"requestId": "e9bdf43a-f5db-4221-a0d1-68784c73f044"
  }
}

Am consuming all api from endpoint https://cldilstaffweb04.insurancearticlez.com/HIU/api/hiu/ . As i have transaction id , can i get patient data directly by using transaction ID

Hi @satindersingh,

After you get callback response on health-information/hiu/on-request then you should get an API call on your dataPushUrl with the encrypted patients data. Please make sure you have implemented https://cldilstaffweb04.insurancearticlez.com/HIU/api/hiu/v0.5/health-information/transfer this API on your HIU.

Hi @dheerajp
I will share full summary, which i tried with request/response so you get clear idea. I know it might be long post sorry for that.

Below process I followed:

When i create consent request i got below response on callback v0.5/consent-requests/on-init

{
  "requestId": "e4c20d2b-2887-4a7a-88b9-d58101973a68",
  "timestamp": "2020-11-06T08:48:38.723813",
  "consentRequest": {
    "id": "4902ab78-2d66-486c-9707-2efdb8485369"
  },
  "error": null,
  "resp": {
    "requestId": "d1f2b09c-b5e4-4a5c-b052-07e2757df1c0"
  }
}

After that when user grant permission from PHR mobile, got below response as callback api v0.5/consents/hiu/notify

{
  "requestId": "c8a7b9dc-4c75-4f36-9102-768399fb845b",
  "timestamp": "2020-11-06T08:48:56.196296",
  "notification": {
    "consentRequestId": "4902ab78-2d66-486c-9707-2efdb8485369",
    "status": "GRANTED",
    "consentArtefacts": [
      {
        "id": "eb0e71d4-6471-48fa-92d1-eb9fdab1a127"
      }
    ]
  }
}

Then i consume Fetch API using url https://dev.ndhm.gov.in/gateway/v0.5/consents/fetch
with requestbody as below:

{
  "requestId": "80fd8a63-ef94-42cd-8934-2859a5d1e4e1",
  "timestamp": "2020-11-06T08:49:34.471Z",
  "consentId": "eb0e71d4-6471-48fa-92d1-eb9fdab1a127"
}

Note: Here in requestbody i set consentId as consentArtefacts.id which got from above response ( v0.5/consents/hiu/notify)

Now i got response from callback v0.5/consents/on-fetch

{
  "requestId": "e4110a4f-ca64-4d26-953f-d3bd3ad42eea",
  "timestamp": "2020-11-06T08:49:34.679404",
  "consent": {
    "status": "GRANTED",
    "consentDetail": {
      "schemaVersion": "v0.5",
      "consentId": "eb0e71d4-6471-48fa-92d1-eb9fdab1a127",
      "createdAt": "2020-11-06T08:48:56.168156",
      "patient": {
        "id": "satinder@sbx"
      },
      "careContexts": [
        {
          "patientReference": "12660",
          "careContextReference": "12660"
        }
      ],
      "purpose": {
        "text": "Care Management",
        "code": "CAREMGT",
        "refUri": ""
      },
      "hip": {
        "id": "139245-01"
      },
      "hiu": {
        "id": "115"
      },
      "consentManager": {
        "id": "sbx"
      },
      "requester": {
        "name": "Dr. Poonam",
        "identifier": {
          "type": "REGNO",
          "value": "MH1001",
          "system": "https://www.mciindia.org"
        }
      },
      "hiTypes": [
        "OPConsultation"
      ],
      "permission": {
        "accessMode": "VIEW",
        "dateRange": {
          "from": "2020-10-02T05:18:52.261",
          "to": "2020-10-31T05:18:52.261"
        },
        "dataEraseAt": "2020-11-07T08:48:38.609",
        "frequency": {
          "unit": "HOUR",
          "value": 0,
          "repeats": 0
        }
      }
    },
    "signature": "elOkCjE3QTq1UoXEuVLKMlgI6/NV7HdeiMDVi3fhOW2W6Gn53sXS5bYQLEeZCH+Q2FEMhw8dXqBsSsPcLoTV4ohhXWKXo8OTRQCUHwMmPindfzopz0xU810klDg6ZJO+ELfQV1TwZe1vYmaEWZ85p/+5ZVn77WyE3cnQ1cVDfJzG8IC5xnCbrrdSJU3gDF4yy0U1QCoB1JHNZgWWP4nAT2Eo1cMcKeqGybx0mYKZ37ZFgoTom+5y0iEZIKCuqBnzwKxheA17RGNc7R75sU0ho3wlcrpWEG+850yHVRQCtS82DwR1vvMGFPtJxoF0iXtqqgKSQ/yun1QUHkIGweCHxw=="
  },
  "error": null,
  "resp": {
    "requestId": "80fd8a63-ef94-42cd-8934-2859a5d1e4e1"
  }
}

Now i consume healthInformationRequest Api using url v0.5/health-information/cm/request
with requestbody as below:

{
  "requestId": "993bc7c0-e421-4bc0-8fb3-f932bb675a85",
  "timestamp": "2020-11-06T08:50:07.806Z",
  "hiRequest": {
    "consent": {
      "id": "eb0e71d4-6471-48fa-92d1-eb9fdab1a127"
    },
    "dateRange": {
      "from": "2020-10-02T05:18:52.261Z",
      "to": "2020-10-31T05:18:52.261Z"
    },
    "dataPushUrl": "https://cldilstaffweb04.insurancearticlez.com/HIU/api/hiu/patientdata",
    "keyMaterial": {
      "cryptoAlg": "ECDH",
      "curve": "Curve25519",
      "dhPublicKey": {
        "expiry": "2020-11-06T08:50:07.806Z",
        "parameters": "Curve25519/32byte random key",
        "keyValue": "MIIBMTCB6gYHKoZIzj0CATCB3gIBATArBgcqhkjOPQEBAiB/////////////////////////////////////////7TBEBCAqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqYSRShRAQge0Je0Je0Je0Je0Je0Je0Je0Je0Je0Je0JgtenHcQyGQEQQQqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq0kWiCuGaG4oIa04B7dLHdI0UySPU1+bXxhsinpxaJ+ztPZAiAQAAAAAAAAAAAAAAAAAAAAFN753qL3nNZYEmMaXPXT7QIBCANCAARNpNg+Fr7lLHKEd1CnnnxRci4VLo0iA26XNQKmpT0h3x+PKsYWHZk/i04Du7AoCHPTOKVS4wRvBGSBWkgUdjXL"
      },
      "nonce": "EJjILFA/5i+Xb+iH10N5qQKyKWYpik9rOI7BVdyhzjI="
    }
  }
}

And got callback response from v0.5/health-information/hiu/on-request

{
  "requestId": "5f26d789-e360-4aec-88d9-1c05e20b0137",
  "timestamp": "2020-11-06T08:50:08.036231",
  "hiRequest": {
    "transactionId": "6649e6f0-d771-417c-8f20-e5d279408d22",
    "sessionStatus": "REQUESTED"
  },
  "error": null,
  "resp": {
    "requestId": "993bc7c0-e421-4bc0-8fb3-f932bb675a85"
  }
}

But no response from dataPushUrl, i have teseted url set to dataPushUrl from postman , and i am able to post data.

Hi @satindersingh,

We can see that WebEMR HIP(From where the data is requested) is acknowledging the data request made by HIU but because of some issue it’s not sending the data. We will need to investigate the issue on WebEMR’s side.
We will get back to you once we find the issue. Sorry for the inconvenience.

Hello @139245,

Could you please check this on WebEMR’s HIP side.

Thank you very much!

Hi @dheerajp
Thanks for reply, so once WebEMR side issue resolved, then i can expect to get encrypted data at datapushUrl.
Can you please share sample data, which is expected in response at datapushUrl.

Hi @satindersingh,

Please refer to this API contract https://sandbox.ndhm.gov.in/swagger/ndhm-hiu.yaml --> /v0.5/health-information/transfer for the dataPushUrl.

The request body contains

"entries": [
    {
      "content": "Encrypted content of data packaged in FHIR bundle",
      "media": "application/fhir+json",
      "checksum": "string",
      "careContextReference": "RVH1008"
    },
    {
      "link": "https://data-from.net/sa2321afaf12e13",
      "media": "application/fhir+json",
      "checksum": "string",
      "careContextReference": "NCC1701"
    }
  ]

The encrypted data will come in the “content”: “Encrypted content of data packaged in FHIR bundle”.
Here is link to sample data JSON files of FHIR bundle.

Hi @139245 @dheerajp
Any update on dataPushUrl , still not able to fetch data. Below is new transactionId created.

{
  "requestId": "799b0759-0b23-4e4c-9379-d5ad43d14b77",
  "timestamp": "2020-11-09T08:58:21.696833",
  "hiRequest": {
    "transactionId": "f4cc3762-49f4-4648-a951-340c9ee9b5de",
    "sessionStatus": "REQUESTED"
  },
  "error": null,
  "resp": {
    "requestId": "becb7ef6-3503-4fd5-84b6-9ae03cfd808e"
  }
}

Hi @satindersingh,

We are really sorry for the inconvenience. We are still checking the issue, please bear with us.

Hello @139245,

Please update here if there is any update on this.

Thank you very much.