Skip to content

Commit 0352297

Browse files
committed
Document match score extensions
1 parent 5ba24ac commit 0352297

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

docs/match-operation.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ stable tie-breaker. If no candidate passes, the response is an empty searchset.
102102
The response is a FHIR Bundle of type `searchset`. Each entry includes:
103103

104104
- `resource` — the matched FHIR resource
105-
- `search.score`raw match weight
106-
- `search.normalizedScore` — probability-like score from 0 to 1 derived from the
107-
match weight
108-
- `search.extension`match grade (`certain`, `probable`, or `possible`)
105+
- `search.score`probability-like FHIR search score from 0 to 1 derived from
106+
the raw match weight
107+
- `search.extension`match grade (`certain`, `probable`, or `possible`), raw
108+
match weight, and per-feature match details
109109

110110
```json
111111
{
@@ -122,12 +122,23 @@ The response is a FHIR Bundle of type `searchset`. Each entry includes:
122122
},
123123
"search": {
124124
"mode": "match",
125-
"score": 12.4,
126-
"normalizedScore": 0.9998,
125+
"score": 0.9998,
127126
"extension": [
128127
{
129128
"url": "http://hl7.org/fhir/StructureDefinition/match-grade",
130129
"valueCode": "certain"
130+
},
131+
{
132+
"url": "https://mdmbox.health-samurai.io/fhir/StructureDefinition/match-weight",
133+
"valueDecimal": 12.4
134+
},
135+
{
136+
"url": "https://mdmbox.health-samurai.io/fhir/StructureDefinition/match-details",
137+
"extension": [
138+
{"url": "given", "valueDecimal": 4.5},
139+
{"url": "family", "valueDecimal": 5.1},
140+
{"url": "birthDate", "valueDecimal": 2.8}
141+
]
131142
}
132143
]
133144
}
@@ -140,10 +151,12 @@ The response is a FHIR Bundle of type `searchset`. Each entry includes:
140151
For large datasets, create database indexes on columns used in matching model blocks. Without indexes, `$match` performs a full table scan for each block, which can be very slow.
141152
{% endhint %}
142153

143-
## Score calculation
154+
## Weight and score calculation
144155

145-
Match scores are log2 Bayes factor sums, converted to probabilities using a sigmoid function:
156+
Match weights are log2 Bayes factor sums. MDMbox exposes the raw weight in the
157+
`https://mdmbox.health-samurai.io/fhir/StructureDefinition/match-weight`
158+
extension and converts it to `search.score` using a sigmoid function:
146159

147160
`probability = 1 / (1 + 2^(-weight))`
148161

149-
A weight of 25 corresponds to a probability of ~0.99999997. See [Mathematical details](mathematical-details.md) for the full derivation.
162+
See [Mathematical details](mathematical-details.md) for the full derivation.

0 commit comments

Comments
 (0)