This commit is contained in:
2026-06-12 15:32:22 +02:00
parent 51ee67c7f3
commit bed5576efa
9 changed files with 1505 additions and 21 deletions
+92 -7
View File
@@ -509,7 +509,7 @@ def get_pozadavky(
try:
data = _gql("ClinicRequestList2", _POZADAVKY_QUERY, {
"clinicSlug": CLINIC_SLUG,
"queueAssignment": "ALL",
"queueAssignment": "ANY", # 2026-06-12: Medevio prejmenovalo enum ALL -> ANY
"state": stav.upper(),
"pageInfo": {"first": min(pocet, 100), "offset": offset},
"locale": "cs",
@@ -543,20 +543,21 @@ def get_pozadavky(
raise
# Pozn. 2026-06-12: Medevio změnilo schéma — argument je patientRequestId (UUID!),
# evaluationResult/substate vyžadují subfields (vynechány), tags chce onlyImportant.
_POZADAVEK_DETAIL_QUERY = """
query ClinicRequestDetail_GetPatientRequest2(
$clinicSlug: String!, $requestId: ID!, $isDoctor: Boolean!, $locale: Locale!
$clinicSlug: String!, $requestId: UUID!, $locale: Locale!
) {
request: getPatientRequest2(clinicSlug: $clinicSlug, requestId: $requestId) {
request: getPatientRequest2(clinicSlug: $clinicSlug, patientRequestId: $requestId) {
id doneAt doneBy { id name surname }
removedAt createdAt createdBy { id name surname }
displayTitle(locale: $locale) customTitle
clinicMedicalRecord clinicMedicalRecordVisibleToPatient
userNote evaluationResult
userNote
queue { id name }
substate
hasMobileApp
tags { id name }
tags(onlyImportant: false) { id name }
extendedPatient {
id name surname dob identificationNumber phone email
insuranceCompanyObject { code name shortName }
@@ -576,7 +577,6 @@ def get_pozadavek(request_id: str) -> dict:
data = _gql("ClinicRequestDetail_GetPatientRequest2", _POZADAVEK_DETAIL_QUERY, {
"clinicSlug": CLINIC_SLUG,
"requestId": request_id,
"isDoctor": True,
"locale": "cs",
})
return data.get("request") or {}
@@ -723,6 +723,91 @@ def get_pacient(patient_id: str) -> dict:
raise
# ─────────────────────────────────────────────────────────────────────────────
# ZALOŽENÍ POŽADAVKU "RECEPT NA LÉKY"
# ─────────────────────────────────────────────────────────────────────────────
# Flow ověřen 2026-06-12 (Chrome capture + živý test):
# 1. fillECRFForm — vyplní formulář ERECEPT_SIMPLEST_BEZ_DAVKOVANI,
# krok "erecept-gp-request", pole "nazev-leku" (volný text léků).
# 2. createPatientRequestWithoutReservation — založí požadavek; objeví se
# v aktivní frontě ordinace jako "Recept na léky".
# Pozor: createPatientRequest (bez "WithoutReservation") požadavek také
# vytvoří, ale NEZOBRAZÍ se v žádné frontě — nepoužívat.
RECEPT_SID = "ERECEPT_SIMPLEST_BEZ_DAVKOVANI"
RECEPT_STEP_ID = "erecept-gp-request"
RECEPT_USER_ECRF_ID = "79488e86-e9e5-47e3-8b19-7e5229427f23" # šablona kliniky
_FILL_MUTATION = """
mutation Step_FillECRFForm($input: FillECRFFormInput!) {
patientEcrfFill: fillECRFForm(input: $input) { id }
}"""
_CREATE_REQUEST_MUTATION = """
mutation PatientRequestSubmission_CreatePatientRequestWithoutReservation(
$clinicSlug: String!, $input: CreatePatientRequestWithoutReservationInput!
) {
patientRequest: createPatientRequestWithoutReservation(
clinicSlug: $clinicSlug, input: $input
) { id }
}"""
@mcp.tool()
def zaloz_pozadavek_recept(patient_id: str, leky: str, poznamka: str = "") -> dict:
"""Založí v Medeviu požadavek "Recept na léky" za pacienta.
Požadavek se objeví v aktivní frontě ordinace stejně, jako by ho pacient
založil sám v aplikaci.
Args:
patient_id: UUID pacienta (z hledej_pacienta / get_pacient).
leky: Volný text názvů léků (obsah pole "Název léků:").
poznamka: Volitelná uživatelská poznámka k požadavku (userNote).
"""
try:
fill = _gql("Step_FillECRFForm", _FILL_MUTATION, {
"input": {
"fields": [{
"checkedEnumerations": [],
"fieldName": "nazev-leku",
"value": leky,
}],
"patientId": patient_id,
"sid": RECEPT_SID,
"stepId": RECEPT_STEP_ID,
"byDoctor": False,
}
})
fill_id = fill["patientEcrfFill"]["id"]
req = _gql(
"PatientRequestSubmission_CreatePatientRequestWithoutReservation",
_CREATE_REQUEST_MUTATION,
{
"clinicSlug": CLINIC_SLUG,
"input": {
"challengeId": None,
"ecrfFillIds": [fill_id],
"medicalRecordIds": [],
"patientId": patient_id,
"userNote": poznamka,
"createdByDoctor": False,
"userECRFId": RECEPT_USER_ECRF_ID,
},
},
)
return {
"ok": True,
"request_id": req["patientRequest"]["id"],
"fill_id": fill_id,
"patient_id": patient_id,
"leky": leky,
}
except Exception:
log(f"zaloz_pozadavek_recept chyba: {traceback.format_exc()}")
raise
# ─────────────────────────────────────────────────────────────────────────────
if __name__ == "__main__":
log("MCP Medevio server spuštěn (FastMCP)")