In this tutorial, we’ll walk you through the steps required to use the Medicare Advantage Risk Score Calculation API. We’ll demonstrate how to send a request to the API and receive the calculated risk score using the CMS-HCC Model.
Before starting the tutorial, make sure you have:
First, import the namespace containing the models for the API in your application.
using Cortex.OpenApi.Models;
Next, create a RiskCalculationRequestModel object and populate its properties with the required demographic details and diagnosis codes.
RiskCalculationRequestModel requestModel = new RiskCalculationRequestModel
{
Demographics = new DemographicsModel
{
AgeAsOfFebPaymentYear = 65,
SexForClinicalUse = SexForClinical.Male,
DisabledStatus = false,
MedicaidEligibility = false
},
DiagnosisCodes = new List<DiagnosisCodeWithUscdiClass>
{
new DiagnosisCodeWithUscdiClass { DiagnosisCode = "E11.9", UscdiClass = "Condition" },
new DiagnosisCodeWithUscdiClass { DiagnosisCode = "I10", UscdiClass = "Condition" }
},
PaymentYear = 2023
};
Create a method called CalculateRiskScoreAsync that sends a request to the API with the RiskCalculationRequestModel object and returns the calculated risk score.
private async Task<double> CalculateRiskScoreAsync(RiskCalculationRequestModel requestModel)
{
// Replace with the actual API endpoint URL
string apiUrl = "https://api.example.com/api/risk-score";
// Serialize the request model to JSON
string jsonRequest = JsonConvert.SerializeObject(requestModel);
// Send a POST request to the API with the JSON request
using (HttpClient client = new HttpClient())
{
// Add any necessary headers (e.g., authentication)
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
// Create the HTTP content with the JSON request
HttpContent content = new StringContent(jsonRequest, Encoding.UTF8, "application/json");
// Send the request
HttpResponseMessage response = await client.PostAsync(apiUrl, content);
// Ensure the request was successful
response.EnsureSuccessStatusCode();
// Deserialize the response to a double value
string jsonResponse = await response.Content.ReadAsStringAsync();
double riskScore = JsonConvert.DeserializeObject<double>(jsonResponse);
return riskScore;
}
}
Finally, call the CalculateRiskScoreAsync method with the RiskCalculationRequestModel object and display the calculated risk score.
double riskScore = await CalculateRiskScoreAsync(requestModel);
Console.WriteLine($"Calculated Risk Score: {riskScore}");
That’s it! You’ve successfully used the Medicare Advantage Risk Score Calculation API to calculate a risk score using the CMS-HCC Model.