<template>
  <div style="width: 820px">
    <div style="width: 770px; margin-left: 35px; border-left: 1px dashed gray; padding-left: 35px">
      <div style="-webkit-transform: translateX(-52px); transform: translateX(-52px); position: absolute; color: black; font-size: 14px">装<br />订<br />线</div>
      <div>
        <div style="width: 100%; font-size: 17px; text-align: center">住 院 病 案 首 页</div>
        <div style="margin-right: 8px; width: 100%; height: 32px; line-height: 32px; font-size: 15px; text-align: center">
          医疗机构:
          <span style="font-weight: 700">长沙泰和医院</span>
          （组织机构代码:
          <span style="font-weight: 700">43010150145</span>
          ）
        </div>
        <div style="margin-right: 8px; height: 25px; line-height: 25px">
          <span style="display: inline-block">
            医疗付费方式:
            <span style="display: inline-block; width: 180px">{{ filterNameInDic(patient.payMethod, 'getPayMethod') }}</span>
          </span>
          <span style="display: inline-block; margin-right: 8px; width: 120px; margin-left: 12px">健康卡号: {{ patient.healthCardNo }}</span>
          <span style="display: inline-block; margin-right: 8px; width: 100px">第&nbsp;{{ patient.admissTimes }}&nbsp;次住院</span>
          <span style="display: inline-block; margin-right: 8px; width: 130px">病案号: {{ patient.bah }}</span>
        </div>
      </div>
      <div style="border: 1px solid black; padding: 5px">
        <div style="margin: 10px 8px 10px 0">
          姓名:
          <span style="display: inline-block; padding: 0 4px; margin-right: 8px; width: 70px; border-bottom: 1px solid black">{{ patient.name }}</span>
          性别:
          <span style="display: inline-block; padding: 0 4px; margin-right: 8px; border-bottom: 1px solid black">{{ filterNameInDic(patient.sex, 'getSexCode') }}</span>
          出生日期:
          <span style="display: inline-block; padding: 0 4px; margin-right: 8px; width: 130px; border-bottom: 1px solid black">{{ patient.birthDate }}</span>
          年龄:
          <span style="display: inline-block; padding: 0 4px; margin-right: 8px; width: 30px; border-bottom: 1px solid black">{{ patient.age }}</span>
          国籍:
          <span style="display: inline-block; padding: 0 4px; margin-right: 8px; border-bottom: 1px solid black">{{ filterNameInDic(patient.country, 'getCountry') }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          （年龄不足 1 周岁的）年龄:
          <span style="display: inline-block; padding: 0 4px; border-bottom: 1px solid black; width: 50px">{{ patient.ageDays }}</span>
          天<span style="margin-left: 8px">新生儿出生体重:</span>
          <span style="display: inline-block; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.newBornWeight }}</span>
          克<span style="margin-left: 8px">新生儿入院体重:</span>
          <span style="display: inline-block; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.newBornAdmissWeight }}</span>
          克
        </div>
        <div style="margin: 10px 8px 10px 0">
          出生地:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 230px">{{ patient.birthPlaceName }}</span>
          籍贯:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 230px">{{ patient.nativePlaceName }}</span>
          民族:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.nation, 'getNation') }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          身份证号:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 160px">{{ patient.socialNo }}</span>
          职业:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.occupation, 'getOccupation') }}</span>
          婚姻:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.marriage, 'getMarriageCode') }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          现住址:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 300px">{{ patient.livePlaceCombo }}</span>
          电话:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ patient.phone }}</span>
          邮编:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.addrZipCode }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          户口地址:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 300px">{{ patient.hkPlaceName }}</span>
          邮编:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.hkZipCode }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          工作单位及地址:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; margin-right: 0; width: 330px">
            {{ patient.unitName }}/{{ patient.unitPlace }}
          </span>
          单位电话:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 80px">{{ patient.unitPhone }}</span>
          邮编:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 50px">{{ patient.unitZipCode }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          联系人姓名:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 90px">{{ patient.contactName }}</span>
          联系人关系:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{
            filterNameInDic(patient.contactRelation, 'getRelations')
          }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          联系人地址:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 300px">{{ patient.contactAddrName }}</span>
          联系人电话:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 90px">{{ patient.contactPhone }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          入院途径:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.zyAdmissWay, 'getAdmissWay') }}</span>
          是否手术:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.hasSurgery, 'getOperations') }}</span>
        </div>
        <div style="margin: 10px 0 10px 0">
          入院时间:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 122px">{{ patient.admissDate }}</span>
          入院科别:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 118px">{{ patient.admissDept }}</span>
          病房:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 80px">{{ patient.admissWard }}</span>
          转科科别:
          <span style="display: inline-block; padding: 0 4px; border-bottom: 1px solid black; width: 118px">{{ patient.transDept }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          出院时间:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 122px">{{ patient.dismissDate }}</span>
          出院科别:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 118px">{{ patient.dismissDept }}</span>
          病房:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 80px">{{ patient.dismissWard }}</span>
          住院天数:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 118px">{{ patient.admissDays }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          门（急）诊诊断:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding: 0 4px;
              border-bottom: 1px solid black;
              width: 350px;
              text-overflow: ellipsis;
              white-space: nowrap;
              overflow: hidden;
            "
          >
            {{ patient.clinicDiagStr }}
          </span>
          疾病编码:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 110px">{{ patient.clinicDiagCode }}</span>
        </div>
        <div style="height: max-content; width: 720px">
          <span style="display: inline-block; width: 360px">
            <table style="width: 360px; border: 1px solid black; border-collapse: collapse">
              <tr>
                <th>主要诊断</th>
                <th>疾病编码</th>
                <th>入院病情</th>
                <th>出院病情</th>
              </tr>
              <tr>
                <td style="width: 170px">
                  {{ patient.disdiagList[0].name }}
                </td>
                <td style="width: 100px; text-align: center">
                  {{ patient.disdiagList[0].code }}
                </td>
                <td style="width: 30px">
                  {{ patient.disdiagList[0].admissStatus }}
                </td>
                <td style="width: 30px">
                  {{ patient.disdiagList[0].dismissStatus }}
                </td>
              </tr>
              <tr>
                <th colspan="4">其他诊断</th>
              </tr>
              <tr v-for="n in 11" :key="n">
                <td style="text-align: left; padding-left: 5px">
                  {{ patient.disdiagList[n].name }}
                </td>
                <td style="width: 90px">
                  {{ patient.disdiagList[n].code }}
                </td>
                <td style="width: 30px">
                  {{ patient.disdiagList[n].admissStatus }}
                </td>
                <td style="width: 30px">
                  {{ patient.disdiagList[n].dismissStatus }}
                </td>
              </tr>
            </table>
          </span>
          <span style="display: inline-block; width: 360px">
            <table style="width: 360px; border: 1px solid black; border-collapse: collapse">
              <tr v-for="n in 14" :key="n">
                <td style="margin-right: 8px; width: 170px">
                  {{ patient.disdiagList[n + 11].name }}
                </td>
                <td style="margin-right: 8px; width: 100px">
                  {{ patient.disdiagList[n + 11].code }}
                </td>
                <td style="margin-right: 8px; width: 30px">
                  {{ patient.disdiagList[n + 11].admissStatus }}
                </td>
                <td style="margin-right: 8px; width: 30px">
                  {{ patient.disdiagList[n + 11].dismissStatus }}
                </td>
              </tr>
            </table>
          </span>
        </div>
        <div style="width: 700px; margin: 4px 0 2px 0; padding: 0 4px; border-bottom: 1px solid black; font-size: 12px">
          备注：
          <span style="display: inline-block">入院病情：</span>
          1.有，2.临床未确定，3.情况不明，4.无
          <span style="display: inline-block; margin-right: 8px; margin-left: 10px">出院病情：</span>
          1.治愈，2.好转，3.未愈，4.死亡，9.其他
        </div>
        <div style="margin: 10px 8px 10px 0">
          损伤、中毒的外部原因:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 300px">{{ patient.hurtReasonName }}</span>
          疾病编码:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 110px">{{ patient.hurtReasonCode }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          病理诊断:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 300px">{{ patient.pathologicDiagStr }}</span>
          病理编码:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 90px">{{ patient.pathologicDiagCode }}</span>
          病理号:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.blh }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          药物过敏:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.allergy, 'getHaveOrNot') }}</span>
          ，过敏药物:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 110px">{{ patient.allergicMedicine }}</span>
          死亡患者尸检:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.autopsy, 'getAutopsies') }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          输血前四项: HbsAg
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.hbsAg, 'getHbsag') }}</span>
          HCV-Ab
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; margin-left: 8px">{{
            filterNameInDic(patient.hcvAb, 'getHbsag')
          }}</span>
          HIV-Ab
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; margin-left: 8px">{{
            filterNameInDic(patient.hivAb, 'getHbsag')
          }}</span>
          TP-Ab
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; margin-left: 8px">{{
            filterNameInDic(patient.tpAb, 'getHbsag')
          }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          血型:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.bloodType, 'getBloodType') }}</span>
          Rh:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">{{ filterNameInDic(patient.rh, 'getHbsag') }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          科室主任:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.deptLeaderName }}</span>
          主任(副主任)医师:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.leaderDoctorName }}</span>
          主治医师:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.mainDoctorName }}</span>
          住院医师:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.admissDoctorName }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          责任护士:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.dutyNurseName }}</span>
          进修医师:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.studyDoctorName }}</span>
          实习医师:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.internshipDoctorName }}</span>
          编码员:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.coderName }}</span>
        </div>
        <div style="margin: 10px 8px 10px 0">
          病案质量:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black">
            {{ filterNameInDic(patient.qualityControlLevel, 'getQualityLevel') }}
          </span>
          质控医师:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.qualityControlDoctorName }}</span>
          质控护士:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 70px">{{ patient.qualityControlNurseName }}</span>
          质控日期:
          <span style="display: inline-block; margin-right: 8px; padding: 0 4px; border-bottom: 1px solid black; width: 170px">{{ patient.qualityControlDate }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    patient: {
      type: Object,
      required: true,
    },
    dics: {
      type: Object,
      required: true,
    },
  },
  setup(props) {
    const filterNameInDic = (val, dic) => {
      if (!val) {
        return ''
      }
      const dicValue = props.dics[dic]
      for (let i = 0; i < dicValue.length; i++) {
        const dicItem = dicValue[i]
        if (dicItem.code == val) {
          return dicItem.name
        }
      }
      return '-'
    }

    return {
      filterNameInDic,
    }
  },
}
</script>

<style scoped>
table,
th,
td {
  border: 1px solid black;
  border-collapse: collapse;
}
td,
th {
  height: 24px;
  padding-left: 4px;
}
</style>
