<template>
  <div class="plate-box">
    <h2 class="DetailsTit">
      <span>{{ title }}</span>
    </h2>
    <div class="plate ">
      <ul>
        <li v-if="isShow('入室方式')">
          <label>入室方式 : </label>
          <span class="content">{{ way }}</span>
        </li>

        <li v-if="isShow('体位')">
          <label>体位 : </label>
          <span class="content">{{ posture }}</span>
        </li>
        <li v-if="isShow('其他病情')">
          <label>其他病情:</label>
          <span class="content">{{ this.record.sick_condition_other }}</span>
        </li>

        <li v-if="isShow('跌倒风险预防措施')">
          <label>跌倒风险预防措施:</label>
          <span class="content">{{ precaution }}</span>
        </li>

        <li v-if="isShow('营养状况')">
          <label>营养状况:</label>
          <span class="content">{{nutritions}}</span>
        </li>

        <li v-if="isShow('其他心理评估')">
          <label>其他心理评估:</label>
          <span class="content">{{this.record.psychological_other}}</span>
        </li>







      </ul>
      <ul>
        <li v-if="isShow('病人情况')">
          <label>病人情况 : </label>
          <span class="content">{{ condition }}</span>
        </li>

        <li v-if="isShow('病人食欲')">
          <label>病人食欲 : </label>
          <span class="content">{{ appetite }}</span>
        </li>
        <li v-if="isShow('跌倒风险评估评分')">
          <label>跌倒风险评估评分:</label>
          <span class="content">{{ this.record.score }}分</span>
        </li>
        <li v-if="isShow('其他跌倒风险预防措施')">
          <label>其他跌倒风险预防措施:</label>
          <span class="content">{{ this.record.precaution_other }}</span>
        </li>

        <li v-if="isShow('心理评估')">
          <label> 心理评估</label>
          <span class="content">{{ psychologicalAssessment }}</span>
        </li>


      </ul>
      <ul>
        <li v-if="this.record.condition == 1">
          <label> 住院号</label>
          <span class="content">{{ this.record.admission_number }}</span>
        </li>

        <li v-if="isShow('病人意识')">
          <label>病人意识 :</label>
          <span class="content">{{ consciousness }}</span>
        </li>

        <li v-if="isShow('病情')">
          <label>病情 </label>
          <span class="content">{{sickCondition}} </span>
        </li>

        <li v-if="isShow('风险程度')">
          <label>风险程度:</label>
          <span class="content">{{ dangerLevel }}</span>
        </li>

        <li v-if="isShow('摄入量')">
          <label>摄入量:</label>
          <span class="content">{{intakes}}</span>
        </li>
        <li
          v-if="
            isShow('心理评估异常原因') &&
              this.record.psychological_assessment == 2
          "
        >
          <label>心理评估异常原因:</label>
          <span class="content">{{
            this.record.psychological_assessment_other
          }}</span>
        </li>


      </ul>

    </div>
    <!-- <div class="note">处方医生 : {{doctor}}</div> -->
    <div class="middleLine"></div>

  </div>
</template>

