Skip to content

Commit

Permalink
Merge pull request #3585 from mikhailprivalov/slots-stationar
Browse files Browse the repository at this point in the history
Лист назначений - запись на услуги
  • Loading branch information
urchinpro authored Mar 7, 2024
2 parents f47dd0c + 432bdac commit 4beac92
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 39 deletions.
3 changes: 2 additions & 1 deletion api/ecp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def fill_slot(request):
slot_title = request_data.get('slot_title')
doctor_pk = request_data['doctor_pk']
research_pk = request_data['research_pk']
direction_id = request_data.get('directionId')
date = request_data['date']
card = Card.objects.get(pk=card_pk)
ecp_id = None
Expand All @@ -63,7 +64,7 @@ def fill_slot(request):

if doctor_pk.find("@L") > -1:
s: SlotPlan = SlotPlan.objects.filter(pk=slot_id).first()
save_slot = save_slot_fact(s, card_pk, "reserved", research_pk, False, None , None, False)
save_slot = save_slot_fact(s, card_pk, "reserved", research_pk, False, None, None, False, direction_id)
if save_slot:
r = {'register': True}
else:
Expand Down
7 changes: 5 additions & 2 deletions api/schedule/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from datetime import timedelta

from directory.models import Researches
from doctor_schedule.models import ScheduleResource, SlotFact, SlotPlan, SlotFactCancel
from doctor_schedule.models import ScheduleResource, SlotFact, SlotPlan, SlotFactCancel, SlotFactDirection
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse
from django.db import transaction
Expand Down Expand Up @@ -326,7 +326,7 @@ def cancel(request):
return status_response(False, 'Не получилось отменить')


