Paul
--
You received this message because you are subscribed to the Google Groups "SMART on FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smart-on-fhi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Bob,
We haven't gotten around to adding write functionality in our client library for a couple of reasons:
1. We have been cautious to add features that we don't think will be widely supported on the EHR server side.
2. We have been considering whether to swap out our client library for fhir.js around the DSTU2 time frame.
That said, hearing from the user community is the most important way that we make informed decisions! And of course we are always happy to accept code contributions :-)
Josh
The fhir.js client doesn't currently handle the details of obtaining authorization from a SMART server. SMART's client has this built in. Ideally We'd extract two components, one for doing the authorization and one for making API calls. Then fhir.js could be used as an option for the latter.
-Josh
FHIR.oauth2.ready(function (smart) {
$scope.token = smart.server.auth.token; // This is Angular-code. If pure Javascript, you could use a normal var instead of $scope
...further down....$scope.saveData = function (pId, weight) { $scope.message = 'Saving data'; console.log("inside getObservations:"+$scope.smart); var json = { "resourceType": "Observation", "text": { "status": "generated", "div": '<div xmlns=\"http://www.w3.org/1999/xhtml\">' + weight + ' kg</div>' }, "code": { "coding": [ { "system": "http://loinc.org", "code": "3141-9", "display": "weight" } ] }, "appliesDateTime":new Date(), "valueQuantity": { "value": weight, "units": "kg", "system": "http://unitsofmeasure.org/", "code": "kg" }, "reliability": "ok", "subject": {"reference": "Patient/" + pId} }; $.ajax({ type: "POST", url: FHIR_URL + '/Observation', headers: { "Authorization":"Bearer "+$scope.token }, data: JSON.stringify(json), success: function (data) { $scope.$apply(function () { $scope.message = 'Data sent'; //$scope.search(); $scope.getObservations(); }); }, datatype: 'json', contentType: 'application/json+fhir;charset=utf-8' }); };
patient.api.update()//getting the FHIR server url
var url = smart.server.serviceUrl;
//getting the token
var token = smart.server.auth.token;
//function to be called as postToFHIR(paitentID, jsonFhirResource)
var postToFHIR = function (patientID, resJson) {
resJson.subject = {
"reference": "Patient/" + patientID
},
$.ajax({
type: "POST",
url: url + '/' + resJson.resourceType,
headers: {
"Authorization": "Bearer " + token
},
data: JSON.stringify(resJson),
success: function (data) {
Console.log('the Resource was POSTed Successfully');
var xmlString = (new XMLSerializer()).serializeToString(data);
//Parsing the response XML for the newly assigned resource.id, meta.versionid and meta.lastUpdated
var xmlDoc = $.parseXML(xmlString),
$xml = $(xmlDoc),
$idValue = $xml.find("id").attr('value'),
$versionIdValue = $xml.find("versionId").attr('value'),
$lastUpdatedValue = $xml.find("lastUpdated ").attr('value');
//the following can be used to log to the console some of the retrieved response data
//console.log($idValue);
//console.log($versionIdValue);
//console.log($lastUpdatedValue);
//adding the new information to the input resource and returning it
resJson.id = $idValue;
resJson.meta = {
versionId: $versionIdValue,
lastUpdated: $lastUpdatedValue
};
return resJson;
},
datatype: 'json',
contentType: 'application/json+fhir;charset=utf-8'
});
};...
Hi Adrian,
To briefly answer your question: SMART on FHIR gives app developers they tools they need to build health apps that integrate with EHR data. This includes an authorization process, single sign-on, data profiles that lock down vocabularies, and (optionally) some UX integration glue including context sharing so apps can be embedded within an EHR.
Please check out our developer docs as described in this thread for detail about how to read and write days in our sandbox environment, which illustrates use of the API.
Best,
Josh