<template>
  <div class="plate-box">
    <h2 class="title">
      <span class="line"></span>
      <p>{{ title }}</p>
      <span class="line"></span>
    </h2>
    <div class="plate">
      <ul>
        <li>
          <label>透析模式 : </label>
          <span class="content">{{ dialysis_mode }}</span>
        </li>
        <li>
          <label>灌流器 : </label>
          <span class="content">{{ perfusion_apparatus }}</span>
        </li>
        <li>
          <label>置换液(L) : </label>
          <span class="content">{{ displace_liqui }}</span>
          <span class="unit">L</span>
        </li>
        <li>
          <label>首剂(mg) : </label>
          <span class="content">{{ anticoagulant_shouji }}</span>
          <span class="unit">mg</span>
        </li>
        <li>
          <label>钾(mmol/L) : </label>
          <span class="content">{{ kalium }}</span>
          <span class="unit">mmol/L</span>
        </li>
        <li>
          <label>碳酸氢盐 : </label>
          <span class="content">{{ bicarbonate }}</span>
          <span class="unit">mmol/l</span>
        </li>
        <li>
          <label>透析液流量 : </label>
          <span class="content">{{ dialysate_flow }}</span>
          <span class="unit">ml/min</span>
        </li>
      </ul>
      <ul>
        <li>
          <label>透析时长 : </label>
          <span class="content">{{ dialysis_duration }}</span>
          <span class="unit">h</span>
        </li>
        <li>
          <label>血流量 : </label>
          <span class="content">{{ blood_flow_volume }}</span>
          <span class="unit">ml/min</span>
        </li>
        <li>
          <label>置换方式 : </label>
          <span class="content">{{ replacement_way }}</span>
        </li>
        <li>
          <label>维持(mg/h) : </label>
          <span class="content">{{ anticoagulant_weichi }}</span>
          <span class="unit">mg/h</span>
        </li>
        <li>
          <label>钠(mmol/L): </label>
          <span class="content">{{ sodium }}</span>
          <span class="unit">mmol/l</span>
        </li>
        <li>
          <label>葡萄糖 : </label>
          <span class="content">{{ glucose }}</span>
          <span class="unit">mmol/l</span>
        </li>
        <li>
          <label>透析液温度 : </label>
          <span class="content">{{ dialysate_temperature }}</span>
          <span class="unit">℃</span>
        </li>
      </ul>
      <ul>
        <li>
          <label>透析器 : </label>
          <span class="content">{{ dialyzer }}</span>
        </li>
        <li>
          <label>脱水量 : </label>
          <span class="content">{{ prescription_dewatering }}</span>
          <span class="unit">L</span>
        </li>
        <li>
          <label>抗疑剂 : </label>
          <span class="content">{{ anticoagulant }}</span>
        </li>
        <li>
          <label>总量(mg) : </label>
          <span class="content">{{ anticoagulant_zongliang }}</span>
          <span class="unit">mg</span>
        </li>
        <li>
          <label>钙(mmol/L): </label>
          <span class="content">{{ calcium }}</span>
          <span class="unit">mmol/l</span>
        </li>
        <li>
          <label>干体重(kg) : </label>
          <span class="content">{{ dry_weight }}</span>
          <span class="unit">kg</span>
        </li>
        <li>
          <label>电导率 : </label>
          <span class="content">{{ conductivity }}</span>
          <span class="unit">mS/cm</span>
        </li>
      </ul>
    </div>
    <div class="note">
      备注 : <span>{{ note }}</span>
    </div>
    <!-- <div class="note">处方医生 : {{doctor}}</div> -->
  </div>
</template>

