Skip to content

Commit

Permalink
Merge pull request #4080 from mikhailprivalov/directionFromGroup
Browse files Browse the repository at this point in the history
Direction from group
  • Loading branch information
Wellheor1 authored Jul 9, 2024
2 parents 9ec4fa0 + 8a6f67a commit 8ab3c92
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 28 deletions.
6 changes: 5 additions & 1 deletion directions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 3 additions & 4 deletions directions/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
)
Expand Down
8 changes: 7 additions & 1 deletion directions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions l2-frontend/src/registerHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
38 changes: 19 additions & 19 deletions l2-frontend/src/ui-cards/DirectionsHistory/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
</td>
<td class="button-td">
<div
v-if="!row.is_application && active_type !== 5 && active_type !== 6"
v-if="!row.is_application && active_type !== 5 && active_type !== 6 && active_type !== 8"
class="button-td-inner"
:class="[
{
Expand Down Expand Up @@ -351,6 +351,23 @@
Договор
</button>
</div>
<div
v-else-if="active_type===8"
class="button-td-inner"
>
<button
class="btn btn-blue-nb"
@click="show_results(row)"
>
Результаты
</button>
<button
class="btn btn-blue-nb"
@click="print_direction_for_complex(row.pk)"
>
Направления
</button>
</div>
<div
v-else-if="active_type===6"
class="button-td-inner has_pacs"
Expand Down Expand Up @@ -378,23 +395,6 @@
Талон-А6
</button>
</div>
<div
v-else-if="active_type===8"
class="button-td-inner has_pacs"
>
<button
class="btn btn-blue-nb"
@click="show_results(row)"
>
Результаты
</button>
<button
class="btn btn-blue-nb"
@click="print_direction_for_complex(row.pk)"
>
Направления
</button>
</div>
</td>
<td class="nopd">
<input
Expand Down Expand Up @@ -676,7 +676,7 @@ export default {
this.$root.$emit('print:directions', [pk]);
},
print_direction_for_complex(pk) {
this.$root.$emit('print:directions:complex', [pk]);
this.$root.$emit('print:complex:directions', [pk]);
},
print_hosp(pk) {
this.$root.$emit('print:hosp', [pk]);
Expand Down
2 changes: 1 addition & 1 deletion results/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def result_print(request):
with_signature_stamps = request.GET.get("withSignatureStamps", "0") == "1"

if complex:
pk = ComplexResearchAccountPerson.get_complex_directions(tuple(pk))
pk = ComplexResearchAccountPerson.get_complex_confirm_directions(tuple(pk))

doc = BaseDocTemplate(
buffer,
Expand Down

0 comments on commit 8ab3c92

Please sign in to comment.