Skip to content

Port FHIR compliance checker to C# and add compliance-status endpoint#481

Merged
aurelianware merged 2 commits intomainfrom
claude/port-fhir-compliance-checker-zffzM
Mar 15, 2026
Merged

Port FHIR compliance checker to C# and add compliance-status endpoint#481
aurelianware merged 2 commits intomainfrom
claude/port-fhir-compliance-checker-zffzM

Conversation

@aurelianware
Copy link
Owner

Port src/fhir/compliance-checker.ts to C# as Cms0057ComplianceChecker service
with full resource validation (ServiceRequest, ExplanationOfBenefit, Claim,
Patient) against CMS-0057-F Prior Authorization Rule requirements.

Add GET /fhir/compliance-status controller endpoint that returns a structured
report of which CMS-0057-F requirements are met/unmet for the current tenant:

  • Patient Access API enabled with FHIR R4
  • Provider Directory API enabled
  • Prior Authorization API with required operations
  • Payer-to-Payer data exchange configured
  • Required SMART on FHIR scopes registered

https://claude.ai/code/session_01DPvEvpu9zvaxiRoRmiYLyg

Port src/fhir/compliance-checker.ts to C# as Cms0057ComplianceChecker service
with full resource validation (ServiceRequest, ExplanationOfBenefit, Claim,
Patient) against CMS-0057-F Prior Authorization Rule requirements.

Add GET /fhir/compliance-status controller endpoint that returns a structured
report of which CMS-0057-F requirements are met/unmet for the current tenant:
- Patient Access API enabled with FHIR R4
- Provider Directory API enabled
- Prior Authorization API with required operations
- Payer-to-Payer data exchange configured
- Required SMART on FHIR scopes registered

https://claude.ai/code/session_01DPvEvpu9zvaxiRoRmiYLyg
Copilot AI review requested due to automatic review settings March 15, 2026 22:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports the existing CMS-0057-F compliance checking logic into the .NET FHIR service and adds a new endpoint intended to report a tenant’s CMS-0057-F compliance posture.

Changes:

  • Added Cms0057ComplianceChecker service to validate key FHIR R4 resources (ServiceRequest, EOB, Claim, Patient) against CMS-0057-F-oriented rules.
  • Registered the compliance checker in DI for fhir-service.
  • Added GET /fhir/compliance-status endpoint returning a structured, config-driven CMS-0057-F requirements report.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
src/services/fhir-service/Services/Cms0057ComplianceChecker.cs Introduces resource validators and reporting DTOs for CMS-0057-F-style compliance evaluation.
src/services/fhir-service/Program.cs Registers the compliance checker service in the fhir-service DI container.
src/services/fhir-service/Controllers/ComplianceController.cs Adds a new endpoint to expose a tenant compliance-status report based on configuration signals.

