Closed johngrimes closed 7 months ago
@johngrimes, do you have any ideas on how we can express the fact that the value returned by getResourceKey()
and getReferenceKey()
matches in the JSON test representation?
I have two ideas, both of which are quite cumbersome:
To use a self-referencing resource. The issue is that it's artificial, and I'm not sure if FHIR allows self-references.
{
"title": "forEach, forEachOrNull",
"resources": [
{
"resourceType": "Patient",
"id": "p1",
"link": [{"other": "Patient/p1"}]
}
],
"tests": [
{
"title": "forEach matching some",
"view": {
"resource": "Patient",
"select": [
{
"column": [{ "path": "getResourceKey() == link.other.getReferenceKey()", "name": "key_equal_ref" }]
}
]
},
"expect": [{ "key_equal_ref": true }]
}
]
}
Add new syntax to the test definition that allows comparing different views. I'm not sure if we want to add new syntax, and I don't see any other use for it right now.
{
"title": "reference keys",
"resources": [
{
"resourceType": "Patient",
"id": "p1",
"link": [{"other": "Person/per1"}]
},
{
"resourceType": "Person",
"id": "per1"
}
],
"tests": [
{
"title": "forEach matching some",
"expectViewEqual": [
{
"resource": "Patient",
"select": [
{"column": [{ "path": "link.other.getReferenceKey()", "name": "key" }]}
]
},
{
"resource": "Person",
"select": [
{"column": [{ "path": "getResourceKey()", "name": "key" }]}
]
}
]
}
]
}
As discussed in the meeting this morning, let's go with option 1 for now.
The data in your test is not quite right, and there is a minor problem with the FHIRPath expression. Something like this should work:
{
"title": "references",
"resources": [
{
"resourceType": "Patient",
"id": "p1",
"link": [
{
"other": {
"reference": "Patient/p1"
}
}
]
}
],
"tests": [
{
"title": "getReferenceKey result matches getResourceKey",
"view": {
"resource": "Patient",
"select": [
{
"column": [
{
"path": "getResourceKey() = link.other.getReferenceKey()",
"name": "key_equal_ref"
}
]
}
]
},
"expect": [
{
"key_equal_ref": true
}
]
}
]
}
The following tests have expectations that are implementation-specific. The expectations should be weakened to reflect the fact that implementations can return any values from these functions, as long as they match up.
Also, there seem to be two tests with the same name (
getReferenceKey(<type>)
). We should fix this, the test name should be unique within the suite.