Skip to content

Commit

Permalink
Merge pull request #4171 from mikhailprivalov/customDate_inGetContainer
Browse files Browse the repository at this point in the history
customDate in getBiomaterial
  • Loading branch information
Wellheor1 authored Aug 6, 2024
2 parents 7a9c1c8 + 8d47df0 commit 548999e
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 14 deletions.
4 changes: 3 additions & 1 deletion api/directions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3723,6 +3723,8 @@ def tubes_for_get(request):
@login_required
def tubes_register_get(request):
pks = data_parse(request.body, {'pks': list})[0]
data = json.loads(request.body)
manual_select_get_time = data.get('selectGetTime')

get_details = {}

Expand All @@ -3740,7 +3742,7 @@ def tubes_register_get(request):
if napravleniye.external_executor_hospital and napravleniye.external_executor_hospital.is_external_performing_organization:
napravleniye.need_order_redirection = True
if not val.doc_get and not val.time_get:
val.set_get(request.user.doctorprofile)
val.set_get(request.user.doctorprofile, manual_select_get_time)
get_details[pk] = val.get_details()

return status_response(True, data={'details': get_details})
Expand Down
1 change: 1 addition & 0 deletions appconf/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def l2_modules() -> dict:
"medbook_auto_start": SettingManager.get_medbook_auto_start(),
"descriptive_rich_text": SettingManager.get("descriptive_rich_text", default='false', default_type='b'),
"number_generator_field": SettingManager.get("number_generator_field", default='false', default_type='b'),
"show_manual_select_get_time": SettingManager.get("show_manual_select_get_time", default='false', default_type='b'),
"tfoms_attachment_field": SettingManager.get("tfoms_attachment_field", default='false', default_type='b'),
"auto_clinical_examination_direct": SettingManager.get("auto_clinical_examination_direct", default='false', default_type='b'),
"legal_authenticator": SettingManager.get("legal_authenticator", default='false', default_type='b'),
Expand Down
9 changes: 6 additions & 3 deletions directions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class TubesRegistration(models.Model):
number = models.BigIntegerField(db_index=True, help_text='Номер ёмкости', blank=True, null=True, default=None)
chunk_number = models.PositiveSmallIntegerField(db_index=True, blank=True, null=True, default=None, help_text='Номер разложения ёмкости на несколько')
type = models.ForeignKey(directory.ReleationsFT, help_text='Тип ёмкости', on_delete=models.CASCADE)
time_get = models.DateTimeField(null=True, blank=True, help_text='Время взятия материала', db_index=True)
time_get = models.DateTimeField(null=True, blank=True, help_text='Время взятия материала/ фиксация перации', db_index=True)
manual_selected_time_get = models.DateTimeField(null=True, blank=True, default=None, help_text='Время взятия материала введенное вручну', db_index=True)
doc_get = models.ForeignKey(DoctorProfile, null=True, blank=True, db_index=True, related_name='docget', help_text='Кто взял материал', on_delete=models.SET_NULL)
time_recive = models.DateTimeField(null=True, blank=True, help_text='Время получения материала', db_index=True)
doc_recive = models.ForeignKey(DoctorProfile, null=True, blank=True, db_index=True, related_name='docrecive', help_text='Кто получил материал', on_delete=models.SET_NULL)
Expand Down Expand Up @@ -187,7 +188,7 @@ def day_num(self, doc, num):

return {"n": self.daynum, "new": new_t}

