Open rouaneta opened 4 years ago
The issue is that the FHIR::
module contains R4 resources only, and the FHIR::STU3::
module contains STU3 resources only, and the FHIR::DSTU2::
module contains DSTU2 resources only.
The client can parse different FHIR versions, but it does not monkey-patch any of the FHIR
modules.
So, when you explicitly call FHIR::CommunicationRequest...
you are explicitly saying "use R4 CommunicationRequest."
Apologies if this was not obvious or a point of confusion. We hope to improve the documentation and examples for this gem in the future. This should be a topic we cover.
Thanks @jawalonoski for the quick reply. The problem is that the behaviour is not the same for each client version. If we look more closely to the parse_reply
method: https://github.com/fhir-crucible/fhir_client/blob/59ccd55c4130c821d7ace4e992296850fc9e6291/lib/fhir_client/client.rb#L320-L338
It appears that the behaviour is as follows (assuming that the format is xml
- same behaviour for json
):
dstu2
I would go through FHIR::DSTU2::Xml.from_xml
anywayr4
I would go through FHIR::Xml.from_xml
, except if I explicitly call FHIR::DSTU2::...Read
, in which case I would go through FHIR::DSTU2::Xml.from_xml
stu3
it depends only on the module I call the read
method on:
• FHIR::DSTU2::...Read
-> FHIR::DSTU2::Xml.from_xml
• FHIR::...Read
-> FHIR::Xml.from_xml
• FHIR::STU3::...Read
-> FHIR::STU3::Xml.from_xml
In other words:
I am having troubles reading the
CommunicationRequest.requester.agent
(please find an example of payload here).Our client uses the
STU3
version. We call the methoduse_stu3
on our client. We usually read CommunicationRequest using the syntaxFHIR::CommunicationRequest.read("123456")
. I realized that to be able to read the attributerequester.agent
, I had to use the syntaxFHIR::STU3::Communication.read("123456")
.Should the method used to parse the fhir payload not be based on the fhir_version of the client in priority ? So that I can call
FHIR::CommunicationRequest.read("123456")
and the resource will be read correctly according to the client version.