FHIR Chat · Custom Resource · implementers

Stream: implementers

Topic: Custom Resource


view this post on Zulip Domenico (Apr 07 2017 at 09:31):

Hi all,
what are the steps to create a Custom Resource? Should I use the Basic Resource or the StructureDefinition Resource? I would like have a Custom Resource with the set of attributes, search parameters and the the REST API (such as baseUrl/CustomResource/).
Please let me know if it's possible and how I can build it.

view this post on Zulip Domenico (Apr 07 2017 at 09:44):

Hi all,
what are the steps to create a Custom Resource? Should I use the Basic Resource or the StructureDefinition Resource? I would like have a Custom Resource with the set of attributes, search parameters and the REST API (such as baseUrl/CustomResource/).
Please let me know if it's possible and how I can build it.

view this post on Zulip Grahame Grieve (Apr 07 2017 at 10:40):

it's not possible right now. We've talked about it, but we haven't landed on how to manage it, and it's pretty controversial

view this post on Zulip Domenico (Apr 07 2017 at 10:49):

@Grahame Grieve can you explain me because it is not possible to build a custom resources ? Even through Basic Resource?

view this post on Zulip Sunanda Veeraganti (Apr 07 2017 at 11:32):

@Domenico Basic Resource is used when you need to convey a narrative-only construct that doesn't neatly correspond to one of the other resources.

view this post on Zulip Domenico (Apr 07 2017 at 11:43):

@Sunanda Veeraganti Thank you for your reply. So do you confirm that I can't build a custom resource? I read on this link http://wiki.hl7.org/index.php?title=FHIR_Custom_Resources that it is possible.

view this post on Zulip John Moehrke (Apr 07 2017 at 11:54):

It depends on what you consider Custom. You certainly can use StructureDefinition to add to Basic and end up with functionally what you want, something that doesn't exist today. BUT it will not be a named 'resource', it will be Basic... The only way you will differentiate your custom functionality from others on the same server is through tags and element values.

view this post on Zulip Sunanda Veeraganti (Apr 07 2017 at 12:01):

@Domenico As Grahame Grieve said in his reply that it was discussed. For now custom resource is not possible.

view this post on Zulip Domenico (Apr 07 2017 at 12:03):

@John Moehrke I consider as Custom a new Resource for handling a concept not yet defined in FHIR. It will have its attributes (including the cardinalities), its search paramenters, its profile, its REST APIs and so on.

view this post on Zulip Sunanda Veeraganti (Apr 07 2017 at 12:08):

if you think that there is a new concept which is not yet defined in FHIR then you can suggest and it will be discussed. Probably a new resource will be created. Manging custom resource will be hard. And the conformance to such resource will be vague

view this post on Zulip John Moehrke (Apr 07 2017 at 12:13):

Now is an especially easy time to bring a new use-case to FHIR, but anytime in the future is also good. We can always add Resources that the community find as useful and needed. We know we are not done creating new Resource types. You can pilot your idea using Basic, and a pilot would be useful when you present your need and solution proposal.

view this post on Zulip Grahame Grieve (Apr 07 2017 at 12:27):

The wiki link you referred to is a proposed policy that was never endorsed. In fact, some committees declined to discuss it, and others never even started to get consensus about it

view this post on Zulip Domenico (Apr 07 2017 at 12:32):

