Flusso E — Upload referto firmato su T4MED¶
Operazione: POST / (Bundle transaction)
Flusso: E — grepoServices → gt4medServices → T4MED (post-visita)
Contesto¶
Dopo che gefidServices ha firmato digitalmente il PDF unito (T4MED + MEDWARE), consegna il documento a grepoServices. grepoServices pubblica il referto sul repository aziendale (REPO) e sul FSE. Solo dopo la conferma di pubblicazione su REPO/FSE, grepoServices chiama gt4medServices per caricare il referto firmato anche su T4MED tramite un Bundle transaction contenente Binary e DocumentReference.
Ordine delle operazioni:
- gefidServices → grepoServices (PDF firmato)
- grepoServices → REPO → FSE (pubblicazione)
- grepoServices → gt4medServices → T4MED (upload, solo dopo OK da REPO/FSE)
Dati del caso di esempio¶
| Campo | Valore |
|---|---|
| T4MED Appointment ID | T00450 |
| T4MED Patient ID | 4578934 (ipotetico = cod. ospedaliero — lacuna L4) |
| Codice fiscale | RSVDMN11A41H620X |
| Paziente | ROSAVIOLA DALMINA (nome di fantasia) |
| Data televisita | 2026-06-03 |
| UniqueDocumentId | urn:uuid:e7c3f91b-8a42-4d5e-9f16-3b8c7a2e5d41 (assegnato da REPO al momento della pubblicazione) |
Conformità FHIR R4¶
Per il Flusso E l'endpoint è conforme a FHIR R4 (POST /fhir — base URL per Bundle transaction). La risposta attesa è un Bundle "transaction-response": conforme.
L'unica divergenza riguarda il campo DocumentReference.identifier:
| Elemento | Spec T4MED | FHIR R4 standard |
|---|---|---|
| Endpoint | POST /fhir |
POST /fhir (identico) |
DocumentReference.identifier |
codice fiscale del paziente [D03] | UniqueDocumentId del documento |
[D03] In FHIR R4,
DocumentReference.identifierè il business identifier del documento, non del paziente. Il paziente appartiene aDocumentReference.subject. La spec T4MED richiede invece di inserire il codice fiscale nell'identifier. Il significato di questa scelta (chiave di ricerca per il paziente? requisito del sistema T4MED?) è da chiarire con TESI — vedere lacuna L10.
Versionamento del documento¶
Il comportamento dell'identifier varia a seconda che il referto sia una prima pubblicazione, una sostituzione o un annullamento.
| Versione | Descrizione | identifier |
Meccanismo aggiuntivo |
|---|---|---|---|
| Prima pubblicazione (v1) | Nuovo referto, mai pubblicato in precedenza | UniqueDocumentId della v1 | — |
| Sostitutivo (v > 1) | Sostituisce un referto già pubblicato | UniqueDocumentId della nuova versione | relatesTo.code = "replaces" → DocumentReference originale |
| Annullativo | Revoca un referto già pubblicato | UniqueDocumentId del documento annullativo | DocumentReference.status = "entered-in-error" sull'originale (richiede PUT/PATCH) |
Punto aperto L11: la specifica T4MED per il Flusso E copre solo la prima pubblicazione. I casi di referto sostitutivo e annullativo non sono documentati e sono da chiarire con TESI prima dell'implementazione. Vedere lacuna L11.
Parte 1 — Versione conforme alla specifica T4MED¶
DocumentReference.identifier contiene il codice fiscale del paziente, come richiesto dalla spec T4MED. Non conforme a FHIR R4 per la semantica dell'identifier — vedere [D03].
Versione minima (solo i campi richiesti dalla spec T4MED)¶
REQUEST¶
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "urn:uuid:f4e72b38-9d16-4c5a-8f73-6b2e1a9d4c87",
"resource": {
"resourceType": "Binary",
"contentType": "application/pdf",
"data": "<PDF_FIRMATO_DIGITALMENTE_IN_BASE64>"
},
"request": {
"method": "POST",
"url": "Binary"
}
},
{
"fullUrl": "urn:uuid:a8c35f71-4b92-4e6d-b184-9f7e2c5a8d13",
"resource": {
"resourceType": "DocumentReference",
"status": "current",
"identifier": [
{
"system": "urn:oid:2.16.840.1.113883.2.9.4.3.2",
"value": "RSVDMN11A41H620X"
}
],
"content": [
{
"attachment": {
"contentType": "application/pdf",
"url": "urn:uuid:f4e72b38-9d16-4c5a-8f73-6b2e1a9d4c87"
}
}
]
},
"request": {
"method": "POST",
"url": "DocumentReference"
}
}
]
}
RESPONSE ATTESA¶
{
"resourceType": "Bundle",
"type": "transaction-response",
"entry": [
{
"response": {
"status": "201 Created",
"location": "Binary/<id-assegnato>"
}
},
{
"response": {
"status": "201 Created",
"location": "DocumentReference/<id-assegnato>"
}
}
]
}
Versione estesa (metadati completi — spec T4MED + buone pratiche FHIR R4)¶
DocumentReference con metadati completi: tipo documento (LOINC), paziente, data, collegamento all'appuntamento T4MED. L'identifier rimane il codice fiscale come richiesto dalla spec T4MED.
REQUEST¶
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "urn:uuid:f4e72b38-9d16-4c5a-8f73-6b2e1a9d4c87",
"resource": {
"resourceType": "Binary",
"contentType": "application/pdf",
"data": "<PDF_FIRMATO_DIGITALMENTE_IN_BASE64>"
},
"request": {
"method": "POST",
"url": "Binary"
}
},
{
"fullUrl": "urn:uuid:a8c35f71-4b92-4e6d-b184-9f7e2c5a8d13",
"resource": {
"resourceType": "DocumentReference",
"status": "current",
"identifier": [
{
"system": "urn:oid:2.16.840.1.113883.2.9.4.3.2",
"value": "RSVDMN11A41H620X"
}
],
"type": {
"coding": [
{
"system": "http://loinc.org",
"code": "11488-4",
"display": "Consult note"
}
]
},
"subject": {
"reference": "Patient/4578934",
"display": "ROSAVIOLA DALMINA"
},
"date": "2026-06-03T11:00:00+02:00",
"content": [
{
"attachment": {
"contentType": "application/pdf",
"url": "urn:uuid:f4e72b38-9d16-4c5a-8f73-6b2e1a9d4c87",
"title": "Referto televisita nefrologica - 03/06/2026"
}
}
],
"context": {
"related": [
{
"reference": "Appointment/T00450"
}
]
}
},
"request": {
"method": "POST",
"url": "DocumentReference"
}
}
]
}
RESPONSE ATTESA¶
{
"resourceType": "Bundle",
"type": "transaction-response",
"entry": [
{
"response": {
"status": "201 Created",
"location": "Binary/<id-assegnato>"
}
},
{
"response": {
"status": "201 Created",
"location": "DocumentReference/<id-assegnato>"
}
}
]
}
Parte 2 — Versione conforme a FHIR R4 standard¶
DocumentReference.identifier contiene il UniqueDocumentId del referto (assegnato da REPO al momento della pubblicazione). Il paziente è identificato tramite subject, non tramite identifier. Questa versione è semanticamente corretta rispetto a FHIR R4 ma diverge dalla spec T4MED — vedere [D03] e lacuna L10.
Prima pubblicazione (versione 1)¶
REQUEST¶
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "urn:uuid:f4e72b38-9d16-4c5a-8f73-6b2e1a9d4c87",
"resource": {
"resourceType": "Binary",
"contentType": "application/pdf",
"data": "<PDF_FIRMATO_DIGITALMENTE_IN_BASE64>"
},
"request": {
"method": "POST",
"url": "Binary"
}
},
{
"fullUrl": "urn:uuid:a8c35f71-4b92-4e6d-b184-9f7e2c5a8d13",
"resource": {
"resourceType": "DocumentReference",
"status": "current",
"identifier": [
{
"system": "urn:ietf:rfc:3986",
"value": "urn:uuid:e7c3f91b-8a42-4d5e-9f16-3b8c7a2e5d41"
}
],
"type": {
"coding": [
{
"system": "http://loinc.org",
"code": "11488-4",
"display": "Consult note"
}
]
},
"subject": {
"reference": "Patient/4578934",
"display": "ROSAVIOLA DALMINA"
},
"date": "2026-06-03T11:00:00+02:00",
"content": [
{
"attachment": {
"contentType": "application/pdf",
"url": "urn:uuid:f4e72b38-9d16-4c5a-8f73-6b2e1a9d4c87",
"title": "Referto televisita nefrologica - 03/06/2026"
}
}
],
"context": {
"related": [
{
"reference": "Appointment/T00450"
}
]
}
},
"request": {
"method": "POST",
"url": "DocumentReference"
}
}
]
}
RESPONSE ATTESA¶
{
"resourceType": "Bundle",
"type": "transaction-response",
"entry": [
{
"response": {
"status": "201 Created",
"location": "Binary/<id-assegnato>"
}
},
{
"response": {
"status": "201 Created",
"location": "DocumentReference/<id-assegnato>"
}
}
]
}
Referto sostitutivo (versione N > 1) — PUNTO APERTO L11¶
Punto aperto: questo scenario non è coperto dalla specifica T4MED. Il messaggio seguente illustra come andrebbe strutturato secondo FHIR R4 standard, ma non può essere implementato prima della conferma da parte di TESI — vedere lacuna L11.
Il referto sostitutivo ha un nuovo identifier (UniqueDocumentId della versione N) e dichiara esplicitamente di sostituire il documento precedente tramite relatesTo.
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "urn:uuid:b2d84a19-5c73-4f8e-a291-7c4b9e3d6f52",
"resource": {
"resourceType": "Binary",
"contentType": "application/pdf",
"data": "<PDF_SOSTITUTIVO_FIRMATO_IN_BASE64>"
},
"request": {
"method": "POST",
"url": "Binary"
}
},
{
"fullUrl": "urn:uuid:d5f92c38-1b64-4a7e-8c35-2e9d8f4b7a61",
"resource": {
"resourceType": "DocumentReference",
"status": "current",
"identifier": [
{
"system": "urn:ietf:rfc:3986",
"value": "urn:uuid:d5f92c38-1b64-4a7e-8c35-2e9d8f4b7a61"
}
],
"relatesTo": [
{
"code": "replaces",
"target": {
"reference": "DocumentReference/<id-t4med-del-documento-originale>"
}
}
],
"type": {
"coding": [
{
"system": "http://loinc.org",
"code": "11488-4",
"display": "Consult note"
}
]
},
"subject": {
"reference": "Patient/4578934",
"display": "ROSAVIOLA DALMINA"
},
"date": "2026-06-03T14:30:00+02:00",
"content": [
{
"attachment": {
"contentType": "application/pdf",
"url": "urn:uuid:b2d84a19-5c73-4f8e-a291-7c4b9e3d6f52",
"title": "Referto televisita nefrologica - 03/06/2026 (sostitutivo)"
}
}
],
"context": {
"related": [
{
"reference": "Appointment/T00450"
}
]
}
},
"request": {
"method": "POST",
"url": "DocumentReference"
}
}
]
}
Referto annullativo — PUNTO APERTO L11¶
Punto aperto: questo scenario non è coperto dalla specifica T4MED. Il meccanismo FHIR R4 standard prevede un
PUTsulDocumentReferenceoriginale già caricato su T4MED, impostandostatus = "entered-in-error". Questo richiede che gt4medServices abbia memorizzato il T4MED DocumentReference ID restituito al momento dell'upload originale. Da chiarire con TESI — vedere lacuna L11.
PUT https://api.t4med.it/fhir/DocumentReference/<id-t4med-del-documento-originale>
Content-Type: application/fhir+json
Authorization: ApiKey <api-key>
{
"resourceType": "DocumentReference",
"id": "<id-t4med-del-documento-originale>",
"status": "entered-in-error",
"identifier": [
{
"system": "urn:ietf:rfc:3986",
"value": "urn:uuid:e7c3f91b-8a42-4d5e-9f16-3b8c7a2e5d41"
}
],
"content": [
{
"attachment": {
"contentType": "application/pdf",
"url": "Binary/<id-t4med-del-binary-originale>"
}
}
]
}