FHIR Chat · FHIRPath Patch Test Cases · implementers

Stream: implementers

Topic: FHIRPath Patch Test Cases


view this post on Zulip Lee Surprenant (Feb 18 2020 at 22:52):

I recently added FHIRPath Patch support to our server. I downloaded the FHIRPath Patch test cases from https://www.hl7.org/fhir/fhirpatch.html but hit a couple issues.

view this post on Zulip Lee Surprenant (Feb 18 2020 at 22:53):

IMHO the most egregious one is Reorder List #4:

  <case name="Reorder List #4" mode="forwards">
    <input>
      <Patient xmlns="http://hl7.org/fhir"><id value="test"/>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 1"/>
        </identifier>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 2"/>
        </identifier>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 3"/>
        </identifier>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 4"/>
        </identifier>
      </Patient>
    </input>
    <diff>
      <Parameters xmlns="http://hl7.org/fhir"><id value="test"/>
        <parameter>
          <name value="operation"/>
          <part>
            <name value="type"/>
            <valueCode value="move"/>
          </part>
          <part>
            <name value="path"/>
            <valueString value="Patient.identifier"/>
          </part>
          <part>
            <name value="source"/>
            <valueInteger value="0"/>
          </part>
          <part>
            <name value="destination"/>
            <valueInteger value="3"/>
          </part>
        </parameter>
      </Parameters>
    </diff>
    <output>
      <Patient xmlns="http://hl7.org/fhir"><id value="test"/>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 2"/>
        </identifier>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 3"/>
        </identifier>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 1"/>
        </identifier>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 4"/>
        </identifier>
      </Patient>
    </output>
  </case>

view this post on Zulip Lee Surprenant (Feb 18 2020 at 22:53):

Shouldn't the expected output be:

      <Patient xmlns="http://hl7.org/fhir"><id value="test"/>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 2"/>
        </identifier>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 3"/>
        </identifier>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 4"/>
        </identifier>
        <identifier>
          <system value="http://example.org"/>
          <value value="value 1"/>
        </identifier>
      </Patient>

?

view this post on Zulip Lee Surprenant (Feb 18 2020 at 22:54):

what does mode="forwards" mean in the test case element?

view this post on Zulip Brian Postlethwaite (Feb 19 2020 at 05:48):

Something is not right there, how do you move it to the start or to the end?
Is the position the result after removing it, or before removing it, and is it 0 based.
If that is the expected result, the only answer I can come up with is it means insert before item (without removing the source).
I agree that this could do with some clarification.

view this post on Zulip Lee Surprenant (Feb 19 2020 at 14:49):

yeah, here was my assumption about how move should work for a list like [1,2,3,4]:

move(0,0) -> 1,2,3,4
move(0,1) -> 2,1,3,4
move(0,2) -> 2,3,1,4
move(0,3) -> 2,3,4,1

view this post on Zulip Lee Surprenant (Feb 19 2020 at 14:57):

OK, I opened https://jira.hl7.org/browse/FHIR-26324 for it...and I'm happy to open a PR with my suggested fix if someone can point me to the source of these examples

view this post on Zulip Grahame Grieve (Feb 20 2020 at 01:47):

mode is an instruction to the test engine for whether the test case is testing applying or generating differences

view this post on Zulip Grahame Grieve (Feb 20 2020 at 01:47):

because you can't always go in both directions

view this post on Zulip Grahame Grieve (Feb 20 2020 at 01:55):

further, I agree with your assumption and I can't see how my code doesn't work the way you think

view this post on Zulip Grahame Grieve (Feb 20 2020 at 02:01):

no it does - insert before delete

view this post on Zulip Grahame Grieve (Feb 20 2020 at 02:03):

That's the only test that's affected

view this post on Zulip Grahame Grieve (Feb 20 2020 at 02:12):

so I agree that test cases are wrong, and I'll update the test cases in their master location:

view this post on Zulip Grahame Grieve (Feb 20 2020 at 02:12):

https://github.com/FHIR/fhir-test-cases


Last updated: Apr 12 2022 at 19:14 UTC