Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restful server can handle multiple fhircontext versions #2406

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hdconradi
Copy link
Contributor

I am currently trying to work with multiple fhir versions simultaneously by using
one fhir servlet with R4 FhirContext and a resource provider for R4 and an
additional interceptor which converts incoming R3 resources into R4 and the same for outgoing resources.

This is working more or less.

However, for the outgoing resources there is a problem when the parser needs some non-standard properties:

At the very end of the call stack the RestfulServerUtils class is used for transforming
the Resource into a String. In order to do so, it needs a FhirContext.
However, the context of the server here is of course R4 while R3 is needed.
The utils class then creates a new default context in the getNewParser method using the getContextForVersion.

In order to make the new FhirContext aware of necessary configurations one
could either trying to copy the configuration from the R4 configuration to the R3 context.
Alternatively one could open the backing Map<FhirVersionEnum, FhirContext> by e.g. adding a method

    public static void addFhirContext(FhirVersionEnum fhirVersion, FhirContext fhirContext) {
        myFhirContextMap.put(fhirVersion, fhirContext);
    }

This alternative has the advantage that the configuration is explicit and does not depend
on some implicit conversion which might even run into incompatibilities between R3 and R4.

A cleaner and more powerful way for doing this, would probably be to add this structure to
the RestfulServer and access it via the IRestfulServerDefaults

I have explored the latter in this patch which adds a new data structure to the RestfulServer

  • a map of FhirVersionEnums to FhirContext - which is then used by the
    RestfulServerUtils when serializing a resource.

When working with multiple fhir versions simultaneously,
the RestfulServer sometimes needs the ability to work with the correct
version of the FhirContext - and it is not sufficient to just create
default FhirContext for that version.

This patch adds a new data structure to the RestfulServer
- a map of FhirVersionEnums to FhirContext - which is then used by the
RestfulServerUtils when serializing a resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant