-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Add read and search scenarios for Patient resource
Ref: #2
- Loading branch information
Showing
1 changed file
with
303 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,303 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "882164f7-7c59-4c06-a2bf-0aa33ad6aea3", | ||
"metadata": {}, | ||
"source": [ | ||
"# Read & Search Test Scenarios" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "77127db2-e748-4886-ae01-49ef604e14f4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from fhirpy import SyncFHIRClient\n", | ||
"from fhirpy.base.exceptions import OperationOutcome\n", | ||
"from collections import defaultdict" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "af105705-0061-4783-862b-70345a776905", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"SOURCE_BASE_URL = \"https://au-core.beda.software/fhir/\"\n", | ||
"DESTINATION_BASE_URL = \"http://localhost:8080/fhir/\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2cae58b2-2a7a-4897-b123-8cbb644e3404", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"source = SyncFHIRClient(SOURCE_BASE_URL)\n", | ||
"destination = SyncFHIRClient(DESTINATION_BASE_URL)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "73736c63-f1e1-4084-9953-44cf16386f9c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"resources = defaultdict(list)\n", | ||
"all_patients = source.resources(\"Patient\").fetch_all()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "75b6a6c4-9f06-479a-b962-819be2eafcf7", | ||
"metadata": {}, | ||
"source": [ | ||
"## 1 Patient\n", | ||
"### 1.1 read\n", | ||
"**Action:** FHIR client retrieves the patient resource with the Id\n", | ||
"\n", | ||
"**Precondition:** Patient has been created\n", | ||
"\n", | ||
"**Success Criteria:** Patient resource is displayed in interface (use browser to query FHIR server)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5309f452-e561-483d-bab2-613b1dead6a9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"patient = source.reference('Patient', '16054').to_resource()\n", | ||
"print(patient.serialize())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "fe65c2b4-27a4-4256-82b1-13fccc16eb10", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1.2 search: \\_id\n", | ||
"**Action:** FHIR client searches the FHIR server for patients with a given id\n", | ||
"\n", | ||
"**Precondition:** Patients with that id have been created\n", | ||
"\n", | ||
"**Success Criteria:** patients displayed in interface (use browser query to confirm)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4960abfe-a860-4a52-bd3f-5b6b7588a577", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"patients = source.resources(\"Patient\").search(_id='16054').fetch_all()\n", | ||
"print([patient.serialize() for patient in patients])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "57051207-5178-4a99-be16-38cb0a577021", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1.3 search: identifier" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4d389550-66b6-460c-94ef-79b7bf2a948c", | ||
"metadata": {}, | ||
"source": [ | ||
"**Action:** FHIR client searches the FHIR server for patients with an identifier\n", | ||
"\n", | ||
"**Precondition:** Patient with specified identifier has been created\n", | ||
"\n", | ||
"**Success Criteria:** patients displayed in interface (use browser query to confirm)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "281e9d65-f4a6-4bc3-848e-d1aed72f900d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"patients = source.resources(\"Patient\").search(_identifier='16054').fetch_all()\n", | ||
"print([patient.serialize() for patient in patients])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "c7e14960-42a9-4f4b-a7bc-5d9e6dbe18da", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1.4 search: birthdate+family\n", | ||
"**Action:** FHIR client searches the FHIR server for patients with specified family name and birthdate\n", | ||
"\n", | ||
"**Precondition:** Patients with specified family name and birthdate have been created\n", | ||
"\n", | ||
"**Success Criteria:** patients displayed in interface. (use browser query to confirm)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "947b161d-3681-48e1-b818-e1e9356d0b05", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"patients = source.resources(\"Patient\").search(birthdate='', family=\"\").fetch_all()\n", | ||
"print([patient.serialize() for patient in patients])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "80a4f97e-7e9a-41bc-9357-0d8cdb3529dc", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1.5 search: birthdate+name\n", | ||
"\n", | ||
"**Action:** FHIR client searches the FHIR server for patients with a name that match any of the string fields in the HumanName, including family, give, prefix, suffix, suffix, and/or text and birthdate\n", | ||
"\n", | ||
"**Precondition:** Patients with the specified birthdate and name name have been created\n", | ||
"\n", | ||
"**Success Criteria:** patients displayed in interface. (use browser query to confirm)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "552c6649-0e04-4f9e-a096-2396dce3febe", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"patients = source.resources(\"Patient\").search(birthdate='', name=\"\").fetch_all()\n", | ||
"print([patient.serialize() for patient in patients])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "11efbdbe-2181-444c-b53c-501c32e639dd", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1.6 search: family \n", | ||
"**Action:** FHIR client searches the FHIR server for patients with a family name\n", | ||
"\n", | ||
"**Precondition:** Patients with that family name have been created\n", | ||
"\n", | ||
"**Success Criteria:** patients displayed in interface. (use browser query to confirm)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bfcfa112-6459-44c6-bff3-b7d2e64e6b56", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"patients = source.resources(\"Patient\").search(family='').fetch_all()\n", | ||
"print([patient.serialize() for patient in patients])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "9ca70a91-53cc-4a10-9c60-6c6eb3fcee1e", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1.7 search: family+gender \n", | ||
"**Action:** FHIR client searches the FHIR server for patients with a family name and gender\n", | ||
"\n", | ||
"**Precondition:** Patients with specified family name and gender have been created\n", | ||
"\n", | ||
"**Success Criteria:** patients displayed in interface (use browser query to confirm)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "97ac6b67-5ebe-4ded-9da3-35c3ccf2d239", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"patients = source.resources(\"Patient\").search(family='', gender=\"\").fetch_all()\n", | ||
"print([patient.serialize() for patient in patients])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0fbcaa82-0400-4093-b5b0-189ef6442bea", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1.8 search: gender+name\n", | ||
"**Action:** FHIR client searches the FHIR server for patients with a name that match any of the string fields in the HumanName, including family, give, prefix, suffix, suffix, and/or text and gender\n", | ||
"\n", | ||
"**Precondition:** Patients with specified name and gender have been created\n", | ||
"\n", | ||
"**Success Criteria:** patients displayed in interface (use browser query to confirm)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "229076ce-a592-4183-b55e-0ed54286ac15", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"patients = source.resources(\"Patient\").search(gender='', name=\"\").fetch_all()\n", | ||
"print([patient.serialize() for patient in patients])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "fead8d4d-0edc-4a2b-a885-924b3e0d7c57", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1.9 search: name \n", | ||
"**Action:** FHIR client searches the FHIR server for patients with a name that match any of the string fields in the HumanName, including family, give, prefix, suffix, suffix, and/or text\n", | ||
"\n", | ||
"**Precondition:** Patients with that name have been created\n", | ||
"\n", | ||
"**Success Criteria:** patients displayed in interface. (use browser query to confirm)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8082e5d4-4fed-40c2-a3b7-62e1ec995fd9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"patients = source.resources(\"Patient\").search(name=\"\").fetch_all()\n", | ||
"print([patient.serialize() for patient in patients])" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |