notebook
This commit is contained in:
2
.idea/Medevio.iml
generated
2
.idea/Medevio.iml
generated
@@ -4,7 +4,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.12 virtualenv at U:\Medevio\.venv" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.12 (Medevio)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -3,5 +3,5 @@
|
|||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.12 (Medevio)" />
|
<option name="sdkName" value="Python 3.12 (Medevio)" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 virtualenv at U:\Medevio\.venv" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (Medevio)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
||||||
@@ -32,7 +32,7 @@ DB_CONFIG = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ✅ Optional: Only process requests created after this date ("" = no limit)
|
# ✅ Optional: Only process requests created after this date ("" = no limit)
|
||||||
CREATED_AFTER = "2024-01-01"
|
CREATED_AFTER = "2024-12-01"
|
||||||
|
|
||||||
GRAPHQL_QUERY_MESSAGES = r"""
|
GRAPHQL_QUERY_MESSAGES = r"""
|
||||||
query UseMessages_ListMessages($requestId: String!, $updatedSince: DateTime) {
|
query UseMessages_ListMessages($requestId: String!, $updatedSince: DateTime) {
|
||||||
|
|||||||
96
Testy/03 Testt.py
Normal file
96
Testy/03 Testt.py
Normal 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()
|
||||||
Reference in New Issue
Block a user