This commit is contained in:
2025-11-13 07:22:28 +01:00
parent 32b728006e
commit c72d1f15a1
4 changed files with 99 additions and 3 deletions

View File

@@ -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) {

96
Testy/03 Testt.py Normal file
View File

@@ -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()