Skip to content

Commit 2c81e3f

Browse files
committed
MSC4302: Exchanging FHIR resources via Matrix events
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
1 parent 5beaf2e commit 2c81e3f

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

proposals/4302-🔥-resources.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# MSC4302: Exchanging FHIR resources via Matrix events
2+
3+
[FHIR] (pronounced 🔥) is a globally established standard for exchanging healthcare information
4+
electronically. The base building block of FHIR are so called resources, such as [`Patient`]. These
5+
resources can be serialised into JSON or XML which allows them to be transmitted via the [`m.file`]
6+
message type. This is insufficient, however, because a generic MIME type of `application/xml` or
7+
`application/json` doesn't let clients recognise the content as FHIR before downloading it. The
8+
`m.file` mechanism also doesn't allow clients to infer any details about the types of resources
9+
contained in the file ahead of downloading it. Furthermore, in many cases FHIR resources are small
10+
enough to be inlined into Matrix events which significantly simplifies client-side processing.
11+
12+
This proposal introduces an event type for transmitting FHIR resources and type information over
13+
Matrix in either inlined or uploaded form.
14+
15+
## Proposal
16+
17+
A new event type `m.fhir.resource` is introduced with the following properties in `content`:
18+
19+
- `canonical_url` (string, required): The resource's [canonical URL], that is the globally unique
20+
identifier defining its schema. MAY contain a version suffix separated by `|` as per the FHIR
21+
specification.
22+
- `m.fhir.resource` (object): The serialised JSON if it fits within the [64 KiB event size limit].
23+
Required if `m.file` is missing.
24+
- `m.file` (object): An [MSC3551] content block describing an uploaded JSON or XML serialisation of
25+
the resource if it is too large to be inlined. Required if `m.fhir.resource` is missing.
26+
27+
``` json5
28+
{
29+
"type": "m.fhir.resource",
30+
"content": {
31+
"canonical_url": "http://hl7.org/fhir/patient.html|4.0.1",
32+
"m.fhir.resource": {
33+
"resourceType" : "Patient",
34+
"name" : [{
35+
"use" : "official",
36+
"given" : ["John", "James"],
37+
"family" : "Doe"
38+
}],
39+
"gender" : "male",
40+
"birthDate" : "1970-01-01",
41+
// further properties as per the Patient schema
42+
},
43+
"m.file": {
44+
"url": "mxc://example.org/abcd1234",
45+
"mimetype": "application/json",
46+
// further properties as per MSC3551
47+
}
48+
}
49+
```
50+
51+
## Potential issues
52+
53+
FHIR includes generic resources such as [`Bundle`] which wrap other resources. The `canonical_url`
54+
will not help clients understand the wrapped content without downloading it in these cases.
55+
Dedicated event types may be introduced in future to cater to these situations.
56+
57+
## Alternatives
58+
59+
A dedicated MIME type such as `application/fhir+xml` would allow clients to recognise an uploaded
60+
file as FHIR ahead of the download. It would not provide clients with information about the types of
61+
contained resources, however. Since FHIR supports a vast number of resources it doesn't appear
62+
practical to introduce dedicated mimetypes per resource, version and serialisation format
63+
64+
## Security considerations
65+
66+
None.
67+
68+
## Unstable prefix
69+
70+
While this MSC is not considered stable, the event type `m.fhir.resource` should be referred to as
71+
`de.gematik.msc4302.fhir.resource`.
72+
73+
## Dependencies
74+
75+
None.
76+
77+
[FHIR]: https://hl7.org/fhir/
78+
[`Patient`]: http://hl7.org/fhir/R4/patient.html
79+
[`m.file`]: https://spec.matrix.org/v1.14/client-server-api/#mfile
80+
[canonical URL]: https://build.fhir.org/references.html#canonical
81+
[64 KiB event size limit]: https://spec.matrix.org/v1.14/client-server-api/#size-limits
82+
[MSC3551]: https://github.com/matrix-org/matrix-spec-proposals/pull/3551
83+
[`Bundle`]: http://hl7.org/fhir/StructureDefinition/Bundle

0 commit comments

Comments
 (0)