Cannot save a very simple fhir patient bundle - hl7-fhir

I am trying to save this very simple fhir patient bundle against https://vonk.fire.ly/Bundle, by doing a PUT using Postman, however I am not able to get it working. When I simply copy the inner Patient resource data and do a PUT directly to the https://vonk.fire.ly/Patient endpoint it works just fine (for example - I just did it to this url https://vonk.fire.ly/Patient/deb7338181).
Can someone please please point me in the direction of what exactly it is going wrong here in this bundle??
{
"resourceType": "Bundle",
"id": "b6ec685a-26a2-4bb3-814b-841fba6a6edb",
"meta": {
"lastUpdated": "2018-05-29T23:45:32Z"
}
"type": "transaction",
"entry": [
{
"resource": {
"resourceType": "Patient",
"id": "deb73381811",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Some narrative</div>"
},
"active": true,
"name": [
{
"use": "official",
"family": "Chalmers1",
"given": [
"Peter1",
"James1"
]
}
],
"gender": "male",
"birthDate": "1974-12-25"
},
"request": {
"method": "POST",
"url": "Patient"
}
}
]
}

If you want to send a transaction to a FHIR server, you do a POST of the transaction Bundle to the endpoint, just like you mention in your comment. Within the transaction, for each entry you have to set the request part to the kind of request you want.
For your Patient entry you have asked the server to do a POST, which means a create with a server assigned ID. If you want the server to use your own ID, you should instruct it to perform a PUT, which is usually an update, but can also be used for create with your own ID.
The syntax for the update request is:
"request": {
"method": "PUT",
"url": "Patient/<my_patient_id>"
}
Please note that although it is a valid FHIR request and Vonk allows it, not all servers will.

Related

How to link batch-response entries with the request entries in FHIR (DSTU3)

