Fiware Orion NGSI-LD : Support of LanguageMap - fiware

I would like to know weither the LanguageMap functionnality is supported (or will be supported) in the Orion-LD implementation.
The languageMap is presented on the folowing video : https://www.youtube.com/watch?v=ll-t8Vi9i50
The idea is to be able to request an attribute in a specific language. Exemple with the following JSON :
"pitch": {
"type": "Property",
"value": [
{
"language ": "fr",
"article": "Mariage"
},
{
"language": "en",
"article": "Wedding"
},
{
"language": "ru",
"article": "Выставка!"
},
{
"language": "zh",
"article": "展览"
},
{
"language": "ja",
"article": "展覧会"
}
]
},
How to query a specific language article?
Many thanks in advance for your feedback.
Rgds
LC

Yes, it will most definitely be supported.
Not the very first item on our Backlog, but yeah, it's quite prioritized. Third item in a list of hundreds of items ... (right now - the list is somewhat volatile).
It will not be exactly as in your example, please check the latest published ETSI NGSI-LD spec to get it right. It's something like this:
"pitch": {
"type": "LanguageProperty",
"languageMap": {
"en": "marriage",
"fr": "mariage",
"es": "matrimonio",
...
}
}
If you create an issue on Orion-LD's github, you will be informed as soon as the work begins on this, and I can even send a hint every now and then, before the work actually begins. Hopefully, work will commence on this interesting feature before summer, but I can't really promise anything.
About queries, if I remember correctly, the query will be done simply with
?q=pitch==matrimonio&lang=es
(please check the API spec to verify what I just said)

Related

FHIR one actor in two different roles

I'm creating a procedure in a transaction bundle and add practitioners as actors to the performers collection, having different functions. As far as the practitioners references are unique, all is fine. But when I'm trying to add a practitioners twice, with a different functions, an exception is thrown:
Can not process entity with ID[urn:uuid:7165d406-da59-4436-aa93-372ca882c4e5], this is not a valid FHIR ID
I found this message in HAPI FHIR unit tests, but in my case, the uuid seems to be fine. But maybe only one uuid is replaced with the id of the created practitioner.
I'm also not sure, whether this is the correct way for what I want to achieve.
I also tried to add the practioner only once and then add the second role to function.coding. But the resulting entry looks for me kinda strange:
performer": [
{
"function": {
"coding": [
{
"system": "http://somewhere/performer-role",
"code": "88888888"
},
{
"system": "http://somewhere/performer-role",
"code": "99999999",
"display": "Role-2"
}
],
"text": "Role-1"
},
"actor": {
"reference": "Practitioner/2925"
}
},
I'm fairly new to Fhir. Does anybody knows what's wrong here ?
And, what's the recommended practice, to have one performer/actor in to different roles ?
Thanks in advance
P.S. I'm using HAPI FHIR 4.0
Multiple coding repetitions would be used to convey translations - so you're saying that 888888888 and 99999999 are two different codes that represent the same role. If you want to indicate that the same Practitioner had two different roles, then you need to have two different performer repetitions. E.g.
perfomer: [
{
"function": {
"coding": [ {
"system": "http://somewhere/performer-role",
"code": "88888888"
}]},
"actor": {
"reference": "Practitioner/2925"
}
}, {
"function": {
"coding": [ {
"system": "http://somewhere/performer-role",
"code": "99999999"
}]},
"actor": {
"reference": "Practitioner/2925"
}
}
]

Is returning only IDs for a JSON API collection allowed?

