I would like to know what FHIR resource has to be used for bringing the list of specialities that are available for an organisation. These specialities are encounter specific so the response must be returned along with its encounter information based on the organisation.
Is that advisable to use List resource in FHIR?
If you search a FHIR server for a 'collection' of resources (like Encounter, HealthcareService or any other) the standard response would be a Bundle rather than a List.
Related
I'm struggling a bit with reverse chaining in fhir search.
I can find all PractitionerRole resources for a given Practitioner with:
[base]/PractitionerRole?practitioner:Practitioner:id=100
How do I combine chaning and reverse chaining to find all HealthcareService resources for a given Practitioner? I tried the below and some variations of it.
[base]/HealthcareService?_has:PractitionerRole:practitioner:Practitioner:id=100
I would use:
[base]/PractitionerRole?practitioner=100&_include=PractitionerRole.service
It's more likely to be supported, and would also give you the roles in which the Practitioner is associated with the service.
A little background of my problem. I have a set of the following services:
AdapterService - intended for loading certain products from an external system
ApiGateway - accepts requests from UI. In particular, now there is only one request that receives product data to display product in UI from Product Service
ProductService - data storage service for various products. The service itself does not specifically know what kind of product it specifically stores. All types of products are created dynamically by other services that are responsible for these products. Product data is stored as a key-value map (technically it is a json string in DB column)
There is a schema for service interations
So, services in BLUE zone are mine (they can be changed in any way). RED zone describes services of another team (they can't be changed).
Whats the problem
To load product from external system I want to use SpecialProductDto which will store product data. I can use some validation features like Spring annotations and so on. Then to load the product from Adapter Service to ProductService I must transform SpecialProductDto to Map<String, Object> because ProductSerivcie requires it via API.
When I would get product info for UI through ApiGateway, I will need to call ProductService api for getting product that return attribues in Map<String, Object> and then transform this data to some UIReponse which contains some part of product data (because I dont need all product information, just only name and price for example).
But I also want to use SpecialProductDto in my ApiGateway service, because it seems working with Map<String, Object> is error prone... I practically need to fetch data blindly from Map to construct UIResponse. And what if some attribute names will be changed? With Map I only will know it when the request would be made from UI but using special DTO I get such exception in compilation time.
Question
So, what is the best practiсe or maybe patterт should I use in such situation? At the moment I see the following solutions:
Duplicate DTOs in both AdapterService and ApiGateway services. So, any changes in one class must be supported in another
Use Map<String, Object> at my own peril and risk, hoping that nothing will change there
Share SpecialProductDTO between ApiGateway and AdapterSerivce in some separate library and service (seems to be antipattern because of sharing someting can make a lot of problems)
Сan anyone help?
In my opinion, there's nothing wrong on duplicating DTOs.
Also, there's nothing wrong on providing the DTO in a separate library to be imported on each project, you will only be sharing the ProductService's contract and that's it. It does not cause any tight coupling between the Api Gateway and the Adapter. If the contract changes, then it must be changed on all of it's consumers (api gateway and adapter), simple as that.
About using Maps: usually I don't recommend this, because, like you said, you will not be able to take advantages of the built-in Bean Validations that Spring (and other frameworks) provides, but not only that, you'll also, depending on the situation, be using lots of casts and type conversions, which is not good and can be prevented by using DTOs.
Also, be aware that a DTO, in my opinion, should not be named with the suffix of 'DTO'. That's because a name like SpecialProductDTO doesn't clearly states where this object is being used or should be used.
Instead, prefer a something like CreateSpecialProductRequest - this indicates that this object is used when creating a Special Product. Another example is CreateSpecialProductResponse which just represents the response (if needed) after a Special Product creation. Take a look at this StackOverflow answer: Java data transfer object naming convention?
The Resource entity define an id attribute as "Logical id of this artifact". Meanwhile for resources like MedicationRequest also define an attribute named identifier. The description is "External identifier" or "Business identifier".
I'm wondering what's the difference between these two attributes? From the RESTful API definition like update, the id can be used to uniquely locate the resource, like POST [base]/[resource]/[id]. After POST another GET should be able to retrieve that resource using GET [base]/[resource]/[id]. It's more like something similar to a storage identifier. Then how about that identifier?
the .id is controlled by the local server. As a resource is coped from server to server, it will change. it's basically the internal primary key for the object, and it's entirely controlled by the FHIR server itself (or, more precisely, by the interaction between the client and server). So it's not a portable identifier.
But almost all the resources correspond to (somewhat) real world entities that also are recorded in other systems, and that are assigned portable identifiers that are used across multiple systems to track the entity. These identifiers are constant as a resource (or other forms of representation of the real world entity) are copied around and moved from place to place. Some identifiers are assigned by external (government) agencies. Identifiers includes things like Patient MRNs, Provider Numbers etc. Often, because of distributed record processing, entities have many identifiers to carry, and there's a whole business in arbitrating between them.
Is use of search parameters limited to the common search parameters (ie. _id, _text) and those defined at the bottom of each resource definition? For instance, family, that's defined on the Patient resource # https://www.hl7.org/fhir/patient.html#search.
I'd like to know if it's possible to use any element of a resource directly as a search parameter? For example:
to search ImagingStudy with more than 3 series: /ImagingStudy?numberOfSeries>3
to search ImagingStudy with any series with ONLINE availability:
/ImagingStudy?series.availability=ONLINE. This is similar to Complex Type filter from Odata (http://www.odata.org/getting-started/basic-tutorial/#filter), where the same query could be written in OData as /ImagingStudy?$filter=series/any(s:s/availability eq 'ONLINE')
Following added on 2015-11-28:
Our server is a read-only service that aggregates data from various source systems and implements an API based on FHIR. Here are some interesting facts and challenges about the infrastructure:
Most of source systems can only provide primitive query capability,
for instance, filter by date.
We are not able to create indexes as we do not own the data repository.
In a typical scenario, we would first retrieve the date filter from the client's request and use it to reduce the amount of data that needs to be returned by a source system. Then our service will process the remaining filter, sorting, and paging on the aggregated result.
As an example, we have a requirement to implement string searching against ImagingStudy.procedure.code.coding[].display.
It is nice to know that server has the ability to define extra search parameters in the conformance statement; however, for our scenario, the search parameters are mostly driven by the clients needs. Any change or update to this needs could trigger a change to the server's conformance. This makes the conformance/contract vulnerable to changes.
This is the motivation that prompted my question, that since FHIR client and server already have a well defined contract defined via FHIR resources, would it be possible to extend this contract for search parameters, where the client and server will be able to leverage the existing object graph of the FHIR resource as the search parameters without having to define a separate list.
The search parameters are defined separately and mapped to actual paths within the resources to allow servers to maintain indexes via something like map/reduce rather than execute the queries long hand against unindexed content. You cannot simply query against arbitrary paths in the resources. Note: This includes the _filter search parameter.
Servers are allowed, however, to define their own search parameters and map these to arbitrary paths in the resources. If the server exposes a search parameter, it should declare it in the conformance statement, and then you'll know whether you can use it or not.
(btw, Servers are also allowed to choose not to use map/reduce, and to execute the queries long hand, and therefore to allow any path to be used as a parameter, if that is an effective strategy for their technology base - though I don't know of one that does this.)
I am new in FHIR, I want to develop FHIR's Server in C#, Please help me how to handle Resource within Resource. For Example in Encounter Resource, (partOf : Resource(Encounter)), similarly in Organization resource there is Organization etc, I am trying but it goes to Infinite LOOP. Not proceed to next classes.I am retrieving data from Database for time being... Thanks in advance
When you look at the definition of a Resource and you see an element with a datatype of Resource(X) (like the example you mentioned, partOf: Resource(Encounter)) this means that resource references another Resource (in this case, an Encounter). The 'partOf' element is actually an URL (or rather, an uri) pointing to another resource somewhere else on the same RESTful endpoint (or within the same message or document if you are using those constructs). So, this is more like a 'foreign key' in "traditional" database technology.
So, yes, Organizations can reference Organizations, Encounters can reference Encounters!
In my tutorial on FHIR (available at http://www.slideshare.net/ewoutkramer/fhir-tutorial-morning), you can find some examples and background from slide 29 on. Basically, this is what a reference looks like:
<partOf>
<reference value='http://spark.furore.com/fhir/Organizaiton/4433EF-33'/>
<display value="Some other organization"/>
</partOf>
Note that this is very different from containment. If you take a look at the same Encounter resource (at http://www.hl7.org/implement/standards/fhir/encounter.html), you'll see a component 'Hospitalization', this component is nested within the resource (so no reference), as indicated by the "closed diamond" shape in the UML.
In case you need an example of how to implement a .NET FHIR server, please take a look at our open-source implementation here: http://www.github.com/furore-fhir/spark. Also, be sure to get the .NET helper API's via NuGet (just look for FHIR).
With regard to the infinite loop, it's entirely possible for references to loop back to an initiating resource. While resources don't generally point directly to themselves, traversing a chain of resources and winding back up at the starting resource is quite possible. Systems that traverse links will need to account for this potential looping.