I am currently building an application for which it is important to check the existence of resources with a certain profile.
As we need to check this for 40+ profiles I'd like to put this all in 1 batch request and let our HAPI-FHIR server implementation handle this, as opposed to querying them one by one. This would get too chatty otherwise.
Because I only need to know about whether the resource exists I'd like to use _summary=count. I am assuming this increases the performance of the request.
Example request
{
"resourceType": "Bundle",
"type": "batch",
"entry": [
{
"request": {
"method": "GET",
"url": "/Observation?_profile=http://nictiz.nl/fhir/StructureDefinition/zib-DrugUse&_summary=true"
}
},
{
"request": {
"method": "GET",
"url": "/RelatedPerson?_profile=http://fhir.nl/fhir/StructureDefinition/nl-core-relatedperson&_summary=count"
}
}
]
}
Response
{
"resourceType": "Bundle",
"id": "fd66cfd9-4693-496d-86fc-98289067480b",
"type": "batch-response",
"link": [
{
"relation": "self",
"url": "<redacted>"
}
],
"entry": [
{
"resource": {
"resourceType": "Bundle",
"id": "2647a49f-0503-496b-b274-07d4e9163f1b",
"meta": {
"lastUpdated": "2021-02-15T11:44:18.035+00:00",
"tag": [
{
"system": "http://hl7.org/fhir/v3/ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
},
"type": "searchset",
"total": 48
},
"response": {
"status": "200 OK"
}
},
{
"resource": {
"resourceType": "Bundle",
"id": "2f9cc861-5d20-4da1-aa9f-12153b75539d",
"meta": {
"lastUpdated": "2021-02-15T11:44:18.151+00:00",
"tag": [
{
"system": "http://hl7.org/fhir/v3/ObservationValue",
"code": "SUBSETTED",
"display": "Resource encoded in summary mode"
}
]
},
"type": "searchset",
"total": 10
},
"response": {
"status": "200 OK"
}
}
]
}
Can I assume that the ordering of the batch-response is the same as that of the batch-request?
Or is there a method to annotate the batch entries which are persisted onto the batch-response?
Or finally, is there a flag I can turn on to make the response include the request.url part?
I'm using HAPI-FHIR 5.1.0 both for client and server.
Apparently I didn't look well enough in the specs, as I just found the following:
From the FHIR spec
For a batch, or a successful transaction, the response the server SHALL return a Bundle with type set to batch-response or transaction-response that contains one entry for each entry in the request, in the same order, with the outcome of processing the entry.

Access control at property level (hiding/showing properties in api response based on the role)

I have a spring-boot based micro-service generated using JHipster.
I am using keycloak as my Auth Server. I could enable Role-based & scope based authorization on my resources(apis).
Now the requirement is: based on the role of the client, I need to restrict the information to send in the response (either mask the attributes or nullify them).
eg:
consider the following api to get the person's profile
/api/person/{id}
{
"name": {
"firstName": "Jack",
"lastName": "Sparrow"
},
"gender": "MALE",
"emails": {
"details": [
{
"emailId": "jack.sparrow#gmail.com"
}
]
},
"phones": {
"details": [
{
"phoneNumber": "1234567890",
"countryCode": "+1"
}
]
},
"addresses": {
"details": [
{
"addressLine1": "aaaaaaaa",
"addressLine2": "bbbbbbb",
"city": "cccccc",
"state": "ddddd",
"country": "South Africa",
"postalCode": "987654"
}
]
},
"photo": "string",
"nationality": "South Africa",
"countryOfResidence": "string",
"active": true,
"createdAt": 1537431339569,
"modifiedAt": 1537436600693,
"createdBy": "admin",
"modifiedBy": "admin"
}
Now, when a person with BASIC role calls this API, the requirement is to show only basic information like:
- name, gender
If he has INTERMEDIATE role then we can send something more than basic but not full information. eg: name, gender, photo, nationality
If he has ADMIN role then we can send the complete information.
Can anyone please let me know What is the best approach to achieve this.
-- Thanks in advance :)

How to send a mail with mention?

When I get mails:
GET /beta/me/messages
I can check this to see if someone mentioned me.
mentionsPreview: {
isMentioned: true
}
How can I send out a mail and mention someone or some people in the mail?
I didn't find any info in the document.
UPDATE 1:
I can successfully add mentions when create a new mail and send out by
POST /beta/me/sendMail
{
// ...
"mentions":[{
"mentioned": {
"name": "Jack",
"address": "jack#example.com"
},
"createdBy": {
"name": "Me",
"address": "me#example.com"
}
}]
}
However, I failed to add mentions when reply a mail. I create a draft first by
POST /beta/me/messages/{messageId}/createReplyAll
Then I update it by (this step failed to add mentions)
PATCH /beta/me/messages/{messageId}
{
"body": {
"contentType": "html",
"content": "hi"
},
"mentions":[{
"mentioned": {
"name": "Jack",
"address": "jack#example.com"
},
"createdBy": {
"name": "Me",
"address": "me#example.com"
}
}]
}
I send it out by
POST /beta/me/messages/{messageId}/send
In the mail Jack got, the content successfully updated. But mentionsPreview is still null.
UPDATE 2:
Thanks Jason's help.
Further test, I succeed add mention by
POST /beta/me/messages/{messageId}/mentions
{
"mentioned": {
"address": "jack#example.com"
}
}
But I failed to add mentions using array
POST /beta/me/messages/{messageId}/mentions
{
"mentions":[{
"mentioned": {
"address": "jack#example.com"
}
}]
}
which means I have to POST mentions one by one at least for now.
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/mention
When creating a message, an app can create a mention in the same POST request by including the mention in the mentions property.
UPDATE
On your new question about doing this on a reply, the problem is you cannot PATCH in mentions like that. You can only include mentions inline with the rest of the message if you do it at message creation. Since you've already created the message (via the createReplyAll method), to update mentions you need to POST new mentions to the /mentions relationship on the message, like:
POST /me/messages/{messageId}/mentions
{
"mentioned": {
"name": "Jack",
"address": "jack#example.com"
},
"createdBy": {
"name": "Me",
"address": "me#example.com"
}
}
As an interesting side note, you CANNOT currently include mentions inline using the replyAll method. It seems that you can only do this when creating a brand new message or when sending a new message. For all other cases, you need to do a POST to the /mentions relationship as above.

Can't get almost all information from event from service Hook

I am trying to use the Trello service hook with Team Foundation Server. I have followed this tutorial and the connection worked without problems but, I can't get the informations I need from the Event JSON:
The Description I Tried
This is the Event JSON:
{
"id": "03c164c2-8912-4d5e-8009-3707d5f83734",
"eventType": "git.push",
"publisherId": "tfs",
"scope": 0,
"message": {
"text": "Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master.",
"html": "Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master.",
"markdown": "Jamal Hartnett pushed updates to `Fabrikam-Fiber-Git`:`master`."
},
"detailedMessage": {
"text": "Jamal Hartnett pushed a commit to Fabrikam-Fiber-Git:master.\n - Fixed bug in web.config file 33b55f7c",
"html": "Jamal Hartnett pushed a commit to Fabrikam-Fiber-Git:master.\n<ul>\n<li>Fixed bug in web.config file 33b55f7c\n</ul>",
"markdown": "Jamal Hartnett pushed a commit to [Fabrikam-Fiber-Git](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/):[master](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/#version=GBmaster).\n* Fixed bug in web.config file [33b55f7c](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74)"
},
"resource": {
"commits": [
{
"commitId": "33b55f7cb7e7e245323987634f960cf4a6e6bc74",
"author": {
"name": "Jamal Hartnett",
"email": "fabrikamfiber4#hotmail.com",
"date": "2015-02-25T19:01:00Z"
},
"committer": {
"name": "Jamal Hartnett",
"email": "fabrikamfiber4#hotmail.com",
"date": "2015-02-25T19:01:00Z"
},
"comment": "Fixed bug in web.config file",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74"
}
],
"refUpdates": [
{
"name": "refs/heads/master",
"oldObjectId": "aad331d8d3b131fa9ae03cf5e53965b51942618a",
"newObjectId": "33b55f7cb7e7e245323987634f960cf4a6e6bc74"
}
],
"repository": {
"id": "278d5cd2-584d-4b63-824a-2ba458937249",
"name": "Fabrikam-Fiber-Git",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249",
"project": {
"id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"name": "Fabrikam-Fiber-Git",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"state": "wellFormed",
"visibility": "unchanged"
},
"defaultBranch": "refs/heads/master",
"remoteUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git"
},
"pushedBy": {
"id": "00067FFED5C7AF52#Live.com",
"displayName": "Jamal Hartnett",
"uniqueName": "Windows Live ID\\fabrikamfiber4#hotmail.com"
},
"pushId": 14,
"date": "2014-05-02T19:17:13.3309587Z",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/pushes/14"
},
"resourceVersion": "1.0",
"resourceContainers": {
"collection": {
"id": "c12d0eb8-e382-443b-9f9c-c52cba5014c2"
},
"account": {
"id": "f844ec47-a9db-4511-8281-8b63f4eaf94e"
},
"project": {
"id": "be9b3917-87e6-42a4-a549-2bc06a7a878f"
}
},
"createdDate": "2017-07-21T16:48:44.312Z"
}
This is the Request that was send to Trello:
Method: POST
URI: https://api.trello.com/1/cards?key=7d6630fd03ac2b6fc9fde2f2ef0c4096&token=********
HTTP Version: 1.1
Headers:
{
Content-Type: application/json; charset=utf-8
}
Content:
{
"name": "Test NÂș ",
"desc": "Description: ",
"pos": "top",
"due": null,
"labels": "green",
"idList": "5935a0d45ff8e5a6c8f828b9"
}
The only field that I could get/read from the Event JSON was the "message".
What am I doing wrong?
If you want to get the push ID and comments, the description is:
{{push.pushId}}
{{push.commits[0].comment}}
Update
Eddie is right you should use push as the resource in this case. The docs are not so clear. In the end, it was something so simple. However the corresponding checkin is not work for Code checked in event.
The docs could definitely be more clear in how the resource are for each event which applied to help avoid this confusion.
The basic form of the placeholder is {{resource.field}} where
resource is the name of the resource raising the event (workitem, build, etc) and field is a field within the resource section of the
event, like id. So, if the subscription were for a completed build,
it might be something like:
Build {{build.id}} completed at {{build.finishTime}}
Seems the issue is you are using the wrong placeholder in this case. According to your send Request , resource.pushID & resource.commits.[0].comment is not replaced by values from the event that was raised.

Different versions of API Blueprint

The structure to the example on http://apiblueprint.org/#get-started seems to differ from the structure on APIary.io.
Can anyone please comment on whether they are different, and if so, which structure is correct?
For example,
API Blueprint Document Structure
1.) Metadata
2.) API Name & Overview
3.) Resource
A.) URI Parameters
B.) Model
1.) Headers
2.) Body
3.) Schema
C.) Action
1.) URI Parameters
2.) Request
a.) Headers
b.) Body
c.) Schema
3.) Response
a.) Headers
b.) Body
c.) Schema
4.) Resource Group
A.) Resource
versus
{
"_version": "2.0",
"metadata": [],
"name": "",
"description": "",
"resourceGroups": [
{
"name": "",
"description": "",
"resources": [
{
"name": "",
"description": "",
"uriTemplate": "/message",
"model": {},
"parameters": [],
"actions": [
{
"name": "",
"description": "",
"method": "GET",
"parameters": [],
"examples": [
{
"name": "",
"description": "",
"requests": [],
"responses": [
{
"name": "200",
"description": "",
"headers": [
{
"name": "Content-Type",
"value": "text/plain"
}
],
"body": "Hello World!\n",
"schema": ""
}
]
}
]
}
]
}
]
}
]
}
Many thanks,
The "API Blueprint Document Structure" you mentioned is how you write an API Blueprint document.
The JSON you wrote above is the AST that you get when you parse the above API Blueprint using the API Blueprint parser like https://github.com/apiaryio/snowcrash.
So, both of them represent your API Blueprint correctly, but the non-AST one is much more readable.
Hope that clears your confusion.

Resources