@Sunanda Veeraganti @John Moehrke @Grahame Grieve Thank you very much for your replies. I made this question because reading the scope and usage of the Basic Resource (https://www.hl7.org/fhir/basic.html) I understood that, by means it, I could create new Custom Resources not yet defined in FHIR.

view this post on Zulip Yunwei Wang (Apr 07 2017 at 12:42):

@Domenico The purpose of FHIR is to improve interoperability. Yes, you could create custom resource but the new resource need to be accepted and managed by FHIR community as a whole. So if you have a use case for new FHIR resource, you can raise the request and discuss with FHIR-I WG. The we will see if a new source is required or an existing resource can be adapted.

view this post on Zulip Lloyd McKenzie (Apr 07 2017 at 13:36):

Basic is currently the "approved" mechanism to represent resources that aren't otherwise supported in FHIR. Basic + extensions allows you to convey any concept you wish. But it means that almost all of the data you care about will be sent as an extension, which is pretty ugly. The challenge we have with allowing "true" custom resources (where you could actually have a custom schema for the resource) is that it's very hard to keep the notion from being abused and fragmenting the community and it's hard to do in a "safe" way that lets clients that might not be familiar with the resource still function. These are 'hard' problems, but not necessarily insurmountable problems. It's my belief we'll figure out a path eventually - hopefully before R4. But for right now, you're stuck with using Basic or being non-conformant.

view this post on Zulip Lloyd McKenzie (Apr 07 2017 at 13:37):

(Being non-conformant means that you won't work with any of the public test servers, the standard validation or testing tooling, won't be able to use the standard IG tooling, etc. And any existing FHIR systems won't be able to talk to you without customization. So it's a bit more painful than just "oh well, I'm not conformant".

view this post on Zulip Lloyd McKenzie (Apr 07 2017 at 13:39):

But that is a solution within "closed" communities - at least while we're still in the "trial use" phase of FHIR. As well, you're always free to propose a new resource to HL7. If we agree it's appropriate, it'll probably show up in the continuous integration build within a few weeks to a few months and start showing up in the more stable Connectathon releases thereafter.

view this post on Zulip Luan Garrido (Nov 18 2019 at 13:48):

Hello, I created a new resource extending it from DomainResource, btw I'm using HAPI FHIR (Java).
When I output the MethodOutcome (based on this resource) or try to print the resource the only attribute printed is "resourceType".
My resource has only two attributes, both annotated as "child".
What do I need to do to have the inner children attributes printed?

view this post on Zulip Lloyd McKenzie (Nov 18 2019 at 14:00):

I think HAPI supports 'custom' resources, but be aware that your system won't be FHIR conformant. (Only HL7-defined resources are permitted in conformant systems.) @James Agnew ?

view this post on Zulip Luan Garrido (Nov 18 2019 at 14:08):

Hello @Lloyd McKenzie , I know, this resource won't be FHIR conformant.
The problem I'm facing is related to not have subclasses attributes printed. Example:

Class A
---StringType first
---B second
------StringType third

In this example, only first get printed.

view this post on Zulip Luan Garrido (Nov 18 2019 at 14:11):

The class B is annotated as "@Block" in the above example.

view this post on Zulip Lloyd McKenzie (Nov 18 2019 at 16:14):

You might want to raise this on the #hapi stream. (Responses this week might be a bit slow due to DevDays)

view this post on Zulip James Agnew (Nov 18 2019 at 17:03):

This should work, although for the reasons everyone gives here it's a risky thing to do- you certainly won't get any interoperability that way.

Make sure you register your custom type against your FhirContext, and your resource provider should also declare it via the getResourceType() method.

Also make sure you are using the HAPI FHIR ca.uhn.fhir.model.api.annotation.Child annotation and not one from some other package- if nothing is being serialized I would suspect that your fields are not correctly annotated.

view this post on Zulip Theodor Szymkowiak (Jun 28 2021 at 14:07):

Hello all,
I have a problem with fitting in the FHIR Standard. Let’s say I have a bunch of attributes that didn’t really fit in any given FHIR Resource. I could extend a resource but I wouldn’t need 95% of the base content in that resource and just extend it with 3 more fields. Therefore, this would be more an abuse of that resource just to fit in the FHIR Standard. That’s how I specified my use case in this moment but I’m curious if there is a better way to handle this.
I saw something about Custom Resources but don’t know how to use them properly (how to profile a resource to fit my needs). Is there any good documentation with examples etc.
So basically my question is what should I do if my data model don’t fit in the given FHIR Resources.

view this post on Zulip Michele Mottini (Jun 28 2021 at 14:18):

Use the Basic resource, adding the data you need as extensions

view this post on Zulip Chris Moesel (Jun 28 2021 at 15:36):

Yes, @Michele Mottini's suggestion to create a profile on Basic (adding extensions for what you need) is the recommended approach -- and it adresses your concern about not needing "95% of the base content in that resource" since Basic has no significant base content.

Although you can create custom resources, it is not encouraged because custom resources do not work with most of the FHIR tooling that currently exists (e.g., IG publisher, validators, registries, clients, etc). If you were to create custom resources, you'd also need to create a custom software stack to work with them (and you wouldn't be able to exchange them with others).

view this post on Zulip Elliot Silver (Jun 28 2021 at 16:13):

I'd note that "not needing 95% of the base content in a resource" isn't a problem. In almost every case anything in a resource that you might not need for some use is optional. There is no need to bloat your instance filling in elements that you have no need for; leave them out. There is no harm in filling in a resource only with what is needed for your use.

On the other hand, if the 95% of the content needed by your use case isn't represented in a resource (or combination of resources), then looking at Basic is an option, although extensions to existing resources are also an option.

view this post on Zulip Theodor Szymkowiak (Jun 29 2021 at 08:54):

Thanks for all the answers. How can I use the Basic Resource properly? It seems quite strange to use CRUD Operations on this (GET /Resource/123). Maybe let’s get more specific on my needs.
Right now, I use the “ChargeItem” Resource to handle the billing process for my patients. But mainly I need just 3 attributes in this resource that I could extend or abuse in “supportingInformation”. These attributes are 3 Bundles, that I get from another system and have to store and handle in my system. The only other Fields that I use in this resource are “status” and “subject”. All other fields don’t belong to my needs (even the “code” parameter that I have to use because it is mandatory).
I can stick to that plan but somehow it feels like I’m abusing FHIR and the “ChargeItem”. On the other hand, I need to use CRUD Operations and other FHIR tooling like Chris sad.

view this post on Zulip Rik Smithies (Jun 29 2021 at 11:10):

If you are using ChargeItem then just extend it. It's fine. This is not abusing FHIR. Of course your extensions, no matter what proportion of the resource they are, will not be standard FHIR, understandable by others without some special knowledge. But that is to be expected. It's still better to do this within FHIR.
You only need to use Basic if you have a new concept that doesn't exist in FHIR and is a standalone entity (with its own lifecycle) in your system. Basic is not meant for adding a few properties to another resource.

view this post on Zulip Lloyd McKenzie (Jun 29 2021 at 13:25):

If you're using Basic, you'd be doing GET [base]/Basic/123, not Resource/123

view this post on Zulip Vassil Peytchev (Jun 29 2021 at 15:14):

If the billing process requires Bundles of additional information that is not currently available in ChargeItem, it will be probably useful to try to improve ChargeItem to support the information within the Bundles...

view this post on Zulip Pavel Khromov (Sep 08 2021 at 11:00):

Hello everyone!
I'm new to HAPI. I understand correctly, if I create a completely custom resource that extends the DomainResource and the provider for it, then I still won't be able to create my custom resource on the server and perform operations (read, update, delete, etc.) on it.
Instead, I have to use the Basic resource and add extensions to it in order to get my custom resource with which I can perform CRUD operations on the server.

view this post on Zulip S. K MEDE (Sep 08 2021 at 12:13):

I've just chanced upon this and seems to answer a query I have.

I want to represent custom aggregate medication data (KPIs) grouped by Organisation. End users will collate the KPIs by organisation for benchmarking. It doesn't fit as an attribute to the Organisation, just merely medication management outcomes within that organisation. From the above, I can use Basic with extensions ?

view this post on Zulip Lloyd McKenzie (Sep 08 2021 at 13:08):

@Pavel Khromov From an interoperability perspective, Basic is the correct solution. However, if you have a concept you can't find a home for in the existing resources, it's always best to raise a question here to see if there's a recommended way to use the standard resources. (Sometimes a use-case is already supported, just not with the name/approach you might have expected.) If you have specific questions about HAPI's custom resource capabilities, that's best asked on #hapi

view this post on Zulip Lloyd McKenzie (Sep 08 2021 at 13:09):

@S. K MEDE This sounds like either Observation or Measure - have you looked at both of those?

view this post on Zulip Pavel Khromov (Sep 08 2021 at 14:25):

@Lloyd McKenzie Thanks for reply!

view this post on Zulip Saad Naseem (Sep 09 2021 at 06:36):

can we create custom resource in fhir?

view this post on Zulip John Moehrke (Sep 09 2021 at 12:24):

see Basic http://hl7.org/fhir/basic.html

view this post on Zulip Lloyd McKenzie (Sep 09 2021 at 15:08):

To be conformant to FHIR, you're limited to only the resources defined in the core specification. What concepts are you trying to represent @Saad Naseem that you want a new resource for?

view this post on Zulip Saad Naseem (Sep 12 2021 at 13:34):

Thanks for the reply sir


Last updated: Apr 12 2022 at 19:14 UTC