Skip to content

Commit

Permalink
MAT-6835: Display Stratifications when present on test cases.
Browse files Browse the repository at this point in the history
Include Stratifications in the Pass/Fail determinations at Pop Criteria and Test Case levels.

Add helper methods that determine if a test case's populations and stratifications pass/fail.
  • Loading branch information
jkotanchik-SB committed Jul 9, 2024
1 parent f956eb8 commit a311d65
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 21 deletions.
17 changes: 15 additions & 2 deletions service/web_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ def as_json(*args)
return { summaryReport: summary_report, individualReports: generated_reports }.to_json
end

# Helper methods for rendering the Summary Report
helpers do
def strat_fail(test_case)
if test_case["stratifications"].nil?
false
end
test_case["stratifications"].any? { |strats| strats["stratificationDtos"].find { |strat| strat["pass"] == false }}
end

def pop_fail(test_case)
test_case["populations"].any? { |pop| pop["pass"] == false }
end
end

def summary_report(patients, qrda_errors, html_errors, measure, population_results)
erb "top_level_summary".to_sym, {}, {
measure: ,
Expand All @@ -129,7 +143,6 @@ def summary_report(patients, qrda_errors, html_errors, measure, population_resul
}
end


get "/api/health" do
puts "QRDA Export Service is up"
"QRDA Export Service is up"
Expand Down Expand Up @@ -253,7 +266,7 @@ def instantiate_model(model_name)
when "PhysicalExamRecommended"
return QDM::PhysicalExamRecommended.new
when "PatientCharacteristicBirthdate"
return PatientCharacteristicBirthdate.new
return QDM::PatientCharacteristicBirthdate.new
when "AdverseEvent"
return QDM::AdverseEvent.new
when "DeviceRecommended"
Expand Down
53 changes: 34 additions & 19 deletions views/top_level_summary.erb
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@
</tr>
<tr>
<%
result = pop_crit["testCaseDTOs"].find { |result| result["populations"].find {| pop | pop["pass"] == false} } ? 'fail' : 'pass'
result = pop_crit["testCaseDTOs"].any? { |test_case| pop_fail(test_case) || strat_fail(test_case)} ? 'fail' : 'pass'
%>
<td class="<%= result %>"><%= result %></td>
<% passed_count = 0 %>
<% total = pop_crit["testCaseDTOs"].length %>
<% pop_crit["testCaseDTOs"].each do |test_case| %>
<% passed_count += 1 unless test_case["populations"].find { |pop| pop["pass"] == false} %>
<% passed_count+= 1 unless (pop_fail(test_case) || strat_fail(test_case)) %>
<% end %>
<td><span class="test-case-number"><%= passed_count %></span>/<%= total %></td>
</tr>
Expand All @@ -127,48 +127,47 @@
</table>
</div>
<br>
<% pop_crit["testCaseDTOs"].each_with_index do |patient_summary, index| %>
<%# patient_result = result[1]['differences'].values.select{|difference| difference['medicalRecordNumber'] == record.qdmPatient.id.to_s}.first %>
<% pop_crit["testCaseDTOs"].each_with_index do |test_case, index| %>
<br>
<table>
<tr>
<td>
<h2>
<% result = patient_summary["populations"].find {|pop| pop["pass"] == false}.nil? ? 'pass' : 'fail' %>
<% result = (!pop_fail(test_case) && !strat_fail(test_case)) ? 'pass' : 'fail' %>
<span class="<%= result %>"><%= result %>: </span>
<% unless html_errors[patient_summary["testCaseId"]] %>
<a href="<%= File.join(".","html","#{index+1}_#{patient_summary["lastName"]}_#{patient_summary["firstName"]}.html")%>"><%=patient_summary["lastName"]%>, <%=patient_summary["firstName"]%></a>
<% unless html_errors[test_case["testCaseId"]] %>
<a href="<%= File.join(".","html","#{index+1}_#{test_case["lastName"]}_#{test_case["firstName"]}.html")%>"><%=test_case["lastName"]%>, <%=test_case["firstName"]%></a>
<% else %>
<%=patient_summary["lastName"]%>, <%=patient_summary["firstName"]%>
<%=test_case["lastName"]%>, <%=test_case["firstName"]%>
<% end %>
<% unless qrda_errors[patient_summary["testCaseId"]] %>
<a class="btn" href="<%= File.join(".","qrda","#{index+1}_#{patient_summary["lastName"]}_#{patient_summary["firstName"]}.xml")%>">qrda</a>
<% unless qrda_errors[test_case["testCaseId"]] %>
<a class="btn" href="<%= File.join(".","qrda","#{index+1}_#{test_case["lastName"]}_#{test_case["firstName"]}.xml")%>">qrda</a>
<% end %>
</h2>
</td>
</tr>
</table>
<% if qrda_errors[patient_summary["testCaseId"]] %>
<% if qrda_errors[test_case["testCaseId"]] %>
<div class="error">
<span class="important">There was an error exporting the QRDA for this Test Case:</span>
<% data_criteria = qrda_errors[patient_summary["testCaseId"]].data_criteria rescue nil %>
<% data_criteria = qrda_errors[test_case["testCaseId"]].data_criteria rescue nil %>
<% if data_criteria %>
<span class="important">could not generate appropriate QRDA content for <%= data_criteria.description %></span>
<span class="secondary">(<%= qrda_errors[patient_summary["testCaseId"]].message %>)</span>
<span class="secondary">(<%= qrda_errors[test_case["testCaseId"]].message %>)</span>
<% else %>
<%= qrda_errors[patient_summary["testCaseId"]].message %>
<%= qrda_errors[test_case["testCaseId"]].message %>
<% end %>
</div>
<% end %>
<% if html_errors[patient_summary["testCaseId"]] %>
<% if html_errors[test_case["testCaseId"]] %>
<div class="error">
<span class="important">There was an error exporting the HTML for this Test Case:</span>
<% data_criteria = html_errors[patient_summary["testCaseId"]].data_criteria rescue nil %>
<% data_criteria = html_errors[test_case["testCaseId"]].data_criteria rescue nil %>
<% if data_criteria %>
<span class="important">could not generate appropriate HTML content for <%= data_criteria.description %></span>
<span class="secondary">(<%= html_errors[patient_summary["testCaseId"]].message %>)</span>
<span class="secondary">(<%= html_errors[test_case["testCaseId"]].message %>)</span>
<% else %>
<%= html_errors[patient_summary["testCaseId"]].message %>
<%= html_errors[test_case["testCaseId"]].message %>
<% end %>
</div>
<% end %>
Expand All @@ -179,7 +178,7 @@
<th>Expected</th>
<th>Actual</th>
</tr>
<% patient_summary["populations"].each do |pop| %>
<% test_case["populations"].each do |pop| %>
<% pop["name"] = 'OBSERV_1' if pop["name"] == 'OBSERV'%>
<tr>
<% if pop["pass"] %>
Expand All @@ -192,6 +191,22 @@
<td><%= pop["actual"] %><%= pop["unit"] %></td>
</tr>
<% end %>
<% unless test_case["stratifications"].empty? %>
<% test_case["stratifications"].each do |strats| %>
<% strats["stratificationDtos"].each do |strat| %>
<tr>
<% if strat["pass"] %>
<td class="pass">&#10003;</td>
<% else %>
<td class="fail">&times;</td>
<% end %>
<td><%= population_abbr[strat["name"]].nil? ? strat["name"] : population_abbr[strat["name"]] %></td>
<td><%= strat["expected"] %><%= strat["unit"] %></td>
<td><%= strat["actual"] %><%= strat["unit"] %></td>
</tr>
<% end %>
<% end %>
<% end %>
</table>
<% end %>
<br><br>
Expand Down

0 comments on commit a311d65

Please sign in to comment.