So let's say I have a resources called articles. These have a numeric id and you can access them under something such as:
GET /articles/1 for a specific article.
And let's say that returns something like:
{
"data": {
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON:API paints my bikeshed!",
"body": "A bunch of text here"
}
}
}
Now my question is how to handle a request to GET /articles. I.e. how to deal with the request to the collection.
You see, accessing the body of the article is slow and painful. The last thing I want this REST API to do is actually try to get all that information. Yet as far as I can tell the JSON API schema seems to assume that you can always return full resources.
Is there any "allowed" way to return just the IDs (or partial attributes, like "title") under JSON API while actively not providing the ability to get the full resource?
Something like:
GET /articles returning:
{
"data": [
{
"type": "article_snubs",
"id": 1,
"attributes": {
"title": "JSON:API paints my bikeshed!"
}
}, {
"type": "article_snubs",
"id": 2,
"attributes": {
"title": "Some second thing here"
}
}
]
}
Maybe with links to the full articles?
Basically, is this at all possible while following JSON API or a REST standard? Because there is absolutely no way that GET /articles is ever going to be returning full resources due to the associate cost of getting the data, which I do not think is a rare situation to be in.
As far as I understand the JSON API specification there is no requirement that an API must return all fields (attributes and relationships) of a resource by default. The only MUST statement regarding fields inclusion that I'm aware of is related to Sparse Fieldsets (fields query param):
Sparse Fieldsets
[...]
If a client requests a restricted set of fields for a given resource type, an endpoint MUST NOT include additional fields in resource objects of that type in its response.
https://jsonapi.org/format/#fetching-sparse-fieldsets
Even so this is not forbidden by spec I would not recommend that approach. Returning only a subset of fields makes consuming your API much harder as you have to consult the documentation in order to get a list of all supported fields. It's much more within the meaning of the spec to let the client decide which information (and related resources) should be included.
The "attributes" object of a JSON-API doc does not need to be a complete representation:
attributes: an attributes object representing some of the resource’s data.
You can provide a "self" link to get the full representation, or perhaps even a "body" link to get just the body:
links: a links object containing links related to the resource.
E.g.
{
"data": [
{
"type": "articles_snubs",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!"
},
"links": {
"self": "/articles/1",
"body": "/articles/1/body"
}
},
{
"type": "article_snubs",
"id": "2",
"attributes": {
"title": "Some second thing here"
},
"links": {
"self": "/articles/2",
"body": "/articles/2/body"
}
}
]
}

FHIR Extension - ContactPoint Extension

