Coder Social home page Coder Social logo

Comments (12)

mbaltus avatar mbaltus commented on July 22, 2024

If you put multiple resources within the tag, the server will create a resource, but only the first contained resource will be saved.

from spark.

CorinaCiocanea avatar CorinaCiocanea commented on July 22, 2024

Could you also give me an example for this? It is not clear in what tag can one add multiple resources. I have tried it with a couple of tags and parsing throws an exception.

from spark.

ewoutkramer avatar ewoutkramer commented on July 22, 2024

It's been too long ago, I don't understand this bug-report myself anymore, but it seems Mirjam still does ;-)

from spark.

mbaltus avatar mbaltus commented on July 22, 2024

The issue is with contained resources. Try posting:

<Patient xmlns="http://hl7.org/fhir">
    <contained>
        <Organization>
            <id value="myManagingOrganization"/>
            <name value="Just testing this"/>
        </Organization>
        <Organization>
            <id value="myManagingOrganization2"/>
            <name value="Just testing this 2"/>
        </Organization>
    </contained>
    <name>
        <use value="usual" />
    <given value="Jim" />
    </name>
    <managingOrganization>
        <reference value="#myManagingOrganization" />
    </managingOrganization>
</Patient>

The contained tag is invalid since it can only contain 1 resource, but spark accepts it and stores the first organization.

from spark.

CorinaCiocanea avatar CorinaCiocanea commented on July 22, 2024
  1. From what I understand you can have multiple contained resources in a contained tag (https://www.hl7.org/fhir/references.html). The json representation from the example seems to expect an arrray : contained: [ { "resourceType" : "Organization", "id" : "org1", .. whatever information is available ... } ]

or is this example wrong?
Is there some documentation where this is explicitly explained?

  1. Also from this constraint "A contained resource SHALL only be included in a resource if something in that resource (potentially another contained resource) has a reference to it" I understand that there can be multiple contained resources, but that could also be done using multiple contained tags. So what do you understand from this?
  2. At the same time the example from @mbaltus should still be invalid because one of the organization is not used anywhere in the resource. Should Spark check that?

from spark.

mbaltus avatar mbaltus commented on July 22, 2024

Yes, it is possible to have multiple contained resources, but they should be in their own <contained> tag, just like if you have more than 1 Patient.name you get multiple <name> tags. So my post should have resulted in an error. Also, Spark should not have just thrown away the second resource in contained if my construction was valid, because I've tested with a reference to the second one (and no reference to the first) and it still got deleted.
So I still think my posted resource is invalid, and Spark should reject it.
I think if a contained resource was not referenced, Spark should also reject it and send back an OperationOutcome, since SHALL implies this is an error.

from spark.

CorinaCiocanea avatar CorinaCiocanea commented on July 22, 2024

Thank you. That clears things out.

from spark.

ewoutkramer avatar ewoutkramer commented on July 22, 2024

Yes, the fact that Json has an array notation ([]) and you cannot repeat properties in Json makes all the difference here...

from spark.

CorinaCiocanea avatar CorinaCiocanea commented on July 22, 2024

So, this seems indeed to be a FHIR .NET Api bug (at least the part about accepting more resources in a contained tag).
After debugging this, the problem appears to be in the XmlDomFhirReader.GetMembers() method. Here for parsing an XElement we just take the value = (XElement)elem.FirstNode; and ignore any other nodes. We should probably check here the Elements() collection and throw an exception if there are multiple elements in it. I will add a bug for this.

Related to the second problem that we don't check if the actual contained resource is used anywhere in the resource, this would imply a validation step after the resource is constructed. Should this happen in Spark? or it would be better to make sure all parsed resources are correct? I think this should be part of implementing the rest of the validation support in Spark (that is currently missing - see Spark.Service.Validate). Maybe after implementation this could also be exported as a separate library.
What do you tink?

from spark.

paulbarrynz avatar paulbarrynz commented on July 22, 2024

We are experiencing the same issue currently. So just to clarify, should we be saving our contained resources using the following format? Will this deserialise correctly?
<Patient xmlns="http://hl7.org/fhir"> <contained> <Organization> <id value="myManagingOrganization"/> <name value="Just testing this"/> </Organization> </contained> <contained> <Organization> <id value="myManagingOrganization2"/> <name value="Just testing this 2"/> </Organization> </contained> <name> <use value="usual" /> <given value="Jim" /> </name> <managingOrganization> <reference value="#myManagingOrganization" /> </managingOrganization> </Patient>

from spark.

cknaap avatar cknaap commented on July 22, 2024

Yes, this should be handled correctly. If Spark doesn't please leave a new comment here.

from spark.

kennethmyhra avatar kennethmyhra commented on July 22, 2024

Fixed by #152 and #153.

  • If PermissiveParsing is set to false it will fail and return an OperationOutcome.
  • If PermissiveParsing is set to true one of the resources will be removed from the contained section.

from spark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.