-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve and Approve operation implementation (#675)
* #641: added resolve operation, updated constants, updated ra.evaluate-measure operation and tests, updated evidence status date extension * #641: Added closure request test and fixed MR group update logic * #641: added invalidation and creation tests * #641: Added creation error and precondition tests and logic - added ordering to tests and updated dates to ensure the correct bundle is being fetched * RA Approve operation implementation (#669) * Added Composition.author as a Bundle.entry to prevent error in building IG (document type Bundle requires Composition.author to be an entry) Added fullUrl values for all Bundle.entry to prevent errors in building IG (document type Bundle requires fullUrl) Removed http://hl7.org/fhir/us/davinci-ra/StructureDefinition/ra-groupReference extension from the DetectedIssue.detail to prevent errors in building IG (extension not valid for that element) Updated profile for Composition to match IG * Updated the id for remediate bundle Fixed bug with getting remediate issues Fixed bug where updating the DetectedIssue detail references to remove the group extension was removing the group extension from the MR Updated DetectedIssue.code to be the HCC code * Updated report profile to fix errors in IG (the Bundle profile was being used instead of the MR profile) Added author to Bundle.entry for remediate and resolve to fix errors in IG (Composition.author is required to be in the Bundle when the type is document) Updated evaluate to use the bundle profile instead of the mr profile * #662: implemented approve operation logic and tests - fixed build * Fixing build and tests * Update tests to account for author Organization * Add required Composition.author and Organization to fix tests * Fix error message for missing Composition.author * Protect the Composition author value * Added protection for creating fullUrls Increased test counts to account for updates to RA operations Added ids to test resources to fix tests * applied feedback * applied feedback - fixed tests * #670: fixed resolve operation precondition chek and updated tests * Undo unintentional update of launch file Co-authored-by: rob-reynolds <rob@alphora.com> Co-authored-by: Jonathan Percival <jonathan.i.percival@gmail.com> Co-authored-by: rob-reynolds <rob@alphora.com>
- Loading branch information
1 parent
96ce3ed
commit e6cf0c1
Showing
28 changed files
with
6,165 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
plugin/ra/src/main/java/org/opencds/cqf/ruler/ra/r4/ApproveProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package org.opencds.cqf.ruler.ra.r4; | ||
|
||
import static org.opencds.cqf.cql.evaluator.fhir.util.r4.Parameters.parameters; | ||
import static org.opencds.cqf.cql.evaluator.fhir.util.r4.Parameters.part; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import org.hl7.fhir.exceptions.FHIRException; | ||
import org.hl7.fhir.instance.model.api.IPrimitiveType; | ||
import org.hl7.fhir.r4.model.Bundle; | ||
import org.hl7.fhir.r4.model.Composition; | ||
import org.hl7.fhir.r4.model.DetectedIssue; | ||
import org.hl7.fhir.r4.model.MeasureReport; | ||
import org.hl7.fhir.r4.model.Parameters; | ||
import org.hl7.fhir.r4.model.Resource; | ||
import org.opencds.cqf.ruler.behavior.ResourceCreator; | ||
import org.opencds.cqf.ruler.behavior.r4.ParameterUser; | ||
import org.opencds.cqf.ruler.provider.DaoRegistryOperationProvider; | ||
import org.opencds.cqf.ruler.ra.RAConstants; | ||
import org.opencds.cqf.ruler.utility.Operations; | ||
|
||
import ca.uhn.fhir.model.api.annotation.Description; | ||
import ca.uhn.fhir.rest.annotation.Operation; | ||
import ca.uhn.fhir.rest.annotation.OperationParam; | ||
import ca.uhn.fhir.rest.api.server.RequestDetails; | ||
|
||
public class ApproveProvider extends DaoRegistryOperationProvider | ||
implements ParameterUser, ResourceCreator, RiskAdjustmentUser { | ||
|
||
/** | ||
* Implements the <a href= | ||
* "https://build.fhir.org/ig/HL7/davinci-ra/OperationDefinition-ra.approve-coding-gaps.html">$ra.approve-coding-gaps</a> | ||
* operation found in the | ||
* <a href="https://build.fhir.org/ig/HL7/davinci-ra/index.html">Da Vinci Risk | ||
* Adjustment IG</a>. | ||
* | ||
* @param requestDetails metadata about the current request being processed. | ||
* Generally auto-populated by the HAPI FHIR server | ||
* framework. | ||
* @param periodStart the start of the clinical evaluation period | ||
* @param periodEnd the end of the clinical evaluation period | ||
* @param subject a Patient or Patient Group | ||
* @param measureId the id of a Measure resource | ||
* @param measureIdentifier the identifier of a Measure resource | ||
* @param measureUrl the url of a Measure resource | ||
* @return a Parameters with <a href= | ||
* "http://build.fhir.org/ig/HL7/davinci-ra/StructureDefinition-ra-coding-gap-bundle.html">Risk | ||
* Adjustment Coding Gap Bundles</a> | ||
*/ | ||
@Description(shortDefinition = "$ra.approve-coding-gaps operation", value = "Implements the <a href=\"https://build.fhir.org/ig/HL7/davinci-ra/OperationDefinition-ra.approve-coding-gaps.html\">$ra.approve-coding-gaps</a> operation found in the <a href=\"https://build.fhir.org/ig/HL7/davinci-ra/index.html\">Da Vinci Risk Adjustment IG</a>.") | ||
@Operation(name = "$ra.approve-coding-gaps", idempotent = true, type = MeasureReport.class) | ||
public Parameters approve( | ||
RequestDetails requestDetails, | ||
@OperationParam(name = RAConstants.PERIOD_START, typeName = "date") IPrimitiveType<Date> periodStart, | ||
@OperationParam(name = RAConstants.PERIOD_END, typeName = "date") IPrimitiveType<Date> periodEnd, | ||
@OperationParam(name = RAConstants.SUBJECT) String subject, | ||
@OperationParam(name = RAConstants.MEASURE_ID) List<String> measureId, | ||
@OperationParam(name = RAConstants.MEASURE_IDENTIFIER) List<String> measureIdentifier, | ||
@OperationParam(name = RAConstants.MEASURE_URL) List<String> measureUrl) throws FHIRException { | ||
try { | ||
validateParameters(requestDetails); | ||
} catch (Exception e) { | ||
return parameters(part(RAConstants.INVALID_PARAMETERS_NAME, | ||
generateIssue(RAConstants.INVALID_PARAMETERS_SEVERITY, e.getMessage()))); | ||
} | ||
|
||
List<Bundle> codingGapReportBundles = new ArrayList<>(); | ||
getPatientListFromSubject(subject).forEach( | ||
patient -> { | ||
Bundle b = getMostRecentCodingGapReportBundle(subject, normalizeMeasureReference( | ||
measureId, measureIdentifier, measureUrl), periodStart.getValue(), periodEnd.getValue()); | ||
MeasureReport mr = getReportFromBundle(b); | ||
Composition composition = getCompositionFromBundle(b); | ||
List<DetectedIssue> issues = getMostRecentIssuesFromBundle(b); | ||
updateDetectedIssueStatusByCode(issues); | ||
Resource author = getAuthorFromBundle(b, composition); | ||
codingGapReportBundles.add( | ||
buildCodingGapReportBundle(requestDetails.getFhirServerBase(), composition, issues, mr, author)); | ||
}); | ||
|
||
Parameters result = newResource(Parameters.class, RAConstants.APPROVE_ID_PREFIX + UUID.randomUUID()); | ||
|
||
for (Bundle codingGapReportBundle : codingGapReportBundles) { | ||
result.addParameter(part(RAConstants.RETURN_PARAM_NAME, codingGapReportBundle)); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
@Override | ||
public void validateParameters(RequestDetails requestDetails) { | ||
Operations.validateCardinality(requestDetails, RAConstants.PERIOD_START, 1); | ||
Operations.validateCardinality(requestDetails, RAConstants.PERIOD_END, 1); | ||
Operations.validateCardinality(requestDetails, RAConstants.SUBJECT, 1); | ||
Operations.validatePeriod(requestDetails, RAConstants.PERIOD_START, RAConstants.PERIOD_END); | ||
Operations.validateSingularPattern(requestDetails, RAConstants.SUBJECT, | ||
Operations.PATIENT_OR_GROUP_REFERENCE); | ||
Operations.validateAtLeastOne(requestDetails, RAConstants.MEASURE_ID, | ||
RAConstants.MEASURE_IDENTIFIER, RAConstants.MEASURE_URL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.