SMART on FHIR JavaScript API does not return JSON with out additional call to fetchAll for Observation in Cerner tutorial - smart-on-fhir

I'm working on creating a SMART on FHIR application based on the Cerner tutorial at https://engineering.cerner.com/smart-on-fhir-tutorial/.
The following is called in example-smart-app.js
var patient = smart.patient;
var pt = patient.read();
var obv = smart.patient.api.fetchAll({
type: 'Observation',
query: {
code: {
$or: ['http://loinc.org|8302-2', 'http://loinc.org|8462-4',
'http://loinc.org|8480-6', 'http://loinc.org|2085-9',
'http://loinc.org|2089-1', 'http://loinc.org|55284-4']
}
}
});
I've modified slightly to the following:
<script>
fhirOnReady = function(smart) {
patient = smart.patient;
pt = patient.read();
var obv = smart.patient.api.fetchAll({
type: 'Observation',
query: {
code: {
$or: [
'http://loinc.org|8302-2',
'http://loinc.org|8462-4',
'http://loinc.org|8480-6',
'http://loinc.org|2085-9',
'http://loinc.org|2089-1',
'http://loinc.org|55284-4'
]
}
}
});
var populatePatientData = function(patient) {
$("#fname").html(patient.name[0].given);
$("#lname").html(patient.name[0].family);
$("#gender").html(patient.gender);
$("#dob").html(patient.birthDate);
}
$.when(pt, obv).fail(fhirOnError);
$.when(pt, obv).done(
function(patient, obv) {
populatePatientData(patient);
$("#patientJson").html(JSON.stringify(patient,undefined,2));
$("#patientSuccessMsg").html("<h1>Congratulations, you've also successfully loaded a patient using SMART on FHIR</h1>");
}
);
};
fhirOnError = function() {
$("#patientJson").html("An error occurred.\nThis is expected if you are looking at this page from a browser.");
};
FHIR.oauth2.ready(fhirOnReady, fhirOnError);
</script>
If I run the above using the SMART App Launcher at https://launch.smarthealthit.org/ everything seems to work as expected.
However, if I remove the call to smart.patient.api.fetchAll for the observations the patient JSON string is empty.
What is the correct way to get the entire patient resource using the SMART on FHIR JavaScript Library described at http://docs.smarthealthit.org/client-js/?
---EDIT ----------------------------------
If I try to implement using the code in the documentation at http://docs.smarthealthit.org/client-js/#smart-api I get the error shown below.
Code
<!-- index.html -->
<script src="./node_module/fhirclient/build/fhir-client.js"></script>
<script>
FHIR.oauth2.ready()
.then(client => client.request("Patient"))
.then(console.log)
.catch(console.error);
</script>
Error
Libraries are taken directly from the Cerner tutorial.

SMART apps usually have a "patient" in context that is already part of the data passed over to the system from which you are trying to elicit information. In this case you are trying to hit the Cerner FHIR server to get the observations linked to that Patient. Two things are possible at this point:
The Server may not have the Patient resource, which is why it is using the Id of the patient to fetch all observations
Check your smart SCOPEs, you may not be allowed to read Patient records in it's entirety.
Usually the FHIR endpoint can be deciphered using Fiddler following the launch sequence. As per the SMART exchange the CapabilityStatement is queried for the authorization and Token endpoints. If you are able to see the server then you can tack on the /Patient/id to get the resource but this means you have to have a valid token and the appropriate scope statements in place.

Related

User profile enrichment in AZUREAD

