I wonder if it is possible to load reference data in the first call. In my case I want to load the patient reference in the Encounter Resource. As I know I always need the patient data I want to avoid to to do an additional call to get the patient data.
The server is HAPI FHIR and the client firely .Net API
Yes, that is possible. Your request will have to be a search, that way you can include any referenced resources.
On REST level it looks like this:
GET <hapi_server>/Encounter?_include=patient
Add any filters you have. For example if you have a specific encounter you would add &_id=<technical_id>.
With the FhirClient from the .Net api, the code looks like this:
var c = new FhirClient("<hapi_server");
var q = new SearchParams().Include("Encounter:patient");
q.Add("_id", "<technical_id>");
var result = c.Search<Encounter>(q);
Related
I need some help getting the value and unit of a result from the FHIR Observation DSTU2 resource. I want to map these values to strings but it looks like Observation.value[x] can have different type of data. Any thoughts on how to do this in C#? I tried a few ways but no luck so far because the sandbox I'm using contains results as strings, Quantity and CodeableConcept.
http://hl7.org/fhir/observation-definitions.html#Observation.value_x_
For the Observation.value field you indeed have a choice of type, so the data in the FHIR resource can hold any of the choices listed for that field.
If you use the Hl7.Fhir.Dstu2 library - the official C# reference implementation available through NuGet, you can use it to easily retrieve the resources from your sandbox and get them into a POCO. Here's an example:
using Hl7.Fhir.Model;
using Hl7.Fhir.Rest;
var client = new FhirClient("<your sandbox url>");
var obs = client.Read<Observation>("Observation/<technical id>");
// now you can access obs.Value regardless of the type in it
if you need to serialize the data to xml or json, you use the serializer:
using Hl7.Fhir.Serialization;
var serializer = new FhirJsonSerializer();
Console.WriteLine(serializer.SerializeToString(obs));
Is there a way to convert a fhir bundle from json to xml by means that is independent of the FHIR version used?
I think the .net fhir api by firely can do it, but any given version of the api seems to be specific to a certain release of FHIR.
The problem is that a FHIR Bundle (or any resource) implicitly always has a version. The rationale is that each FHIR version has (or can have) a different underlying data model.
It is possible though, using the .NET FHIR API (specifically package https://www.nuget.org/packages/Hl7.Fhir.Serialization) to do the conversion with minimal version differences.
The following code does the conversion using the version-independent ISourceNode (http://docs.simplifier.net/fhirnetapi/parsing/isourcenode.html)
using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Serialization;
var xml = "<Patient xmlns=\"http://hl7.org/fhir\"><identifier><use value=\"official\" /></identifier></Patient>";
var patientNode = FhirXmlNode.Parse(xml);
var typedElement = patientNode.ToTypedElement();
var json = typedElement.ToJson();
The above code has one problem though, as VS will tell you. Using ToTypedElement() without parameters is dangerous because ignoring the version is. It will work in many cases though and if it is good enough for you that may be the way to go.
A safer solution is to use the same code, but to additionally use a so-called IStructureDefinitionSummaryProvider (apologies for the naming ;) to provide the API with specific version information. Implementations for this interface can be found in version-specific API libraries, e.g. https://www.nuget.org/packages/Hl7.Fhir.R4.
using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Serialization;
using Hl7.Fhir.Specification;
var xml = "<Patient xmlns=\"http://hl7.org/fhir\"><identifier><use value=\"official\" /></identifier></Patient>";
var patientNode = FhirXmlNode.Parse(xml);
var summaryProvider = new PocoStructureDefinitionSummaryProvider();
var typedElement = patientNode.ToTypedElement(summaryProvider);
var json = typedElement.ToJson();
You may be able to inject these PocoStructureDefinitionSummaryProviders based on some property of the input you are reading from. That is how we do it in the Vonk FHIR server for instance.
The FHIR java validator can do this for any version. That might be suitable depending on what you need to use it
The Background
In an attempt to build some back-end services for my e-commerce (Shopify based) site I have set up a Firestore trigger that writes order details with every new order created which is updated by a web hook POST function provided by Shopify - (orders/Create webhook).
My current cloud function -
exports.saveOrderDetails = functions.https.onRequest((req, res) => {
var docRef = db.collection('orders').doc(req.body.name);
const details = req.body;
var setData = docRef.set(req.body).then( a =>{
res.status(200).send();
});
});
Which is able to capture the data from the webhook and store it in the order number's "name" document within my "orders" collection. This is how it looks in Firestore:
My question is - with the help of body-parser (already parsing out "name" which is represented as #9999 in my screenshot, to set my document name value) - how could I improve my cloud function to handle storing this webhook POST in a better data structure for Firestore and to query it later?
After reviewing the comments on this question, I moved this question over to Firebase-Talk and it appears the feature I am attempting here would be close to what is known as "collection group queries" and was informed I should adjust my data model approach since this feature is currently still on the road map - and perhaps look into the Firestore REST API as suggested by #jason-berryman
Besides the REST APi, #frank-van-puffelen made a great suggestion to look into working with Arrays, Lists, Sets for Firebase/Firestore
Another approach that could mitigate this in my scenario is to have my HTTP Firestore cloud trigger have multiple parsing arguments that create top more top level documents - however this could cause a point of scaling failure or an increase of cost factor due to putting more parsing processing logic in my cloud function and adding additional latency...
I will mark my question as answered for the time being to hopefully help others to understand how to work with documents in a single collection in Firestore and not attempt to query groups of collections before they get too far into modelling and need to restructure their app.
I'm building a web service for a client that pulls data from the Sitefinity CMS. The problem is they want to pass in a Guid for the service and receive the info about this item. No problem except I only have been able to locate the "live" Guid for one Item (and that was by combing through the HTML in the back end).
I was going to look at the tables in SQL Server but I'm not sure which table to look at. The content items have several tables all related of course and there isn't any documentation on how to look at this. I can find plenty of documentation on querying the master Guid, but no place to find it.
Oh, and these are custom content types built by the Module Builder.
Any Help would be SOOOOO appreciated!
var master = DynamicModuleManager.GetManager().Lifecycle.GetMaster(<liveGuidHere>);
One of the biggest consumers of Sitefinity webservices is Sitefinity. The best place to start looking for that guid is to take a look at what web service calls are being made when you pull up your custom content item list in the backend. I used the chrome developer tools and check in the network tab.
One I found for a stores module made with module builder was something to the effect of http://www.testsite.com/Sitefinity/Services/DynamicModules/Data.svc/?managerType=Telerik.Sitefinity.DynamicModules.DynamicModuleManager&providerName=OpenAccessProvider&itemType=Telerik.Sitefinity.DynamicTypes.Model.Stores.Store&provider=OpenAccessProvider&sortExpression=LastModified%20DESC&skip=0&take=50
The json this returns is a list of all the masters with their ids (note in the list that the content items all have have a status of 0) http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/modules/content-lifecycle
When you go to Administration / Module Builder / Your Module, you will see a link to the API on the top right corner.
This link goes to a page full of API examples for your particular module which is kind of cool.
Basically you would have to find your item first using LINQ and the GetValue extension method.
Once you have the item you can get its ID or any other property.
using Telerik.Sitefinity.Utilities.TypeConverters;
using Telerik.Sitefinity.DynamicModules;
using Telerik.Sitefinity.Model;
....
var mgr = DynamicModuleManager.GetManager();
var countrymasters = from ctry in mgr.GetDataItems(TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Destinations.Destination"))
where ctry.GetValue<string>("culture") == siteid &&
(ctry.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && ctry.Visible == true)
select new
{
airport_cd = ctry.GetValue<string>("airport_cd"),
country_master_cd = ctry.GetValue<string>("country_master_cd")
};
I’m building an MVC3 application with form authentication and a single hierarchical entity. The entity has a Region object as the “root” with several other objects. It looks something like:
Region->Language->objectA->objectB
Region->Application->….
Each user (other than administrators) is associated with single region. I'd like to limit the data loaded to the entity based on the user’s region. I’m not too familiar with EF. Is this appropriate or is there a better approach? How would I implement the best approach
You can certainly filter the data returned via Entity Framework. The code would look something like this:
using (MyContext ctx = new MyContext())
{
var filtered = (from r in ctx.Regions where SOME_CONDITIONS select r);
// Do stuff with filtered (which is an IEnumerable<Region>)
}
Note that you may need to use Include to load related objects, e.g.
ctx.Regions.Include("Language").Include("Application")
see http://msdn.microsoft.com/en-us/library/bb896272.aspx