fetching resources for a specific version - hl7-fhir

Is there a way to etxract the resources of a type for a specific version id.
e.g something like this
http://fhir-server/hapi-fhir-jpaserver/fhir/Organization?versionId>30
I can go to the database and execute the below query to get results but same way if exists using the REST query?
select RES_VER, RES_TYPE
from HFJ_RESOURCE
where RES_VER >= 10 and Res_type = 'Practitioner'

You cannot do this based on the versionId for the resources, since the versionId does not have to be an incremental number. It could be something like a GUID, only holding meaning for the server.
What you can do, is ask for the complete history for that resource type, and for example limit that based on the date. An example:
GET [base]/Observation/_history?_at=lt2020-10-26
See http://hl7.org/fhir/http.html#history for more information.

GET [base]/[type]/[id]/_history/[vid] {?_format=[mime-type]}
See http://hl7.org/fhir/http.html#vread

Related

Cursor vs. Start parameter in Scopus API

I am working on a project that uses Scopus API to get document names or journal names under different scenarios. I am using ScopusSearch API (https://dev.elsevier.com/documentation/ScopusSearchAPI.wadl) and SerialTitle API (https://dev.elsevier.com/documentation/SerialTitleAPI.wadl) for the purpose.
However, the total number of documents I am able to retrieve using these API's is very few. I want to increase the number of documents being fetched. Now, I've been through the documentation of these API's a several times but I am confused with the use of start parameter and the cursor parameter.
Take for example, ScopusSearch API, under its query params section:
start parameter
cursor parameter
Can someone please help me understand the difference between these two? And more specifically when to use the start and when to use the cursor parameter?
If you use pybliometrics, as your tag suggests, then you don't need to care about this.
The basic idea behind this pagination (that's what you're after) is:
Run a query with unlimited number of results with cursor set to "*"
Set start to 0 and get the first count results
Set start to start+count+1 and get the next count results
Repeat step 3 until all results are fetched

column "likes.id" must appear in the GROUP BY clause or be used in an aggregate function

So I am trying to add top posts functionality for my Sinatra project using postgresql with the following statement Like.group(:exercise_id).order('COUNT(exercise_id) DESC').each do |like|
But when I try this I get an error saying column "likes.id" must appear in the GROUP BY clause or be used in an aggregate function
And when I add this
Like.group(:exercise_id, :id).order('COUNT(exercise_id) DESC')
It gives me the whole table when all I want is to group by likes. Is there a workaround for this?
What the error is telling you, is that you're selecting for "likes.id", but there is no single likes.id that the database can give you.
This is because by default when you don't tell Rails what you need, Rails will select EVERYTHING.
Think, do you actually need "likes.id"? Looks to me that you're grouping by exercise_id so what you're trying to get is exercises and their like counts. (correct me if I'm wrong.) You don't actually need specific like id-s.
If that's so, we need to tell rails about our intention.
Like.group(:exercise_id).order('COUNT(exercise_id) DESC').select(:exercise_id)
If you also need the count itself, just add it to the select.
Something else you might want to try is just .count. It's pretty smart and will respect your grouping. See if this helps.
Like.group(:exercise_id).count

How to find the date and time the order was cancelled in Magento 1.9.x

Bit of a complex question for you..
I am exporting orders from Magento 1.9.4.0 using an extention from XTENTO.
It uses XSL to build 'profiles' to all me to cycle through orders programatically and export them in a format of my choice.
I have everything working aside from pulling the correct date the order was cancelled. I can see that in Magento this date appears to be in the table 'sales_flat_order_status_history'.
Looking at the table i can see the following:
sales_flat_order_status_history table
And the XSL I have been using is below..
XSL query
It IS finding a date; but it is finding the LAST update to the order and pulling the created_at value.
Does anyone know how I could find the FIRST timestamp where the order was in a cancelled state using the XSL notation?
The documentation for the XSL engine is available here, if helpful: https://support.xtento.com/wiki/Magento_Extensions:Magento_Order_Export_Module#2.29_Export_Fields
Many thanks
This seems to be hardcoded on your module files.
You could be able to change the query it is making to the database. I can't give complete guidance since I do not have the module files to look at.
Try opening the module folder in some code editor and search for something like:
Mage::getModel('sales/order_status_history')
You will then find where the code may reside and then change the query to filter for what you want.

Nhibernate Update timestamp

Is there a way to do
"UPDATE Item SET start_date = CURRENT_TIMESTAMP" ?
in Nhibernate without using hql/sql.
I am trying to avoid hql/sql because the rest of my code is in criteria. I want to do something like :
var item = session.get<Item>(id)
item.start_date = current_timestamp
There are two ways and sql is correct one.
Either you will
load all entities, change, update and commit, or
write sql query and let dbms handle most of the work
I am trying to avoid hql/sql because the rest of my code is in criteria
That is not a valid argument. Criteria is an API intended for relational search, and it does not support mass updates.
Different tasks, different APIs.
In this case, you can use either HQL or SQL, as the syntax is the same. I recommend the former, because you'll be using your entity/property names instead of table/column ones.

Cache and SqlCacheDependency (ASP.NET MVC)

We need to return subset of records and for that we use the following command:
using (SqlCommand command = new SqlCommand(
"SELECT ID, Name, Flag, IsDefault FROM (SELECT ROW_NUMBER() OVER (ORDER BY #OrderBy DESC) as Row, ID, Name, Flag, IsDefault FROM dbo.Languages) results WHERE Row BETWEEN ((#Page - 1) * #ItemsPerPage + 1) AND (#Page * #ItemsPerPage)",
connection))
I set a SqlCacheDependency declared like this:
SqlCacheDependency cacheDependency = new SqlCacheDependency(command);
But immediately after I run the command.ExecuteReader() instruction, the hasChanged base property of the SqlCacheDependency object becomes true although I did not change the result of the query in any way! And, because of this, the result of this query is not kept in cache.
HttpRuntime.Cache.Insert( cacheKey, list, cacheDependency, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(AppConfiguration.CacheExpiration.VeryLowActivity));
Is it because the command has 2 SELECT statements? Is it ROW_NUMBER()? If yes, is there any other way to paginate results?
Please help! After too many hours, a little will be greatly appreciated! Thank you
Running into the same issue and finding the same answers online without any help, I was reasearching the xml invalid subsicription response from profiler.
I found an example on msdn support site that had a slightly different order of code. When I tried it I realized the problem - Don't open your connection object until after you've created the command object and the cache dependency object. Here is the order you must follow and all will be good:
Be sure to enable notifications (SqlCahceDependencyAdmin) and run SqlDependency.Start first
Create the connection object
Create the command object and assign command text, type, and connection object (any combination of constructors, setting properties, or using CreateCommand).
Create the sql cache dependency object
Open the connection object
Execute the query
Add item to cache using dependency.
If you follow this order, and follow all other requirements on your select statement, don't have any permissions issues, this will work!
I believe the issue has to do with how the .NET framework manages the connection, specifically what settings are set. I tried overriding this in my sql command test but it never worked. This is only a guess - what I do know is changing the order immediately solved the issue.
I was able to piece it together from the following to msdn posts.
This post was one of the more common causes of the invalid subscription, and shows how the .Net client sets the properties that are in contrast to what notification requires.
https://social.msdn.microsoft.com/Forums/en-US/cf3853f3-0ea1-41b9-987e-9922e5766066/changing-default-set-options-forced-by-net?forum=adodotnetdataproviders
Then this post was from a user who, like me, had reduced his code to the simplest format. My original code pattern was similar to his.
https://social.technet.microsoft.com/Forums/windows/en-US/5a29d49b-8c2c-4fe8-b8de-d632a3f60f68/subscriptions-always-invalid-usual-suspects-checked-no-joy?forum=sqlservicebroker
Then I found this post, also a very simple reduction of the problem, only his was a simple issue - needing 2 part name for tables. In his case the suggestion resolved the issue. After looking at his code I noticed the main difference was waiting to open the connection object until AFTER the command object AND the dependency object were created. My only assumption is under the hood (I have not yet started reflector to check so only an assumption) the Connection object is opened differently, or order of events and command happen differently, because of this association.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/bc9ca094-a989-4403-82c6-7f608ed462ce/sql-server-not-creating-subscription-for-simple-select-query-when-using-sqlcachedependency?forum=sqlservicebroker
I hope this helps someone else in a similar issue.
Just a guess, but could it be because your SELECT statement doesn't have an ORDER BY clause?
If you don't specify an explicit ordering then it's possible for the query to return the results in any order each time it is run. Maybe this is causing the SqlCacheDependency object to think that the results have changed.
Try adding an ORDER BY clause:
SELECT ID, Name, Flag, IsDefault
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY #OrderBy DESC) AS Row,
ID, Name, Flag, IsDefault
FROM dbo.Languages
) AS results
WHERE Row BETWEEN ((#Page - 1) * #ItemsPerPage + 1) AND (#Page * #ItemsPerPage)
ORDER BY Row
i'm no expert on SqlCacheDependency, in fact, i found this question whilst looking for answers to my own issues with it! However, i believe the reason your SqlCacheDependency is not working is because your SQL contains a nested sub query.
Take a look at the documentation which lists what you can/can not use in your SQL: Creating a Query for Notification
"....The statement must not contain subqueries, outer joins, or self-joins....."
I also found some invaluable troubleshooting info from a guy at Redgate here: Using and Monitoring SQL 2005 Query Notification that helped me solve my own problem: By using Sql Profiler to trace the QN events he suggests, i was able to spot my connection was incorrectly using the 'SET ARITHABORT OFF' option, causing my notifications to fail.

Resources