💫Socket.IO
Retrieve observation from Kligo synchronously using Socket.IO client.
Kligo embeds a Socket.IO server. It can accessed on port 63336 on the user's computer. You can register a client to this server in order to receive the observations when they are created.
Here is an example for listening to data points using a javascript Socket.IO client:
var socket = io('http://localhost:63336');
socket.on('fhir', function (data) {
console.log(data);
});
A working version of this example can be found here.
Emitting events
There are one type of event emitted from this socket:
'fhir'
: this event is emitted every time an observation is created in Kligo. There are two types of Observation that can be received : simple and multiple. This dpends on the the measurement that gets the device.
Simple FHIR Observation
The type of observation you can get when you use a simple device like weight scale or thermometer.
{
"category": [{
"coding": [{
"code": "vital-signs",
"display": "Vital Signs",
"system": "http://hl7.org/fhir/observation-category"
}],
"text": "Vital Signs"
}],
"code": {
"coding": [{
"code": "",
"display": "body_weight",
"system": "http://loinc.org"
}],
"text": "Poids"
},
"context": {
"reference": "ac8f39cc-f5eb-450e-a354..."
},
"device": {
"display": "weight_scale",
"reference": "5da0709..."
},
"resourceType": "Observation",
"effectiveDateTime": "2019-12-09T14:19:44Z",
"status": "final",
"valueQuantity": {
"code": "kg"
"system": "http://unitsofmeasure.org",
"unit": "kg",
"value": 50.4
}
}
Multiple FHIR Observation
When you are using a pulse oximeter or a blood pressure monitor, you get two or three measurement. We decide to gather the observations and put them in the component section.
{
"category": [{
"coding": [{
"code": "vital-signs",
"display": "Vital Signs",
"system": "http://hl7.org/fhir/observation-category"
}],
"text": "Vital Signs"
}],
"code": {
"coding": [{
"code": "",
"display": "oxygen_saturation",
"system": "http://loinc.org"
}],
"text": "Saturation pulsée"
},
"component": [{
"code": {
"coding": [{
"code": 131329,
"display": "0",
"system": "http://www.pchalliance.org/"
}]
},
"valueQuantity": {
"type": "0",
"unit": "bpm",
"value": 86
}
}, {
"code": {
"coding": [{
"code": 131329,
"display": "1",
"system": "http://www.pchalliance.org/"
}]
},
"valueQuantity": {
"type": "0",
"unit": "%",
"value": 99
}
}],
"context": {
"reference": "ac8f39cc-f5eb-450e-a354..."
},
"device": {
"display": "pulse_oxymeter",
"reference": "5da0709..."
},
"resourceType": "Observation",
"effectiveDateTime": "2019-12-09T14:19:44Z",
"status": "final"
}
Receiving events
The socket is able to receive events from a client.
There are two types of events that the socket can receive :
'ekuoreStartRecording'
: this event triggers the recording. Kligo expects you to pass the SSID of the device when firing this event.'ekuoreStopRecording'
: this event stopping the recording
here is an example for starting the recording from the client.
var socket = io('http://localhost:63336');
<button onClick="socket.emit('ekuoreStartRecording', {ssid:'ekuorePro_xxxxx'})">Start record</button>
// Emit Ekuore
const emit = (emitMessage) => {
socket.emit(emitMessage)
}
See an example code here.
Last updated
Was this helpful?