<script>
  import store from '@/store'
  import { getDataConfig } from '@/utils/data'
  export default {
    name: 'AcceptsAssessment',
    data() {
      return {
        title: '接诊评估 ',

        ways: [],
        conditions: {
          '1': '住院',
          '2': '门诊',
          '3': '手术期'
        },
        consciousnesses:[],
        appetites: [],
        postures: [],
        sick_condition:[],
        danger_level: {
          '1': '无',
          '2': '低风险',
          '3': '中度风险',
          '4': '高风险'

        },
        intake:[],
        nutrition: [],
        psychological_assessment: {
          '1': '正常',
          '2': '异常'
        },
        precautions:[]
      }
    },
    props: {
      record: {
        type: Object
      }
    },
    computed: {
      way: function() {
        if (this.record.id == 0) {
          return ''
        } else {
          // return this.ways[this.record.way] == undefined ? '' : (this.ways[this.record.way] + '')

          for (let i = 0; i < this.ways.length; i++){
            if (this.record.way == this.ways[i].id){
              return this.ways[i].name

            }
          }
        }
      },
      condition: function() {
        if (this.record.id == 0) {
          return ''
        } else {
          return this.conditions[this.record.condition] == undefined ? '' : this.conditions[this.record.condition] + ''
        }
      },
      consciousness: function() {
        if (this.record.id == 0) {
          return ''
        } else {
          for (let i = 0; i < this.consciousnesses.length; i++){
            if (this.record.consciousness == this.consciousnesses[i].id){
              return this.consciousnesses[i].name

            }
          }
          // return this.consciousnesses[this.record.consciousness] == undefined ? '' : this.consciousnesses[this.record.consciousness] + ''
        }
      },
      appetite: function() {
        if (this.record.id == 0) {
          return ''
        } else {
          // return this.appetites[this.record.appetite] == undefined ? '' : this.appetites[this.record.appetite] + ''
          for (let i = 0; i < this.appetites.length; i++){
            if (this.record.appetite == this.appetites[i].id){
              return this.appetites[i].name

            }
          }
        }
      },
      posture: function() {
        if (this.record.id == 0) {
          return ''
        } else {
          // return this.postures[this.record.posture] == undefined ? '' : this.postures[this.record.posture] + ''

          for (let i = 0; i < this.postures.length; i++){
            if (this.record.posture == this.postures[i].id){
              return this.postures[i].name

            }
          }
        }
      }, sickCondition: function() {
        if (this.record == null || this.record.id == '') {
          return ''
        } else {
          for (let i = 0; i < this.sick_condition.length; i++){
            if (this.record.sick_condition == this.sick_condition[i].id){
              return this.sick_condition[i].name

            }
          }
          // return this.sick_condition[this.record.sick_condition] == undefined ? '' : this.sick_condition[this.record.sick_condition] + ''
        }
      }, dangerLevel: function() {
        if (this.record == null || this.record.id == '') {
          return ''
        } else {
          return this.danger_level[this.record.danger_level] == undefined ? '' : this.danger_level[this.record.danger_level] + ''
        }
      }, intakes: function() {
        if (this.record == null || this.record.id == '') {
          return ''
        } else {
          for (let i = 0; i < this.intake.length; i++){
            if (this.record.intake == this.intake[i].id){
              return this.intake[i].name

            }
          }
          // return this.intake[this.record.intake] == undefined ? '' : this.intake[this.record.intake] + ''
        }
      }, nutritions: function() {
        if (this.record == null || this.record.id == '') {
          return ''
        } else {
          for (let i = 0; i < this.nutrition.length; i++){
            if (this.record.nutrition == this.nutrition[i].id){
              return this.nutrition[i].name

            }
          }
          // return this.nutrition[this.record.nutrition] == undefined ? '' : this.nutrition[this.record.nutrition] + ''
        }
      }, psychologicalAssessment: function() {
        if (this.record == null || this.record.id == '') {
          return ''
        } else {
          return this.psychological_assessment[this.record.psychological_assessment] == undefined ? '' : this.psychological_assessment[this.record.psychological_assessment] + ''
        }
      }, precaution: function() {
        if (this.record.id == 0) {
          return ''
        } else {
          for (let i = 0; i < this.precautions.length; i++){
            if (this.record.precaution == this.precautions[i].id){
              return this.precautions[i].name

            }
          }
          // return this.precautions[this.record.precaution] == undefined ? '' : this.precautions[this.record.precaution] + ''
        }
      }
    },
    methods: {
      isShow(name) {
        var filedList = store.getters.xt_user.fileds
        for (let i = 0; i < filedList.length; i++) {
          if (filedList[i].module == 2 && filedList[i].filed_name_cn == name && filedList[i].is_show == 1) {
            return true
          }
        }
        return false
      }
    },
    created(){
      this.ways = getDataConfig('hemodialysis', 'way')
      this.consciousnesses = getDataConfig('hemodialysis', 'consciousness')
      this.appetites = getDataConfig('hemodialysis', 'appetite')
      this.postures = getDataConfig('hemodialysis', 'posture')
      this.sick_condition = getDataConfig('hemodialysis', 'sick_condition')
      this.precautions = getDataConfig('hemodialysis', 'precaution')
      this.intake = getDataConfig('hemodialysis', 'intake')
      this.nutrition = getDataConfig('hemodialysis', 'nutrition')
      console.log(this.ways)


    },

  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped></style>
