<commit_before><template>
  <tr v-if="!data.remove">
    <td>
      <button class="btn btn-blue-nb" v-if="data.isNew" @click="delete_row" v-tippy="{ placement : 'bottom'}"
              title="Удалить назначение">
        <i class="fa fa-times"/>
      </button>
      {{ data.drug }}
    </td>
    <td class="cl-td">
      <select class="form-control nbr" :class="!isValidFormRelease && 'invalid'"
              v-model.number="data.form_release" :readonly="confirmed">
        <option value="-1" v-if="data.form_release === -1" disabled>Не выбрано</option>
        <option :value="f.pk" v-for="f in params.formReleases">{{ f.title }}</option>
      </select>
    </td>
    <td class="cl-td">
      <select class="form-control nbr" :class="!isValidMethod && 'invalid'" v-model.number="data.method" :readonly="confirmed">
        <option value="-1" v-if="data.method === -1" disabled>Не выбрано</option>
        <option :value="f.pk" v-for="f in params.methods">{{ f.title }}</option>
      </select>
    </td>
    <td class="cl-td">
      <input class="form-control" v-model.number="data.dosage" type="number" min="0" step="0.001" :readonly="confirmed"/>
    </td>
    <td class="cl-td">
      <select class="form-control nbr" :class="!isValidUnits && 'invalid'" v-model="data.units" :readonly="confirmed">
        <option :value="null" v-if="data.units === null" disabled>–</option>
        <option :value="u" v-for="u in params.units">{{ u }}</option>
      </select>
    </td>
    <td class="cl-td">
      <Treeselect class="treeselect-noborder"
              :multiple="true" :disable-branch-nodes="true" :options="timesToSelect"
              placeholder="Режим приёма не выбран" v-model="data.timesSelected"
              :searchable="false"
              :append-to-body="true" :disabled="confirmed" />
    </td>
    <td class="cl-td">
      <input class="form-control" v-model="data.dateStart" style="padding-right: 0;" type="date" :min="td" step="1" :readonly="confirmed"/>
    </td>
    <td class="cl-td">
      <input class="form-control" v-model.number="data.countDays" type="number" min="1" step="1" :readonly="confirmed"/>
    </td>
    <td>
      {{dateEnd}}
    </td>
  </tr>
</template>

<script>
import Treeselect from "@riophae/vue-treeselect";
import '@riophae/vue-treeselect/dist/vue-treeselect.css'

import moment from "moment";

export default {
  name: "PharmacotherapyRow",
  components: {Treeselect},
  props: {
    data: {},
    params: {},
    confirmed: {},
  },
  computed: {
    isValidMethod() {
      if (!this.data.method) {
        return false;
      }

      return Number(this.data.method) > -1;
    },
    isValidFormRelease() {
      if (!this.data.form_release) {
        return false;
      }

      return Number(this.data.form_release) > -1;
    },
    isValidTimesSelected() {
      if (!this.data.timesSelected) {
        return false;
      }

      return this.data.timesSelected.length > 0;
    },
    isValidUnits() {
      return Boolean(this.data.units);
    },
    dateEnd() {
      return moment(this.data.dateStart).add(this.data.countDays, 'days').format('DD.MM.YYYY');
    },
    timesToSelect() {
      return (this.params.times || []).map(t => ({
        id: t,
        label: t,
      }));
    },
  },
  watch: {
    dateEnd: {
      immediate: true,
      handler() {
        this.data.dateEnd = this.dateEnd;
      },
    }
  },
  data() {
    return {<commit_msg>fix-отображение даты в дневнике в Фармакологии назначение<commit_after><template>
  <tr v-if="!data.remove">
    <td>
      <button class="btn btn-blue-nb" v-if="data.isNew" @click="delete_row" v-tippy="{ placement : 'bottom'}"
              title="Удалить назначение">
        <i class="fa fa-times"/>
      </button>
      {{ data.drug }}
    </td>
    <td class="cl-td">
      <select class="form-control nbr" :class="!isValidFormRelease && 'invalid'"
              v-model.number="data.form_release" :readonly="confirmed">
        <option value="-1" v-if="data.form_release === -1" disabled>Не выбрано</option>
        <option :value="f.pk" v-for="f in params.formReleases">{{ f.title }}</option>
      </select>
    </td>
    <td class="cl-td">
      <select class="form-control nbr" :class="!isValidMethod && 'invalid'" v-model.number="data.method" :readonly="confirmed">
        <option value="-1" v-if="data.method === -1" disabled>Не выбрано</option>
        <option :value="f.pk" v-for="f in params.methods">{{ f.title }}</option>
      </select>
    </td>
    <td class="cl-td">
      <input class="form-control" v-model.number="data.dosage" type="number" min="0" step="0.001" :readonly="confirmed"/>
    </td>
    <td class="cl-td">
      <select class="form-control nbr" :class="!isValidUnits && 'invalid'" v-model="data.units" :readonly="confirmed">
        <option :value="null" v-if="data.units === null" disabled>–</option>
        <option :value="u" v-for="u in params.units">{{ u }}</option>
      </select>
    </td>
    <td class="cl-td">
      <Treeselect class="treeselect-noborder"
              :multiple="true" :disable-branch-nodes="true" :options="timesToSelect"
              placeholder="Режим приёма не выбран" v-model="data.timesSelected"
              :searchable="false"
              :append-to-body="true" :disabled="confirmed" />
    </td>
    <td class="cl-td">
      <input class="form-control" v-model="data.dateStart" style="padding-right: 0;" type="date" :min="td" step="1" :readonly="confirmed"/>
    </td>
    <td class="cl-td">
      <input class="form-control" v-model.number="data.countDays" type="number" min="1" step="1" :readonly="confirmed"/>
    </td>
    <td>
      {{dateEndVisible}}
    </td>
  </tr>
</template>

<script>
import Treeselect from "@riophae/vue-treeselect";
import '@riophae/vue-treeselect/dist/vue-treeselect.css'

import moment from "moment";

export default {
  name: "PharmacotherapyRow",
  components: {Treeselect},
  props: {
    data: {},
    params: {},
    confirmed: {},
  },
  computed: {
    isValidMethod() {
      if (!this.data.method) {
        return false;
      }

      return Number(this.data.method) > -1;
    },
    isValidFormRelease() {
      if (!this.data.form_release) {
        return false;
      }

      return Number(this.data.form_release) > -1;
    },
    isValidTimesSelected() {
      if (!this.data.timesSelected) {
        return false;
      }

      return this.data.timesSelected.length > 0;
    },
    isValidUnits() {
      return Boolean(this.data.units);
    },
    dateEnd() {
      return moment(this.data.dateStart).add(this.data.countDays, 'days').format('DD.MM.YYYY');
    },
    dateEndVisible() {
      return moment(this.data.dateStart).add(this.data.countDays-1, 'days').format('DD.MM.YYYY');
    },
    timesToSelect() {
      return (this.params.times || []).map(t => ({
        id: t,
        label: t,
      }));
    },
  },
  watch: {
    dateEnd: {
      immediate: true,
      handler() {
        this.data.dateEnd = this.dateEnd;
      },
    },
  },
  data() {
    return {
{'fraction_non_alphanumeric': 0.1899346033551322, 'fraction_numerical': 0.004691498436167188, 'mean_word_length': 2.681318681318681, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '406822', 'n_tokens_mistral': 2437, 'n_tokens_neox': 2402, 'n_words': 438}