Hiu implementation for milestone-3

Hi @Shubham,

We might not be able to help much just with the error message. However we would suggest to compare the code from the open source HIU implementation and if there are any slight deviations.

Hi,

@bhaskar.dabhi, Did the java code for encrypting the entries provided by us work for you?

@Shubham, Were you able to compare with the suggested implementations? Was it helpful?

Please let us know.

Yes sir ,I have gone through the implementation guide but still the problem is’nt solved.

Hello sir,
we are using this file for encryption and decryption ,only the decryption part is not working as after decrypt function the content is showing null.
we have changed the load public key function with load public key using eka in the decrypt function
below is the response we are getting from our hip to hiu
request:
{“keyMaterial”:{“curve”:“Curve25519”,“cryptoAlg”:“ECDH”,“dhPublicKey”:{“keyValue”:“MIIBMTCB6gYHKoZIzj0CATCB3gIBATArBgcqhkjOPQEBAiB/////////////////////////////////////////7TBEBCAqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqYSRShRAQge0Je0Je0Je0Je0Je0Je0Je0Je0Je0Je0JgtenHcQyGQEQQQqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq0kWiCuGaG4oIa04B7dLHdI0UySPU1+bXxhsinpxaJ+ztPZAiAQAAAAAAAAAAAAAAAAAAAAFN753qL3nNZYEmMaXPXT7QIBCANCAAQdd19LMG1Wpn2HW4hdB0b2W3M+yJGQocSs7GvHbHut3whzYbcP+4IbmKwW980k8HgZ+4kY+cI1T/1LAExE83Oi”},“nonce”:"/+cDY/tW8ARvxfL5lJI64emFT7xVUPpymUYCCXJDpi0="},“pageCount”:0,“entries”:[{“careContextReference”:“Prescription”,“link”:“https://data-from.net/sa2321afaf12e13",“media”:“application/fhir+json”,“content”:“uRj0dmGYVShAUbbtcv5YfeTVJvM4vXdYLooKtAGTMXCTkq/3YCOzve36E42u2GJjj3VpY4ApW9Bz/8ScLC7VeN9H9lUjCXURRYanPdySYGN+4g98BFoxm0YNgjGjibvS0DBut3Znn4yrXpypxXldpG93wSbVcg2uVHTRExxRqwVY193JYylIg/rOfl53S7NDx5X7t7lMZoZwn3q+3+f7QlwOaV54n2IQ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MqbMsUdeN341kpN58kzD4dwTrKFzTYBw==”}],“pageNumber”:0,“transactionId”:"97550f29-69f2-4ec3-885c-4ca5fb405b59”}

after decrypting this the content is showing null,can you please try to decrypt at your end.
@mdubey sir

@mdubey,

I am trying the snippet you provided but looks like it is not a complete snippet. Please check my following feedbacks:

  • Need the definition of EncryptedEntries, Entries, KeyMaterial, Entry, KeyStructure, Mono for DataEntryFactory

Or can you point us to the complete gist of the code that you posted? We tried to look into ProjectEka but looks like code is written in C#

Hi @bhaskar.dabhi,

Thanks for pointing out shortcomings on that snipped. I have added the required definitions. Please let me know if something else is missing.

Also you can ignore the Mono part and return EncryptedEntries itself, as that is present because we are using reactive java stack. In the last line replace

return Mono.just(new EncryptedEntries(processedEntries, keyMaterial))

With

return new EncryptedEntries(processedEntries, keyMaterial)

Thanks, @mdubey I will check and will get back to you.

Hello @mdubey sir,
Any updates please let us know if you are able to decrypt the above encrypted data which i have send above,in our side after decryption content is getting null.

Hello @mdubey sir,
As we are receiving entry.consent in string format then how to convert in json format to map in in our end.

hello sir,
Below is our sample content which we are receiving after decrypting
{\n “resourceType”: “Bundle”,\n “id”: “81713b3a-2a74-4676-b35b-bd47529841b8”,\n “meta”: {\n “versionId”: “1”,\n “lastUpdated”: “2021-02-10T10:38:34.319+05:30”,\n “profile”: [ “https://nrces.in/ndhm/fhir/r4/StructureDefinition/DocumentBundle” ],\n “security”: [ {\n “system”: “http://terminology.hl7.org/CodeSystem/v3-Confidentiality”,\n “code”: “V”,\n “display”: “very restricted”\n } ]\n },\n “identifier”: {\n “system”: “http://hip.in”,\n “value”: “bc3c6c57-2053-4d0e-ac40-139ccccff645”\n },\n “type”: “document”,\n “timestamp”: “2021-02-17T10:13:52.236+05:30”,\n “entry”: [ {\n “fullUrl”: “Composition/Composition-01”,\n “resource”: {\n “resourceType”: “Composition”,\n “id”: “Composition-01”,\n “identifier”: {\n “system”: “https://ndhm.in/phr”,\n “value”: “645bb0c3-ff7e-4123-bef5-3852a4784813”\n },\n “status”: “final”,\n “type”: {\n “coding”: [ {\n “system”: “http://snomed.info/sct”,\n “code”: “440545006”,\n “display”: “Prescription record”\n } ],\n “text”: “Prescription record”\n },\n “subject”: {\n “reference”: “Patient/6023b795b26e082c79ea09e7”\n },\n “date”: “2021-02-17T10:13:52.240+05:30”,\n “author”: [ {\n “reference”: “Practitioner/5fbca309b26e084ebc3c1971”\n } ],\n “title”: “Prescription record”,\n “section”: [ {\n “title”: “Prescription record”,\n “code”: {\n “coding”: [ {\n “system”: “http://snomed.info/sct”,\n “code”: “440545006”,\n “display”: “Prescription record”\n } ]\n },\n “entry”: [ {\n “reference”: “MedicationRequest/02102021GEOrmf”,\n “type”: “MedicationRequest”\n } ]\n } ]\n }\n }, {\n “fullUrl”: “Patient/6023b795b26e082c79ea09e7”,\n “resource”: {\n “resourceType”: “Patient”,\n “id”: “6023b795b26e082c79ea09e7”,\n “identifier”: [ {\n “type”: {\n “coding”: [ {\n “system”: “http://terminology.hl7.org/CodeSystem/v2-0203”,\n “code”: “MR”,\n “display”: “Medical record number”\n } ]\n },\n “system”: “https://plus.healthcoco.com”,\n “value”: “12345”\n } ],\n “name”: [ {\n “text”: “Health Test”\n } ]\n }\n }, {\n “fullUrl”: “Practitioner/5fbca309b26e084ebc3c1971”,\n “resource”: {\n “resourceType”: “Practitioner”,\n “id”: “5fbca309b26e084ebc3c1971”,\n “identifier”: [ {\n “type”: {\n “coding”: [ {\n “system”: “http://terminology.hl7.org/CodeSystem/v2-0203”,\n “code”: “MD”,\n “display”: “Medical License number”\n } ]\n },\n “system”: “https://plus.healthcoco.com”,\n “value”: “12345”\n } ],\n “name”: [ {\n “text”: “Dr.Cello Pen”\n } ]\n }\n }, {\n “fullUrl”: “MedicationRequest/02102021GEOrmf”,\n “resource”: {\n “resourceType”: “MedicationRequest”,\n “id”: “02102021GEOrmf”,\n “status”: “active”,\n “intent”: “order”,\n “medicationCodeableConcept”: {\n “text”: “[ METROGYL 400]”\n },\n “subject”: {\n “reference”: “Patient/6023b795b26e082c79ea09e7”\n },\n “authoredOn”: “2021-02-10”,\n “requester”: {\n “reference”: “Practitioner/5fbca309b26e084ebc3c1971”\n },\n “dosageInstruction”: [ {\n “text”: “[1-0-1]”\n } ]\n }\n } ]\n}
could you please tell us how you are mapping in phr app.

Hi @Shubham

If you checked our HIU code. After decrypting the content we parse it as a bundle resource. Please check here.

Post that you would receive the same bunle which was sent by HIP. You can follow our code base. In short there will below things to take care of:

  • The first Entry in the bundle will be a composition.
  • A composition will have section, which will have references to other resources, medication/Observation etc.
    -You can find out the values sent from these resources.

Hello sir,
I have checked but the link is showing 404 .

Sorry! Corrected the link

Thankyou sir,will check that

@mdubey Still facing issues with the java snippet.

Can we set up a call with you or someone from the dev team of NDHM? We have been struggling with the issue for the last many months. We are not getting the platform-agnostic answers, nor snippets are resolving our issues.

@angshuonline in last webinar you mentioned to @kishan.gor to setup a call with NDHM developer team. Can you please do that? Can we have a call related to the issue?

Hi @bhaskar.dabhi,

Are you getting any error while trying the snippet? We are trying to see if we can setup a call ASAP.

Hi @mdubey,

We faced the following issues:

Many dependecines in the code were not working so we tried to make the code minimal and tried the encryption and got following error:

Exception in thread “main” java.lang.IllegalArgumentException: Invalid point encoding 0x30
at org.bouncycastle.math.ec.ECCurve.decodePoint(ECCurve.java:443)
at Encryptor.loadPublicKey(Encryptor.java:110)
at Encryptor.doECDH(Encryptor.java:118)
at Encryptor.encrypt(Encryptor.java:49)
at Encryptor.encryptData(Encryptor.java:45)
at main.main(main.java:72)

You can check our code here

Sure, Let us know your availability time for the call. You can reach out to me at bhaskar.dabhi@plus91.in

Thanks.

Hi @bhaskar.dabhi,

I had a look at your code, and if I change below in your main.java, I don’t see any errors. Please try the same.

The change is to replace line below with:

keyMaterial.dhPublicKey.keyValue = Encryptor.getBase64String(Encryptor.getEncodedPublicKeyForProjectEKAHIU(Encryptor.generateKeyPair().getPublic()));

With

keyMaterial.dhPublicKey.keyValue = Encryptor.getBase64String(Encryptor.getEncodedPublicKey(Encryptor.generateKeyPair().getPublic()));

The definition of this new method getEncodedPublicKey you can get from our java gist.

Could you please give it a quick try and get back to us.

Thank you

Thanks @mdubey Let me check