def set_get(self, doc_get):
def set_get(self, doc_get, manual_select_get_time=None):
"""
Установка статуса взятия
:param doc_get: врач/мед сестра, взявшая материал
Expand All @@ -198,6 +199,8 @@ def set_get(self, doc_get):
self.time_get = timezone.now()
self.doc_get = doc_get
self.barcode = str(self.number)
if manual_select_get_time:
self.manual_selected_time_get = manual_select_get_time
self.save()
slog.Log(key=str(self.number), type=9, body="", user=doc_get).save()

Expand Down Expand Up @@ -1531,7 +1534,7 @@ def gen_napravleniya_by_issledovaniya(
if research.direction and external_organization == "NONE" and (not SettingManager.get("dirgroup_by_tube", default='false', default_type='b')):
dir_group = research.direction_id

if SettingManager.get("dirgroup_by_tube", default='false', default_type='b') and research.podrazdeleniye.p_type == 2:
if SettingManager.get("dirgroup_by_tube", default='false', default_type='b') and research.podrazdeleniye and research.podrazdeleniye.p_type == 2:
fraction = directory.Fractions.objects.filter(research=research).first()
dir_group = fraction.relation_id

Expand Down
3 changes: 2 additions & 1 deletion directions/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ def get_data_by_directions_id(direction_ids):
to_char(ci.birthday AT TIME ZONE %(tz)s, 'DD.MM.YY') as patient_birthday,
to_char(dn.data_sozdaniya AT TIME ZONE %(tz)s, 'DD.MM.YY HH24:MI') as direction_create,
dr.internal_code as research_internal_code,
dlm.title as laboratory_material
dlm.title as laboratory_material,
to_char(directions_tubesregistration.time_get AT TIME ZONE %(tz)s, 'DD.MM - HH24:MI') as tube_registration_time
FROM directions_tubesregistration
LEFT JOIN directions_issledovaniya_tubes dit on directions_tubesregistration.id = dit.tubesregistration_id
LEFT JOIN directory_releationsft drft on drft.id = directions_tubesregistration.type_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def handle(self, *args, **kwargs):
for i in ReleationsFT.objects.filter(tube=tube):
if i.pk != relation_tmp:
fraction_obj = Fractions.objects.filter(relation_id=i.pk).first()
if not fraction_obj:
continue
fraction_data[i.pk] = fraction_obj.research.laboratory_material
relation_tmp = i.pk

Expand Down
26 changes: 20 additions & 6 deletions forms/forms114.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, KeepTogether, Image

from directions.models import TubesRegistration, Issledovaniya
from directions.sql_func import get_data_by_directions_id, get_directions_by_who_create
from hospitals.models import Hospitals
from laboratory.settings import FONTS_FOLDER
Expand All @@ -20,6 +21,7 @@
from laboratory.utils import current_time, strdate, strdatetimeru
from utils.dates import normalize_dots_date
from utils.pagenum import PageNumCanvasPartitionAll
import simplejson as json


def form_01(request_data):
Expand Down Expand Up @@ -127,18 +129,29 @@ def form_01(request_data):
Paragraph('Биоматериал', styleT),
Paragraph('ФИО пациента', styleT),
Paragraph('ШтрихКод', styleT),
Paragraph('Направление №', styleT),
Paragraph('Примечание', styleT),
]
]

directions = get_directions_by_who_create(tuple([user_data.doctorprofile.pk]), f"{normalize_date_act} 00:00:00", f"{normalize_date_act} 23:59:59")
directions = [i.napravleniye_id for i in directions]
tubes = []
directions = []
if "filter" in request_data.keys():
filterArray = json.loads(request_data.get("filter"))
for v in filterArray:
tubes.append(TubesRegistration.objects.get(number=v))
for v in tubes: # Перебор пробирок
iss: Issledovaniya = Issledovaniya.objects.filter(tubes__number=v.number).first()
directions.append(iss.napravleniye_id)
directions = list(set(directions))
else:
directions = get_directions_by_who_create(tuple([user_data.doctorprofile.pk]), f"{normalize_date_act} 00:00:00", f"{normalize_date_act} 23:59:59")
directions = [i.napravleniye_id for i in directions]
directions_data = get_data_by_directions_id(tuple(sorted(directions)))
old_tube_number = ""
old_type_material = ""
old_tube_title = ""
old_patient_fio = ""
old_direction = ""
old_tube_registration_time = ""
step = 0

total_container = {}
Expand All @@ -152,7 +165,7 @@ def form_01(request_data):
Paragraph(str(old_type_material), styleT),
Paragraph(old_patient_fio, styleT),
bcd,
Paragraph(str(old_direction), styleT),
Paragraph(f"№{str(old_direction)}<br/>{old_tube_registration_time}", styleT),
]
)
count = total_container.get(old_tube_title, 0)
Expand All @@ -163,6 +176,7 @@ def form_01(request_data):
old_tube_title = i.tube_title
old_patient_fio = f'{i.patient_family} {i.patient_name} {i.patient_patronymic}'
old_direction = i.direction_number
old_tube_registration_time = i.tube_registration_time
step += 1
bcd = createBarcodeDrawing('Code128', value=old_tube_number, humanReadable=1, barHeight=7 * mm, width=45 * mm)
bcd.hAlign = 'LEFT'
Expand All @@ -175,7 +189,7 @@ def form_01(request_data):
Paragraph(str(old_type_material), styleT),
Paragraph(old_patient_fio, styleT),
bcd,
Paragraph(str(old_direction), styleT),
Paragraph(f"№{str(old_direction)}<br/>{old_tube_registration_time}", styleT),
]
)

Expand Down
30 changes: 29 additions & 1 deletion l2-frontend/src/ui-cards/BiomaterialHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,28 @@
class="btn-group btn-group-justified"
style="margin-bottom: 10px; width: 50%"
>
<div class="btn-group">
<div
v-if="!showManualSelectGetTime"
class="btn-group"
>
<a
type="button"
class="btn btn-primary-nb btn-ell"
target="_blank"
:href="historyUrl"
>Печать</a>
</div>
<div
v-if="showManualSelectGetTime"
class="btn-group"
>
<a
type="button"
class="btn btn-primary-nb btn-ell"
target="_blank"
:href="actUrl"
>Акт</a>
</div>
<div class="btn-group">
<button
type="button"
Expand Down Expand Up @@ -112,6 +126,7 @@
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
import moment from 'moment/moment';

Check warning on line 129 in l2-frontend/src/ui-cards/BiomaterialHistory.vue

View workflow job for this annotation

GitHub Actions / webpack_build_prod

'moment' is defined but never used

Check warning on line 129 in l2-frontend/src/ui-cards/BiomaterialHistory.vue

View workflow job for this annotation

GitHub Actions / webpack_build_prod

'moment' is defined but never used
import ColorTitled from '@/ui-cards/ColorTitled.vue';
import JournalGetMaterial from '@/modals/JournalGetMaterial.vue';
Expand Down Expand Up @@ -143,6 +158,10 @@ export default class BiomaterialHistory extends Vue {
showJournal: boolean;
get showManualSelectGetTime() {
return !!this.$store.getters.modules.show_manual_select_get_time;
}
get historyUrl() {
const checked = this.tubes.filter(t => t.checked).map(t => t.pk);
Expand All @@ -153,6 +172,15 @@ export default class BiomaterialHistory extends Vue {
return `/direction/researches/update/history/print?filter=${JSON.stringify(checked)}`;
}
get actUrl() {
const checked = this.tubes.filter(t => t.checked).map(t => t.pk);
if (checked.length === 0) {
return '/direction/researches/update/history/print';
}
return `/forms/pdf?type=114.01&filter=${JSON.stringify(checked)}`;
}
async load(pks = null) {
this.loading = !pks;
const { rows } = await this.$api('/directions/tubes-get-history', { pks });
Expand Down
24 changes: 22 additions & 2 deletions l2-frontend/src/ui-cards/BiomaterialSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@
</table>

<div class="btn-group btn-group-justified control-buttons">
<div class="btn-group">
<div
class="btn-group"
>
<button
v-if="!showManualSelectGetTime"
v-tippy
type="button"
:disabled="!tubes || direction.full_confirm || !needGlobalCheck"
Expand All @@ -103,6 +106,14 @@
>
Отмена направления
</button>
<input
v-if="showManualSelectGetTime"
v-model="manualSelectGetTime"
type="datetime-local"
:readonly="!tubes || !hasAnyChecked"
step="1"
class="form-control"
>
</div>
<div class="btn-group">
<button
Expand Down Expand Up @@ -449,6 +460,7 @@ import UrlData from '@/UrlData';
tubesForConfirm: [],
loading: false,
showConfirmList: false,
manualSelectGetTime: null,
};
},
created() {
Expand Down Expand Up @@ -506,6 +518,8 @@ export default class BiomaterialSearch extends Vue {
tubesForConfirm: any[];
manualSelectGetTime: null | any;
onKeyPress(event) {
if (window.$('input').is(':focus') || this.loading) {
return;
Expand Down Expand Up @@ -572,6 +586,10 @@ export default class BiomaterialSearch extends Vue {
this.loading = false;
}
get showManualSelectGetTime() {
return !!this.$store.getters.modules.show_manual_select_get_time;
}
get navState() {
if (!this.direction) {
return null;
Expand Down Expand Up @@ -694,6 +712,7 @@ export default class BiomaterialSearch extends Vue {
async save(needPrintBarcodes, toConfirmPks = null) {
await this.$store.dispatch(actions.INC_LOADING);
const selectGetTime = this.manualSelectGetTime;
const pks = toConfirmPks
|| Object.values<any>(this.tubes).reduce(
(a, tubes) => [
Expand All @@ -704,7 +723,8 @@ export default class BiomaterialSearch extends Vue {
],
[],
);
const { ok, details } = await this.$api('/directions/tubes-register-get', { pks });
// eslint-disable-next-line max-len
const { ok, details } = await this.$api('/directions/tubes-register-get', { pks, selectGetTime });
await this.$store.dispatch(actions.DEC_LOADING);
if (needPrintBarcodes && ok) {
this.printBarcodes(pks);
Expand Down

0 comments on commit 548999e

Please sign in to comment.