notebook
This commit is contained in:
58
10ReadPozadavky/0701 test.py
Normal file
58
10ReadPozadavky/0701 test.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import requests
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
TOKEN_PATH = Path("token.txt")
|
||||
REQUEST_ID = "092a0c63-28be-4c6b-ab3b-204e1e2641d4"
|
||||
|
||||
def read_token(p: Path) -> str:
|
||||
tok = p.read_text(encoding="utf-8").strip()
|
||||
if tok.startswith("Bearer "):
|
||||
tok = tok.split(" ", 1)[1]
|
||||
return tok
|
||||
|
||||
GRAPHQL_QUERY = r"""
|
||||
query ClinicRequestDetail_GetPatientRequest2(
|
||||
$requestId: UUID!,
|
||||
$isDoctor: Boolean!
|
||||
) {
|
||||
patientRequestMedicalRecords: listMedicalRecordsForPatientRequest(
|
||||
attachmentTypes: [ECRF_FILL_ATTACHMENT, MESSAGE_ATTACHMENT, PATIENT_REQUEST_ATTACHMENT]
|
||||
patientRequestId: $requestId
|
||||
pageInfo: {first: 100, offset: 0}
|
||||
) {
|
||||
attachmentType
|
||||
id
|
||||
medicalRecord {
|
||||
contentType
|
||||
description
|
||||
downloadUrl
|
||||
id
|
||||
url
|
||||
visibleToPatient @include(if: $isDoctor)
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
variables = {
|
||||
"isDoctor": True,
|
||||
"requestId": REQUEST_ID,
|
||||
}
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {read_token(TOKEN_PATH)}",
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}
|
||||
|
||||
payload = {
|
||||
"operationName": "ClinicRequestDetail_GetPatientRequest2",
|
||||
"query": GRAPHQL_QUERY,
|
||||
"variables": variables,
|
||||
}
|
||||
|
||||
print("📡 Querying Medevio API...\n")
|
||||
r = requests.post("https://api.medevio.cz/graphql", json=payload, headers=headers)
|
||||
print(f"HTTP status: {r.status_code}\n")
|
||||
print(json.dumps(r.json(), indent=2, ensure_ascii=False))
|
||||
Reference in New Issue
Block a user