From c72d1f15a1b05653fd9dbbcd6c19557d1c3af66d Mon Sep 17 00:00:00 2001 From: Vladimir Buzalka Date: Thu, 13 Nov 2025 07:22:28 +0100 Subject: [PATCH] notebook --- .idea/Medevio.iml | 2 +- .idea/misc.xml | 2 +- Testy/02 Test.py | 2 +- Testy/03 Testt.py | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 Testy/03 Testt.py diff --git a/.idea/Medevio.iml b/.idea/Medevio.iml index 78fd998..3cd7809 100644 --- a/.idea/Medevio.iml +++ b/.idea/Medevio.iml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 7b70d2f..7a3c570 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/Testy/02 Test.py b/Testy/02 Test.py index ac6c4ae..c9266df 100644 --- a/Testy/02 Test.py +++ b/Testy/02 Test.py @@ -32,7 +32,7 @@ DB_CONFIG = { } # ✅ Optional: Only process requests created after this date ("" = no limit) -CREATED_AFTER = "2024-01-01" +CREATED_AFTER = "2024-12-01" GRAPHQL_QUERY_MESSAGES = r""" query UseMessages_ListMessages($requestId: String!, $updatedSince: DateTime) { diff --git a/Testy/03 Testt.py b/Testy/03 Testt.py new file mode 100644 index 0000000..78f0820 --- /dev/null +++ b/Testy/03 Testt.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import json +import requests +from pathlib import Path + +# ============================ +# CONFIG +# ============================ +TOKEN_PATH = Path("token.txt") + +# vlož libovolný existující request ID +REQUEST_ID = "3fc9b28c-ada2-4d21-ab2d-fe60ad29fd8f" + +GRAPHQL_NOTES_QUERY = r""" +query ClinicRequestNotes_Get($patientRequestId: String!) { + notes: getClinicPatientRequestNotes(requestId: $patientRequestId) { + id + content + createdAt + updatedAt + createdBy { + id + name + surname + } + } +} +""" + +# ============================ +# TOKEN +# ============================ +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 + +# ============================ +# FETCH +# ============================ +def fetch_notes(request_id, token): + url = "https://api.medevio.cz/graphql" + + headers = { + "Authorization": f"Bearer {token}", + "Content-Type": "application/json", + "Accept": "application/json", + } + + variables = {"patientRequestId": request_id} + + payload = { + "operationName": "ClinicRequestNotes_Get", + "query": GRAPHQL_NOTES_QUERY, + "variables": variables, + } + + r = requests.post(url, json=payload, headers=headers) + r.raise_for_status() + return r.json() + +# ============================ +# MAIN +# ============================ +def main(): + token = read_token(TOKEN_PATH) + + print(f"\n🔍 Fetching NOTES for request:\n ID = {REQUEST_ID}\n") + + data = fetch_notes(REQUEST_ID, token) + + print("📄 FULL RAW JSON:\n") + print(json.dumps(data, indent=2, ensure_ascii=False)) + + print("\n📝 Parsed notes:\n") + notes = data.get("data", {}).get("notes") or [] + if not notes: + print(" (no notes found)") + return + + for n in notes: + author = n.get("createdBy") + print(f"--- Note {n.get('id')} ---") + print(f"Created: {n.get('createdAt')}") + print(f"Updated: {n.get('updatedAt')}") + if author: + print(f"Author: {author.get('name')} {author.get('surname')}") + print("Content:") + print(n.get("content")) + print() + +if __name__ == "__main__": + main()