<script>
export default {
  name: 'DialysisPrescription',
  data () {
    return {
      title: '透析处方'
    }
  },
  props: {
    prescription: {
      type: Object
    },
    solution: {
      type: Object
    },
    config: {
      type: Object
    }
  },
  computed: {
    // row1
    dialysis_mode: function () {
      return this.getValueStr('mode_id', 'mode_id')
    },
    perfusion_apparatus: function () {
      return this.getValueStr('perfusion_apparatus', 'perfusion_apparatus')
    },
    displace_liqui: function () {
      var v = this.getValueStr('displace_liqui', 'displace_liqui')
      return v.length == 0 ? '0' : v
    },
    anticoagulant_shouji: function () {
      var v = this.getValueStr('anticoagulant_shouji', 'anticoagulant_shouji')
      return v.length == 0 ? '0' : v
    },
    kalium: function () {
      var v = this.getValueStr('kalium', 'kalium')
      return v.length == 0 ? '0' : v
    },
    bicarbonate: function () {
      var v = this.getValueStr('bicarbonate', 'bicarbonate')
      return v.length == 0 ? '0' : v
    },
    dialysate_flow: function () {
      var v = this.getValueStr('dialysate_flow', 'dialysate_flow')
      return v.length == 0 ? '0' : v
    },
    // row2
    dialysis_duration: function () {
      var v = this.getValueStr('dialysis_duration', 'dialysis_duration')
      return v.length == 0 ? '0' : v
    },
    blood_flow_volume: function () {
      var v = this.getValueStr('blood_flow_volume', 'blood_flow_volume')
      return v.length == 0 ? '0' : v
    },
    replacement_way: function () {
      return this.getValueStr('replacement_way', 'replacement_way')
    },
    anticoagulant_weichi: function () {
      var v = this.getValueStr('anticoagulant_weichi', 'anticoagulant_weichi')
      return v.length == 0 ? '0' : v
    },
    sodium: function () {
      var v = this.getValueStr('sodium', 'sodium')
      return v.length == 0 ? '0' : v
    },
    glucose: function () {
      var v = this.getValueStr('glucose', 'glucose')
      return v.length == 0 ? '0' : v
    },
    dialysate_temperature: function () {
      var v = this.getValueStr(
        'dialysate_temperature',
        'dialysate_temperature'
      )
      return v.length == 0 ? '0' : v
    },
    dialyzer: function () {
      var v = this.getValueStr('dialyzer', 'hemodialysis_machine')
      return v.length == 0 ? '0' : v
    },
    prescription_dewatering: function () {
      var v = this.getValueStr('prescription_dewatering', 'dewater')
      return v.length == 0 ? '0' : v
    },
    anticoagulant: function () {
      return this.getValueStr('anticoagulant', 'anticoagulant')
    },
    anticoagulant_zongliang: function () {
      var v = this.getValueStr(
        'anticoagulant_zongliang',
        'anticoagulant_zongliang'
      )
      return v.length == 0 ? '0' : v
    },
    calcium: function () {
      var v = this.getValueStr('calcium', 'calcium')
      return v.length == 0 ? '0' : v
    },
    dry_weight: function () {
      var v = this.getValueStr('dry_weight', 'dry_weight')
      return v.length == 0 ? '0' : v
    },
    conductivity: function () {
      var v = this.getValueStr('conductivity', 'conductivity')
      return v.length == 0 ? '0' : v
    },
    note: function () {
      return this.getValueStr('remark', 'remark')
    }
  },
  methods: {
    
    getValueStr (pkey, skey) {
      // console.log(this.prescription.id)
      if (
        (this.prescription == null || this.prescription.id == '') &&
        (this.solution == null || this.solution.id == '')
      ) {
        return ''
      } else if (this.prescription != null && this.prescription.id != '') {
        if (
          this.prescription[pkey] == null ||
          this.prescription[pkey] == undefined
        ) {
          return ''
        }
        return this.prescription[pkey] + ''
      } else {
        if (this.solution[skey] == null || this.solution[skey] == undefined) {
          return ''
        }
        return this.solution[skey] + ''
      }
    }

  }
}
</script>

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