{% extends 'backOffice/baseAuthenticated.html.twig' %}
{% import 'backOffice/assays/_helpers.html.twig' as assayHelpers %}
{% import 'backOffice/assayReports/_helpers.html.twig' as assayReportHelpers %}
{% set page_title = "Sample ##{ assay.sampleId }" %}
{% set body_classes = "assays-show-page" %}
{% block stylesheets %}
{{ parent() }}
{{ encore_entry_link_tags('assays') }}
{% endblock %}
{% block javascripts %}
{{ parent() }}
{{ encore_entry_script_tags('assays') }}
{% endblock %}
{% block actions %}
{% if assayData | length %}
<a class="btn btn-primary"
href="{{ path('app_backoffice_assaydata_index', {'_format': 'csv', 'assayId': assay.assayId}) }}">
Export Data
</a>
{% endif %}
{% if assay.status == constant('App\\Enum\\AssayStatus::COMPLETED')
and assay.result is not null
and assay.protocol.test.certificateTemplate is not null
%}
<a class="btn btn-primary"
href="{{ path('app_backoffice_assays_downloadreport', {'assayId': assay.assayId}) }}">
Download Report
</a>
{% if app.request.server.get('APP_ENV') == 'dev' and assay.protocol.notifySinave %}
{# This actually emmits a result communication so it's better to do it only in dev env #}
<a class="btn btn-primary"
href="{{ path('app_backoffice_assays_notifysinave', {'assayId': assay.assayId}) }}">
Notify SINAVE
</a>
{% endif %}
{% endif %}
{% endblock %}
{% block body %}
{% for label, messages in app.flashes %}
{% for message in messages %}
<div class="alert alert-{{ label }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span>
</button>
</div>
{% endfor %}
{% endfor %}
<div class="card">
<div class="card-body">
{% if assay.status == constant('App\\Enum\\AssayStatus::WAITING_CONFIRMATION') %}
<div class="alert alert-warning">
This assay is waiting lab confirmation
</div>
{% elseif assay.status == constant('App\\Enum\\AssayStatus::WAITING_RESULT') %}
<div class="alert alert-warning">
This assay is waiting result
</div>
{% endif %}
<div class="row">
<div class="col-md-6">
<strong>ID</strong> {{ assay.assayId }}
<br>
<strong>SKU</strong> {{ assay.protocol.sku }}
<br>
<strong>Batch</strong> {{ assay.batch }}
<br>
<strong>Status</strong> {{ assayHelpers.assay_status(assay) }}
<br>
<strong>Date</strong> {{ assay.createdAt | date }}
<br>
<strong>Sample ID</strong> {{ assay.sampleId }}
<br>
<strong>Device ID</strong> {{ assay.deviceId }}
<br>
<strong>Expected Entry Count</strong> {{ assay.expectedEntryCount }}
<br>
<strong>Received Entry Count</strong> {{ assay.receivedEntryCount }}
</div>
<div class="col-md-6">
<strong>Device Model</strong> {{ assay.deviceModel }}
<br>
<strong>Device Version</strong> {{ assay.deviceVersion }}
<br>
<strong>App Version</strong> {{ appVersion }}
<br>
<strong>Firmware</strong> <small>{{ assay.firmwareVersion }}</small>
<br>
<strong>Hardware</strong> {{ assay.hardwareVersion }}
<br>
<strong>Report results to</strong> {{ assay_reporter(assay.reporter) }}
</div>
</div>
<hr/>
<div class="row">
<div class="col-md-6">
{% if assay.result %}
{% set result = assay.result %}
<strong>CT Assay A</strong>
{% if result.ctAssayA is not null %}
{{ result.ctAssayA }}
{% elseif result.details.ctDataTime is defined %}
{{ result.details.ctDataTime }}
{% endif %}
{% if assay.protocol.requiresConfirmation %}
<br>
<strong>App CT Assay A</strong>
{% if result.predictedDetails.ctDataTime is defined %}
{{ result.predictedDetails.ctDataTime }}
{% endif %}
{% endif %}
<br>
<strong>Biomarker A</strong>
{{ result.biomarkerA }}
<br>
<strong>Result A</strong>
{{ assayHelpers.assay_result(result.resultA, assay.protocol.test) }}
{% if assay.protocol.requiresConfirmation %}
<br>
<strong>App Result A</strong>
{{ assayHelpers.assay_result(result.predictedResultA, assay.protocol.test) }}
{% endif %}
<br/>
<strong>Analysis Channel A</strong>
{{ assayHelpers.analysis_channel(assay.protocol.analysisChannelA) }}
<br/>
{% if result.healthAuthorityRx is not null %}
<a data-toggle="collapse" href="#healthAuthorityRx" role="button" aria-expanded="false"
aria-controls="healthAuthorityRx">
<strong>Health Authority Response <span class="fa fa-caret-down"></span></strong>
</a>
<div class="collapse" id="healthAuthorityRx">
<div class="card card-body">
{{ result.healthAuthorityRx }}
</div>
</div>
{% endif %}
{% endif %}
</div>
<div class="col-md-6">
<strong>Manual Result</strong>
{{ form_start(assayResultForm) }}
{% set resultExtra = {} %}
{% if assay.reporter is not null %}
{% set resultExtra = resultExtra | merge({
'help' : 'Assigning a manual result will report the result to '
~ assay_reporter(assay.reporter)
}) %}
{% endif %}
{{ form_row(
assayResultForm.resultA,
{
'label': false,
} | merge(resultExtra)) }}
{{ form_row(assayResultForm.submit, {'label': 'Submit Result'}) }}
{{ form_end(assayResultForm) }}
<hr>
<strong>Simulate Result</strong>
{{ form_start(analysisMethodSimulationForm) }}
{{ form_row(analysisMethodSimulationForm.analysisMethod, {'label': false}) }}
{{ form_row(analysisMethodSimulationForm.submit, {'label': 'Submit Result'}) }}
{{ form_end(analysisMethodSimulationForm) }}
</div>
</div>
<div class="row">
<div class="col-md-12">
{% if assayData | length %}
<div class="charts-container"
data-protocol="{{ assayHelpers.protocol_json(assay.protocol) }}"
data-points="{{ assayDataPoints | json_encode | e('html_attr') }}">
</div>
{% endif %}
</div>
</div>
{% if assay.reporter is not null %}
<hr/>
<div class="row">
<div class="col-md-12 d-flex">
<h3 class="flex-grow-1">Reported Results</h3>
<div class="flex-shrink-0">
<form
action="{{ path('app_backoffice_assays_notifyreporter', { 'assayId': assay.assayId }) }}"
method="post">
<button class="btn btn-primary" type="submit">
Notify {{ assay_reporter(assay.reporter) }}
</button>
</form>
</div>
</div>
<div class="col-md-12">
<table class="table table-bordered">
{% for assayReport in assayReports %}
<tr>
<td class="text-nowrap">{{ assayReport.createdAt | date }}</td>
<td class="text-nowrap">{{ assay_reporter( assayReport.reporter) }}</td>
<td class="text-nowrap">{{ assayReportHelpers.assay_report_status(assayReport) }}</td>
<td>
<div style="display: grid">
<pre>{{ assayReport.data }}</pre>
</div>
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}