I have a question regarding user profile enrichment.
How can I enrich a user profile with extra information such as id-number, personal telephone, and any other information available in my office356 platform?
I have an Angular SPA in which the user must log in and subsequently do some actions, but I do require to get the info mentioned before in order to do so.
I have code like the showed below. I've searched into Azure's documentation but found nothing yet.
const GRAPH_ENDPOINT = 'https://graph.microsoft.com/v1.0/me';
getProfile() {
this.http.get(GRAPH_ENDPOINT)
.subscribe(profile => {
this.profile = profile;
console.log(profile)
});
}
getProfilePhoto() {
this.http.get(GRAPH_ENDPOINT+'/photo/$value').subscribe(
photo => {
this.photo = photo;
console.log(this.photo);
});
}
Any help or tip to help this poor fellow programmer?
Thanks!
Please check this if query for id or mobile number etc can be worked for the similar code, if am not understating wrong:
As 'https://graph.microsoft.com/v1.0/me gives complete profile details just like code provided
const GRAPH_ENDPOINT = 'https://graph.microsoft.com/v1.0/me';
getProfile() {
this.http.get(GRAPH_ENDPOINT)
.subscribe(profile => {
this.profile = profile;
console.log(profile)
});
}
same in microsoft graph api :
Just like that we can query for id, mobilephone number, and other details
By filtering using select query
See References for more query parameters: Get a user-Microsoft Graph v1.0 | Microsoft Docs -REFERENCE , Use query parameters
So to get mobilenumber in graph https://graph.microsoft.com/v1.0/me?$select=mobilePhone is used, same can be modified for code some thing like below
Example:
getMobileNumber() {
this.http.get(GRAPH_ENDPOINT+'?$select=mobilePhone ').subscribe(
mobilePhone => {
this. mobilePhone = mobilePhone;
console.log( this. mobilePhone);
});
}
Just like from graph
So to get id in graph https://graph.microsoft.com/v1.0/me?$select=id ,modify your code which uses this request.
Example:
getId(){
this.http.get(GRAPH_ENDPOINT+'?$select=id ').subscribe(
Id=> {
this. Id= Id;
console.log( this. Id);
});
}
You can also make use of graph client
References:
Build Angular single-page apps with Microsoft Graph - Microsoft
Graph | Microsoft Docs
azure - Obtaining Profile Photo from MS Graph API to Angular app -
Stack Overflow from >> So reference
create-requests-typescript

Create custom API with strapi