I'm trying to figure out how to add a phone extension to a ContactPoint within a FHIR message. I found this extension, https://hl7.org/fhir/2018Jan/extension-contactpoint-extension.html, but I'm unsure of how to code it exactly.
Would it be like this?
"telecom": [
{
"system": "phone",
"value": "(03) 5555 6473",
"use": "work",
"rank": 1,
"extension": [{"url":"http://hl7.org/fhir/StructureDefinition/contactpoint-extension",
"valueString":123}],
},
{
"system": "phone",
"value": "(03) 3410 5613",
"use": "mobile",
"rank": 2
}
]
Or something like this?
"telecom": {
"system": "phone",
"value": "604-101-1001",
"use": "work"
},
"_telecom": {
"url": "http://hl7.org/fhir/StructureDefinition/contactpoint-extension",
"valueString": "999"
}
Thank you in advance.
Generally, the expectation is that the extension will be included as part of the value. Extension is really intended for when you want to break the parts of a phone number into its constituent pieces for easy validation, automated dialing, consistent rendering, etc. (And even then, best practice is to still send the value element with a rendered version of everything. That said, that looks mostly correct. The '123' needs to be surrounded by quotes.

REST API response describing request and returned data

Before implementation I'm considering the structure of JSON response that produces REST API I'm working on. I went through many Q/A here on SO, read many articles, recommendations and pseudo standards.
Requirements
Inform client about some useful meta information - HTTP status code etc.
Paging and filtering information - offset, limit and filtering queries (API client is aware of all parameters that influenced the result).
Information about data collection - total records count in collection and number of returned items. API client is then able create pagination.
Links to previous and next pages (just considering, not sure if this is useable for API clients but many REST APIs links section use - e.g. PayPal)
Response
This is my first draft of structure of returning search results data:
{
"meta": {
"status_code": 200,
"success": true,
"server_time": "2017-06-29T15:24:40+0200"
},
"request": {
"offset": 5,
"limit": 5,
"query": [
"foo",
"bar"
]
},
"response": {
"count": 5,
"total_count": 754,
"data": [
{
"id": "88b60cc6-70bc-4b1a-8f26-c919355d47d3",
"name": "Name of entity 1"
},
{
"id": "2f4ccda5-11bc-4ef7-b663-30c506f5118c",
"name": "Name of entity 2"
},
{
"id": "1333f2fe-a958-474e-9a82-8b343fda3aff",
"name": "Name of entity 3"
},
{
"id": "f5187143-f3b8-412b-a416-1e3a5830baee",
"name": "Name of entity 4"
},
{
"id": "2dd17750-bbdf-460a-abec-1f74e1170726",
"name": "Name of entity 5"
}
]
},
"links": {
"previous": {
"href": "http:\/\/api.example.com\/envelopes?offset=0&limit=5",
"rel": "previous",
"method": "GET"
},
"self": {
"href": "http:\/\/api.example.com\/envelopes?offset=5&limit=5",
"rel": "self",
"method": "GET"
},
"next": {
"href": "http:\/\/api.example.com\/envelopes?offset=10&limit=5",
"rel": "next",
"method": "GET"
}
}
}
I would like to avoid an "opinion question" to discuss the most appropriate JSON structure. I saw many opinions about envelopes in response, some services / standards it recommends, some not.
Questions:
Is it good idea to return the result in this structure?
Do you see some problems with this structure? What to do better?
Do you see some missing values that are needed for API client? Some unnecessary values?
Is needed return URL to self?
Opinion questions are hard, but I'll try.
First of all, your question should not be addressed to community, but to client itself. Nothing clears assumptions about missing/necessary values better than such feedback.
The structure itself is good enough, at least as a draft. When designing responses you need to remember that you are basically locking yourself up, since clients don't like fundamental changes in API. Only lot of incremental "please add just one more field here". You are doing good job in thinking far enough, about meta fields, pagination and separating actual response, but don't think you can predict everything. You won't. Maybe look for something like HAL or JSON Collection. At least as an inspiration.
In the end design of API is evolutionary and mostly client driven process. So talk to your client.

Freebase MQL to list out all commons types for a given word?

I'm trying to figure out how to write a MQL query to get a list of all the types associated to a given word.
For example I tried:
{
"id":null,
"name":null,
"name~=": "SOME_WORD",
"type":"/type/type",
"domain": {
"id": null,
"/freebase/domain_profile/category": {
"id": "/category/commons"
}
}
}​
I found this to list out all the Commons types or categories but haven't yet figured out how to narrow it down for a given input.
[{
"id": null,
"name": null,
"type": "/freebase/domain_profile",
"category": {
"id": "/category/commons"
}
}]​
There are a couple of different ways to do this with different tradeoffs for each.
Use the Search API with a query like this
https://www.googleapis.com/freebase/v1/search?indent=true&filter=%28all%20name{full}:%22uss%20constitution%22%29
You'll get back JSON results which look like this:
{
"status": "200 OK",
"result": [
{
"mid": "/m/07y14",
"name": "USS Constitution",
"notable": {
"name": "Ship",
"id": "/boats/ship"
},
"lang": "en",
"score": 1401.410400
},
...
You can make the matching more liberal by switching the "{full}" to "{phrase}" which will give you a substring match instead of an exact match.
Caveats:
- You'll only get a single "notable type" and it's fixed by Freebase's (unknown) algorithm
- I don't think there's a way to get both USS Constitution & U.S.S. Constitution results
- You can get a list of all types by adding &mql_output={"type":[]}, but then you lose the "notable" type. I don't think there's a way to get both in a single call.
Use MQL
This query returns the basic information that you want:
[{
"name~=":"uss constitution",
"type":[],
"/common/topic/notable_types" : []
}]​
Caveats:
It won't find "uss constitution" which is an alias rather than the primary name (there's a recipe in the MQL cookbook for that though)
It won't find "u.s.s. constitution"
The "notable_types" API is an MQL extension and MQL extensions aren't supported in the new Freebase API, only the legacy deprecated API
You're tied to whatever (unknown) algorithm Freebase used to compute "notability"
Depending on what you are trying to accomplish, you might need something more sophisticated than this (as well as a deeper understanding of what's in Freebase), but this should get you going with the basics.
Did you try:
[{
"name": "David Bowie",
"type": []
}]