|
| 1 | +# Tests for PR 5285: Handle multiple target types for ReferenceSearchParam |
| 2 | +# |
| 3 | +# The UntypedReferenceRewriter now handles reference search parameters with |
| 4 | +# multiple target types. Previously, only single-target-type references were |
| 5 | +# rewritten. Now, multi-target references get an OR expression over all |
| 6 | +# valid target types (plus IS NULL for untyped string references). |
| 7 | +# |
| 8 | +# Key search parameters exercised: |
| 9 | +# - Encounter.subject targets: Patient, Group |
| 10 | +# - Observation.subject targets: Patient, Group, Device, Location |
| 11 | +# - Condition.asserter targets: Patient, Practitioner, PractitionerRole, RelatedPerson |
| 12 | + |
| 13 | +@hostname = localhost:44348 |
| 14 | + |
| 15 | +### Get the bearer token, if authentication is enabled |
| 16 | +# @name bearer |
| 17 | +POST https://{{hostname}}/connect/token |
| 18 | +content-type: application/x-www-form-urlencoded |
| 19 | + |
| 20 | +grant_type=client_credentials |
| 21 | +&client_id=globalAdminServicePrincipal |
| 22 | +&client_secret=globalAdminServicePrincipal |
| 23 | +&scope=fhir-api |
| 24 | + |
| 25 | +### Setup test data (transaction bundle) |
| 26 | +POST https://{{hostname}} |
| 27 | +Content-Type: application/json |
| 28 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 29 | + |
| 30 | +< ./Data/ReferenceMultipleTargetTypesBundle.json |
| 31 | + |
| 32 | +############################################################################### |
| 33 | +# TEST 1: Untyped reference search with multiple target types |
| 34 | +# Encounter.subject targets Patient and Group. |
| 35 | +# BEFORE this PR: type filter was NOT added for multi-target params. |
| 36 | +# AFTER this PR: an OR filter over (Patient, Group, NULL) is added. |
| 37 | +############################################################################### |
| 38 | + |
| 39 | +### 1a. Untyped - should find encounter with Patient subject |
| 40 | +GET {{hostname}}/Encounter?subject=ref-test-patient1 |
| 41 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 42 | + |
| 43 | +### 1b. Untyped - should find encounter with Group subject |
| 44 | +GET {{hostname}}/Encounter?subject=ref-test-group1 |
| 45 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 46 | + |
| 47 | +############################################################################### |
| 48 | +# TEST 2: Typed reference search (regression - should work same as before) |
| 49 | +############################################################################### |
| 50 | + |
| 51 | +### 2a. Typed - Patient subject |
| 52 | +GET {{hostname}}/Encounter?subject=Patient/ref-test-patient1 |
| 53 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 54 | + |
| 55 | +### 2b. Typed - Group subject |
| 56 | +GET {{hostname}}/Encounter?subject=Group/ref-test-group1 |
| 57 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 58 | + |
| 59 | +### 2c. Typed - wrong type, should return empty |
| 60 | +GET {{hostname}}/Encounter?subject=Device/ref-test-device1 |
| 61 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 62 | + |
| 63 | +############################################################################### |
| 64 | +# TEST 3: Observation.subject (4 target types: Patient, Group, Device, Location) |
| 65 | +# Exercises wider OR expressions. |
| 66 | +############################################################################### |
| 67 | + |
| 68 | +### 3a. Untyped - Patient subject |
| 69 | +GET {{hostname}}/Observation?subject=ref-test-patient1 |
| 70 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 71 | + |
| 72 | +### 3b. Untyped - Device subject |
| 73 | +GET {{hostname}}/Observation?subject=ref-test-device1 |
| 74 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 75 | + |
| 76 | +### 3c. Untyped - Location subject |
| 77 | +GET {{hostname}}/Observation?subject=ref-test-location1 |
| 78 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 79 | + |
| 80 | +### 3d. Typed - only Device observations |
| 81 | +GET {{hostname}}/Observation?subject=Device/ref-test-device1 |
| 82 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 83 | + |
| 84 | +############################################################################### |
| 85 | +# TEST 4: Comma-separated (OR) references mixing typed and untyped |
| 86 | +# Exercises top-level OR handling + per-operand rewriting. |
| 87 | +############################################################################### |
| 88 | + |
| 89 | +### 4a. Two untyped - should find both encounters |
| 90 | +GET {{hostname}}/Encounter?subject=ref-test-patient1,ref-test-group1 |
| 91 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 92 | + |
| 93 | +### 4b. Mixed typed and untyped - should find both encounters |
| 94 | +GET {{hostname}}/Encounter?subject=Patient/ref-test-patient1,ref-test-group1 |
| 95 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 96 | + |
| 97 | +### 4c. Multiple untyped across 4 target types |
| 98 | +GET {{hostname}}/Observation?subject=ref-test-patient1,ref-test-device1,ref-test-location1 |
| 99 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 100 | + |
| 101 | +############################################################################### |
| 102 | +# TEST 5: Chained search through multi-target reference |
| 103 | +############################################################################### |
| 104 | + |
| 105 | +### 5a. Encounter where subject is a Patient named "RefTestPatient" |
| 106 | +GET {{hostname}}/Encounter?subject:Patient.family=RefTestPatient |
| 107 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 108 | + |
| 109 | +### 5b. Encounter where subject is a Group named "Test Group Alpha" |
| 110 | +GET {{hostname}}/Encounter?subject:Group.name=Test Group Alpha |
| 111 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 112 | + |
| 113 | +############################################################################### |
| 114 | +# TEST 6: _include on multi-target reference |
| 115 | +############################################################################### |
| 116 | + |
| 117 | +### 6a. Include subject on Encounter (should pull in Patient and Group) |
| 118 | +GET {{hostname}}/Encounter?_id=ref-test-encounter-patient,ref-test-encounter-group&_include=Encounter:subject |
| 119 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 120 | + |
| 121 | +### 6b. Include subject on Observation (should pull in Patient, Device, Location) |
| 122 | +GET {{hostname}}/Observation?_id=ref-test-obs-patient,ref-test-obs-device,ref-test-obs-location&_include=Observation:subject |
| 123 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 124 | + |
| 125 | +############################################################################### |
| 126 | +# TEST 7: Condition.asserter (4 target types) |
| 127 | +############################################################################### |
| 128 | + |
| 129 | +### 7a. Untyped - matches Practitioner asserter |
| 130 | +GET {{hostname}}/Condition?asserter=ref-test-practitioner1 |
| 131 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 132 | + |
| 133 | +### 7b. Untyped - matches Patient as asserter |
| 134 | +GET {{hostname}}/Condition?asserter=ref-test-patient1 |
| 135 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 136 | + |
| 137 | +### 7c. Typed asserter |
| 138 | +GET {{hostname}}/Condition?asserter=Practitioner/ref-test-practitioner1 |
| 139 | +Authorization: Bearer {{bearer.response.body.access_token}} |
| 140 | + |
| 141 | +### 7d. Comma-separated asserter |
| 142 | +GET {{hostname}}/Condition?asserter=ref-test-practitioner1,ref-test-patient1 |
| 143 | +Authorization: Bearer {{bearer.response.body.access_token}} |
0 commit comments