Comment on lines +9 to +20
/// for the current tenant — a key differentiator for CHO health plans.
/// </summary>
[Route("fhir")]
public class ComplianceController : FhirControllerBase
{
private readonly IConfiguration _config;
private readonly ICms0057ComplianceChecker _complianceChecker;

public ComplianceController(IConfiguration config, ICms0057ComplianceChecker complianceChecker)
{
_config = config;
_complianceChecker = complianceChecker;
if (!enabled)
issues.Add("Provider Directory API is not enabled");

var hasNppesIntegration = !string.IsNullOrEmpty(_config["Nppes:BaseUrl"]);
Comment on lines +143 to +152
var requiredOperations = new[] { "$submit", "$inquire" };
var supportedOperations = _config.GetSection("Cms0057:PriorAuthorizationApi:Operations")
.GetChildren().Select(c => c.Value).ToList();

if (supportedOperations.Count > 0)
{
var missing = requiredOperations.Except(supportedOperations!, StringComparer.OrdinalIgnoreCase).ToList();
if (missing.Count > 0)
issues.Add($"Missing required operations: {string.Join(", ", missing)}");
}
Comment on lines +121 to +124
if (resource.AuthoredOn is null)
issues.Add(new("warning", "MISSING_AUTHORED_ON", "ServiceRequest.authoredOn should be present for timeline tracking", Requirement: "CMS-0057-F Timeline"));
else
requiredPresent++;
Comment on lines +495 to +502
var withinUrgentWindow = hoursDiff <= 72;
var deadline = withinUrgentWindow ? "72 hours" : "7 calendar days";
var maxAllowedHours = withinUrgentWindow ? 72.0 : 168.0;
var compliant = hoursDiff <= maxAllowedHours;

return new TimelineCompliance(
Applicable: true,
Requirement: $"CMS-0057-F: Response within {deadline} for {(withinUrgentWindow ? "urgent" : "standard")} requests",
Comment on lines +11 to +30
[Route("fhir")]
public class ComplianceController : FhirControllerBase
{
private readonly IConfiguration _config;
private readonly ICms0057ComplianceChecker _complianceChecker;

public ComplianceController(IConfiguration config, ICms0057ComplianceChecker complianceChecker)
{
_config = config;
_complianceChecker = complianceChecker;
}

/// <summary>
/// GET /fhir/compliance-status
/// Returns a structured report of CMS-0057-F compliance posture for the current tenant.
/// </summary>
[HttpGet("compliance-status")]
[Produces("application/json")]
[ProducesResponseType(typeof(Cms0057ComplianceReport), 200)]
public IActionResult GetComplianceStatus()
Comment on lines +27 to +64
[HttpGet("compliance-status")]
[Produces("application/json")]
[ProducesResponseType(typeof(Cms0057ComplianceReport), 200)]
public IActionResult GetComplianceStatus()
{
var tenantId = TenantId;

var patientAccessCheck = CheckPatientAccessApi();
var providerDirectoryCheck = CheckProviderDirectoryApi();
var priorAuthCheck = CheckPriorAuthorizationApi();
var payerToPayerCheck = CheckPayerToPayerExchange();
var smartScopesCheck = CheckSmartOnFhirScopes();

var requirements = new List<Cms0057Requirement>
{
patientAccessCheck,
providerDirectoryCheck,
priorAuthCheck,
payerToPayerCheck,
smartScopesCheck
};

var metCount = requirements.Count(r => r.Met);

var report = new Cms0057ComplianceReport(
TenantId: tenantId,
OverallCompliant: requirements.All(r => r.Met),
RequirementsMet: metCount,
TotalRequirements: requirements.Count,
CompliancePercentage: (int)Math.Round(100.0 * metCount / requirements.Count),
Requirements: requirements,
AssessedAt: DateTimeOffset.UtcNow,
FhirVersion: "4.0.1",
RuleName: "CMS-0057-F",
RuleDescription: "CMS Interoperability and Prior Authorization Final Rule");

return Ok(report);
}
Comment on lines +175 to +178
if (resource.Priority == RequestPriority.Urgent)
{
uscdiClasses.Add("Clinical Notes");
requiredPresent++;
Comment on lines +511 to +520
var issues = new List<ComplianceIssue>
{
new("warning", "UNSUPPORTED_RESOURCE",
$"Resource type {resource.TypeName} is not specifically validated for CMS-0057-F")
};

return new ComplianceResult(
Compliant: true,
Issues: issues,
Warnings: [],
1. Use injected ICms0057ComplianceChecker to expose supported resource types
   in the compliance report (was unused dead code)
2. Fix NPPES config check — Program.cs supplies a default base URL, so only
   flag when explicitly disabled to avoid false negatives
3. Flag missing Prior Auth operations config as non-compliant instead of
   silently assuming all operations are supported
4. Move warning-severity items from Issues to Warnings collection consistently
   across all validators (ServiceRequest, EOB, Claim, unsupported fallback)
5. Determine urgent vs standard timeline from ServiceRequest.priority field
   instead of inferring from elapsed time since authoring
6. Add [Authorize] attribute and move endpoint to /fhir/r4/compliance-status
   so it requires authentication and SMART scope enforcement

https://claude.ai/code/session_01DPvEvpu9zvaxiRoRmiYLyg
@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Health
CloudHealthOffice.Portal 3% 4%
CloudHealthOffice.Portal 3% 4%
Summary 3% (390 / 12126) 4% (96 / 2604)

@aurelianware aurelianware merged commit c42ad9c into main Mar 15, 2026
59 checks passed
@aurelianware aurelianware deleted the claude/port-fhir-compliance-checker-zffzM branch March 15, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants