Skip to content

Commit

Permalink
Merge pull request #4410 from mikhailprivalov/statisticPatternXLS
Browse files Browse the repository at this point in the history
statisticPattern xls - front constructor research
  • Loading branch information
Wellheor1 authored Oct 20, 2024
2 parents e460995 + a100156 commit a6b4b2a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
2 changes: 0 additions & 2 deletions api/reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ def xlsx_model(request):
data = json.loads(request.body)
directions = data.get("directions")
id_model = data.get("idModel")

sql_pair_direction_iss = {i.iss_id: i.direction_id for i in get_pair_direction_iss(tuple(directions))}
sql_simple_directions = [i.direction_id for i in get_simple_directions_for_hosp_stationar(tuple(sql_pair_direction_iss.keys()))]

statistic_param_data = StatisticPatternParamSet.get_statistic_param(id_model)
input_field_statistic_param = ParaclinicInputField.get_field_input_by_pattern_param(list(statistic_param_data.keys()))
laboratory_fractions_statistic_param = Fractions.get_fraction_id_by_pattern_param(list(statistic_param_data.keys()))
Expand Down
2 changes: 2 additions & 0 deletions api/researches/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ def researches_update(request):
control_param=field.get("controlParam", ""),
cda_option_id=field.get("cdaOption", -1) if field.get("cdaOption", -1) != -1 else None,
patient_control_param_id=field.get("patientControlParam", -1) if field.get("patientControlParam", -1) != -1 else None,
statistic_pattern_param_id=field.get("patternParam") if field.get("patternParam") != -1 else None,
)
if department_template_pk:
department_template_field = ParaclinicFieldTemplateDepartment(
Expand Down Expand Up @@ -700,6 +701,7 @@ def researches_update(request):
f.control_param = field.get("controlParam", '')
f.patient_control_param_id = field.get("patientControlParam", -1) if field.get("patientControlParam", -1) != -1 else None
f.cda_option_id = field.get("cdaOption", -1) if field.get("cdaOption", -1) != -1 else None
f.statistic_pattern_param_id = field.get("patternParam") if field.get("patternParam") != -1 else None

if department_template_pk:
department_template_field: ParaclinicFieldTemplateDepartment = ParaclinicFieldTemplateDepartment.objects.filter(pk=f.pk).first()
Expand Down
10 changes: 8 additions & 2 deletions directory/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ def change_service_hidden(complex_id: int, service_id: int):


class StatisticPattern(models.Model):
title = models.CharField(max_length=400, unique=True, help_text="Название стастической модели данных")
title = models.CharField(max_length=400, unique=True, help_text="Название статистической модели данных")
hide = models.BooleanField(default=False, blank=True, help_text="Скрытие модели", db_index=True)

def __str__(self):
Expand All @@ -1069,7 +1069,7 @@ class Meta:


class PatternParam(models.Model):
title = models.CharField(max_length=400, unique=True, help_text="Название название стастического параметра параметра")
title = models.CharField(max_length=400, unique=True, help_text="Название статистического параметра")
code = models.CharField(max_length=400, help_text="Код параметра")
is_dynamic_param = models.BooleanField(default=False, blank=True, help_text="Динамический параметр", db_index=True)
order = models.IntegerField(default=-1)
Expand All @@ -1081,6 +1081,12 @@ class Meta:
verbose_name = "Статистическая модель - параметр"
verbose_name_plural = "Статистическая модель - параметры "

@staticmethod
def get_pattern_params():
params = PatternParam.objects.all().order_by("title").values("title", "pk")
result = [{"label": p["title"], "id": p["pk"]} for p in params]
return result


class StatisticPatternParamSet(models.Model):
statistic_pattern = models.ForeignKey(StatisticPattern, default=None, null=True, blank=True, help_text="Статистическая модель", on_delete=models.CASCADE)
Expand Down
3 changes: 3 additions & 0 deletions directory/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ParaclinicInputGroups,
ParaclinicInputField,
PatientControlParam,
PatternParam,
)
import simplejson as json

Expand All @@ -18,6 +19,7 @@ def get_researches_details(pk, templates_department_pk=None):
response["patient_control_param_all"] = PatientControlParam.get_patient_control_params()
research = DResearches.objects.filter(pk=pk).first()
response["cda_options"] = CdaFields.get_cda_params(research.is_doc_refferal, research.is_treatment, research.is_form, research.is_extract)
response["patternParams"] = PatternParam.get_pattern_params()
direction_expertise_all = [{"id": -1, "label": "Пусто"}, *[{"id": x.pk, "label": x.title} for x in DResearches.objects.filter(is_expertise=True).order_by("title")]]
response["direction_expertise_all"] = direction_expertise_all
if DResearches.objects.filter(pk=pk).exists():
Expand Down Expand Up @@ -110,6 +112,7 @@ def get_researches_details(pk, templates_department_pk=None):
"controlParam": field.control_param,
"patientControlParam": field.patient_control_param_id if field.patient_control_param else -1,
"cdaOption": field.cda_option_id if field.cda_option else -1,
"patternParam": field.statistic_pattern_param_id if field.statistic_pattern_param else -1,
}
)
response["groups"].append(g)
Expand Down
20 changes: 18 additions & 2 deletions l2-frontend/src/construct/ParaclinicResearchEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@
>
</div>
<div class="row">
<div class="col-xs-6">
<div class="col-xs-4">
<strong>Контролируемый параметр:</strong>
<Treeselect
v-model="row.patientControlParam"
Expand All @@ -659,7 +659,7 @@
:clearable="false"
/>
</div>
<div class="col-xs-6">
<div class="col-xs-4">
<strong>CDA-отношение:</strong>
<Treeselect
v-model="row.cdaOption"
Expand All @@ -672,6 +672,19 @@
:clearable="false"
/>
</div>
<div class="col-xs-4">
<strong>Параметр статистики:</strong>
<Treeselect
v-model="row.patternParam"
class="treeselect treeselect-26px"
:multiple="false"
:disable-branch-nodes="true"
:options="patternParams"
placeholder="CDA-отношение"
:append-to-body="true"
:clearable="false"
/>
</div>
</div>
<div v-if="row.field_type === 0 || row.field_type === 29">
<strong>Значение по умолчанию:</strong>
Expand Down Expand Up @@ -1276,6 +1289,7 @@ export default {
assigned_to_params: [],
type_period: null,
cda_options: [],
patternParams: [],
dynamicDirectories: [],
autoRegisterRmisLocation: '',
departmentForTemplatesField: null,
Expand Down Expand Up @@ -1587,6 +1601,7 @@ export default {
attached: field.attached ?? '',
patientControlParam: field.patientControlParam ?? -1,
cdaOption: field.cdaOption ?? -1,
patternParam: field.patternParam ?? -1,
});
},
add_group(groupSettings: any = {}) {
Expand Down Expand Up @@ -1662,6 +1677,7 @@ export default {
this.direction_params_all = data.direction_params_all;
this.patient_control_param_all = data.patient_control_param_all;
this.cda_options = data.cda_options;
this.patternParams = data.patternParams;
this.direction_current_params = data.direction_current_params;
this.direction_expertise_all = data.direction_expertise_all;
this.direction_current_expertise = data.direction_current_expertise;
Expand Down

0 comments on commit a6b4b2a

Please sign in to comment.