From b6e918bb05ae6dee58372993169853d82683f23d Mon Sep 17 00:00:00 2001 From: well Date: Mon, 7 Oct 2024 10:14:58 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=D0=93=D1=80=D1=83=D0=BF=D0=BF=D0=B0=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=20=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- context_processors/utils.py | 2 +- l2-frontend/src/mainWithRouter.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/context_processors/utils.py b/context_processors/utils.py index 397b296f12..d80eda591e 100644 --- a/context_processors/utils.py +++ b/context_processors/utils.py @@ -144,7 +144,7 @@ def menu(request): "nt": False, "access": ["Управление анализаторами"], }, - {"url": "/ui/chambers", "title": "Палаты", "nt": False, "access": ["Управления палатами"]}, + {"url": "/ui/chambers", "title": "Палаты", "nt": False, "access": ["Лечащий врач"]}, {"url": '/ui/list-wait', "title": "Листы ожидания", "nt": False, "access": ["Лечащий врач", "Оператор лечащего врача"], "module": "l2_list_wait"}, {"url": '/ui/doc-call', "title": "Вызовы врача и заявки", "nt": False, "access": ["Лечащий врач", "Оператор лечащего врача", "Вызов врача"], "module": "l2_doc_call"}, { diff --git a/l2-frontend/src/mainWithRouter.ts b/l2-frontend/src/mainWithRouter.ts index 3333efbe40..3dbff7e089 100644 --- a/l2-frontend/src/mainWithRouter.ts +++ b/l2-frontend/src/mainWithRouter.ts @@ -750,7 +750,7 @@ const router = new Router({ meta: { narrowLayout: true, title: 'Палаты', - groups: ['Палаты'], + groups: ['Лечащий врач'], fullPageLayout: true, }, }, From bf996b7b5a557a6252dd3ee4fa65300b79547421 Mon Sep 17 00:00:00 2001 From: well Date: Mon, 7 Oct 2024 10:16:42 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=B2=D1=8F=D0=B7?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BA=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8E=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=86=D0=B8=D0=BE=D0=BD=D0=B0=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- context_processors/utils.py | 2 +- l2-frontend/src/mainWithRouter.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/context_processors/utils.py b/context_processors/utils.py index d80eda591e..1bd447b0ee 100644 --- a/context_processors/utils.py +++ b/context_processors/utils.py @@ -144,7 +144,7 @@ def menu(request): "nt": False, "access": ["Управление анализаторами"], }, - {"url": "/ui/chambers", "title": "Палаты", "nt": False, "access": ["Лечащий врач"]}, + {"url": "/ui/chambers", "title": "Палаты", "nt": False, "access": ["Лечащий врач"], "module": "l2_hosp"}, {"url": '/ui/list-wait', "title": "Листы ожидания", "nt": False, "access": ["Лечащий врач", "Оператор лечащего врача"], "module": "l2_list_wait"}, {"url": '/ui/doc-call', "title": "Вызовы врача и заявки", "nt": False, "access": ["Лечащий врач", "Оператор лечащего врача", "Вызов врача"], "module": "l2_doc_call"}, { diff --git a/l2-frontend/src/mainWithRouter.ts b/l2-frontend/src/mainWithRouter.ts index 3dbff7e089..d9fb2e345c 100644 --- a/l2-frontend/src/mainWithRouter.ts +++ b/l2-frontend/src/mainWithRouter.ts @@ -751,6 +751,7 @@ const router = new Router({ narrowLayout: true, title: 'Палаты', groups: ['Лечащий врач'], + module: 'l2_hosp', fullPageLayout: true, }, }, From de7ebbde515282f0876419344f64e1c6d6cd5590 Mon Sep 17 00:00:00 2001 From: well Date: Mon, 7 Oct 2024 10:18:36 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=D0=93=D1=80=D1=83=D0=BF=D0=BF=D0=B0=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=20=D0=BD=D0=B0=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/chambers/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/chambers/views.py b/api/chambers/views.py index e25c4f395f..4bfbe40980 100644 --- a/api/chambers/views.py +++ b/api/chambers/views.py @@ -9,7 +9,7 @@ @login_required -@group_required("Управления палатами") +@group_required("Лечащий врач") def get_unallocated_patients(request): request_data = json.loads(request.body) department_pk = request_data.get('department_pk', -1) @@ -27,7 +27,7 @@ def get_unallocated_patients(request): @login_required -@group_required("Управления палатами") +@group_required("Лечащий врач") def get_chambers_and_beds(request): request_data = json.loads(request.body) department_id = request_data.get('department_pk', -1) @@ -99,7 +99,7 @@ def extract_patient_bed(request): @login_required -@group_required("Управления палатами") +@group_required("Лечащий врач") def get_attending_doctors(request): request_data = json.loads(request.body) department_pk = request_data.get('department_pk', -1) @@ -126,7 +126,7 @@ def update_doctor_to_bed(request): @login_required -@group_required("Управления палатами") +@group_required("Лечащий врач") def get_patients_without_bed(request): request_data = json.loads(request.body) department_pk = request_data.get('department_pk', -1) From e2f7b917ff10dd5f770c229e4caff24691f65d4d Mon Sep 17 00:00:00 2001 From: well Date: Mon, 7 Oct 2024 10:20:18 +0800 Subject: [PATCH 04/21] fix --- l2-frontend/src/mainWithRouter.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/l2-frontend/src/mainWithRouter.ts b/l2-frontend/src/mainWithRouter.ts index d9fb2e345c..eaad7c5769 100644 --- a/l2-frontend/src/mainWithRouter.ts +++ b/l2-frontend/src/mainWithRouter.ts @@ -748,7 +748,6 @@ const router = new Router({ name: 'ManageChamber', component: () => import('@/pages/ManageChambers/index.vue'), meta: { - narrowLayout: true, title: 'Палаты', groups: ['Лечащий врач'], module: 'l2_hosp', From 7cf0304e200dbe8b61c8791fa73ebeb2ccfb772a Mon Sep 17 00:00:00 2001 From: well Date: Mon, 7 Oct 2024 10:38:50 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=D0=94=D0=BE=D1=81=D1=82=D1=83=D0=BF=20?= =?UTF-8?q?=D1=81=D1=80=D0=B5=D0=B4=D0=BD=D0=B5=D0=BC=D1=83=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=B4.=20=D0=BF=D0=B5=D1=80=D1=81=D0=BE=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/chambers/views.py | 18 +++++++++--------- context_processors/utils.py | 2 +- l2-frontend/src/mainWithRouter.ts | 5 ++++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/api/chambers/views.py b/api/chambers/views.py index 4bfbe40980..0cba0ce093 100644 --- a/api/chambers/views.py +++ b/api/chambers/views.py @@ -9,7 +9,7 @@ @login_required -@group_required("Лечащий врач") +@group_required("Оператор лечащего врача", "Лечащий врач") def get_unallocated_patients(request): request_data = json.loads(request.body) department_pk = request_data.get('department_pk', -1) @@ -27,7 +27,7 @@ def get_unallocated_patients(request): @login_required -@group_required("Лечащий врач") +@group_required("Оператор лечащего врача", "Лечащий врач") def get_chambers_and_beds(request): request_data = json.loads(request.body) department_id = request_data.get('department_pk', -1) @@ -77,7 +77,7 @@ def get_chambers_and_beds(request): @login_required -@group_required("Управления палатами") +@group_required("Оператор лечащего врача", "Лечащий врач") def entrance_patient_to_bed(request): request_data = json.loads(request.body) bed_id = request_data.get('bed_id') @@ -88,7 +88,7 @@ def entrance_patient_to_bed(request): @login_required -@group_required("Управления палатами") +@group_required("Оператор лечащего врача", "Лечащий врач") def extract_patient_bed(request): request_data = json.loads(request.body) direction_pk = request_data.get('patient') @@ -99,7 +99,7 @@ def extract_patient_bed(request): @login_required -@group_required("Лечащий врач") +@group_required("Оператор лечащего врача", "Лечащий врач") def get_attending_doctors(request): request_data = json.loads(request.body) department_pk = request_data.get('department_pk', -1) @@ -117,7 +117,7 @@ def get_attending_doctors(request): @login_required -@group_required("Управления палатами") +@group_required("Оператор лечащего врача", "Лечащий врач") def update_doctor_to_bed(request): request_data = json.loads(request.body) doctor_obj = request_data.get('doctor') @@ -126,7 +126,7 @@ def update_doctor_to_bed(request): @login_required -@group_required("Лечащий врач") +@group_required("Оператор лечащего врача", "Лечащий врач") def get_patients_without_bed(request): request_data = json.loads(request.body) department_pk = request_data.get('department_pk', -1) @@ -146,7 +146,7 @@ def get_patients_without_bed(request): @login_required -@group_required("Управления палатами") +@group_required("Оператор лечащего врача", "Лечащий врач") def save_patient_without_bed(request): request_data = json.loads(request.body) department_pk = request_data.get('department_pk') @@ -156,7 +156,7 @@ def save_patient_without_bed(request): @login_required -@group_required("Управления палатами") +@group_required("Оператор лечащего врача", "Лечащий врач") def delete_patient_without_bed(request): request_data = json.loads(request.body) patient_obj = request_data.get('patient_obj') diff --git a/context_processors/utils.py b/context_processors/utils.py index 1bd447b0ee..4c5be62a68 100644 --- a/context_processors/utils.py +++ b/context_processors/utils.py @@ -144,7 +144,7 @@ def menu(request): "nt": False, "access": ["Управление анализаторами"], }, - {"url": "/ui/chambers", "title": "Палаты", "nt": False, "access": ["Лечащий врач"], "module": "l2_hosp"}, + {"url": "/ui/chambers", "title": "Палаты", "nt": False, "access": ["Оператор лечащего врача", "Лечащий врач"], "module": "l2_hosp"}, {"url": '/ui/list-wait', "title": "Листы ожидания", "nt": False, "access": ["Лечащий врач", "Оператор лечащего врача"], "module": "l2_list_wait"}, {"url": '/ui/doc-call', "title": "Вызовы врача и заявки", "nt": False, "access": ["Лечащий врач", "Оператор лечащего врача", "Вызов врача"], "module": "l2_doc_call"}, { diff --git a/l2-frontend/src/mainWithRouter.ts b/l2-frontend/src/mainWithRouter.ts index eaad7c5769..f372ec0470 100644 --- a/l2-frontend/src/mainWithRouter.ts +++ b/l2-frontend/src/mainWithRouter.ts @@ -749,7 +749,10 @@ const router = new Router({ component: () => import('@/pages/ManageChambers/index.vue'), meta: { title: 'Палаты', - groups: ['Лечащий врач'], + groups: [ + 'Оператор лечащего врача', + 'Лечащий врач', + ], module: 'l2_hosp', fullPageLayout: true, }, From 2b918dc01411c3c54b5dbd5912d391b4ccaa731e Mon Sep 17 00:00:00 2001 From: well Date: Mon, 7 Oct 2024 11:18:48 +0800 Subject: [PATCH 06/21] =?UTF-8?q?=D0=A0=D0=B0=D0=B7=D1=80=D0=B5=D1=88?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D1=8C=20?= =?UTF-8?q?=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D1=81=D0=BE=D1=82=D1=80?= =?UTF-8?q?=D1=83=D0=B4=D0=BD=D0=B8=D0=BA=D0=B0=D0=BC=20=D0=BE=D1=82=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/chambers/views.py | 28 +++++++++++++++++-- .../src/pages/ManageChambers/index.vue | 1 + podrazdeleniya/models.py | 22 +++++++++------ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/api/chambers/views.py b/api/chambers/views.py index 0cba0ce093..dfecb52bf4 100644 --- a/api/chambers/views.py +++ b/api/chambers/views.py @@ -82,6 +82,13 @@ def entrance_patient_to_bed(request): request_data = json.loads(request.body) bed_id = request_data.get('bed_id') direction_id = request_data.get('direction_id') + user_department_id = request.user.doctorprofile.podrazdeleniye_id + bed: Bed = Bed.objects.filter(pk=bed_id).select_related('chamber').first() + if not bed: + return status_response(False, "ID кровати обязателен") + bed_department_id = bed.chamber.podrazdelenie_id + if not user_department_id == bed_department_id: + return status_response(False, "Пользователь не принадлежит к данному подразделению") if not PatientToBed.objects.filter(bed_id=bed_id, date_out=None).exists(): PatientToBed(direction_id=direction_id, bed_id=bed_id).save() return status_response(True) @@ -92,7 +99,13 @@ def entrance_patient_to_bed(request): def extract_patient_bed(request): request_data = json.loads(request.body) direction_pk = request_data.get('patient') - patient = PatientToBed.objects.filter(direction_id=direction_pk, date_out=None).first() + user_department_id = request.user.doctorprofile.podrazdeleniye_id + patient: PatientToBed = PatientToBed.objects.filter(direction_id=direction_pk, date_out=None).select_related('bed__chamber').first() + if not patient: + return status_response(False, "ID истории болезни обязателен") + bed_department_id = patient.bed.chamber.podrazdelenie_id + if not user_department_id == bed_department_id: + return status_response(False, "Пользователь не принадлежит к данному подразделению") patient.date_out = datetime.datetime.today() patient.save() return status_response(True) @@ -120,8 +133,12 @@ def get_attending_doctors(request): @group_required("Оператор лечащего врача", "Лечащий врач") def update_doctor_to_bed(request): request_data = json.loads(request.body) + user_department_id = request.user.doctorprofile.podrazdeleniye_id doctor_obj = request_data.get('doctor') - result = PatientToBed.update_doctor(doctor_obj) + doctor_id = doctor_obj.get('doctor_pk') + direction_id = doctor_obj.get('direction_id') + is_assign = doctor_obj.get('is_assign') + result = PatientToBed.update_doctor(doctor_id, direction_id, is_assign, user_department_id) return status_response(result) @@ -151,6 +168,9 @@ def save_patient_without_bed(request): request_data = json.loads(request.body) department_pk = request_data.get('department_pk') patient_obj = request_data.get('patient_obj') + user_department_id = request.user.doctorprofile.podrazdeleniye_id + if user_department_id != department_pk: + return status_response(False, "Пользователь не принадлежит к данному подразделению") PatientStationarWithoutBeds(direction_id=patient_obj["direction_pk"], department_id=department_pk).save() return status_response(True) @@ -159,6 +179,10 @@ def save_patient_without_bed(request): @group_required("Оператор лечащего врача", "Лечащий врач") def delete_patient_without_bed(request): request_data = json.loads(request.body) + department_pk = request_data.get('department_pk') patient_obj = request_data.get('patient_obj') + user_department_id = request.user.doctorprofile.podrazdeleniye_id + if user_department_id != department_pk: + return status_response(False, "Пользователь не принадлежит к данному подразделению") PatientStationarWithoutBeds.objects.get(direction_id=patient_obj["direction_pk"]).delete() return status_response(True) diff --git a/l2-frontend/src/pages/ManageChambers/index.vue b/l2-frontend/src/pages/ManageChambers/index.vue index cb72992f11..e98563f801 100644 --- a/l2-frontend/src/pages/ManageChambers/index.vue +++ b/l2-frontend/src/pages/ManageChambers/index.vue @@ -394,6 +394,7 @@ const PatientWaitBed = async ({ added, removed }) => { if (removed) { await store.dispatch(actions.INC_LOADING); await api('chambers/delete-patient-without-bed', { + department_pk: departmentPatientPk.value, patient_obj: removed.element, }); await store.dispatch(actions.DEC_LOADING); diff --git a/podrazdeleniya/models.py b/podrazdeleniya/models.py index 92171ca115..1345aa7575 100644 --- a/podrazdeleniya/models.py +++ b/podrazdeleniya/models.py @@ -153,16 +153,20 @@ def __str__(self): return f'{self.direction.client.individual.fio()}' @staticmethod - def update_doctor(doctor_obj): - if doctor_obj["is_assign"]: - doctor = PatientToBed.objects.filter(direction_id=doctor_obj["direction_id"], doctor=None, date_out=None).first() - doctor.doctor_id = doctor_obj["doctor_pk"] - doctor.save() + def update_doctor(doctor_id, direction_id, is_assign, user_deparment_id): + result = {"ok": True, "message": ""} + patient_to_bed = PatientToBed.objects.filter(direction_id=direction_id, date_out=None).select_related('bed__chamber').first() + bed_department_id = patient_to_bed.bed.chamber.podrazdelenie_id + if bed_department_id != user_deparment_id: + result = {"ok": False, "message": "Пользователь не принадлежит к данному подразделению"} + return result + if is_assign: + patient_to_bed.doctor_id = doctor_id + patient_to_bed.save() else: - doctor = PatientToBed.objects.filter(doctor_id=doctor_obj["doctor_pk"], direction_id=doctor_obj["direction_id"], date_out=None).first() - doctor.doctor = None - doctor.save() - return True + patient_to_bed.doctor = None + patient_to_bed.save() + return result class Meta: verbose_name = 'Историю коек' From e87cc4b0cb4e0145681e7bd0faa985910bbf5fe0 Mon Sep 17 00:00:00 2001 From: well Date: Mon, 7 Oct 2024 11:31:49 +0800 Subject: [PATCH 07/21] =?UTF-8?q?message=20=D0=BE=20=D1=81=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D1=8F=D0=BD=D0=B8=D0=B8=20=D0=B7=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/ManageChambers/index.vue | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/l2-frontend/src/pages/ManageChambers/index.vue b/l2-frontend/src/pages/ManageChambers/index.vue index e98563f801..3f6fcb4585 100644 --- a/l2-frontend/src/pages/ManageChambers/index.vue +++ b/l2-frontend/src/pages/ManageChambers/index.vue @@ -243,7 +243,7 @@