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

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")
}

Related

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

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.

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.

Trying to get data from another table, snapshot is null

I'm trying to get data from another table using a cloud function and it's telling me the snapshot is null.
I have a Firebase database that I have some IoT devices connected to. They update their respective tables(I hope that's the right word) in the database (device_001, device_002, device_003) and send on to the external API I am using, that works which are great.
Now I need to get the devices to look up where they are, I have set up another table which each contain their id, location, and timestamp.
Lookup table structure:
devices
device_001
id: ...
location: ...
timestamp: ...
Code:
exports.devices_Listener = functions.database.ref('/devices/{deviceId}/{entryId}').onWrite(snapshot => {
object = snapshot.after.val();
getCurrentLocation();
process();
return null
})
function getCurrentLocation() { functions.database.ref('locations/{deviceId}').limitToLast(1).once('value').then(function(snapshot) {
var o = snapshot.val();
})
}
I expected this to get the snapshot and allow me to get the location so I can store it with the processed data (that's all working so not included here).
When I try to get the location field I get can't read the property 'location'
and when I try to just log the snapshot to the console it tells me it is null.
I can't see what I've done wrong here but I'm sure it's small and simple.
Thanks for taking the time to read this nonsensical mess.

laravel pagination Method links does not exist

I am building a dynamic query using eloquent based on user inputs.
$query = \App\Model::query();
if($this == request('that')){
$query->where(...); // building dynamic query based on user inputs
}
and finally user can type number of records shown per page in an html input field named count or checking a checkbox input type named all and following code completes dynamic query in back-end:
if (request('all')) {
$result = $query->get();
}else {
$result = $query->paginate(request('count'));
}
Also in front-end I have following code to show pagination links:
{{$result->links()}}
The problem is when user chooses to show all records we face following error:
Method links does not exist.
links method is not callable when we retrieve objects via get() method. What is the best practice in order not to face this error?
It's because ->get() method return collection instead of paginator model Illuminate\Pagination\LengthAwarePaginator. So I can recomment you send some addition variable from your controller which indicate if you need execute $result->links().
Controller:
return view('yourView', [showPagination => is_null(request('all'))]);
View:
#if($showPagination)
{{$result->links()}}
#endif

MitreID Connect : Retrieve LDAP operational attributes

I'm working on the LDAP overlay of MitreID Connect project and everthing is working greatly:
Authentication
Retrieving attributes from LDAP Directory
The problem I have now, is how to retrieve operational attributes in LDAP directory.
I'm not good with Spring development, but I found some documentation which treat this sub, but I'm not able to make it work.
Here's what I found:
Retrieving operational attributes
Ldap Server maintains many operational attributes internally. Example entryUUID is an operational attribute assigns the Universally Unique Identifier (UUID) to the entry. The createTimestamp, modifyTimestamp are also operational attributes assigned to the entry on create or update. These operational attributes does not belong to an object class and hence they were not returned as part of your search or lookup. You need to explicitly request them by their name in your search or build the custom AttributeMapper implementation with matching attribute names.
Now let’s try to retrieve the entryUUID, first you need to build the search controls like this,
SearchControls controls = new SearchControls();
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
controls.setReturningObjFlag(false);
controls.setReturningAttributes(new String[]{"entryUUID"});
Once you have search control then it’s simply calling search method just like retrieving any other attributes.
ldapTemplate.search("baseName", "(objectclass=person)", controls, new AttributesMapper() {
public Object mapFromAttributes(Attributes attrs) throws NamingException {
Attribute attrUuid = attrs.get("entryUUID");
return attrUuid;
}});
Here is another way to do the same using ContextMapper,
ldapTemplate.search("baseName","(objectclass=person)", 1, new String[]{"entryUUID"},
new ContextMapper(){
public Object mapFromContext(Object ctx) {
DirContextAdapter context = (DirContextAdapter)ctx;
return context.getStringAttributes("entryUUID");
}
});
Let’s add the filter based off of operational attributes like below,
OrFilter orFilter = new OrFilter();
orFilter.or(new GreaterThanOrEqualsFilter("createTimestamp", "YYYYMMDDHHMMSSZ"));
orFilter.or(new LessThanOrEqualsFilter("modifyTimestamp", "YYYYMMDDHHMMSSZ"));
Now call the above search with the filter
ldapTemplate.search("baseName", orFilter.encode(), controls, new AttributesMapper() {
public Object mapFromAttributes(Attributes attrs) throws NamingException {
Attribute attrUuid = attrs.get("entryUUID");
return attrUuid;
}});

Resources