def save_slot_fact(s, card_pk, status, service_id, is_cito, fin_source, plan_id, disabled):
def save_slot_fact(s, card_pk, status, service_id, is_cito, fin_source, plan_id, disabled, direction_id=None):
if card_pk:
status = {
'reserved': 0,
Expand All @@ -345,6 +345,9 @@ def save_slot_fact(s, card_pk, status, service_id, is_cito, fin_source, plan_id,
slot_fact.is_cito = is_cito
slot_fact.fin_source_id = fin_source
slot_fact.save()
if direction_id:
slot_fact_direction: SlotFactDirection = SlotFactDirection(slot_fact_id=slot_fact.pk, direction_id=direction_id)
slot_fact_direction.save()
if plan_id:
ph: PlanHospitalization = PlanHospitalization.objects.get(pk=plan_id)
ph.slot_fact = slot_fact
Expand Down
10 changes: 9 additions & 1 deletion api/stationar/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ def get_assignments_by_history(history_id: int):
with connection.cursor() as cursor:
cursor.execute(
"""
SELECT public.directions_napravleniya.id as napravlenie_id, public.directions_napravleniya.data_sozdaniya,
SELECT public.directions_napravleniya.id as napravlenie_id, public.directions_napravleniya.data_sozdaniya,
public.doctor_schedule_slotplan.id as slot_plan_id, public.doctor_schedule_slotplan.datetime as schedule_date,
public.users_doctorprofile.fio as who_assigned, doc_list.fio as who_confirm, public.directions_napravleniya.total_confirmed,
public.directions_issledovaniya.time_confirmation, public.directory_researches.id as research_id, public.directory_researches.title as research_title
Expand All @@ -226,6 +227,13 @@ def get_assignments_by_history(history_id: int):
ON public.directions_napravleniya.doc_id = public.users_doctorprofile.id
LEFT JOIN (SELECT id, fio FROM public.users_doctorprofile) as doc_list
ON public.directions_issledovaniya.doc_confirmation_id = doc_list.id
LEFT JOIN public.doctor_schedule_slotfactdirection
ON public.directions_napravleniya.id = doctor_schedule_slotfactdirection.direction_id
LEFT JOIN public.doctor_schedule_slotfact
ON public.doctor_schedule_slotfact.id = doctor_schedule_slotfactdirection.slot_fact_id
LEFT JOIN public.doctor_schedule_slotplan
ON public.doctor_schedule_slotfact.plan_id = public.doctor_schedule_slotplan.id
WHERE public.directions_napravleniya.parent_id = %(history_id)s
AND (is_paraclinic = true OR is_doc_refferal = true OR is_microbiology = true OR is_citology = true OR is_gistology = true OR
Expand Down
54 changes: 27 additions & 27 deletions api/stationar/stationar_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
from copy import deepcopy
from typing import List

import pytz
from pytils import dt

from directions.models import Issledovaniya, Napravleniya
from directory.models import Researches, HospitalService
from laboratory.settings import TIME_ZONE
from podrazdeleniya.models import Podrazdeleniya
from utils import tree_directions
from utils.common import shorten_fio
from .sql_func import (
get_research,
get_iss,
Expand Down Expand Up @@ -576,39 +581,34 @@ def force_to_number(val):
def get_assignments(direction_id: int):
if direction_id is None:
return []
results = []
assignment_tmp = {}
issledovanie_id = Issledovaniya.objects.get(napravleniye_id=direction_id).pk
assignments = get_assignments_by_history(issledovanie_id)
prev_directions_id = -1
for i in assignments:
if prev_directions_id != i.napravlenie_id:
who_assigned = i.who_assigned.split(" ")
family_assigned = who_assigned[0]
name_assigned = who_assigned[1][0]
patronymic_assigned = ""
if len(who_assigned) > 2:
patronymic_assigned = who_assigned[2][0]
tmp_res = {
fio_assigned = shorten_fio(i.who_assigned)
schedule_date = dt.ru_strftime("%d.%m %a %H:%M", i.schedule_date.astimezone(pytz.timezone(TIME_ZONE))) if i.schedule_date else None
create_date = i.data_sozdaniya.strftime("%d.%m.%Y")
research_title = f"{i.research_title}; "
if assignment_tmp.get(i.napravlenie_id):
assignment_tmp[i.napravlenie_id]["research_id"].append(i.research_id)
assignment_tmp[i.napravlenie_id]["research_title"].append(research_title)
else:
assignment_tmp[i.napravlenie_id] = {
"direction_id": i.napravlenie_id,
"research_id": [i.research_id],
"research_title": [f"{i.research_title}; "],
"create_date": i.data_sozdaniya.strftime("%d.%m.%Y"),
"who_assigned": f"{family_assigned} {name_assigned}.{patronymic_assigned}.",
"research_title": [research_title],
"create_date": create_date,
"schedule_date": schedule_date,
"who_assigned": fio_assigned,
"time_confirmation": "",
"who_confirm": "",
}
if i.total_confirmed:
who_confirm = i.who_confirm.split(" ")
family_confirm = who_confirm[0]
name_confirm = who_confirm[1][0]
patronymic_confirm = ""
if len(who_confirm) > 2:
patronymic_confirm = who_confirm[2][0]
tmp_res["time_confirmation"] = i.time_confirmation.strftime("%d.%m.%Y %H:%M")
tmp_res["who_confirm"] = f"{family_confirm} {name_confirm}.{patronymic_confirm}."
results.append(tmp_res)
else:
results[-1]["research_id"].append(i.research_id)
results[-1]["research_title"].append(f"{i.research_title}; ")
prev_directions_id = i.napravlenie_id
return results
fio_confirm = shorten_fio(i.who_confirm)
time_confirmation = i.time_confirmation.astimezone(pytz.timezone(TIME_ZONE))
assignment_tmp[i.napravlenie_id]["time_confirmation"] = time_confirmation.strftime("%d.%m.%Y %H:%M")
assignment_tmp[i.napravlenie_id]["who_confirm"] = fio_confirm

result = [value for value in assignment_tmp.values()]

return result
86 changes: 78 additions & 8 deletions l2-frontend/src/fields/AggregateAssignments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<div class="button">
<button
v-tippy
title="печать"
title="Печать"
class="btn last btn-blue-nb"
@click="printForm"
>
печать
Печать
</button>
</div>
</div>
<div>
<VeTable
:columns="columns"
:table-data="assignments"
:table-data="assignmentPagination"
/>
<div
v-show="assignments.length === 0"
Expand All @@ -34,12 +34,19 @@
/>
</div>
</div>
<ScheduleModal
v-if="showSchedule"
:card-pk="props.cardPk"
:service-number="currentResearchPk"
:direction-id="currentDirectionPk"
@hide="showSchedule = false"
/>
</div>
</template>

<script setup lang="ts">
import {
onMounted, ref,
computed, onMounted, ref,
} from 'vue';
import {
VeLocale,
Expand All @@ -52,12 +59,29 @@ import * as actions from '@/store/action-types';
import api from '@/api';
import { useStore } from '@/store';
import ruRu from '@/locales/ve';
import ScheduleModal from '@/modals/ScheduleModal.vue';
VeLocale.use(ruRu);
const props = defineProps<{
direction: number;
}>();
const props = defineProps({
direction: {
type: Number,
required: true,
},
cardPk: {
type: Number,
required: true,
},
});
const showSchedule = ref(false);
const currentResearchPk = ref(null);
const currentDirectionPk = ref(null);
const openSchedule = (researchId, directionId) => {
currentResearchPk.value = researchId;
currentDirectionPk.value = directionId;
showSchedule.value = true;
};
const columns = ref([
{
Expand All @@ -69,6 +93,28 @@ const columns = ref([
{
field: 'create_date', key: 'create_date', title: 'Дата назначения', align: 'center', width: 150,
},
{
field: 'schedule_date',
key: 'schedule_date',
title: 'Расписание',
align: 'center',
width: 100,
renderBodyCell: ({ row }, h) => {
if (row.schedule_date) {
return row.schedule_date;
}
return h('div', { class: 'button' }, [
h('button', {
class: 'transparent-button',
on: {
click: () => {
openSchedule(row.research_id[0], row.direction_id);
},
},
}, 'Записать'),
]);
},
},
{
field: 'who_assigned', key: 'who_assigned', title: 'ФИО назначившего', align: 'center', width: 200,
},
Expand Down Expand Up @@ -98,6 +144,11 @@ const getAssignments = async () => {
assignments.value = results.data;
};
const assignmentPagination = computed(() => assignments.value.slice(
(page.value - 1) * pageSize.value,
page.value * pageSize.value,
));
const printForm = () => {
window.open(`/forms/pdf?type=107.03&&hosp_pk=${props.direction}`);
};
Expand All @@ -106,7 +157,7 @@ onMounted(getAssignments);
</script>

<style scoped>
<style scoped lang="scss">
.empty-list {
width: 85px;
margin: 20px auto;
Expand All @@ -132,3 +183,22 @@ onMounted(getAssignments);
padding: 6px 0;
}
</style>

<style lang="scss">
.transparent-button {
background-color: transparent;
color: #434A54;
border: none;
border-radius: 4px;
padding: 6px 12px;
&:hover {
background-color: #434a54;
color: #FFF;
}
&:active {
background-color: #37BC9B;
color: #FFF;
}
}
</style>
72 changes: 72 additions & 0 deletions l2-frontend/src/modals/ScheduleModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<Modal
ref="modal"
show-footer="true"
white-bg="true"
max-width="600px"
width="100%"
height="20%"
margin-left-right="auto"
margin-top
class="an"
@close="hide"
>
<span slot="header">Расписание</span>
<div
slot="body"
class="modal-body"
>
<ServiceScheduleEcp
:card-id="props.cardPk"
:service-pk="props.serviceNumber"
:direction-id="props.directionId"
/>
</div>
<div slot="footer">
<div class="row">
<div class="col-xs-8" />
<div class="col-xs-4">
<button
class="btn btn-primary-nb btn-blue-nb"
type="button"
@click="hide"
>
Закрыть
</button>
</div>
</div>
</div>
</Modal>
</template>

<script setup lang="ts">
import Modal from '@/ui-cards/Modal.vue';
import ServiceScheduleEcp from '@/ui-cards/ServiceScheduleEcp.vue';
const props = defineProps({
cardPk: {
type: Number,
required: true,
},
serviceNumber: {
type: Number,
required: true,
},
directionId: {
type: Number,
required: false,
},
});
const emit = defineEmits(['hide']);
const hide = () => {
emit('hide');
};
</script>

<style scoped lang="scss">
</style>
1 change: 1 addition & 0 deletions l2-frontend/src/pages/Stationar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@
<AggregateAssignments
v-if="opened_list_key === 'assignments'"
:direction="direction"
:card-pk="patient.card_pk"
/>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions l2-frontend/src/ui-cards/ServiceScheduleEcp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export default {
type: Number,
required: true,
},
directionId: {
type: Number,
required: false,
},
},
data() {
return {
Expand Down Expand Up @@ -285,6 +289,7 @@ export default {
date: this.activeDate,
slot_title: this.activeSlotTitle,
research_pk: this.servicePk,
directionId: this.directionId,
});
if (register) {
this.$root.$emit('msg', 'ok', 'Пациент записан на прием');
Expand Down
Loading

0 comments on commit 4beac92

Please sign in to comment.