Skip to content

Commit

Permalink
Merge pull request #4388 from mikhailprivalov/chambers-v2.6
Browse files Browse the repository at this point in the history
Палаты и койки v2.6
  • Loading branch information
urchinpro authored Oct 15, 2024
2 parents c0a9839 + e01f762 commit af7115b
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 38 deletions.
30 changes: 25 additions & 5 deletions api/chambers/sql_func.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.db import connection

from laboratory.settings import TIME_ZONE
from utils.db import namedtuplefetchall


Expand All @@ -7,15 +9,17 @@ def load_patients_stationar_unallocated_sql(department_id):
cursor.execute(
"""
SELECT
family,
name,
patronymic,
sex,
family,
name,
patronymic,
sex,
napravleniye_id,
directory_researches.title as service_title,
directions_issledovaniya.id as issledovanie_id,
birthday,
date_part('year', age(birthday))::int AS age
FROM directions_issledovaniya
FROM directions_issledovaniya
INNER JOIN directory_researches ON directions_issledovaniya.research_id = directory_researches.id
INNER JOIN directions_napravleniya ON directions_issledovaniya.napravleniye_id=directions_napravleniya.id
INNER JOIN clients_card ON directions_napravleniya.client_id=clients_card.id
INNER JOIN public.clients_individual ON clients_card.individual_id = public.clients_individual.id
Expand Down Expand Up @@ -163,3 +167,19 @@ def load_chambers_and_beds_by_department(department_id):

rows = namedtuplefetchall(cursor)
return rows


def load_plan_operations_next_day(start_time, end_time):
with connection.cursor() as cursor:
cursor.execute(
"""
SELECT
direction
FROM plans_planoperations
WHERE date AT TIME ZONE %(tz)s BETWEEN %(start_time)s AND %(end_time)s
""",
params={"tz": TIME_ZONE, "start_time": start_time, "end_time": end_time},
)

rows = namedtuplefetchall(cursor)
return rows
11 changes: 11 additions & 0 deletions api/chambers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.http import JsonResponse

from laboratory.settings import CHAMBER_DOCTOR_GROUP_ID
from laboratory.utils import current_time
from podrazdeleniya.models import Chamber, Bed, PatientToBed, PatientStationarWithoutBeds
from slog.models import Log
from utils.response import status_response
Expand All @@ -14,6 +15,7 @@
load_patients_stationar_unallocated_sql,
load_chambers_and_beds_by_department,
get_closing_protocols,
load_plan_operations_next_day,
)


Expand All @@ -26,6 +28,7 @@ def get_unallocated_patients(request):
all_histories = load_patients_stationar_unallocated_sql(department_pk)
all_issledovaniya_ids = [history.issledovanie_id for history in all_histories]
all_issledovaniya_ids = tuple(all_issledovaniya_ids)
closed_issledovaniya_ids = []
if all_issledovaniya_ids:
closed_histories = get_closing_protocols(all_issledovaniya_ids, transferable_epicrisis_titles)
closed_issledovaniya_ids = [extract.parent_id for extract in closed_histories]
Expand All @@ -38,6 +41,7 @@ def get_unallocated_patients(request):
"short_fio": f'{patient.family} {patient.name[0]}. {patient.patronymic[0] if patient.patronymic else ""}.',
"sex": patient.sex,
"direction_pk": patient.napravleniye_id,
"service_title": patient.service_title,
}
for patient in load_patients_stationar_unallocated_sql(department_pk)
if patient.issledovanie_id not in closed_issledovaniya_ids
Expand All @@ -52,6 +56,12 @@ def get_chambers_and_beds(request):
request_data = json.loads(request.body)
department_id = request_data.get('department_pk', -1)
chambers = {}
current_date = current_time(True)
next_date = current_date + datetime.timedelta(days=1)
start_time = f"{next_date.year}-{next_date.month}-{next_date.day} 00:00"
end_time = f"{next_date.year}-{next_date.month}-{next_date.day} 23:59"
operation_plan = load_plan_operations_next_day(start_time, end_time)
directions_ids_operation = [int(operation.direction) for operation in operation_plan]
chambers_beds = load_chambers_and_beds_by_department(department_id)
for chamber in chambers_beds:
if not chambers.get(chamber.chamber_id):
Expand All @@ -76,6 +86,7 @@ def get_chambers_and_beds(request):
"short_fio": f"{chamber.patient_family} {chamber.patient_name[0]}. {chamber.patient_patronymic[0] if chamber.patient_patronymic else ''}.",
"age": chamber.patient_age,
"sex": chamber.patient_sex,
"operationNextDay": chamber.direction_id in directions_ids_operation,
}
)
if chamber.doctor_id:
Expand Down
33 changes: 24 additions & 9 deletions l2-frontend/src/pages/ManageChambers/components/VueTippyDiv.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
@mouseenter="showTitle"
>
<a
v-if="props.historyId && showLink"
v-if="props.link && props.showLink"
class="a-under"
target="_blank"
:href="stationarLink(props.historyId)"
:href="props.link"
:class="props.gender === 'ж' ? 'women' : 'men'"
>
{{ props.text }}
</a>
<p v-else>
<p
v-else
class="text"
>
{{ props.text }}
</p>
</component>
Expand All @@ -39,14 +43,18 @@ const props = defineProps({
required: false,
default: 'div',
},
historyId: {
type: Number,
required: false,
},
showLink: {
type: Boolean,
required: false,
},
link: {
type: String,
required: false,
},
gender: {
type: String,
required: false,
},
});
const show = ref(false);
Expand All @@ -61,9 +69,16 @@ const showTitle = (event) => {
};
// eslint-disable-next-line max-len
const stationarLink = (historyId) => `/ui/stationar#{%22pk%22:${historyId},%22opened_list_key%22:null,%22opened_form_pk%22:null,%22every%22:false}`;
</script>

<style scoped lang="scss">
.text {
margin: 0;
}
.women {
color: #ff73ea;
}
.man {
color: #00bfff;
}
</style>
103 changes: 79 additions & 24 deletions l2-frontend/src/pages/ManageChambers/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@
<div
v-for="patient in unallocatedPatientsFiltered"
:key="patient.direction_pk"
v-tippy="{ placement: 'top', arrow: true }"
class="draggable-item"
:title="`${patient.direction_pk} ${patient.service_title}`"
>
{{ patient.fio }}
<a
class="a-under"
target="_blank"
:href="stationarLink(patient.direction_pk)"
:class="{ 'women': changeColorWomen(patient), 'man': changeColorMan(patient) }"
>
{{ patient.short_fio }}
</a>
<i
class="fa-solid fa-child-reaching icon-patient"
:class="{ 'women': changeColorWomen(patient), 'man': changeColorMan(patient) }"
Expand All @@ -65,19 +74,19 @@
<th>
<div class="flex-space">
<div>
Управление койками
(Кол.коек: {{ bedInformationCounter.bed }},
Койки
(Кол-во: {{ bedInformationCounter.bed }},
Занятых: {{ bedInformationCounter.occupied }},
М: {{ bedInformationCounter.man }},
Ж: {{ bedInformationCounter.women }})
</div>
<div>
<input
id="onlyUserPatient"
v-model="onlyUserPatient"
type="checkbox"
>
<label for="onlyUserPatient">Только мои</label>
<div class="filter-width">
<Treeselect
v-model="bedFilter"
:options="bedsFilters"
placeholder="Фильтр"
class="treeselect-25px"
/>
</div>
</div>
</th>
Expand All @@ -99,7 +108,7 @@
v-for="bed in chamber.beds"
:key="bed.pk"
class="beds-item"
:class="{'opacity': checkConditionsOpacity(bed.doctor) }"
:class="{'opacity': checkConditionsOpacity(bed) }"
>
<draggable
v-model="bed.doctor"
Expand Down Expand Up @@ -162,14 +171,14 @@
</div>
</draggable>
<div
v-if="bed.patient.length > 0 || bed.doctor.length > 0"
class="info"
>
<VueTippyDiv
v-if="bed.patient.length > 0"
:text="bed.patient[0].short_fio"
:history-id="bed.patient[0].direction_pk"
:show-link="userCanGoHistory"
:gender="bed.patient[0].sex"
:link="stationarLink(bed.patient[0].direction_pk)"
class="text-size"
/>
<hr
Expand Down Expand Up @@ -225,7 +234,14 @@
:key="patient.direction_pk"
class="draggable-item waiting-item"
>
{{ patient.short_fio }}
<a
class="a-under"
target="_blank"
:href="stationarLink(patient.direction_pk)"
:class="{ 'women': changeColorWomen(patient), 'man': changeColorMan(patient) }"
>
{{ patient.short_fio }}
</a>
<i
class="fa-solid fa-child-reaching icon-patient"
:class="{ 'women': changeColorWomen(patient), 'man': changeColorMan(patient) }"
Expand Down Expand Up @@ -301,6 +317,8 @@ interface patientData {
fio: string
sex: string
short_fio: string
operationNextDay?: boolean,
service_title?: string,
}
interface doctorData {
fio: string
Expand Down Expand Up @@ -338,7 +356,11 @@ const userDepartmentId = user.department.pk;
const userCanGoHistory = ref(false);
const patientSearch = ref('');
const doctorSearch = ref('');
const onlyUserPatient = ref(false);
const bedFilter = ref(null);
const bedsFilters = ref([
{ id: 'my', label: 'Только мои' },
{ id: 'operation', label: 'На операцию' },
]);
const transferDoctor = ref(null);
const copyBedDoctor = (bed) => {
Expand Down Expand Up @@ -590,13 +612,29 @@ const checkConditionsPullBed = (patient: patientData[]) => {
return false;
};
const checkConditionsOpacity = (doctor: doctorData[]) => {
if (onlyUserPatient.value) {
if (doctor.length > 0) {
const [userData] = doctor;
return userData.pk !== user.doc_pk;
const checkByDoctor = (doctor: doctorData[]) => {
if (doctor.length > 0) {
const [userData] = doctor;
return userData.pk !== user.doc_pk;
}
return true;
};
const checkByOperation = (patient: patientData[]) => {
if (patient.length > 0) {
const [dataPatient] = patient;
return !dataPatient.operationNextDay;
}
return true;
};
const checkConditionsOpacity = (bed: bedData) => {
if (bedFilter.value) {
if (bedFilter.value === 'my') {
return checkByDoctor(bed.doctor);
} if (bedFilter.value === 'operation') {
return checkByOperation(bed.patient);
}
return true;
}
return false;
};
Expand Down Expand Up @@ -665,6 +703,9 @@ onMounted(() => {
checkUserCanGoHistory();
});
// eslint-disable-next-line max-len
const stationarLink = (historyId) => `/ui/stationar#{%22pk%22:${historyId},%22opened_list_key%22:null,%22opened_form_pk%22:null,%22every%22:false}`;
</script>

<style scoped lang="scss">
Expand All @@ -678,7 +719,7 @@ onMounted(() => {
background-color: #FFFAFA;
}
.women {
color: #ffb9ea;
color: #ff73ea;
}
.man {
color: #00bfff;
Expand Down Expand Up @@ -835,7 +876,7 @@ onMounted(() => {
}
.waiting-item {
align-self: flex-start;
flex: 0 1 143px;
flex: 0 1 176px;
}
.no-rooms {
text-align: center;
Expand All @@ -851,7 +892,7 @@ onMounted(() => {
flex-wrap: wrap;
}
.beds-item {
flex: 1 1 33.3333%;
flex: 0 1 33.3333%;
display: flex;
flex-wrap: nowrap;
margin: 10px 0;
Expand Down Expand Up @@ -921,5 +962,19 @@ onMounted(() => {
.flex-space {
display: flex;
justify-content: space-between;
align-items: center;
}
.filter-width {
width: 150px;
}
::v-deep .treeselect-25px .vue-treeselect {
&__control {
height: 25px !important;
}
&__placeholder,
&__single-value {
line-height: 25px !important;
}
}
</style>

0 comments on commit af7115b

Please sign in to comment.