OpenREM 1.0.0b2__py3-none-any.whl → 1.0.0b3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openrem/locale/de/LC_MESSAGES/django.po +1060 -1059
- openrem/locale/django.pot +973 -972
- openrem/locale/es_MX/LC_MESSAGES/django.po +1049 -1048
- openrem/locale/it/LC_MESSAGES/django.po +1044 -1043
- openrem/locale/lt/LC_MESSAGES/django.po +989 -988
- openrem/locale/nb_NO/LC_MESSAGES/django.po +985 -984
- openrem/locale/pt_BR/LC_MESSAGES/django.po +1003 -1002
- openrem/manage.py +10 -10
- openrem/openremproject/__init__.py +1 -1
- openrem/openremproject/local_settings.py.linux +128 -128
- openrem/openremproject/local_settings.py.windows +144 -144
- openrem/openremproject/local_settings.py.windows-sqlite3 +129 -129
- openrem/openremproject/settings.py +278 -278
- openrem/openremproject/urls.py +32 -32
- openrem/openremproject/wsgi.py.example +28 -28
- openrem/remapp/__init__.py +2 -2
- openrem/remapp/admin.py +31 -31
- openrem/remapp/exports/ct_export.py +780 -753
- openrem/remapp/exports/dx_export.py +817 -805
- openrem/remapp/exports/export_common.py +931 -951
- openrem/remapp/exports/export_common_pandas.py +2422 -0
- openrem/remapp/exports/exportviews.py +815 -860
- openrem/remapp/exports/mg_csv_nhsbsp.py +292 -292
- openrem/remapp/exports/mg_export.py +673 -510
- openrem/remapp/exports/nm_export.py +796 -575
- openrem/remapp/exports/rf_export.py +1418 -1431
- openrem/remapp/extractors/ct_philips.py +424 -414
- openrem/remapp/extractors/ct_toshiba.py +2116 -2108
- openrem/remapp/extractors/dx.py +1033 -952
- openrem/remapp/extractors/extract_common.py +817 -817
- openrem/remapp/extractors/import_views.py +426 -426
- openrem/remapp/extractors/mam.py +685 -672
- openrem/remapp/extractors/nm_image.py +439 -431
- openrem/remapp/extractors/ptsizecsv2db.py +368 -368
- openrem/remapp/extractors/rdsr.py +667 -654
- openrem/remapp/extractors/rdsr_methods.py +1771 -1768
- openrem/remapp/extractors/rrdsr_methods.py +630 -622
- openrem/remapp/fixtures/openskin_safelist.json +11 -11
- openrem/remapp/forms.py +2286 -2277
- openrem/remapp/interface/chart_functions.py +2412 -2393
- openrem/remapp/interface/mod_filters.py +1241 -1243
- openrem/remapp/migrations/0001_initial.py.1-0-upgrade +1043 -1043
- openrem/remapp/models.py +3418 -3407
- openrem/remapp/netdicom/dicomviews.py +681 -683
- openrem/remapp/netdicom/qrscu.py +2646 -2646
- openrem/remapp/netdicom/tools.py +134 -134
- openrem/remapp/static/css/bootstrap-theme.css +587 -587
- openrem/remapp/static/css/bootstrap-theme.min.css +4 -4
- openrem/remapp/static/css/bootstrap.css +6800 -6800
- openrem/remapp/static/css/bootstrap.min.css +4 -4
- openrem/remapp/static/css/datepicker3.css +790 -790
- openrem/remapp/static/css/jquery.qtip.min.css +2 -2
- openrem/remapp/static/css/openrem-extra.css +442 -442
- openrem/remapp/static/css/openrem.css +96 -96
- openrem/remapp/static/css/registration.css +34 -34
- openrem/remapp/static/fonts/glyphicons-halflings-regular.svg +287 -287
- openrem/remapp/static/js/bootstrap-datepicker.js +1671 -1671
- openrem/remapp/static/js/bootstrap.js +2363 -2363
- openrem/remapp/static/js/bootstrap.min.js +6 -6
- openrem/remapp/static/js/charts/chartCommonFunctions.js +75 -75
- openrem/remapp/static/js/charts/chartFullScreen.js +41 -41
- openrem/remapp/static/js/charts/ctChartAjax.js +331 -331
- openrem/remapp/static/js/charts/dxChartAjax.js +290 -290
- openrem/remapp/static/js/charts/mgChartAjax.js +144 -144
- openrem/remapp/static/js/charts/nmChartAjax.js +64 -64
- openrem/remapp/static/js/charts/plotly-2.35.2.min.js +8 -0
- openrem/remapp/static/js/charts/rfChartAjax.js +128 -128
- openrem/remapp/static/js/chroma.min.js +32 -32
- openrem/remapp/static/js/datepicker.js +5 -5
- openrem/remapp/static/js/dicom.js +115 -115
- openrem/remapp/static/js/django_reverse/reverse.js +13 -13
- openrem/remapp/static/js/formatDate.js +7 -7
- openrem/remapp/static/js/html5shiv.min.js +8 -8
- openrem/remapp/static/js/jquery-1.11.0.min.js +4 -4
- openrem/remapp/static/js/npm.js +12 -12
- openrem/remapp/static/js/respond.min.js +4 -4
- openrem/remapp/static/js/skin-dose-maps/jquery.qtip.min.js +4 -4
- openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMap3dHUDObject.js +112 -112
- openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMap3dObject.js +367 -367
- openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMap3dPersonObject.js +158 -158
- openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMapColourScaleObject.js +153 -153
- openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMapObject.js +367 -367
- openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMapping.js +584 -584
- openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMapping3d.js +255 -255
- openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMappingAjax.js +267 -212
- openrem/remapp/static/js/skin-dose-maps/three.min.js +835 -835
- openrem/remapp/static/js/sorttable.js +495 -495
- openrem/remapp/templates/base.html +253 -253
- openrem/remapp/templates/registration/changepassword.html +25 -25
- openrem/remapp/templates/registration/changepassworddone.html +12 -12
- openrem/remapp/templates/registration/login.html +42 -42
- openrem/remapp/templates/remapp/backgroundtaskmaximumrows_form.html +29 -29
- openrem/remapp/templates/remapp/base.html +1 -1
- openrem/remapp/templates/remapp/ctdetail.html +235 -235
- openrem/remapp/templates/remapp/ctfiltered.html +310 -310
- openrem/remapp/templates/remapp/dicomdeletesettings_form.html +31 -31
- openrem/remapp/templates/remapp/dicomqr.html +147 -147
- openrem/remapp/templates/remapp/dicomquerydetails.html +83 -83
- openrem/remapp/templates/remapp/dicomqueryimages.html +49 -49
- openrem/remapp/templates/remapp/dicomqueryseries.html +109 -109
- openrem/remapp/templates/remapp/dicomquerysummary.html +48 -48
- openrem/remapp/templates/remapp/dicomremoteqr_confirm_delete.html +60 -60
- openrem/remapp/templates/remapp/dicomremoteqr_form.html +32 -32
- openrem/remapp/templates/remapp/dicomstorescp_confirm_delete.html +53 -53
- openrem/remapp/templates/remapp/dicomstorescp_form.html +48 -48
- openrem/remapp/templates/remapp/dicomsummary.html +257 -257
- openrem/remapp/templates/remapp/displaychartoptions.html +184 -184
- openrem/remapp/templates/remapp/displayhomepageoptions.html +57 -57
- openrem/remapp/templates/remapp/displayname-count.html +6 -6
- openrem/remapp/templates/remapp/displayname-last-date.html +3 -3
- openrem/remapp/templates/remapp/displayname-modality.html +86 -105
- openrem/remapp/templates/remapp/displayname-skinmap.html +18 -18
- openrem/remapp/templates/remapp/displaynameupdate.html +100 -100
- openrem/remapp/templates/remapp/displaynameview.html +222 -219
- openrem/remapp/templates/remapp/dxdetail.html +176 -176
- openrem/remapp/templates/remapp/dxfiltered.html +324 -324
- openrem/remapp/templates/remapp/exports-active.html +25 -25
- openrem/remapp/templates/remapp/exports-complete.html +35 -35
- openrem/remapp/templates/remapp/exports-error.html +26 -26
- openrem/remapp/templates/remapp/exports-queue.html +18 -18
- openrem/remapp/templates/remapp/exports.html +191 -191
- openrem/remapp/templates/remapp/failed_summary_list.html +27 -27
- openrem/remapp/templates/remapp/filteredbase.html +162 -162
- openrem/remapp/templates/remapp/highdosemetricalertsettings_form.html +76 -76
- openrem/remapp/templates/remapp/home-list-modalities.html +94 -94
- openrem/remapp/templates/remapp/home.html +202 -202
- openrem/remapp/templates/remapp/list_filters.html +24 -24
- openrem/remapp/templates/remapp/mgdetail.html +160 -138
- openrem/remapp/templates/remapp/mgfiltered.html +311 -311
- openrem/remapp/templates/remapp/nmdetail.html +300 -300
- openrem/remapp/templates/remapp/nmfiltered.html +255 -255
- openrem/remapp/templates/remapp/notpatient.html +190 -190
- openrem/remapp/templates/remapp/notpatientindicators_form_base.html +81 -81
- openrem/remapp/templates/remapp/notpatientindicatorsid_confirm_delete.html +54 -54
- openrem/remapp/templates/remapp/notpatientindicatorsid_form.html +23 -23
- openrem/remapp/templates/remapp/notpatientindicatorsname_confirm_delete.html +54 -54
- openrem/remapp/templates/remapp/notpatientindicatorsname_form.html +23 -23
- openrem/remapp/templates/remapp/notpatientindicatorsname_form_base.html +85 -85
- openrem/remapp/templates/remapp/openskinsafelist_add.html +130 -130
- openrem/remapp/templates/remapp/openskinsafelist_confirm_delete.html +100 -100
- openrem/remapp/templates/remapp/openskinsafelist_form.html +207 -207
- openrem/remapp/templates/remapp/patientidsettings_form.html +83 -83
- openrem/remapp/templates/remapp/populate_summary_progress.html +83 -83
- openrem/remapp/templates/remapp/populate_summary_progress_error.html +36 -36
- openrem/remapp/templates/remapp/review_failed_imports.html +157 -157
- openrem/remapp/templates/remapp/review_failed_study.html +41 -41
- openrem/remapp/templates/remapp/review_studies_delete_button.html +20 -20
- openrem/remapp/templates/remapp/review_study.html +19 -19
- openrem/remapp/templates/remapp/review_summary_list.html +245 -245
- openrem/remapp/templates/remapp/rf_dose_alert_email_template.html +14 -1
- openrem/remapp/templates/remapp/rfalertnotificationsview.html +59 -59
- openrem/remapp/templates/remapp/rfdetail.html +547 -543
- openrem/remapp/templates/remapp/rfdetailbase.html +18 -18
- openrem/remapp/templates/remapp/rffiltered.html +404 -404
- openrem/remapp/templates/remapp/sizeimports.html +119 -119
- openrem/remapp/templates/remapp/sizeprocess.html +96 -96
- openrem/remapp/templates/remapp/sizeupload.html +110 -110
- openrem/remapp/templates/remapp/skindosemapcalcsettings_form.html +28 -28
- openrem/remapp/templates/remapp/standardname-modality.html +69 -69
- openrem/remapp/templates/remapp/standardnames_confirm_delete.html +71 -71
- openrem/remapp/templates/remapp/standardnames_form.html +87 -87
- openrem/remapp/templates/remapp/standardnamesettings_form.html +41 -41
- openrem/remapp/templates/remapp/standardnamesrefreshall.html +92 -92
- openrem/remapp/templates/remapp/standardnameview.html +103 -103
- openrem/remapp/templates/remapp/study_confirm_delete.html +147 -147
- openrem/remapp/templates/remapp/task_admin.html +265 -265
- openrem/remapp/templates/remapp/tasks.html +76 -76
- openrem/remapp/templatetags/formfilters.py +13 -13
- openrem/remapp/templatetags/proper_paginate.py +38 -38
- openrem/remapp/templatetags/remappduration.py +36 -36
- openrem/remapp/templatetags/sigdig.py +38 -38
- openrem/remapp/templatetags/sort_class_property_value.py +15 -15
- openrem/remapp/templatetags/update_variable.py +20 -20
- openrem/remapp/templatetags/url_replace.py +25 -25
- openrem/remapp/tests/test_charts_common.py +202 -202
- openrem/remapp/tests/test_charts_ct.py +7111 -7111
- openrem/remapp/tests/test_charts_dx.py +3513 -3513
- openrem/remapp/tests/test_charts_mg.py +1116 -1115
- openrem/remapp/tests/test_dcmdatetime.py +189 -189
- openrem/remapp/tests/test_dicom_qr.py +2580 -2580
- openrem/remapp/tests/test_display_name.py +274 -274
- openrem/remapp/tests/test_export_ct_xlsx.py +272 -248
- openrem/remapp/tests/test_export_dx_xlsx.py +137 -134
- openrem/remapp/tests/test_export_mammo_csv.py +242 -242
- openrem/remapp/tests/test_export_rf_xlsx.py +246 -246
- openrem/remapp/tests/test_files/DX-Im-DRGEM.dcm +0 -0
- openrem/remapp/tests/test_files/MG-RDSR-GEPristina-2D.dcm +0 -0
- openrem/remapp/tests/test_files/MG-RDSR-GEPristina-DBT.dcm +0 -0
- openrem/remapp/tests/test_files/MG-RDSR-Giotto-DBT.dcm +0 -0
- openrem/remapp/tests/test_files/skin_map_alphenix.py +590 -590
- openrem/remapp/tests/test_files/skin_map_zee.py +354 -354
- openrem/remapp/tests/test_filters_ct.py +321 -321
- openrem/remapp/tests/test_filters_dx.py +92 -92
- openrem/remapp/tests/test_filters_mammo.py +183 -183
- openrem/remapp/tests/test_filters_rf.py +118 -118
- openrem/remapp/tests/test_get_values.py +72 -72
- openrem/remapp/tests/test_hash_id.py +65 -65
- openrem/remapp/tests/test_import_ct_esr_ge.py +3034 -3034
- openrem/remapp/tests/test_import_ct_philips_rdsr.py +42 -42
- openrem/remapp/tests/test_import_ct_rdsr_multiple.py +256 -256
- openrem/remapp/tests/test_import_ct_rdsr_siemens.py +827 -827
- openrem/remapp/tests/test_import_ct_rdsr_spectrumdynamics.py +91 -91
- openrem/remapp/tests/test_import_ct_rdsr_toshiba_dosecheck.py +67 -67
- openrem/remapp/tests/test_import_ct_rdsr_toshiba_multivaluesd.py +33 -33
- openrem/remapp/tests/test_import_ct_rdsr_toshiba_pixelmed.py +118 -118
- openrem/remapp/tests/test_import_ct_sc_philips.py +44 -44
- openrem/remapp/tests/test_import_dual_rdsr.py +110 -110
- openrem/remapp/tests/test_import_dx.py +1267 -1191
- openrem/remapp/tests/test_import_dx_rdsr.py +1250 -1253
- openrem/remapp/tests/test_import_mam.py +438 -438
- openrem/remapp/tests/test_import_mg_im_hol_proj.py +46 -46
- openrem/remapp/tests/test_import_mg_rdsr.py +586 -586
- openrem/remapp/tests/test_import_nm_image.py +420 -420
- openrem/remapp/tests/test_import_nm_siemens_rdsr.py +396 -396
- openrem/remapp/tests/test_import_px.py +161 -161
- openrem/remapp/tests/test_import_rf_rdsr.py +420 -418
- openrem/remapp/tests/test_missing_date.py +42 -42
- openrem/remapp/tests/test_not_patient.py +60 -60
- openrem/remapp/tests/test_openskin.py +272 -272
- openrem/remapp/tests/test_patient_id_settings.py +72 -72
- openrem/remapp/tests/test_pt_size_import.py +232 -232
- openrem/remapp/tests/test_rf_detail.py +113 -113
- openrem/remapp/tests/test_rf_high_dose_alert.py +361 -361
- openrem/remapp/tools/background.py +361 -361
- openrem/remapp/tools/check_standard_name_status.py +47 -0
- openrem/remapp/tools/check_uid.py +70 -70
- openrem/remapp/tools/dcmdatetime.py +248 -248
- openrem/remapp/tools/default_import.py +44 -47
- openrem/remapp/tools/get_values.py +230 -230
- openrem/remapp/tools/hash_id.py +58 -58
- openrem/remapp/tools/make_skin_map.py +448 -406
- openrem/remapp/tools/not_patient_indicators.py +72 -72
- openrem/remapp/tools/openskin/calc_exp_map.py +173 -173
- openrem/remapp/tools/openskin/geomclass.py +475 -475
- openrem/remapp/tools/openskin/geomfunc.py +433 -432
- openrem/remapp/tools/openskin/skinmap.py +417 -417
- openrem/remapp/tools/populate_summary.py +185 -193
- openrem/remapp/tools/save_skin_map_structure.py +73 -73
- openrem/remapp/tools/send_high_dose_alert_emails.py +238 -207
- openrem/remapp/urls.py +456 -448
- openrem/remapp/version.py +11 -11
- openrem/remapp/views.py +1147 -1052
- openrem/remapp/views_admin.py +3876 -3936
- openrem/remapp/views_charts_ct.py +2110 -2058
- openrem/remapp/views_charts_dx.py +1906 -1836
- openrem/remapp/views_charts_mg.py +1349 -1196
- openrem/remapp/views_charts_nm.py +535 -535
- openrem/remapp/views_charts_rf.py +1219 -1241
- openrem/remapp/views_openskin.py +379 -384
- openrem/sample-config/openrem-consumer.service +12 -12
- openrem/sample-config/openrem-gunicorn.service +13 -13
- openrem/sample-config/openrem-server +14 -13
- openrem/sample-config/openrem_orthanc_config_linux.lua +454 -454
- openrem/sample-config/openrem_orthanc_config_windows.lua +455 -455
- openrem/sample-config/queue-init.bat +73 -73
- openrem/scripts/openrem_ctphilips.py +25 -25
- openrem/scripts/openrem_cttoshiba.py +28 -28
- openrem/scripts/openrem_dx.py +22 -22
- openrem/scripts/openrem_mg.py +22 -22
- openrem/scripts/openrem_nm.py +22 -22
- openrem/scripts/openrem_ptsizecsv.py +17 -17
- openrem/scripts/openrem_qr.py +12 -12
- openrem/scripts/openrem_rdsr.py +25 -25
- {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info}/METADATA +39 -29
- openrem-1.0.0b3.dist-info/RECORD +379 -0
- {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info}/WHEEL +1 -1
- {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info/licenses}/COPYING-GPLv3 +674 -674
- {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info/licenses}/LICENSE +22 -22
- OpenREM-1.0.0b2.dist-info/RECORD +0 -373
- openrem/remapp/static/js/charts/plotly-2.17.1.min.js +0 -8
- {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_ctphilips.py +0 -0
- {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_cttoshiba.py +0 -0
- {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_dx.py +0 -0
- {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_mg.py +0 -0
- {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_nm.py +0 -0
- {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_ptsizecsv.py +0 -0
- {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_qr.py +0 -0
- {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_rdsr.py +0 -0
- {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info}/top_level.txt +0 -0
|
@@ -1,1431 +1,1418 @@
|
|
|
1
|
-
# OpenREM - Radiation Exposure Monitoring tools for the physicist
|
|
2
|
-
# Copyright (C) 2012,2013 The Royal Marsden NHS Foundation Trust
|
|
3
|
-
#
|
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
# (at your option) any later version.
|
|
8
|
-
#
|
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
# GNU General Public License for more details.
|
|
13
|
-
#
|
|
14
|
-
# Additional permission under section 7 of GPLv3:
|
|
15
|
-
# You shall not make any use of the name of The Royal Marsden NHS
|
|
16
|
-
# Foundation trust in connection with this Program in any press or
|
|
17
|
-
# other public announcement without the prior written consent of
|
|
18
|
-
# The Royal Marsden NHS Foundation Trust.
|
|
19
|
-
#
|
|
20
|
-
# You should have received a copy of the GNU General Public License
|
|
21
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
22
|
-
|
|
23
|
-
"""
|
|
24
|
-
.. module:: rf_export.
|
|
25
|
-
:synopsis: Module to export RF data from database to single sheet csv and multisheet xlsx.
|
|
26
|
-
|
|
27
|
-
.. moduleauthor:: Ed McDonagh
|
|
28
|
-
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
import datetime
|
|
32
|
-
import logging
|
|
33
|
-
from openrem.remapp.tools.background import get_or_generate_task_uuid
|
|
34
|
-
|
|
35
|
-
from django.core.exceptions import ObjectDoesNotExist
|
|
36
|
-
from django.db.models import Avg, Max, Min
|
|
37
|
-
|
|
38
|
-
from
|
|
39
|
-
GeneralStudyModuleAttr,
|
|
40
|
-
IrradEventXRayData,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
] =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
] =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
] =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
accum["
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
] =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
accum[
|
|
106
|
-
|
|
107
|
-
] =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
] =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
] =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
accum["
|
|
118
|
-
accum["
|
|
119
|
-
accum["
|
|
120
|
-
accum["
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
accum["
|
|
151
|
-
accum["
|
|
152
|
-
accum["
|
|
153
|
-
accum["
|
|
154
|
-
accum["
|
|
155
|
-
accum["
|
|
156
|
-
accum["
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
"A
|
|
260
|
-
"A
|
|
261
|
-
"A
|
|
262
|
-
"A
|
|
263
|
-
"A
|
|
264
|
-
"
|
|
265
|
-
"
|
|
266
|
-
"
|
|
267
|
-
"
|
|
268
|
-
"B
|
|
269
|
-
"B
|
|
270
|
-
"B
|
|
271
|
-
"B
|
|
272
|
-
"B
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
:param
|
|
285
|
-
:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
"
|
|
371
|
-
"
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
"
|
|
381
|
-
"
|
|
382
|
-
"
|
|
383
|
-
"
|
|
384
|
-
"
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
pulse_rate =
|
|
442
|
-
fieldsize =
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
if
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
)
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
Min("
|
|
523
|
-
Max("
|
|
524
|
-
Avg("
|
|
525
|
-
)
|
|
526
|
-
|
|
527
|
-
Min("
|
|
528
|
-
Max("
|
|
529
|
-
Avg("
|
|
530
|
-
)
|
|
531
|
-
|
|
532
|
-
Min("
|
|
533
|
-
Max("
|
|
534
|
-
Avg("
|
|
535
|
-
)
|
|
536
|
-
|
|
537
|
-
Min("
|
|
538
|
-
Max("
|
|
539
|
-
Avg("
|
|
540
|
-
)
|
|
541
|
-
|
|
542
|
-
Min("
|
|
543
|
-
Max("
|
|
544
|
-
Avg("
|
|
545
|
-
)
|
|
546
|
-
|
|
547
|
-
Min("
|
|
548
|
-
Max("
|
|
549
|
-
Avg("
|
|
550
|
-
)
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
],
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
],
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
],
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
error_message
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
)
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
"G" + str(h + 1) + "
|
|
685
|
-
"G" + str(h + 1) + "
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
"G" + str(h + 1) + "
|
|
693
|
-
"G" + str(h + 1) + "
|
|
694
|
-
"G" + str(h + 1) + "
|
|
695
|
-
"G" + str(h + 1) + "
|
|
696
|
-
"G" + str(h + 1) + "
|
|
697
|
-
"G" + str(h + 1) + "
|
|
698
|
-
"G" + str(h + 1) + "
|
|
699
|
-
"G" + str(h + 1) + "
|
|
700
|
-
"G" + str(h + 1) + "
|
|
701
|
-
"G" + str(h + 1) + "
|
|
702
|
-
"G" + str(h + 1) + "
|
|
703
|
-
"G" + str(h + 1) + "
|
|
704
|
-
"G" + str(h + 1) + "
|
|
705
|
-
"G" + str(h + 1) + "
|
|
706
|
-
"G" + str(h + 1) + "
|
|
707
|
-
"G" + str(h + 1) + "
|
|
708
|
-
"G" + str(h + 1) + "
|
|
709
|
-
"G" + str(h + 1) + "
|
|
710
|
-
"G" + str(h + 1) + "
|
|
711
|
-
"G" + str(h + 1) + "
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
)
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
for (
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
tsk
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
event.
|
|
936
|
-
)
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
else:
|
|
1020
|
-
|
|
1021
|
-
event.
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
.
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
.
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
acquisition_protocol
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
tsk
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
accum_data[0]["
|
|
1169
|
-
"
|
|
1170
|
-
]
|
|
1171
|
-
accum_data[0]["
|
|
1172
|
-
|
|
1173
|
-
]
|
|
1174
|
-
accum_data[0]["
|
|
1175
|
-
accum_data[0]["
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
""
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
.
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
)
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
row_data += [""]
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
)
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
)
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
"
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
)
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
)
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
"
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
)
|
|
1420
|
-
row_data += ["", filters_cu_str, filters_al_str] # filtration automated?
|
|
1421
|
-
row_data += ["", "", "", "", "", "", "", "", "", ""]
|
|
1422
|
-
row_data += [column_aq]
|
|
1423
|
-
sheet.write_row(row + 6, 0, row_data)
|
|
1424
|
-
|
|
1425
|
-
book.close()
|
|
1426
|
-
tsk.progress = "PHE IR/Fluoro 2019 export complete"
|
|
1427
|
-
tsk.save()
|
|
1428
|
-
|
|
1429
|
-
xlsxfilename = "PHE_RF_2019_{0}.xlsx".format(datestamp.strftime("%Y%m%d-%H%M%S%f"))
|
|
1430
|
-
|
|
1431
|
-
write_export(tsk, xlsxfilename, tmp_xlsx, datestamp)
|
|
1
|
+
# OpenREM - Radiation Exposure Monitoring tools for the physicist
|
|
2
|
+
# Copyright (C) 2012,2013 The Royal Marsden NHS Foundation Trust
|
|
3
|
+
#
|
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
# (at your option) any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# Additional permission under section 7 of GPLv3:
|
|
15
|
+
# You shall not make any use of the name of The Royal Marsden NHS
|
|
16
|
+
# Foundation trust in connection with this Program in any press or
|
|
17
|
+
# other public announcement without the prior written consent of
|
|
18
|
+
# The Royal Marsden NHS Foundation Trust.
|
|
19
|
+
#
|
|
20
|
+
# You should have received a copy of the GNU General Public License
|
|
21
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
.. module:: rf_export.
|
|
25
|
+
:synopsis: Module to export RF data from database to single sheet csv and multisheet xlsx.
|
|
26
|
+
|
|
27
|
+
.. moduleauthor:: Ed McDonagh
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
import datetime
|
|
32
|
+
import logging
|
|
33
|
+
from openrem.remapp.tools.background import get_or_generate_task_uuid
|
|
34
|
+
|
|
35
|
+
from django.core.exceptions import ObjectDoesNotExist
|
|
36
|
+
from django.db.models import Avg, Max, Min
|
|
37
|
+
|
|
38
|
+
from ..models import (
|
|
39
|
+
GeneralStudyModuleAttr,
|
|
40
|
+
IrradEventXRayData,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
from ..exports.export_common import (
|
|
44
|
+
text_and_date_formats,
|
|
45
|
+
common_headers,
|
|
46
|
+
generate_sheets,
|
|
47
|
+
sheet_name,
|
|
48
|
+
get_common_data,
|
|
49
|
+
get_xray_filter_info,
|
|
50
|
+
create_xlsx,
|
|
51
|
+
create_csv,
|
|
52
|
+
write_export,
|
|
53
|
+
create_summary_sheet,
|
|
54
|
+
get_pulse_data,
|
|
55
|
+
abort_if_zero_studies,
|
|
56
|
+
create_export_task,
|
|
57
|
+
get_patient_study_data,
|
|
58
|
+
)
|
|
59
|
+
from ..interface.mod_filters import (
|
|
60
|
+
RFSummaryListFilter,
|
|
61
|
+
RFFilterPlusPid,
|
|
62
|
+
RFFilterPlusStdNames,
|
|
63
|
+
RFFilterPlusPidPlusStdNames,
|
|
64
|
+
)
|
|
65
|
+
from ..tools.get_values import return_for_export
|
|
66
|
+
|
|
67
|
+
from ..tools.check_standard_name_status import are_standard_names_enabled
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
logger = logging.getLogger(__name__)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _get_accumulated_data(accumXrayDose):
|
|
74
|
+
"""Extract all the summary level data
|
|
75
|
+
|
|
76
|
+
:param accumXrayDose: Accumulated x-ray radiation dose object
|
|
77
|
+
:return: dict of summary level data
|
|
78
|
+
"""
|
|
79
|
+
accum = {}
|
|
80
|
+
accum["plane"] = accumXrayDose.acquisition_plane.code_meaning
|
|
81
|
+
try:
|
|
82
|
+
accumulated_integrated_projection_dose = (
|
|
83
|
+
accumXrayDose.accumintegratedprojradiogdose_set.get()
|
|
84
|
+
)
|
|
85
|
+
accum["dose_area_product_total"] = (
|
|
86
|
+
accumulated_integrated_projection_dose.dose_area_product_total
|
|
87
|
+
)
|
|
88
|
+
accum["dose_rp_total"] = accumulated_integrated_projection_dose.dose_rp_total
|
|
89
|
+
accum["reference_point_definition"] = (
|
|
90
|
+
accumulated_integrated_projection_dose.reference_point_definition_code
|
|
91
|
+
)
|
|
92
|
+
if not accum["reference_point_definition"]:
|
|
93
|
+
accum["reference_point_definition"] = (
|
|
94
|
+
accumulated_integrated_projection_dose.reference_point_definition
|
|
95
|
+
)
|
|
96
|
+
except ObjectDoesNotExist:
|
|
97
|
+
accum["dose_area_product_total"] = None
|
|
98
|
+
accum["dose_rp_total"] = None
|
|
99
|
+
accum["reference_point_definition_code"] = None
|
|
100
|
+
try:
|
|
101
|
+
accumulated_projection_dose = accumXrayDose.accumprojxraydose_set.get()
|
|
102
|
+
accum["fluoro_dose_area_product_total"] = (
|
|
103
|
+
accumulated_projection_dose.fluoro_dose_area_product_total
|
|
104
|
+
)
|
|
105
|
+
accum["fluoro_dose_rp_total"] = accumulated_projection_dose.fluoro_dose_rp_total
|
|
106
|
+
accum["total_fluoro_time"] = accumulated_projection_dose.total_fluoro_time
|
|
107
|
+
accum["acquisition_dose_area_product_total"] = (
|
|
108
|
+
accumulated_projection_dose.acquisition_dose_area_product_total
|
|
109
|
+
)
|
|
110
|
+
accum["acquisition_dose_rp_total"] = (
|
|
111
|
+
accumulated_projection_dose.acquisition_dose_rp_total
|
|
112
|
+
)
|
|
113
|
+
accum["total_acquisition_time"] = (
|
|
114
|
+
accumulated_projection_dose.total_acquisition_time
|
|
115
|
+
)
|
|
116
|
+
except ObjectDoesNotExist:
|
|
117
|
+
accum["fluoro_dose_area_product_total"] = None
|
|
118
|
+
accum["fluoro_dose_rp_total"] = None
|
|
119
|
+
accum["total_fluoro_time"] = None
|
|
120
|
+
accum["acquisition_dose_area_product_total"] = None
|
|
121
|
+
accum["acquisition_dose_rp_total"] = None
|
|
122
|
+
accum["total_acquisition_time"] = None
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
accum["eventcount"] = int(
|
|
126
|
+
accumXrayDose.projection_xray_radiation_dose.irradeventxraydata_set.filter(
|
|
127
|
+
acquisition_plane__code_meaning__exact=accum["plane"]
|
|
128
|
+
).count()
|
|
129
|
+
)
|
|
130
|
+
except ObjectDoesNotExist:
|
|
131
|
+
accum["eventcount"] = None
|
|
132
|
+
|
|
133
|
+
return accum
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _add_plane_summary_data(exam):
|
|
137
|
+
"""Add plane level accumulated data to examdata
|
|
138
|
+
|
|
139
|
+
:param exam: exam to export
|
|
140
|
+
:return: list of summary data at plane level
|
|
141
|
+
"""
|
|
142
|
+
exam_data = []
|
|
143
|
+
for plane in (
|
|
144
|
+
exam.projectionxrayradiationdose_set.get()
|
|
145
|
+
.accumxraydose_set.all()
|
|
146
|
+
.order_by("acquisition_plane__code_value")
|
|
147
|
+
):
|
|
148
|
+
accum = _get_accumulated_data(plane)
|
|
149
|
+
exam_data += [
|
|
150
|
+
accum["dose_area_product_total"],
|
|
151
|
+
accum["dose_rp_total"],
|
|
152
|
+
accum["fluoro_dose_area_product_total"],
|
|
153
|
+
accum["fluoro_dose_rp_total"],
|
|
154
|
+
accum["total_fluoro_time"],
|
|
155
|
+
accum["acquisition_dose_area_product_total"],
|
|
156
|
+
accum["acquisition_dose_rp_total"],
|
|
157
|
+
accum["total_acquisition_time"],
|
|
158
|
+
accum["eventcount"],
|
|
159
|
+
]
|
|
160
|
+
if "Single" in accum["plane"]:
|
|
161
|
+
exam_data += ["", "", "", "", "", "", "", "", ""]
|
|
162
|
+
|
|
163
|
+
return exam_data
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _get_series_data(event, filter_data):
|
|
167
|
+
"""Return series level data for protocol sheets
|
|
168
|
+
|
|
169
|
+
:param event: event in question
|
|
170
|
+
:return: list of data
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
# Obtain the system-level enable_standard_names setting
|
|
174
|
+
enable_standard_names = are_standard_names_enabled()
|
|
175
|
+
|
|
176
|
+
try:
|
|
177
|
+
source_data = event.irradeventxraysourcedata_set.get()
|
|
178
|
+
pulse_rate = source_data.pulse_rate
|
|
179
|
+
ii_field_size = source_data.ii_field_size
|
|
180
|
+
exposure_time = source_data.exposure_time
|
|
181
|
+
dose_rp = source_data.dose_rp
|
|
182
|
+
number_of_pulses = source_data.number_of_pulses
|
|
183
|
+
irradiation_duration = source_data.irradiation_duration
|
|
184
|
+
pulse_data = get_pulse_data(source_data=source_data, modality="RF")
|
|
185
|
+
kVp = pulse_data["kvp"]
|
|
186
|
+
xray_tube_current = pulse_data["xray_tube_current"]
|
|
187
|
+
pulse_width = pulse_data["pulse_width"]
|
|
188
|
+
except ObjectDoesNotExist:
|
|
189
|
+
pulse_rate = None
|
|
190
|
+
ii_field_size = None
|
|
191
|
+
exposure_time = None
|
|
192
|
+
dose_rp = None
|
|
193
|
+
number_of_pulses = None
|
|
194
|
+
irradiation_duration = None
|
|
195
|
+
kVp = None
|
|
196
|
+
xray_tube_current = None
|
|
197
|
+
pulse_width = None
|
|
198
|
+
try:
|
|
199
|
+
mechanical_data = event.irradeventxraymechanicaldata_set.get()
|
|
200
|
+
pos_primary_angle = mechanical_data.positioner_primary_angle
|
|
201
|
+
pos_secondary_angle = mechanical_data.positioner_secondary_angle
|
|
202
|
+
except ObjectDoesNotExist:
|
|
203
|
+
pos_primary_angle = None
|
|
204
|
+
pos_secondary_angle = None
|
|
205
|
+
|
|
206
|
+
series_data = [
|
|
207
|
+
str(event.date_time_started),
|
|
208
|
+
event.irradiation_event_type.code_meaning,
|
|
209
|
+
event.acquisition_protocol,
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
if enable_standard_names:
|
|
213
|
+
try:
|
|
214
|
+
standard_protocol = event.standard_protocols.first().standard_name
|
|
215
|
+
except AttributeError:
|
|
216
|
+
standard_protocol = ""
|
|
217
|
+
|
|
218
|
+
if standard_protocol:
|
|
219
|
+
series_data += [standard_protocol]
|
|
220
|
+
else:
|
|
221
|
+
series_data += [""]
|
|
222
|
+
|
|
223
|
+
series_data = series_data + [
|
|
224
|
+
event.acquisition_plane.code_meaning,
|
|
225
|
+
ii_field_size,
|
|
226
|
+
filter_data["filter_material"],
|
|
227
|
+
filter_data["filter_thick"],
|
|
228
|
+
kVp,
|
|
229
|
+
xray_tube_current,
|
|
230
|
+
pulse_width,
|
|
231
|
+
pulse_rate,
|
|
232
|
+
number_of_pulses,
|
|
233
|
+
exposure_time,
|
|
234
|
+
irradiation_duration,
|
|
235
|
+
event.convert_gym2_to_cgycm2(),
|
|
236
|
+
dose_rp,
|
|
237
|
+
pos_primary_angle,
|
|
238
|
+
pos_secondary_angle,
|
|
239
|
+
]
|
|
240
|
+
|
|
241
|
+
return series_data
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def _all_data_headers(pid=False, name=None, patid=None):
|
|
245
|
+
"""Compile list of column headers
|
|
246
|
+
|
|
247
|
+
:param pid: does the user have patient identifiable data permission
|
|
248
|
+
:param name: has patient name been selected for export
|
|
249
|
+
:param patid: has patient ID been selected for export
|
|
250
|
+
:return: list of headers for all_data sheet and csv sheet
|
|
251
|
+
"""
|
|
252
|
+
all_data_headers = common_headers(
|
|
253
|
+
modality="RF", pid=pid, name=name, patid=patid
|
|
254
|
+
) + [
|
|
255
|
+
"A DAP total (Gy.m^2)",
|
|
256
|
+
"A Dose RP total (Gy)",
|
|
257
|
+
"A Fluoro DAP total (Gy.m^2)",
|
|
258
|
+
"A Fluoro dose RP total (Gy)",
|
|
259
|
+
"A Fluoro duration total (s)",
|
|
260
|
+
"A Acq. DAP total (Gy.m^2)",
|
|
261
|
+
"A Acq. dose RP total (Gy)",
|
|
262
|
+
"A Acq. duration total (s)",
|
|
263
|
+
"A Number of events",
|
|
264
|
+
"B DAP total (Gy.m^2)",
|
|
265
|
+
"B Dose RP total (Gy)",
|
|
266
|
+
"B Fluoro DAP total (Gy.m^2)",
|
|
267
|
+
"B Fluoro dose RP total (Gy)",
|
|
268
|
+
"B Fluoro duration total (s)",
|
|
269
|
+
"B Acq. DAP total (Gy.m^2)",
|
|
270
|
+
"B Acq. dose RP total (Gy)",
|
|
271
|
+
"B Acq. duration total (s)",
|
|
272
|
+
"B Number of events",
|
|
273
|
+
]
|
|
274
|
+
return all_data_headers
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def rfxlsx(filterdict, pid=False, name=None, patid=None, user=None):
|
|
278
|
+
"""Export filtered RF database data to multi-sheet Microsoft XSLX files.
|
|
279
|
+
|
|
280
|
+
:param filterdict: Queryset of studies to export
|
|
281
|
+
:param pid: does the user have patient identifiable data permission
|
|
282
|
+
:param name: has patient name been selected for export
|
|
283
|
+
:param patid: has patient ID been selected for export
|
|
284
|
+
:param user: User that has started the export
|
|
285
|
+
:return: Saves xlsx file into Media directory for user to download
|
|
286
|
+
"""
|
|
287
|
+
|
|
288
|
+
# Obtain the system-level enable_standard_names setting
|
|
289
|
+
enable_standard_names = are_standard_names_enabled()
|
|
290
|
+
|
|
291
|
+
datestamp = datetime.datetime.now()
|
|
292
|
+
task_id = get_or_generate_task_uuid()
|
|
293
|
+
tsk = create_export_task(
|
|
294
|
+
task_id=task_id,
|
|
295
|
+
modality="RF",
|
|
296
|
+
export_type="XLSX export",
|
|
297
|
+
date_stamp=datestamp,
|
|
298
|
+
pid=bool(pid and (name or patid)),
|
|
299
|
+
user=user,
|
|
300
|
+
filters_dict=filterdict,
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
tmpxlsx, book = create_xlsx(tsk)
|
|
304
|
+
if not tmpxlsx:
|
|
305
|
+
exit()
|
|
306
|
+
|
|
307
|
+
# Get the data
|
|
308
|
+
if pid:
|
|
309
|
+
if enable_standard_names:
|
|
310
|
+
df_filtered_qs = RFFilterPlusPidPlusStdNames(
|
|
311
|
+
filterdict,
|
|
312
|
+
queryset=GeneralStudyModuleAttr.objects.filter(
|
|
313
|
+
modality_type__exact="RF"
|
|
314
|
+
).distinct(),
|
|
315
|
+
)
|
|
316
|
+
else:
|
|
317
|
+
df_filtered_qs = RFFilterPlusPid(
|
|
318
|
+
filterdict,
|
|
319
|
+
queryset=GeneralStudyModuleAttr.objects.filter(
|
|
320
|
+
modality_type__exact="RF"
|
|
321
|
+
).distinct(),
|
|
322
|
+
)
|
|
323
|
+
else:
|
|
324
|
+
if enable_standard_names:
|
|
325
|
+
df_filtered_qs = RFFilterPlusStdNames(
|
|
326
|
+
filterdict,
|
|
327
|
+
queryset=GeneralStudyModuleAttr.objects.filter(
|
|
328
|
+
modality_type__exact="RF"
|
|
329
|
+
).distinct(),
|
|
330
|
+
)
|
|
331
|
+
else:
|
|
332
|
+
df_filtered_qs = RFSummaryListFilter(
|
|
333
|
+
filterdict,
|
|
334
|
+
queryset=GeneralStudyModuleAttr.objects.filter(
|
|
335
|
+
modality_type__exact="RF"
|
|
336
|
+
).distinct(),
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
e = df_filtered_qs.qs
|
|
340
|
+
|
|
341
|
+
tsk.num_records = e.count()
|
|
342
|
+
if abort_if_zero_studies(tsk.num_records, tsk):
|
|
343
|
+
return
|
|
344
|
+
|
|
345
|
+
# Add summary sheet and all data sheet
|
|
346
|
+
summarysheet = book.add_worksheet("Summary")
|
|
347
|
+
wsalldata = book.add_worksheet("All data")
|
|
348
|
+
|
|
349
|
+
book = text_and_date_formats(
|
|
350
|
+
book, wsalldata, pid=pid, name=name, patid=patid, modality="RF"
|
|
351
|
+
)
|
|
352
|
+
tsk.progress = "Creating an Excel safe version of protocol names and creating a worksheet for each..."
|
|
353
|
+
tsk.save()
|
|
354
|
+
|
|
355
|
+
all_data_headers = _all_data_headers(pid=pid, name=name, patid=patid)
|
|
356
|
+
|
|
357
|
+
sheet_headers = list(all_data_headers)
|
|
358
|
+
protocolheaders = sheet_headers + [
|
|
359
|
+
"Time",
|
|
360
|
+
"Type",
|
|
361
|
+
"Protocol",
|
|
362
|
+
]
|
|
363
|
+
|
|
364
|
+
if enable_standard_names:
|
|
365
|
+
protocolheaders += [
|
|
366
|
+
"Standard acquisition name",
|
|
367
|
+
]
|
|
368
|
+
|
|
369
|
+
protocolheaders += [
|
|
370
|
+
"Plane",
|
|
371
|
+
"Field size",
|
|
372
|
+
"Filter material",
|
|
373
|
+
"Mean filter thickness (mm)",
|
|
374
|
+
"kVp",
|
|
375
|
+
"mA",
|
|
376
|
+
"Pulse width (ms)",
|
|
377
|
+
"Pulse rate",
|
|
378
|
+
"Number of pulses",
|
|
379
|
+
"Exposure time (ms)",
|
|
380
|
+
"Exposure duration (s)",
|
|
381
|
+
"DAP (cGy.cm^2)",
|
|
382
|
+
"Ref point dose (Gy)",
|
|
383
|
+
"Primary angle",
|
|
384
|
+
"Secondary angle",
|
|
385
|
+
]
|
|
386
|
+
|
|
387
|
+
book, sheetlist = generate_sheets(
|
|
388
|
+
e, book, protocolheaders, modality="RF", pid=pid, name=name, patid=patid
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
##################
|
|
392
|
+
# All data sheet
|
|
393
|
+
|
|
394
|
+
num_groups_max = 0
|
|
395
|
+
for row, exams in enumerate(e):
|
|
396
|
+
|
|
397
|
+
tsk.progress = f"Writing study {row + 1} of {e.count()}"
|
|
398
|
+
tsk.save()
|
|
399
|
+
|
|
400
|
+
try:
|
|
401
|
+
examdata = get_common_data("RF", exams, pid=pid, name=name, patid=patid)
|
|
402
|
+
examdata += _add_plane_summary_data(exams)
|
|
403
|
+
common_exam_data = list(examdata)
|
|
404
|
+
|
|
405
|
+
angle_range = 5.0 # plus or minus range considered to be the same position
|
|
406
|
+
|
|
407
|
+
# TODO: Check if generation of inst could be more efficient, ie start with exams?
|
|
408
|
+
inst = IrradEventXRayData.objects.filter(
|
|
409
|
+
projection_xray_radiation_dose__general_study_module_attributes__id__exact=exams.id
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
num_groups_this_exam = 0
|
|
413
|
+
while (
|
|
414
|
+
inst
|
|
415
|
+
): # ie while there are events still left that haven't been matched into a group
|
|
416
|
+
tsk.progress = "Writing study {0} of {1}; {2} events remaining.".format(
|
|
417
|
+
row + 1, e.count(), inst.count()
|
|
418
|
+
)
|
|
419
|
+
tsk.save()
|
|
420
|
+
num_groups_this_exam += 1
|
|
421
|
+
plane = inst[0].acquisition_plane.code_meaning
|
|
422
|
+
try:
|
|
423
|
+
mechanical_data = inst[0].irradeventxraymechanicaldata_set.get()
|
|
424
|
+
anglei = mechanical_data.positioner_primary_angle
|
|
425
|
+
angleii = mechanical_data.positioner_secondary_angle
|
|
426
|
+
except ObjectDoesNotExist:
|
|
427
|
+
anglei = None
|
|
428
|
+
angleii = None
|
|
429
|
+
try:
|
|
430
|
+
source_data = inst[0].irradeventxraysourcedata_set.get()
|
|
431
|
+
pulse_rate = source_data.pulse_rate
|
|
432
|
+
fieldsize = source_data.ii_field_size
|
|
433
|
+
try:
|
|
434
|
+
filter_material, filter_thick = get_xray_filter_info(
|
|
435
|
+
source_data
|
|
436
|
+
)
|
|
437
|
+
except ObjectDoesNotExist:
|
|
438
|
+
filter_material = None
|
|
439
|
+
filter_thick = None
|
|
440
|
+
except ObjectDoesNotExist:
|
|
441
|
+
pulse_rate = None
|
|
442
|
+
fieldsize = None
|
|
443
|
+
filter_material = None
|
|
444
|
+
filter_thick = None
|
|
445
|
+
|
|
446
|
+
protocol = inst[0].acquisition_protocol
|
|
447
|
+
|
|
448
|
+
standard_protocol = ""
|
|
449
|
+
if enable_standard_names:
|
|
450
|
+
try:
|
|
451
|
+
standard_protocol = (
|
|
452
|
+
inst[0].standard_protocols.first().standard_name
|
|
453
|
+
)
|
|
454
|
+
except AttributeError:
|
|
455
|
+
standard_protocol = ""
|
|
456
|
+
|
|
457
|
+
event_type = inst[0].irradiation_event_type.code_meaning
|
|
458
|
+
|
|
459
|
+
similarexposures = inst
|
|
460
|
+
if plane:
|
|
461
|
+
similarexposures = similarexposures.filter(
|
|
462
|
+
acquisition_plane__code_meaning__exact=plane
|
|
463
|
+
)
|
|
464
|
+
if protocol:
|
|
465
|
+
similarexposures = similarexposures.filter(
|
|
466
|
+
acquisition_protocol__exact=protocol
|
|
467
|
+
)
|
|
468
|
+
if fieldsize:
|
|
469
|
+
similarexposures = similarexposures.filter(
|
|
470
|
+
irradeventxraysourcedata__ii_field_size__exact=fieldsize
|
|
471
|
+
)
|
|
472
|
+
if pulse_rate:
|
|
473
|
+
similarexposures = similarexposures.filter(
|
|
474
|
+
irradeventxraysourcedata__pulse_rate__exact=pulse_rate
|
|
475
|
+
)
|
|
476
|
+
if filter_material:
|
|
477
|
+
for xray_filter in (
|
|
478
|
+
inst[0].irradeventxraysourcedata_set.get().xrayfilters_set.all()
|
|
479
|
+
):
|
|
480
|
+
similarexposures = similarexposures.filter(
|
|
481
|
+
irradeventxraysourcedata__xrayfilters__xray_filter_material__code_meaning__exact=xray_filter.xray_filter_material.code_meaning
|
|
482
|
+
)
|
|
483
|
+
similarexposures = similarexposures.filter(
|
|
484
|
+
irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum__exact=xray_filter.xray_filter_thickness_maximum
|
|
485
|
+
)
|
|
486
|
+
if anglei:
|
|
487
|
+
similarexposures = similarexposures.filter(
|
|
488
|
+
irradeventxraymechanicaldata__positioner_primary_angle__range=(
|
|
489
|
+
float(anglei) - angle_range,
|
|
490
|
+
float(anglei) + angle_range,
|
|
491
|
+
)
|
|
492
|
+
)
|
|
493
|
+
if angleii:
|
|
494
|
+
similarexposures = similarexposures.filter(
|
|
495
|
+
irradeventxraymechanicaldata__positioner_secondary_angle__range=(
|
|
496
|
+
float(angleii) - angle_range,
|
|
497
|
+
float(angleii) + angle_range,
|
|
498
|
+
)
|
|
499
|
+
)
|
|
500
|
+
if event_type:
|
|
501
|
+
similarexposures = similarexposures.filter(
|
|
502
|
+
irradiation_event_type__code_meaning__exact=event_type
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
# Remove exposures included in this group from inst
|
|
506
|
+
exposures_to_exclude = [
|
|
507
|
+
o.irradiation_event_uid for o in similarexposures
|
|
508
|
+
]
|
|
509
|
+
inst = inst.exclude(irradiation_event_uid__in=exposures_to_exclude)
|
|
510
|
+
|
|
511
|
+
angle1 = similarexposures.all().aggregate(
|
|
512
|
+
Min("irradeventxraymechanicaldata__positioner_primary_angle"),
|
|
513
|
+
Max("irradeventxraymechanicaldata__positioner_primary_angle"),
|
|
514
|
+
Avg("irradeventxraymechanicaldata__positioner_primary_angle"),
|
|
515
|
+
)
|
|
516
|
+
angle2 = similarexposures.all().aggregate(
|
|
517
|
+
Min("irradeventxraymechanicaldata__positioner_secondary_angle"),
|
|
518
|
+
Max("irradeventxraymechanicaldata__positioner_secondary_angle"),
|
|
519
|
+
Avg("irradeventxraymechanicaldata__positioner_secondary_angle"),
|
|
520
|
+
)
|
|
521
|
+
dap = similarexposures.all().aggregate(
|
|
522
|
+
Min("dose_area_product"),
|
|
523
|
+
Max("dose_area_product"),
|
|
524
|
+
Avg("dose_area_product"),
|
|
525
|
+
)
|
|
526
|
+
dose_rp = similarexposures.all().aggregate(
|
|
527
|
+
Min("irradeventxraysourcedata__dose_rp"),
|
|
528
|
+
Max("irradeventxraysourcedata__dose_rp"),
|
|
529
|
+
Avg("irradeventxraysourcedata__dose_rp"),
|
|
530
|
+
)
|
|
531
|
+
kvp = similarexposures.all().aggregate(
|
|
532
|
+
Min("irradeventxraysourcedata__kvp__kvp"),
|
|
533
|
+
Max("irradeventxraysourcedata__kvp__kvp"),
|
|
534
|
+
Avg("irradeventxraysourcedata__kvp__kvp"),
|
|
535
|
+
)
|
|
536
|
+
tube_current = similarexposures.all().aggregate(
|
|
537
|
+
Min("irradeventxraysourcedata__xraytubecurrent__xray_tube_current"),
|
|
538
|
+
Max("irradeventxraysourcedata__xraytubecurrent__xray_tube_current"),
|
|
539
|
+
Avg("irradeventxraysourcedata__xraytubecurrent__xray_tube_current"),
|
|
540
|
+
)
|
|
541
|
+
exp_time = similarexposures.all().aggregate(
|
|
542
|
+
Min("irradeventxraysourcedata__exposure_time"),
|
|
543
|
+
Max("irradeventxraysourcedata__exposure_time"),
|
|
544
|
+
Avg("irradeventxraysourcedata__exposure_time"),
|
|
545
|
+
)
|
|
546
|
+
pulse_width = similarexposures.all().aggregate(
|
|
547
|
+
Min("irradeventxraysourcedata__pulsewidth__pulse_width"),
|
|
548
|
+
Max("irradeventxraysourcedata__pulsewidth__pulse_width"),
|
|
549
|
+
Avg("irradeventxraysourcedata__pulsewidth__pulse_width"),
|
|
550
|
+
)
|
|
551
|
+
|
|
552
|
+
examdata += [
|
|
553
|
+
event_type,
|
|
554
|
+
protocol,
|
|
555
|
+
]
|
|
556
|
+
|
|
557
|
+
if enable_standard_names:
|
|
558
|
+
if standard_protocol:
|
|
559
|
+
examdata += [standard_protocol]
|
|
560
|
+
else:
|
|
561
|
+
examdata += [""]
|
|
562
|
+
|
|
563
|
+
examdata += [
|
|
564
|
+
similarexposures.count(),
|
|
565
|
+
plane,
|
|
566
|
+
pulse_rate,
|
|
567
|
+
fieldsize,
|
|
568
|
+
filter_material,
|
|
569
|
+
filter_thick,
|
|
570
|
+
kvp["irradeventxraysourcedata__kvp__kvp__min"],
|
|
571
|
+
kvp["irradeventxraysourcedata__kvp__kvp__max"],
|
|
572
|
+
kvp["irradeventxraysourcedata__kvp__kvp__avg"],
|
|
573
|
+
tube_current[
|
|
574
|
+
"irradeventxraysourcedata__xraytubecurrent__xray_tube_current__min"
|
|
575
|
+
],
|
|
576
|
+
tube_current[
|
|
577
|
+
"irradeventxraysourcedata__xraytubecurrent__xray_tube_current__max"
|
|
578
|
+
],
|
|
579
|
+
tube_current[
|
|
580
|
+
"irradeventxraysourcedata__xraytubecurrent__xray_tube_current__avg"
|
|
581
|
+
],
|
|
582
|
+
pulse_width[
|
|
583
|
+
"irradeventxraysourcedata__pulsewidth__pulse_width__min"
|
|
584
|
+
],
|
|
585
|
+
pulse_width[
|
|
586
|
+
"irradeventxraysourcedata__pulsewidth__pulse_width__max"
|
|
587
|
+
],
|
|
588
|
+
pulse_width[
|
|
589
|
+
"irradeventxraysourcedata__pulsewidth__pulse_width__avg"
|
|
590
|
+
],
|
|
591
|
+
exp_time["irradeventxraysourcedata__exposure_time__min"],
|
|
592
|
+
exp_time["irradeventxraysourcedata__exposure_time__max"],
|
|
593
|
+
exp_time["irradeventxraysourcedata__exposure_time__avg"],
|
|
594
|
+
dap["dose_area_product__min"],
|
|
595
|
+
dap["dose_area_product__max"],
|
|
596
|
+
dap["dose_area_product__avg"],
|
|
597
|
+
dose_rp["irradeventxraysourcedata__dose_rp__min"],
|
|
598
|
+
dose_rp["irradeventxraysourcedata__dose_rp__max"],
|
|
599
|
+
dose_rp["irradeventxraysourcedata__dose_rp__avg"],
|
|
600
|
+
angle1[
|
|
601
|
+
"irradeventxraymechanicaldata__positioner_primary_angle__min"
|
|
602
|
+
],
|
|
603
|
+
angle1[
|
|
604
|
+
"irradeventxraymechanicaldata__positioner_primary_angle__max"
|
|
605
|
+
],
|
|
606
|
+
angle1[
|
|
607
|
+
"irradeventxraymechanicaldata__positioner_primary_angle__avg"
|
|
608
|
+
],
|
|
609
|
+
angle2[
|
|
610
|
+
"irradeventxraymechanicaldata__positioner_secondary_angle__min"
|
|
611
|
+
],
|
|
612
|
+
angle2[
|
|
613
|
+
"irradeventxraymechanicaldata__positioner_secondary_angle__max"
|
|
614
|
+
],
|
|
615
|
+
angle2[
|
|
616
|
+
"irradeventxraymechanicaldata__positioner_secondary_angle__avg"
|
|
617
|
+
],
|
|
618
|
+
]
|
|
619
|
+
|
|
620
|
+
if not protocol:
|
|
621
|
+
protocol = "Unknown"
|
|
622
|
+
tab_text = sheet_name(protocol)
|
|
623
|
+
filter_data = {
|
|
624
|
+
"filter_material": filter_material,
|
|
625
|
+
"filter_thick": filter_thick,
|
|
626
|
+
}
|
|
627
|
+
for exposure in similarexposures.order_by("pk"):
|
|
628
|
+
series_data = _get_series_data(exposure, filter_data)
|
|
629
|
+
sheetlist[tab_text]["count"] += 1
|
|
630
|
+
sheetlist[tab_text]["sheet"].write_row(
|
|
631
|
+
sheetlist[tab_text]["count"], 0, common_exam_data + series_data
|
|
632
|
+
)
|
|
633
|
+
|
|
634
|
+
if enable_standard_names:
|
|
635
|
+
if standard_protocol:
|
|
636
|
+
tab_text = sheet_name("[standard] " + standard_protocol)
|
|
637
|
+
filter_data = {
|
|
638
|
+
"filter_material": filter_material,
|
|
639
|
+
"filter_thick": filter_thick,
|
|
640
|
+
}
|
|
641
|
+
for exposure in similarexposures.order_by("pk"):
|
|
642
|
+
series_data = _get_series_data(exposure, filter_data)
|
|
643
|
+
sheetlist[tab_text]["count"] += 1
|
|
644
|
+
sheetlist[tab_text]["sheet"].write_row(
|
|
645
|
+
sheetlist[tab_text]["count"],
|
|
646
|
+
0,
|
|
647
|
+
common_exam_data + series_data,
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
if num_groups_this_exam > num_groups_max:
|
|
651
|
+
num_groups_max = num_groups_this_exam
|
|
652
|
+
|
|
653
|
+
wsalldata.write_row(row + 1, 0, examdata)
|
|
654
|
+
|
|
655
|
+
except ObjectDoesNotExist:
|
|
656
|
+
error_message = (
|
|
657
|
+
"DoesNotExist error whilst exporting study {0} of {1}, study UID {2}, accession number"
|
|
658
|
+
" {3} - maybe database entry was deleted as part of importing later version of same"
|
|
659
|
+
" study?".format(
|
|
660
|
+
row + 1,
|
|
661
|
+
tsk.num_records,
|
|
662
|
+
exams.study_instance_uid,
|
|
663
|
+
exams.accession_number,
|
|
664
|
+
)
|
|
665
|
+
)
|
|
666
|
+
logger.error(error_message)
|
|
667
|
+
wsalldata.write(row + 1, 0, error_message)
|
|
668
|
+
|
|
669
|
+
tsk.progress = "Generating headers for the all data sheet..."
|
|
670
|
+
tsk.save()
|
|
671
|
+
|
|
672
|
+
for h in range(num_groups_max):
|
|
673
|
+
all_data_headers += [
|
|
674
|
+
"G" + str(h + 1) + " Type",
|
|
675
|
+
"G" + str(h + 1) + " Protocol",
|
|
676
|
+
]
|
|
677
|
+
|
|
678
|
+
if enable_standard_names:
|
|
679
|
+
all_data_headers += ["G" + str(h + 1) + " Standard acquisition name"]
|
|
680
|
+
|
|
681
|
+
all_data_headers += [
|
|
682
|
+
"G" + str(h + 1) + " No. exposures",
|
|
683
|
+
"G" + str(h + 1) + " Plane",
|
|
684
|
+
"G" + str(h + 1) + " Pulse rate",
|
|
685
|
+
"G" + str(h + 1) + " Field size",
|
|
686
|
+
"G" + str(h + 1) + " Filter material",
|
|
687
|
+
"G" + str(h + 1) + " Mean filter thickness (mm)",
|
|
688
|
+
"G" + str(h + 1) + " kVp min",
|
|
689
|
+
"G" + str(h + 1) + " kVp max",
|
|
690
|
+
"G" + str(h + 1) + " kVp mean",
|
|
691
|
+
"G" + str(h + 1) + " mA min",
|
|
692
|
+
"G" + str(h + 1) + " mA max",
|
|
693
|
+
"G" + str(h + 1) + " mA mean",
|
|
694
|
+
"G" + str(h + 1) + " pulse width min (ms)",
|
|
695
|
+
"G" + str(h + 1) + " pulse width max (ms)",
|
|
696
|
+
"G" + str(h + 1) + " pulse width mean (ms)",
|
|
697
|
+
"G" + str(h + 1) + " Exp time min (ms)",
|
|
698
|
+
"G" + str(h + 1) + " Exp time max (ms)",
|
|
699
|
+
"G" + str(h + 1) + " Exp time mean (ms)",
|
|
700
|
+
"G" + str(h + 1) + " DAP min (Gy.m^2)",
|
|
701
|
+
"G" + str(h + 1) + " DAP max (Gy.m^2)",
|
|
702
|
+
"G" + str(h + 1) + " DAP mean (Gy.m^2)",
|
|
703
|
+
"G" + str(h + 1) + " Ref point dose min (Gy)",
|
|
704
|
+
"G" + str(h + 1) + " Ref point dose max (Gy)",
|
|
705
|
+
"G" + str(h + 1) + " Ref point dose mean (Gy)",
|
|
706
|
+
"G" + str(h + 1) + " Primary angle min",
|
|
707
|
+
"G" + str(h + 1) + " Primary angle max",
|
|
708
|
+
"G" + str(h + 1) + " Primary angle mean",
|
|
709
|
+
"G" + str(h + 1) + " Secondary angle min",
|
|
710
|
+
"G" + str(h + 1) + " Secondary angle max",
|
|
711
|
+
"G" + str(h + 1) + " Secondary angle mean",
|
|
712
|
+
]
|
|
713
|
+
wsalldata.write_row("A1", all_data_headers)
|
|
714
|
+
num_rows = e.count()
|
|
715
|
+
wsalldata.autofilter(0, 0, num_rows, len(all_data_headers) - 1)
|
|
716
|
+
|
|
717
|
+
create_summary_sheet(tsk, e, book, summarysheet, sheetlist)
|
|
718
|
+
|
|
719
|
+
book.close()
|
|
720
|
+
tsk.progress = "XLSX book written."
|
|
721
|
+
tsk.save()
|
|
722
|
+
|
|
723
|
+
xlsxfilename = "rfexport{0}.xlsx".format(datestamp.strftime("%Y%m%d-%H%M%S%f"))
|
|
724
|
+
|
|
725
|
+
write_export(tsk, xlsxfilename, tmpxlsx, datestamp)
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
def exportFL2excel(filterdict, pid=False, name=None, patid=None, user=None):
|
|
729
|
+
"""Export filtered fluoro database data to a single-sheet CSV file.
|
|
730
|
+
|
|
731
|
+
:param filterdict: Queryset of studies to export
|
|
732
|
+
:param pid: does the user have patient identifiable data permission
|
|
733
|
+
:param name: has patient name been selected for export
|
|
734
|
+
:param patid: has patient ID been selected for export
|
|
735
|
+
:param user: User that has started the export
|
|
736
|
+
:return: Saves csv file into Media directory for user to download
|
|
737
|
+
"""
|
|
738
|
+
|
|
739
|
+
# Obtain the system-level enable_standard_names setting
|
|
740
|
+
enable_standard_names = are_standard_names_enabled()
|
|
741
|
+
|
|
742
|
+
datestamp = datetime.datetime.now()
|
|
743
|
+
task_id = get_or_generate_task_uuid()
|
|
744
|
+
tsk = create_export_task(
|
|
745
|
+
task_id=task_id,
|
|
746
|
+
modality="RF",
|
|
747
|
+
export_type="CSV export",
|
|
748
|
+
date_stamp=datestamp,
|
|
749
|
+
pid=bool(pid and (name or patid)),
|
|
750
|
+
user=user,
|
|
751
|
+
filters_dict=filterdict,
|
|
752
|
+
)
|
|
753
|
+
|
|
754
|
+
tmpfile, writer = create_csv(tsk)
|
|
755
|
+
if not tmpfile:
|
|
756
|
+
exit()
|
|
757
|
+
|
|
758
|
+
# Get the data!
|
|
759
|
+
if pid:
|
|
760
|
+
if enable_standard_names:
|
|
761
|
+
df_filtered_qs = RFFilterPlusPidPlusStdNames(
|
|
762
|
+
filterdict,
|
|
763
|
+
queryset=GeneralStudyModuleAttr.objects.filter(
|
|
764
|
+
modality_type__exact="RF"
|
|
765
|
+
).distinct(),
|
|
766
|
+
)
|
|
767
|
+
else:
|
|
768
|
+
df_filtered_qs = RFFilterPlusPid(
|
|
769
|
+
filterdict,
|
|
770
|
+
queryset=GeneralStudyModuleAttr.objects.filter(
|
|
771
|
+
modality_type__exact="RF"
|
|
772
|
+
).distinct(),
|
|
773
|
+
)
|
|
774
|
+
else:
|
|
775
|
+
if enable_standard_names:
|
|
776
|
+
df_filtered_qs = RFFilterPlusStdNames(
|
|
777
|
+
filterdict,
|
|
778
|
+
queryset=GeneralStudyModuleAttr.objects.filter(
|
|
779
|
+
modality_type__exact="RF"
|
|
780
|
+
).distinct(),
|
|
781
|
+
)
|
|
782
|
+
else:
|
|
783
|
+
df_filtered_qs = RFSummaryListFilter(
|
|
784
|
+
filterdict,
|
|
785
|
+
queryset=GeneralStudyModuleAttr.objects.filter(
|
|
786
|
+
modality_type__exact="RF"
|
|
787
|
+
).distinct(),
|
|
788
|
+
)
|
|
789
|
+
|
|
790
|
+
e = df_filtered_qs.qs
|
|
791
|
+
|
|
792
|
+
tsk.num_records = e.count()
|
|
793
|
+
if abort_if_zero_studies(tsk.num_records, tsk):
|
|
794
|
+
return
|
|
795
|
+
|
|
796
|
+
headings = _all_data_headers(pid=pid, name=name, patid=patid)
|
|
797
|
+
writer.writerow(headings)
|
|
798
|
+
for i, exams in enumerate(e):
|
|
799
|
+
|
|
800
|
+
tsk.progress = "{0} of {1}".format(i + 1, tsk.num_records)
|
|
801
|
+
tsk.save()
|
|
802
|
+
|
|
803
|
+
try:
|
|
804
|
+
exam_data = get_common_data("RF", exams, pid=pid, name=name, patid=patid)
|
|
805
|
+
|
|
806
|
+
for (
|
|
807
|
+
plane
|
|
808
|
+
) in exams.projectionxrayradiationdose_set.get().accumxraydose_set.all():
|
|
809
|
+
accum = _get_accumulated_data(plane)
|
|
810
|
+
exam_data += [
|
|
811
|
+
accum["dose_area_product_total"],
|
|
812
|
+
accum["dose_rp_total"],
|
|
813
|
+
accum["fluoro_dose_area_product_total"],
|
|
814
|
+
accum["fluoro_dose_rp_total"],
|
|
815
|
+
accum["total_fluoro_time"],
|
|
816
|
+
accum["acquisition_dose_area_product_total"],
|
|
817
|
+
accum["acquisition_dose_rp_total"],
|
|
818
|
+
accum["total_acquisition_time"],
|
|
819
|
+
accum["eventcount"],
|
|
820
|
+
]
|
|
821
|
+
# Clear out any commas
|
|
822
|
+
for index, item in enumerate(exam_data):
|
|
823
|
+
if item is None:
|
|
824
|
+
exam_data[index] = ""
|
|
825
|
+
if isinstance(item, str) and "," in item:
|
|
826
|
+
exam_data[index] = item.replace(",", ";")
|
|
827
|
+
writer.writerow([str(data_string) for data_string in exam_data])
|
|
828
|
+
except ObjectDoesNotExist:
|
|
829
|
+
error_message = (
|
|
830
|
+
"DoesNotExist error whilst exporting study {0} of {1}, study UID {2}, accession number"
|
|
831
|
+
" {3} - maybe database entry was deleted as part of importing later version of same"
|
|
832
|
+
" study?".format(
|
|
833
|
+
i + 1,
|
|
834
|
+
tsk.num_records,
|
|
835
|
+
exams.study_instance_uid,
|
|
836
|
+
exams.accession_number,
|
|
837
|
+
)
|
|
838
|
+
)
|
|
839
|
+
logger.error(error_message)
|
|
840
|
+
writer.writerow([error_message])
|
|
841
|
+
|
|
842
|
+
tsk.progress = "All study data written."
|
|
843
|
+
tsk.save()
|
|
844
|
+
|
|
845
|
+
tmpfile.close()
|
|
846
|
+
tsk.status = "COMPLETE"
|
|
847
|
+
tsk.processtime = (datetime.datetime.now() - datestamp).total_seconds()
|
|
848
|
+
tsk.save()
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
def rfopenskin_csv(studyid):
|
|
852
|
+
# pylint: disable=too-many-locals
|
|
853
|
+
# pylint: disable=too-many-branches
|
|
854
|
+
# pylint: disable=too-many-statements
|
|
855
|
+
"""Export single RF study data to OpenSkin RF csv sheet.
|
|
856
|
+
|
|
857
|
+
:param studyid: RF study database ID.
|
|
858
|
+
:type studyid: int
|
|
859
|
+
|
|
860
|
+
"""
|
|
861
|
+
|
|
862
|
+
datestamp = datetime.datetime.now()
|
|
863
|
+
task_id = get_or_generate_task_uuid()
|
|
864
|
+
tsk = create_export_task(
|
|
865
|
+
task_id=task_id,
|
|
866
|
+
modality="RF-OpenSkin",
|
|
867
|
+
export_type="OpenSkin RF csv export",
|
|
868
|
+
date_stamp=datestamp,
|
|
869
|
+
pid=False,
|
|
870
|
+
user=None,
|
|
871
|
+
filters_dict={"study_id": studyid},
|
|
872
|
+
)
|
|
873
|
+
|
|
874
|
+
tmpfile, writer = create_csv(tsk)
|
|
875
|
+
if not tmpfile:
|
|
876
|
+
exit()
|
|
877
|
+
|
|
878
|
+
# Get the data
|
|
879
|
+
study = GeneralStudyModuleAttr.objects.get(pk=studyid)
|
|
880
|
+
numevents = (
|
|
881
|
+
study.projectionxrayradiationdose_set.get().irradeventxraydata_set.count()
|
|
882
|
+
)
|
|
883
|
+
tsk.num_records = numevents
|
|
884
|
+
tsk.save()
|
|
885
|
+
|
|
886
|
+
for i, event in enumerate(
|
|
887
|
+
study.projectionxrayradiationdose_set.get().irradeventxraydata_set.all()
|
|
888
|
+
):
|
|
889
|
+
try:
|
|
890
|
+
study.patientmoduleattr_set.get()
|
|
891
|
+
except ObjectDoesNotExist:
|
|
892
|
+
patient_sex = ""
|
|
893
|
+
else:
|
|
894
|
+
patient_sex = study.patientmoduleattr_set.get().patient_sex
|
|
895
|
+
|
|
896
|
+
try:
|
|
897
|
+
event.irradeventxraysourcedata_set.get()
|
|
898
|
+
except ObjectDoesNotExist:
|
|
899
|
+
reference_point_definition = ""
|
|
900
|
+
dose_rp = ""
|
|
901
|
+
fluoro_mode = ""
|
|
902
|
+
pulse_rate = ""
|
|
903
|
+
number_of_pulses = ""
|
|
904
|
+
exposure_time = ""
|
|
905
|
+
focal_spot_size = ""
|
|
906
|
+
irradiation_duration = ""
|
|
907
|
+
average_xray_tube_current = ""
|
|
908
|
+
else:
|
|
909
|
+
reference_point_definition = (
|
|
910
|
+
event.irradeventxraysourcedata_set.get().reference_point_definition
|
|
911
|
+
)
|
|
912
|
+
dose_rp = event.irradeventxraysourcedata_set.get().dose_rp
|
|
913
|
+
fluoro_mode = event.irradeventxraysourcedata_set.get().fluoro_mode
|
|
914
|
+
pulse_rate = event.irradeventxraysourcedata_set.get().pulse_rate
|
|
915
|
+
number_of_pulses = event.irradeventxraysourcedata_set.get().number_of_pulses
|
|
916
|
+
exposure_time = event.irradeventxraysourcedata_set.get().exposure_time
|
|
917
|
+
focal_spot_size = event.irradeventxraysourcedata_set.get().focal_spot_size
|
|
918
|
+
irradiation_duration = (
|
|
919
|
+
event.irradeventxraysourcedata_set.get().irradiation_duration
|
|
920
|
+
)
|
|
921
|
+
average_xray_tube_current = (
|
|
922
|
+
event.irradeventxraysourcedata_set.get().average_xray_tube_current
|
|
923
|
+
)
|
|
924
|
+
|
|
925
|
+
try:
|
|
926
|
+
event.irradeventxraymechanicaldata_set.get()
|
|
927
|
+
except ObjectDoesNotExist:
|
|
928
|
+
positioner_primary_angle = ""
|
|
929
|
+
positioner_secondary_angle = ""
|
|
930
|
+
positioner_primary_end_angle = ""
|
|
931
|
+
positioner_secondary_end_angle = ""
|
|
932
|
+
column_angulation = ""
|
|
933
|
+
else:
|
|
934
|
+
positioner_primary_angle = (
|
|
935
|
+
event.irradeventxraymechanicaldata_set.get().positioner_primary_angle
|
|
936
|
+
)
|
|
937
|
+
positioner_secondary_angle = (
|
|
938
|
+
event.irradeventxraymechanicaldata_set.get().positioner_secondary_angle
|
|
939
|
+
)
|
|
940
|
+
positioner_primary_end_angle = (
|
|
941
|
+
event.irradeventxraymechanicaldata_set.get().positioner_primary_end_angle
|
|
942
|
+
)
|
|
943
|
+
positioner_secondary_end_angle = (
|
|
944
|
+
event.irradeventxraymechanicaldata_set.get().positioner_secondary_end_angle
|
|
945
|
+
)
|
|
946
|
+
column_angulation = (
|
|
947
|
+
event.irradeventxraymechanicaldata_set.get().column_angulation
|
|
948
|
+
)
|
|
949
|
+
|
|
950
|
+
xray_filter_type = ""
|
|
951
|
+
xray_filter_material = ""
|
|
952
|
+
xray_filter_thickness_minimum = ""
|
|
953
|
+
xray_filter_thickness_maximum = ""
|
|
954
|
+
try:
|
|
955
|
+
for (
|
|
956
|
+
filters
|
|
957
|
+
) in event.irradeventxraysourcedata_set.get().xrayfilters_set.all():
|
|
958
|
+
try:
|
|
959
|
+
if "Copper" in filters.xray_filter_material.code_meaning:
|
|
960
|
+
xray_filter_type = filters.xray_filter_type
|
|
961
|
+
xray_filter_material = filters.xray_filter_material
|
|
962
|
+
xray_filter_thickness_minimum = (
|
|
963
|
+
filters.xray_filter_thickness_minimum
|
|
964
|
+
)
|
|
965
|
+
xray_filter_thickness_maximum = (
|
|
966
|
+
filters.xray_filter_thickness_maximum
|
|
967
|
+
)
|
|
968
|
+
except AttributeError:
|
|
969
|
+
pass
|
|
970
|
+
except ObjectDoesNotExist:
|
|
971
|
+
pass
|
|
972
|
+
|
|
973
|
+
try:
|
|
974
|
+
event.irradeventxraysourcedata_set.get().kvp_set.get()
|
|
975
|
+
except ObjectDoesNotExist:
|
|
976
|
+
kvp = ""
|
|
977
|
+
else:
|
|
978
|
+
kvp = event.irradeventxraysourcedata_set.get().kvp_set.get().kvp
|
|
979
|
+
|
|
980
|
+
try:
|
|
981
|
+
event.irradeventxraysourcedata_set.get().xraytubecurrent_set.get()
|
|
982
|
+
except ObjectDoesNotExist:
|
|
983
|
+
xray_tube_current = ""
|
|
984
|
+
else:
|
|
985
|
+
xray_tube_current = (
|
|
986
|
+
event.irradeventxraysourcedata_set.get()
|
|
987
|
+
.xraytubecurrent_set.get()
|
|
988
|
+
.xray_tube_current
|
|
989
|
+
)
|
|
990
|
+
|
|
991
|
+
try:
|
|
992
|
+
event.irradeventxraysourcedata_set.get().pulsewidth_set.get()
|
|
993
|
+
except ObjectDoesNotExist:
|
|
994
|
+
pulse_width = ""
|
|
995
|
+
else:
|
|
996
|
+
pulse_width = (
|
|
997
|
+
event.irradeventxraysourcedata_set.get()
|
|
998
|
+
.pulsewidth_set.get()
|
|
999
|
+
.pulse_width
|
|
1000
|
+
)
|
|
1001
|
+
|
|
1002
|
+
try:
|
|
1003
|
+
event.irradeventxraysourcedata_set.get().exposure_set.get()
|
|
1004
|
+
except ObjectDoesNotExist:
|
|
1005
|
+
exposure = ""
|
|
1006
|
+
else:
|
|
1007
|
+
exposure = (
|
|
1008
|
+
event.irradeventxraysourcedata_set.get().exposure_set.get().exposure
|
|
1009
|
+
)
|
|
1010
|
+
|
|
1011
|
+
try:
|
|
1012
|
+
event.irradeventxraymechanicaldata_set.get().doserelateddistancemeasurements_set.get()
|
|
1013
|
+
except ObjectDoesNotExist:
|
|
1014
|
+
distance_source_to_detector = ""
|
|
1015
|
+
distance_source_to_isocenter = ""
|
|
1016
|
+
table_longitudinal_position = ""
|
|
1017
|
+
table_lateral_position = ""
|
|
1018
|
+
table_height_position = ""
|
|
1019
|
+
else:
|
|
1020
|
+
distance_source_to_detector = (
|
|
1021
|
+
event.irradeventxraymechanicaldata_set.get()
|
|
1022
|
+
.doserelateddistancemeasurements_set.get()
|
|
1023
|
+
.distance_source_to_detector
|
|
1024
|
+
)
|
|
1025
|
+
distance_source_to_isocenter = (
|
|
1026
|
+
event.irradeventxraymechanicaldata_set.get()
|
|
1027
|
+
.doserelateddistancemeasurements_set.get()
|
|
1028
|
+
.distance_source_to_isocenter
|
|
1029
|
+
)
|
|
1030
|
+
table_longitudinal_position = (
|
|
1031
|
+
event.irradeventxraymechanicaldata_set.get()
|
|
1032
|
+
.doserelateddistancemeasurements_set.get()
|
|
1033
|
+
.table_longitudinal_position
|
|
1034
|
+
)
|
|
1035
|
+
table_lateral_position = (
|
|
1036
|
+
event.irradeventxraymechanicaldata_set.get()
|
|
1037
|
+
.doserelateddistancemeasurements_set.get()
|
|
1038
|
+
.table_lateral_position
|
|
1039
|
+
)
|
|
1040
|
+
table_height_position = (
|
|
1041
|
+
event.irradeventxraymechanicaldata_set.get()
|
|
1042
|
+
.doserelateddistancemeasurements_set.get()
|
|
1043
|
+
.table_height_position
|
|
1044
|
+
)
|
|
1045
|
+
|
|
1046
|
+
acquisition_protocol = return_for_export(event, "acquisition_protocol")
|
|
1047
|
+
if isinstance(acquisition_protocol, str) and "," in acquisition_protocol:
|
|
1048
|
+
acquisition_protocol = acquisition_protocol.replace(",", ";")
|
|
1049
|
+
comment = event.comment
|
|
1050
|
+
if isinstance(comment, str) and "," in comment:
|
|
1051
|
+
comment = comment.replace(",", ";")
|
|
1052
|
+
|
|
1053
|
+
data = [
|
|
1054
|
+
"Anon",
|
|
1055
|
+
patient_sex,
|
|
1056
|
+
study.study_instance_uid,
|
|
1057
|
+
"",
|
|
1058
|
+
event.acquisition_plane,
|
|
1059
|
+
event.date_time_started,
|
|
1060
|
+
event.irradiation_event_type,
|
|
1061
|
+
acquisition_protocol,
|
|
1062
|
+
reference_point_definition,
|
|
1063
|
+
event.irradiation_event_uid,
|
|
1064
|
+
event.dose_area_product,
|
|
1065
|
+
dose_rp,
|
|
1066
|
+
positioner_primary_angle,
|
|
1067
|
+
positioner_secondary_angle,
|
|
1068
|
+
positioner_primary_end_angle,
|
|
1069
|
+
positioner_secondary_end_angle,
|
|
1070
|
+
column_angulation,
|
|
1071
|
+
xray_filter_type,
|
|
1072
|
+
xray_filter_material,
|
|
1073
|
+
xray_filter_thickness_minimum,
|
|
1074
|
+
xray_filter_thickness_maximum,
|
|
1075
|
+
fluoro_mode,
|
|
1076
|
+
pulse_rate,
|
|
1077
|
+
number_of_pulses,
|
|
1078
|
+
kvp,
|
|
1079
|
+
xray_tube_current,
|
|
1080
|
+
exposure_time,
|
|
1081
|
+
pulse_width,
|
|
1082
|
+
exposure,
|
|
1083
|
+
focal_spot_size,
|
|
1084
|
+
irradiation_duration,
|
|
1085
|
+
average_xray_tube_current,
|
|
1086
|
+
distance_source_to_detector,
|
|
1087
|
+
distance_source_to_isocenter,
|
|
1088
|
+
table_longitudinal_position,
|
|
1089
|
+
table_lateral_position,
|
|
1090
|
+
table_height_position,
|
|
1091
|
+
event.target_region,
|
|
1092
|
+
comment,
|
|
1093
|
+
]
|
|
1094
|
+
writer.writerow(data)
|
|
1095
|
+
tsk.progress = "{0} of {1}".format(i, numevents)
|
|
1096
|
+
tsk.save()
|
|
1097
|
+
tsk.progress = "All study data written."
|
|
1098
|
+
tsk.save()
|
|
1099
|
+
|
|
1100
|
+
tmpfile.close()
|
|
1101
|
+
tsk.status = "COMPLETE"
|
|
1102
|
+
tsk.processtime = (datetime.datetime.now() - datestamp).total_seconds()
|
|
1103
|
+
tsk.save()
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
def rf_phe_2019(filterdict, user=None):
|
|
1107
|
+
"""Export filtered RF database data in the format for the 2019 Public Health England IR/fluoro dose survey
|
|
1108
|
+
|
|
1109
|
+
:param filterdict: Queryset of studies to export
|
|
1110
|
+
:param user: User that has started the export
|
|
1111
|
+
:return: Saves Excel file into media directory for user to download
|
|
1112
|
+
"""
|
|
1113
|
+
|
|
1114
|
+
datestamp = datetime.datetime.now()
|
|
1115
|
+
task_id = get_or_generate_task_uuid()
|
|
1116
|
+
tsk = create_export_task(
|
|
1117
|
+
task_id=task_id,
|
|
1118
|
+
modality="RF",
|
|
1119
|
+
export_type="PHE RF 2019 export",
|
|
1120
|
+
date_stamp=datestamp,
|
|
1121
|
+
pid=False,
|
|
1122
|
+
user=user,
|
|
1123
|
+
filters_dict=filterdict,
|
|
1124
|
+
)
|
|
1125
|
+
|
|
1126
|
+
tmp_xlsx, book = create_xlsx(tsk)
|
|
1127
|
+
if not tmp_xlsx:
|
|
1128
|
+
exit()
|
|
1129
|
+
sheet = book.add_worksheet("PHE IR-Fluoro")
|
|
1130
|
+
|
|
1131
|
+
exams = RFSummaryListFilter(
|
|
1132
|
+
filterdict,
|
|
1133
|
+
queryset=GeneralStudyModuleAttr.objects.filter(modality_type__exact="RF"),
|
|
1134
|
+
).qs
|
|
1135
|
+
tsk.num_records = exams.count()
|
|
1136
|
+
if abort_if_zero_studies(tsk.num_records, tsk):
|
|
1137
|
+
return
|
|
1138
|
+
|
|
1139
|
+
tsk.progress = "{0} studies in query.".format(tsk.num_records)
|
|
1140
|
+
tsk.save()
|
|
1141
|
+
|
|
1142
|
+
row_4 = ["", "", "", "", "", "Gy·m²", "", "seconds", "Gy"]
|
|
1143
|
+
sheet.write_row(3, 0, row_4)
|
|
1144
|
+
|
|
1145
|
+
num_rows = exams.count()
|
|
1146
|
+
for row, exam in enumerate(exams):
|
|
1147
|
+
tsk.progress = "Writing study {0} of {1}".format(row + 1, num_rows)
|
|
1148
|
+
tsk.save()
|
|
1149
|
+
|
|
1150
|
+
row_data = ["", row + 1, exam.pk, exam.study_date, exam.total_dap]
|
|
1151
|
+
accum_data = []
|
|
1152
|
+
for plane in exam.projectionxrayradiationdose_set.get().accumxraydose_set.all():
|
|
1153
|
+
accum_data.append(_get_accumulated_data(plane))
|
|
1154
|
+
if len(accum_data) == 2:
|
|
1155
|
+
accum_data[0]["fluoro_dose_area_product_total"] += accum_data[1][
|
|
1156
|
+
"fluoro_dose_area_product_total"
|
|
1157
|
+
]
|
|
1158
|
+
accum_data[0]["fluoro_dose_rp_total"] += accum_data[1][
|
|
1159
|
+
"fluoro_dose_rp_total"
|
|
1160
|
+
]
|
|
1161
|
+
accum_data[0]["total_fluoro_time"] += accum_data[1]["total_fluoro_time"]
|
|
1162
|
+
accum_data[0]["acquisition_dose_area_product_total"] += accum_data[1][
|
|
1163
|
+
"acquisition_dose_area_product_total"
|
|
1164
|
+
]
|
|
1165
|
+
accum_data[0]["acquisition_dose_rp_total"] += accum_data[1][
|
|
1166
|
+
"acquisition_dose_rp_total"
|
|
1167
|
+
]
|
|
1168
|
+
accum_data[0]["total_acquisition_time"] += accum_data[1][
|
|
1169
|
+
"total_acquisition_time"
|
|
1170
|
+
]
|
|
1171
|
+
accum_data[0]["eventcount"] += accum_data[1]["eventcount"]
|
|
1172
|
+
row_data += [
|
|
1173
|
+
accum_data[0]["fluoro_dose_area_product_total"],
|
|
1174
|
+
accum_data[0]["acquisition_dose_area_product_total"],
|
|
1175
|
+
accum_data[0]["total_fluoro_time"],
|
|
1176
|
+
]
|
|
1177
|
+
|
|
1178
|
+
try:
|
|
1179
|
+
total_rp_dose = exam.total_rp_dose_a + exam.total_rp_dose_b
|
|
1180
|
+
except TypeError:
|
|
1181
|
+
if exam.total_rp_dose_a is not None:
|
|
1182
|
+
total_rp_dose = exam.total_rp_dose_a
|
|
1183
|
+
elif exam.total_rp_dose_b is not None:
|
|
1184
|
+
total_rp_dose = exam.total_rp_dose_b
|
|
1185
|
+
else:
|
|
1186
|
+
total_rp_dose = 0
|
|
1187
|
+
row_data += [
|
|
1188
|
+
total_rp_dose,
|
|
1189
|
+
accum_data[0]["fluoro_dose_rp_total"],
|
|
1190
|
+
accum_data[0]["acquisition_dose_rp_total"],
|
|
1191
|
+
"{0} | {1} | {2}".format(
|
|
1192
|
+
exam.procedure_code_meaning,
|
|
1193
|
+
exam.requested_procedure_code_meaning,
|
|
1194
|
+
exam.study_description,
|
|
1195
|
+
),
|
|
1196
|
+
]
|
|
1197
|
+
patient_study_data = get_patient_study_data(exam)
|
|
1198
|
+
patient_sex = None
|
|
1199
|
+
try:
|
|
1200
|
+
patient_sex = exam.patientmoduleattr_set.get().patient_sex
|
|
1201
|
+
except ObjectDoesNotExist:
|
|
1202
|
+
logger.debug(
|
|
1203
|
+
"Export {0}; patientmoduleattr_set object does not exist. AccNum {1}, Date {2}".format(
|
|
1204
|
+
"PHE 2019 RF", exams.accession_number, exams.study_date
|
|
1205
|
+
)
|
|
1206
|
+
)
|
|
1207
|
+
row_data += [
|
|
1208
|
+
patient_study_data["patient_weight"],
|
|
1209
|
+
"",
|
|
1210
|
+
patient_study_data["patient_age_decimal"],
|
|
1211
|
+
patient_sex,
|
|
1212
|
+
patient_study_data["patient_size"],
|
|
1213
|
+
]
|
|
1214
|
+
|
|
1215
|
+
events = IrradEventXRayData.objects.filter(
|
|
1216
|
+
projection_xray_radiation_dose__general_study_module_attributes__pk__exact=exam.pk
|
|
1217
|
+
)
|
|
1218
|
+
fluoro_events = events.exclude(
|
|
1219
|
+
irradiation_event_type__code_value__contains="11361"
|
|
1220
|
+
) # acq events are 113611, 113612, 113613
|
|
1221
|
+
acquisition_events = events.filter(
|
|
1222
|
+
irradiation_event_type__code_value__contains="11361"
|
|
1223
|
+
)
|
|
1224
|
+
try:
|
|
1225
|
+
row_data += [
|
|
1226
|
+
" | ".join(
|
|
1227
|
+
fluoro_events.order_by()
|
|
1228
|
+
.values_list("acquisition_protocol", flat=True)
|
|
1229
|
+
.distinct()
|
|
1230
|
+
)
|
|
1231
|
+
]
|
|
1232
|
+
except TypeError:
|
|
1233
|
+
row_data += [""]
|
|
1234
|
+
try:
|
|
1235
|
+
row_data += [
|
|
1236
|
+
" | ".join(
|
|
1237
|
+
fluoro_events.order_by()
|
|
1238
|
+
.values_list(
|
|
1239
|
+
"irradeventxraysourcedata__fluoro_mode__code_meaning", flat=True
|
|
1240
|
+
)
|
|
1241
|
+
.distinct()
|
|
1242
|
+
)
|
|
1243
|
+
]
|
|
1244
|
+
except TypeError:
|
|
1245
|
+
row_data += [""]
|
|
1246
|
+
fluoro_frame_rates = (
|
|
1247
|
+
fluoro_events.order_by()
|
|
1248
|
+
.values_list("irradeventxraysourcedata__pulse_rate", flat=True)
|
|
1249
|
+
.distinct()
|
|
1250
|
+
)
|
|
1251
|
+
column_aq = ""
|
|
1252
|
+
if len(fluoro_frame_rates) > 1:
|
|
1253
|
+
column_aq += "Fluoro: "
|
|
1254
|
+
column_aq += " | ".join(
|
|
1255
|
+
format(x, "1.1f") for x in fluoro_frame_rates if x is not None
|
|
1256
|
+
)
|
|
1257
|
+
column_aq += " fps. "
|
|
1258
|
+
row_data += ["Multiple rates"]
|
|
1259
|
+
else:
|
|
1260
|
+
try:
|
|
1261
|
+
row_data += [fluoro_frame_rates[0]]
|
|
1262
|
+
except IndexError:
|
|
1263
|
+
row_data += [""]
|
|
1264
|
+
acquisition_frame_rates = (
|
|
1265
|
+
acquisition_events.order_by()
|
|
1266
|
+
.values_list("irradeventxraysourcedata__pulse_rate", flat=True)
|
|
1267
|
+
.distinct()
|
|
1268
|
+
)
|
|
1269
|
+
add_single = False
|
|
1270
|
+
if None in acquisition_frame_rates:
|
|
1271
|
+
if len(acquisition_frame_rates) == 1:
|
|
1272
|
+
acquisition_frame_rates = ["Single shot"]
|
|
1273
|
+
else:
|
|
1274
|
+
acquisition_frame_rates = acquisition_frame_rates[1:]
|
|
1275
|
+
add_single = True
|
|
1276
|
+
if len(acquisition_frame_rates) > 1:
|
|
1277
|
+
row_data += ["Multiple rates"]
|
|
1278
|
+
column_aq += "Acquisition: "
|
|
1279
|
+
if add_single:
|
|
1280
|
+
column_aq += "Single shot | "
|
|
1281
|
+
column_aq += " | ".join(format(x, "1.1f") for x in acquisition_frame_rates)
|
|
1282
|
+
column_aq += " fps. "
|
|
1283
|
+
else:
|
|
1284
|
+
try:
|
|
1285
|
+
row_data += [acquisition_frame_rates[0]]
|
|
1286
|
+
except IndexError:
|
|
1287
|
+
row_data += [""]
|
|
1288
|
+
row_data += [acquisition_events.count()]
|
|
1289
|
+
try:
|
|
1290
|
+
grid_types = (
|
|
1291
|
+
events.order_by()
|
|
1292
|
+
.values_list(
|
|
1293
|
+
"irradeventxraysourcedata__xraygrid__xray_grid__code_meaning",
|
|
1294
|
+
flat=True,
|
|
1295
|
+
)
|
|
1296
|
+
.distinct()
|
|
1297
|
+
)
|
|
1298
|
+
if None in grid_types:
|
|
1299
|
+
grid_types = grid_types[1:]
|
|
1300
|
+
except ObjectDoesNotExist:
|
|
1301
|
+
grid_types = [""]
|
|
1302
|
+
row_data += [" | ".join(grid_types), ""] # AEC used - not recorded in RDSR
|
|
1303
|
+
patient_position = (
|
|
1304
|
+
events.order_by()
|
|
1305
|
+
.values_list(
|
|
1306
|
+
"patient_table_relationship_cid__code_meaning",
|
|
1307
|
+
"patient_orientation_cid__code_meaning",
|
|
1308
|
+
"patient_orientation_modifier_cid__code_meaning",
|
|
1309
|
+
)
|
|
1310
|
+
.distinct()
|
|
1311
|
+
)
|
|
1312
|
+
patient_position_str = ""
|
|
1313
|
+
for position_set in patient_position:
|
|
1314
|
+
for element in (i for i in position_set if i):
|
|
1315
|
+
patient_position_str += "{0}, ".format(element)
|
|
1316
|
+
row_data += [
|
|
1317
|
+
patient_position_str,
|
|
1318
|
+
"", # digital subtraction
|
|
1319
|
+
"", # circular field of view
|
|
1320
|
+
]
|
|
1321
|
+
field_dimensions = events.aggregate(
|
|
1322
|
+
Min("irradeventxraysourcedata__collimated_field_area"),
|
|
1323
|
+
Max("irradeventxraysourcedata__collimated_field_area"),
|
|
1324
|
+
Min("irradeventxraysourcedata__collimated_field_width"),
|
|
1325
|
+
Max("irradeventxraysourcedata__collimated_field_width"),
|
|
1326
|
+
Min("irradeventxraysourcedata__collimated_field_height"),
|
|
1327
|
+
Max("irradeventxraysourcedata__collimated_field_height"),
|
|
1328
|
+
)
|
|
1329
|
+
rectangular_fov = ""
|
|
1330
|
+
if field_dimensions["irradeventxraysourcedata__collimated_field_area__min"]:
|
|
1331
|
+
rectangular_fov += "Area {0:.4f} to {1:.4f} m², ".format(
|
|
1332
|
+
field_dimensions[
|
|
1333
|
+
"irradeventxraysourcedata__collimated_field_area__min"
|
|
1334
|
+
],
|
|
1335
|
+
field_dimensions[
|
|
1336
|
+
"irradeventxraysourcedata__collimated_field_area__max"
|
|
1337
|
+
],
|
|
1338
|
+
)
|
|
1339
|
+
if field_dimensions["irradeventxraysourcedata__collimated_field_width__min"]:
|
|
1340
|
+
rectangular_fov += "Width {0:.4f} to {1:.4f} m, ".format(
|
|
1341
|
+
field_dimensions[
|
|
1342
|
+
"irradeventxraysourcedata__collimated_field_width__min"
|
|
1343
|
+
],
|
|
1344
|
+
field_dimensions[
|
|
1345
|
+
"irradeventxraysourcedata__collimated_field_width__max"
|
|
1346
|
+
],
|
|
1347
|
+
)
|
|
1348
|
+
if field_dimensions["irradeventxraysourcedata__collimated_field_height__min"]:
|
|
1349
|
+
rectangular_fov += "Height {0:.4f} to {1:.4f} m, ".format(
|
|
1350
|
+
field_dimensions[
|
|
1351
|
+
"irradeventxraysourcedata__collimated_field_height__min"
|
|
1352
|
+
],
|
|
1353
|
+
field_dimensions[
|
|
1354
|
+
"irradeventxraysourcedata__collimated_field_height__max"
|
|
1355
|
+
],
|
|
1356
|
+
)
|
|
1357
|
+
field_sizes = (
|
|
1358
|
+
events.order_by()
|
|
1359
|
+
.values_list("irradeventxraysourcedata__ii_field_size", flat=True)
|
|
1360
|
+
.distinct()
|
|
1361
|
+
)
|
|
1362
|
+
diagonal_fov = ""
|
|
1363
|
+
for fov in field_sizes:
|
|
1364
|
+
if fov:
|
|
1365
|
+
diagonal_fov += "{0}, ".format(fov)
|
|
1366
|
+
if diagonal_fov:
|
|
1367
|
+
diagonal_fov += " mm"
|
|
1368
|
+
row_data += [rectangular_fov, diagonal_fov]
|
|
1369
|
+
filters_al = events.filter(
|
|
1370
|
+
irradeventxraysourcedata__xrayfilters__xray_filter_material__code_value__exact="C-120F9"
|
|
1371
|
+
)
|
|
1372
|
+
filters_cu = events.filter(
|
|
1373
|
+
irradeventxraysourcedata__xrayfilters__xray_filter_material__code_value__exact="C-127F9"
|
|
1374
|
+
)
|
|
1375
|
+
filters_al_thick = filters_al.aggregate(
|
|
1376
|
+
Min("irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum"),
|
|
1377
|
+
Max("irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum"),
|
|
1378
|
+
)
|
|
1379
|
+
filters_cu_thick = filters_cu.aggregate(
|
|
1380
|
+
Min("irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum"),
|
|
1381
|
+
Max("irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum"),
|
|
1382
|
+
)
|
|
1383
|
+
filters_al_str = ""
|
|
1384
|
+
filters_cu_str = ""
|
|
1385
|
+
if filters_al_thick[
|
|
1386
|
+
"irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum__min"
|
|
1387
|
+
]:
|
|
1388
|
+
filters_al_str = "{0:.2} - {1:.2} mm".format(
|
|
1389
|
+
filters_al_thick[
|
|
1390
|
+
"irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum__min"
|
|
1391
|
+
],
|
|
1392
|
+
filters_al_thick[
|
|
1393
|
+
"irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum__max"
|
|
1394
|
+
],
|
|
1395
|
+
)
|
|
1396
|
+
if filters_cu_thick[
|
|
1397
|
+
"irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum__min"
|
|
1398
|
+
]:
|
|
1399
|
+
filters_cu_str = "{0:.2} - {1:.2} mm".format(
|
|
1400
|
+
filters_cu_thick[
|
|
1401
|
+
"irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum__min"
|
|
1402
|
+
],
|
|
1403
|
+
filters_cu_thick[
|
|
1404
|
+
"irradeventxraysourcedata__xrayfilters__xray_filter_thickness_maximum__max"
|
|
1405
|
+
],
|
|
1406
|
+
)
|
|
1407
|
+
row_data += ["", filters_cu_str, filters_al_str] # filtration automated?
|
|
1408
|
+
row_data += ["", "", "", "", "", "", "", "", "", ""]
|
|
1409
|
+
row_data += [column_aq]
|
|
1410
|
+
sheet.write_row(row + 6, 0, row_data)
|
|
1411
|
+
|
|
1412
|
+
book.close()
|
|
1413
|
+
tsk.progress = "PHE IR/Fluoro 2019 export complete"
|
|
1414
|
+
tsk.save()
|
|
1415
|
+
|
|
1416
|
+
xlsxfilename = "PHE_RF_2019_{0}.xlsx".format(datestamp.strftime("%Y%m%d-%H%M%S%f"))
|
|
1417
|
+
|
|
1418
|
+
write_export(tsk, xlsxfilename, tmp_xlsx, datestamp)
|