I'm new to Smart on FHIR and Creating one demo application for training purpose using fhirclient.js. I need to get some specific vital information of patient like Temp, Weight and so for specified period of date (last 3 months).
smart.patient.api.search({
type: "Observation",
query: {
$sort: [
["date",
"asc"]
],
code: {
$or: ['http://loinc.org|8462-4',
'http://loinc.org|8480-6',
'http://loinc.org|55284-4',
'http://loinc.org|8310-5',
'http://loinc.org|3141-9',
'http://loinc.org|718-7']
}
}
}).then(results => {
Let me know how to include date filter in this search api?
This is just a mongo-like syntax sugar provided by fhir.js
. It acts as an URL builder and the result FHIR URL might look like:
Latest versions of fhirclient
does not come with fhir.js
included. Nowadays we have things like URLSearchParams
to help us achieve similar results. Using an up to date version of the fhirclient
library, the code you are looking for could look like this:
const client = new FHIR.client("https://r3.smarthealthit.org");
const query = new URLSearchParams();
query.set("_sort", "date");
query.set("code", [
'http://loinc.org|8462-4',
'http://loinc.org|8480-6',
'http://loinc.org|55284-4',
'http://loinc.org|8310-5',
'http://loinc.org|3141-9',
'http://loinc.org|718-7'
].join(","));
query.set("date", "ge2013-03-14"); // after or equal to 2013-03-14
query.set("date", "le2019-03-14"); // before or equal to 2019-03-14
client.request("Observation?" + query).then(...)
Also see http://hl7.org/fhir/search.html#date for details about the date
parameter syntax.