{% with patientstudy=study.patientstudymoduleattr_set.get %}{% with equipment=study.generalequipmentmoduleattr_set.get %}{% with psd_data=study.skindosemapresults_set.get %}
**OpenREM high dose fluoroscopy alert**

A fluoroscopy study has triggered a high dose alert. See below for details. This message has been
automatically sent by OpenREM: please do not reply as this mailbox is not monitored.

This study
	Study date:		{{ study.study_date|date:"d/m/y" }}
	Study time:		{{ study.study_time|date:"H:i" }}
	Study description:	{{ study.study_description }}
	Procedure:		{{ study.procedure_code_meaning }}
	Requested procedure:	{{ study.requested_procedure_code_meaning }}
	Patient height:		{{ patientstudy.patient_size|floatformat:2 }} m
	Patient weight:		{{ patientstudy.patient_weight|floatformat:1 }} kg

	Institution:		{{ equipment.institution_name }}
	Display name:		{{ study.generalequipmentmoduleattr_set.get.unique_equipment_name.display_name }}
	Accession number:	{{ study.accession_number }}
	Calculated peak skin dose to openSkin phantom (Gy):	{{ psd_data.peak_skin_dose|floatformat:1 }}
	OpenREM link:		{{ server_url }}/openrem/rf/{{ study.pk }}/
{% endwith %}{% for record in accumxraydose_set_all_planes %}{% with accumprojection=record.accumintegratedprojradiogdose_set.get %}
	Total DAP, {{ record.acquisition_plane.code_meaning }} (cGy.cm2):	{{ accumprojection.convert_gym2_to_cgycm2|floatformat:1 }}{% if accumprojection.convert_gym2_to_cgycm2 >= alert_levels.alert_total_dap_rf %}	(This is above the alert level of {{ alert_levels.alert_total_dap_rf|floatformat:1 }}){% endif %}
	Total dose at RP, {{ record.acquisition_plane.code_meaning }} (Gy):	{{ accumprojection.dose_rp_total|floatformat:1 }}{% if accumprojection.dose_rp_total >= alert_levels.alert_total_rp_dose_rf %}	(This is above the alert level of {{ alert_levels.alert_total_rp_dose_rf|floatformat:1 }}){% endif %}
{% endwith %}{% endfor %}
{% if alert_levels.show_accum_dose_over_delta_weeks %}
Studies from the past {{ alert_levels.accum_dose_delta_weeks }} weeks for this patient ID
	Number of studies:	{{ studies_in_week_delta.count }} ({% for each_study in studies_in_week_delta %}{{ server_url }}/openrem/rf/{{ each_study.pk }}/ {% if each_study.pk == study.pk %}- this study{% endif %}{% if not forloop.last%}, {% endif %}{% endfor %}){% with accumxraydose_set_all_planes|first as first_accumxraydose %}{% with accumprojection=first_accumxraydose.accumintegratedprojradiogdose_set.get %}
	Total DAP from all studies (cGy.cm2):	{{ accumprojection.total_dap_delta_gym2_to_cgycm2|floatformat:1 }}{% if accumprojection.total_dap_delta_gym2_to_cgycm2 >= alert_levels.alert_total_dap_rf %}	(This is above the alert level of {{ alert_levels.alert_total_dap_rf|floatformat:1 }}){% endif %}
	Total dose at RP from all studies (Gy):	{{ accumprojection.dose_rp_total_over_delta_weeks|floatformat:1 }}{% if accumprojection.dose_rp_total_over_delta_weeks >= alert_levels.alert_total_rp_dose_rf %}	(This is above the alert level of {{ alert_levels.alert_total_rp_dose_rf|floatformat:1 }}){% endif %}
{% endwith %}{% endwith %}

All studies for this patient ID from the past {{ alert_levels.accum_dose_delta_weeks }} weeks
	Date		Time	Accession number	openSkin PSD (Gy)	OpenREM link{% for each_study in studies_in_week_delta %}{% with psd_data=each_study.skindosemapresults_set.get %}
	{{ each_study.study_date|date:"d/m/y" }}	{{ each_study.study_time|date:"H:i" }}	{{ each_study.accession_number }}			{{ psd_data.peak_skin_dose|floatformat:1 }}	{{ server_url }}/openrem/rf/{{ each_study.pk }}/{% if each_study.pk == study.pk %} (This study){% endif %}{% endwith %}{% endfor %}
{% endif %}
{% endwith %}{% endwith %}