I've a content type called continent. Which we the name suggests contains all the information about each continents. Strapi already created API endpoints for me like
continents/:id
But I want to search the continent by it's name since the general user won't be able to search by id
I've created the endpoint
continents/:continent_name
I've also created custom controller following documentation
const { sanitizeEntity } =
requiree('strapi-utils');
module.exports = {
async findOne(ctx) {
const { continent_name } = ctx.params;
const entity = await
strapi.services.continent.findOne({
continent_name
});
return sanitizeEntity(entity, { model:
continents });
And also exposed the API to public
But doesn't seem to anything
Just returns error
How am I supposed to do it
For your use case, you don't need to extend the model controller. You can just pass the continent name as a query param . For example, your url could be something like base_url/continent?continent_name=Asia.
For the code mentioned in the question, there is an issue, the model name should be strapi.models.continent and not continents. Also in the first line requiree('strapi-utils'), you have an extra e in the require. I am assuming that was just a typo.

Set property in gremlin-node.js/gremlin-server not working

I want to create a graph within gremlin-server from a node.js backend with the javascript driver of gremlin. As I added two properties, one id and one username, the id is working, the username is not stored. Here is the code:
const gremlin = require('gremlin');
const traversal = gremlin.process.AnonymousTraversalSource.traversal;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const g = traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
const { t: { id } } = gremlin.process;
const { cardinality: { single} } = gremlin.process;
async function createUser(userid,username) {
const vertex = await
g.addV('User')
.property(id,userid)
.property(single,'username',username)
.iterate();
return vertex;
}
await createUser(1001,"testuser")
The output is (when I search the node with g.V(1001).listAll();) The properties are always undefined.
[Vertex { id: 1001, label: 'User', properties: undefined }]
The gremlin server was loaded/run with docker with the following commands:
docker pull tinkerpop/gremlin-server
docker run -d -p 8182:8182 --name gremlin tinkerpop/gremlin-server
The gremlin-driver in node.js has a the version: "gremlin": "^3.4.10",
I've tried with and without the cardinality single above, added more properties, but non is working. The internet searches showed some gremlin-console(groovy) working examples with the .property step, but no hint for the combination node.js-driver of gremlin and the gremlin-server.
I imagine your code is working fine and that the properties are present. The issue is that graph elements returned from queries are "references" only - meaning, they only include id and label and no properties. You should convert your results to use generic containers like Map using a step like elementMap(). You can find more discussion on this in the documentation in various places, but perhaps start with this and if you are interested more in why this is the way it is and what challenges are involved in changing it, please see this.

Can't access unique identifier for Bixby using code from docs

To access a unique identifier for Bixby, I'm trying to access the contactId field within the contact library (which is also viv.self I think?). I tried using the code snippet found in the docs here, but I'm getting some errors.
Code Snippet (Source)
text (Name) {
extends (contact.StructuredName)
}
Errors
ERROR: invalid capsule alias contact
ERROR: unknown super-type: contact.contactId
I would ultimately like to do something like this
integer (Identifier) {
extends (contact.ContactId)
}
Would appreciate any help on accessing this data!
I ended up finding another way to get a device identifier from these docs. There's also a sample capsule here.
In your corresponding JavaScript file, access the $vivContext.locale parameter to return the locale information.
module.exports.function = function accessVivContext (dummyInput, $vivContext) {
var result = "Testing Access vivContext..."
// See docs for all the properties of $vivContext
result = $vivContext.userId
return result
}
You would then need to configure your endpoints for this action like below, including making sure that you set up the proper accepted-inputs for your endpoint:
action-endpoint (AccessVivContext) {
accepted-inputs (dummyInput, $vivContext)
local-endpoint ("AccessVivContext.js")
}

Subclass QueryReadStore or ItemFileWriteStore to include write api and server side paging and sorting.

I am using Struts 2 and want to include an editable server side paging and sorting grid.
I need to sublclass the QueryReadStore to implement the write and notification APIs. I do not want to inlcude server side REST services so i do not want to use JsonRest store. Any idea how this can be done.? What methods do i have to override and exactly how. I have gone through many examples but i am not getting how this can be done exactly.
Also is it possible to just extend the ItemFileWriteStore and just override its methods to include server side pagination? If so then which methods do i need to override. Can i get an example about how this can be done?
Answer is ofc yes :)
But do you really need to subclass ItemFileWriteStore, does it not fit your needs? A short explaination of the .save() follows.
Clientside does modify / new / delete in the store and in turn those items are marked as dirty. While having dirty items, the store will keep references to those in a has, like so:
store._pending = { _deletedItems: [], _modifiedItems: [], _newItems: [] };
On call save() each of these should be looped, sending requests to server BUT, this does not happen if neither _saveEverything or _saveCustom is defined. WriteStore simply resets its client-side revert feature and saves in client-memory.
See source search "save: function"
Here is my implementation of a simple writeAPI, must be modified to use without its inbuilt validation:
OoCmS._storeAPI
In short, follow this boiler, given that you would have a CRUD pattern on server:
new ItemFileWriteStore( {
url: 'path/to/c**R**ud',
_saveCustom: function() {
for(var i in this._pending._newItems) if(this._pending._deletedItems.hasOwnProperty(i)) {
item = this._getItemByIdentity(i);
dxhr.post({ url: 'path/to/**C**rud', contents: { id:i }});
}
for(i in this._pending._modifiedItems) if(this._pending._deletedItems.hasOwnProperty(i)) {
item = this._getItemByIdentity(i);
dxhr.post({ url: 'path/to/cr**U**d', contents: { id:i }});
}
for(i in this._pending._deletedItems) if(this._pending._deletedItems.hasOwnProperty(i)) {
item = this._getItemByIdentity(i);
dxhr.post({ url: 'path/to/cru**D**', contents: { id:i }});
}
});
Now; as for paging, ItemFileWriteStore has the pagination in it from its superclass mixins.. You just need to call it with two setups, one being directly on store meaning server should only return a subset - or on a model with query capeabilities where server returns a full set.
var pageSize = 5, // lets say 5 items pr request
currentPage = 2; // note, starting on second page (with *one* being offset)
store.fetch({
onComplete: function(itemsReceived) { },
query: { foo: 'bar*' }, // optional filtering, server gets json urlencoded
count: pageSize, // server gets &count=pageSize
start: currentPage*pageSize-pageSize // server gets &start=offsetCalculation
});
quod erat demonstrandum

Resources