diff --git a/directions/models.py b/directions/models.py index 6e586d8787..a68a4dd5fb 100644 --- a/directions/models.py +++ b/directions/models.py @@ -2340,7 +2340,11 @@ def get_patient_complex_research(date_start, date_end, patient_card): @staticmethod def get_complex_directions(complex_ids): - return [i.napravleniye_id for i in get_directions_by_complex_id(complex_ids)] + return list(set([i.napravleniye_id for i in get_directions_by_complex_id(complex_ids)])) + + @staticmethod + def get_complex_confirm_directions(complex_ids): + return list(set([i.napravleniye_id for i in get_directions_by_complex_id(complex_ids) if i.iss_time_confirmation])) class Issledovaniya(models.Model): diff --git a/directions/sql_func.py b/directions/sql_func.py index cdf9d20bc8..c5bd31fb45 100644 --- a/directions/sql_func.py +++ b/directions/sql_func.py @@ -216,12 +216,11 @@ def get_directions_by_complex_id(complex_ids): cursor.execute( """ SELECT - di.napravleniye_id, - di.time_confirmation + DISTINCT ON (di.napravleniye_id) napravleniye_id, + di.time_confirmation as iss_time_confirmation FROM directions_complexresearchaccountperson LEFT JOIN directions_issledovaniya di on directions_complexresearchaccountperson.id = di.complex_research_account_id - WHERE directions_complexresearchaccountperson.id in %(complex_ids)s and di.time_confirmation is not Null - ORDER BY di.time_confirmation DESC + WHERE directions_complexresearchaccountperson.id in %(complex_ids)s """, params={'complex_ids': complex_ids}, ) diff --git a/directions/views.py b/directions/views.py index 00de725bf9..110b2fe777 100644 --- a/directions/views.py +++ b/directions/views.py @@ -34,7 +34,7 @@ from hospitals.models import Hospitals import slog.models as slog from appconf.manager import SettingManager -from directions.models import Napravleniya, Issledovaniya, TubesRegistration, DirectionParamsResult, IstochnikiFinansirovaniya +from directions.models import Napravleniya, Issledovaniya, TubesRegistration, DirectionParamsResult, IstochnikiFinansirovaniya, ComplexResearchAccountPerson from laboratory.decorators import logged_in_or_token from laboratory.settings import FONTS_FOLDER, PRINT_ADDITIONAL_PAGE_DIRECTION_FIN_SOURCE, PRINT_APPENDIX_PAGE_DIRECTION, FORMS_LABORATORY_DIRECTION_DEFAULT from laboratory.utils import strtime, strdate @@ -173,6 +173,11 @@ def gen_pdf_dir(request): direction_id = json.loads(request.GET.get("napr_id", '[]')) appendix = request.GET.get("appendix", 0) narrow_format = request.GET.get("narrowFormat", "0") == "1" + is_complex = request.GET.get("complex", "0") == "1" + + if is_complex: + complex_id = json.loads(request.GET.get("complex_id", '[]')) + direction_id = ComplexResearchAccountPerson.get_complex_directions(tuple(complex_id)) req_from_additional_pages = False req_from_appendix_pages = False @@ -190,6 +195,7 @@ def gen_pdf_dir(request): pdfmetrics.registerFont(TTFont('OpenSans', os.path.join(FONTS_FOLDER, 'OpenSans.ttf'))) pdfmetrics.registerFont(TTFont('OpenSansBold', os.path.join(FONTS_FOLDER, 'OpenSans-Bold.ttf'))) pdfmetrics.registerFont(TTFont('TimesNewRoman', os.path.join(FONTS_FOLDER, 'TimesNewRoman.ttf'))) + dn = ( Napravleniya.objects.filter(pk__in=direction_id) .prefetch_related( diff --git a/l2-frontend/src/registerHooks.ts b/l2-frontend/src/registerHooks.ts index 4968dfc86b..0c9cb52c15 100644 --- a/l2-frontend/src/registerHooks.ts +++ b/l2-frontend/src/registerHooks.ts @@ -28,8 +28,8 @@ export default (instance: Vue): void => { printForm('/directions/pdf?napr_id={pks}&contract=1', pks); }); - instance.$root.$on('print:directions:complex', pks => { - printForm('/directions/pdf?napr_id={pks}&complex=1', pks); + instance.$root.$on('print:complex:directions', pks => { + printForm('/directions/pdf?complex_id={pks}&complex=1', pks); }); instance.$root.$on('print:directions:appendix', pks => { diff --git a/l2-frontend/src/ui-cards/DirectionsHistory/Bottom/mixins/menu.js b/l2-frontend/src/ui-cards/DirectionsHistory/Bottom/mixins/menu.js index 7aced5f738..a33beec0bb 100644 --- a/l2-frontend/src/ui-cards/DirectionsHistory/Bottom/mixins/menu.js +++ b/l2-frontend/src/ui-cards/DirectionsHistory/Bottom/mixins/menu.js @@ -20,18 +20,21 @@ const menuItems = [ }, { title: 'Печать результатов', + onlyForTypes: [0, 1, 2, 3, 4], handler() { this.$root.$emit('print:results', this.checked); }, }, { title: 'Печать штрих-кодов', + onlyForTypes: [0, 1, 2, 3, 4], handler() { this.$root.$emit('print:barcodes', this.checked); }, }, { title: 'Печать направлений', + onlyForTypes: [0, 1, 2, 3, 4], handler() { this.$root.$emit('print:directions', this.checked); }, diff --git a/l2-frontend/src/ui-cards/DirectionsHistory/index.vue b/l2-frontend/src/ui-cards/DirectionsHistory/index.vue index bf542b5613..3c8597b6f9 100644 --- a/l2-frontend/src/ui-cards/DirectionsHistory/index.vue +++ b/l2-frontend/src/ui-cards/DirectionsHistory/index.vue @@ -243,7 +243,7 @@
+ + +
-
- - -