projecttacoma / fqm-execution

fqm-execution is a library that allows users to calculate FHIR-based electronic Clinical Quality Measures (eCQMs) and retrieve the results in a variety of formats
https://projecttacoma.github.io/fqm-execution/
Apache License 2.0
18 stars 6 forks source link

Human readable pretty statement results for FHIR #257

Closed lmd59 closed 1 year ago

lmd59 commented 1 year ago

Summary

Previously, statement results for FHIR would default to json-like appearances for objects. They now show the most relevant fields for FHIR objects and use mappings to identify more useful information and labels (such as displays for code systems and relevant path properties).

New behavior

Statement results have improved pretty field for results that are objects or codes

Code changes

Testing guidance

Play around with different calculations with interesting FHIR results. Some examples are included in the integration tests:

Screen Shot 2023-06-21 at 2 40 46 PM Screen Shot 2023-06-21 at 2 45 54 PM
github-actions[bot] commented 1 year ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟒 Statements
85.95% (-0.37% πŸ”»)
2307/2684
🟑 Branches
72.97% (-2.55% πŸ”»)
2122/2908
🟒 Functions
89.1% (-0.33% πŸ”»)
425/477
🟒 Lines
86.28% (-0.36% πŸ”»)
2227/2581
Show new covered files 🐣
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------- | :--------- | :------- | :-------- | :---- | | 🟒 |
`...` / system-map.ts
| 100% | 100% | 100% | 100% | | 🟒 |
`...` / codePaths.ts
| 100% | 100% | 100% | 100% |
Show files with reduced coverage πŸ”»
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------- | :------------------------------------------------------------- | :-------------------------------------------------------------- | :------------------------------------------------------------ | :------------------------------------------------------------- | | 🟑 |
`...` / ClauseResultsBuilder.ts
|
74.32% (-1.39% πŸ”»)
|
49.75% (-14.78% πŸ”»)
|
87.8% (-4.09% πŸ”»)
|
74.17% (-1.15% πŸ”»)
|

Test suite run success

431 tests passing in 31 suites.

Report generated by πŸ§ͺjest coverage report action from 9d411923f75d3c634d6c90d47842477f1e392295

mgramigna commented 1 year ago

This fails when running with an old connectathon bundle:

image

In this case, resourceType is actually Coding. Are we assuming that we always have a FHIR resource by the time we access the primaryCodePath? Or is this just identifying an edge-case that we aren't handling?

EDIT: This also happens with the ColorectalCancerScreeningsFHIR bundle in ecqm-content-r4-2021:

image

lmd59 commented 1 year ago

This fails when running with an old connectathon bundle:

image

In this case, resourceType is actually Coding. Are we assuming that we always have a FHIR resource by the time we access the primaryCodePath? Or is this just identifying an edge-case that we aren't handling?

EDIT: This also happens with the ColorectalCancerScreeningsFHIR bundle in ecqm-content-r4-2021:

image

I have this fixed, but I'm looking into some other code-like types handling based on some additional discussion with @hossenlopp .

lmd59 commented 1 year ago

Great stuff! Some small inline comments and some open questions. I tested this on all the ecqm-content-r4-2021 and connectathon measures and found two things I wasn't completely sure about:

  1. It looks like medication request looks doesn't have a space between the two words:

image

Not sure if this even matters but I thought I would point it out. Relevant measure is EXM105-8.2.000 & the numerator patient.

  1. Sometimes the observation statement pretty result isn't in square brackets. An example of it without square brackets can be seen in the DiabetesHemoglobinA1cHbA1cPoorControl9FHIR measure & denom patient (with measurementPeriodStart: 2019-01-01 and measurementPeriodEnd: 2019-12-31):

Screenshot 2023-06-27 at 12 18 33 PM

  1. MedicationRequest is the name of the resource type, which I think we receive as camel case - maybe gets a bit confusing when we all-caps it. I could potentially not capitalize the whole type, leaving it camel case. I don't think that would be too different from Bonnie, though not what I initially discussed with @hossenlopp. Would that work better?
  2. The square brackets are to indicate that it's an array, so if there are square brackets, that just means the type of the result is an array (even if it just has one item). This depends on the statement being made and what kind or results are expected from that statement calculation. We experimented a bit with getting rid of the brackets when there's just one item, but it might still be valuable for the user to know whether the type of the result is an array or not, so we left it with the brackets.
lmd59 commented 1 year ago

Nice! Great additions. Just one inline suggestion. Also, I noticed that buildStatementAndClauseResults has doPretty as a parameter, even though I think it is always set to true. Do we still want this?

Hmm- yeah looks like buildStatementAndClauseResults() is only ever called with doPretty: true. It certainly isn't hurting anything. Maybe we were thinking of making this configurable at a higher level at some point?