<template>
  <div style="width: 820px">
    <div
      style="
        width: 770px;
        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: 770px; font-size: 17px; text-align: center;padding-top: 80px;">
          住 院 病 案 首 页
        </div>
        <div
          style="
            margin-right: 8px;
            width: 100%;
            height: 28px;
            line-height: 28px;
            font-size: 15px;
            text-align: center;
          "
        >
          医疗机构:
          <span style="font-weight: 700">{{ env.VITE_HOSPITAL_NAME }}</span>
          （组织机构代码:
          <span style="font-weight: 700">{{ env.VITE_UNIFIED_SOCIAL_CREDIT_CODE_CODE }}</span>
          ）
        </div>
        <div style="margin-right: 8px; height: 25px; line-height: 25px">
          <span style="display: inline-block">
            医疗付费方式:
            <span style="display: inline-block; width: 180px">{{
              patient.payMethod
            }}</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="display: flex;align-items: end">
          姓名
          <span style="width: 130px;padding-left: 5px;border-bottom: 1px solid black">
            {{patient.name}}
          </span>
          <span style="margin-left: 12px">性别</span>
          <span style="width: 50px;padding-left: 5px; border-bottom: 1px solid black">
            {{patient.sex}}
          </span>
          1.男&nbsp;2.女&nbsp;9.未说明的性别&nbsp;&nbsp;&nbsp;
          <span style="margin-left: 12px">出生日期</span>
          <div id="birthDate" style="display: flex;align-items: end">
            <span
                style="width: 35px;padding-left: 5px; border-bottom: 1px solid black"
            >
              {{patient.birthYear}}
            </span>
            年
            <span
                style="width: 20px;padding-left: 5px; border-bottom: 1px solid black"
            >
              {{patient.birthMonth}}
            </span>
            月
            <span
                style="width: 20px;padding-left: 5px; border-bottom: 1px solid black"
            >
              {{patient.birthDay}}
            </span>
            日
          </div>
        </div>
        <div style="display: flex;align-items: end;margin-top: 4px; ">
          年龄
          <span
              style="width: 25px;padding-left: 5px; border-bottom: 1px solid black"
          >
            {{patient.age}}
          </span>
          岁
          <span style="margin-left: 12px; ">国籍</span>
          <span style="width: 160px;padding-left: 5px; border-bottom: 1px solid black">
            {{filterNameInDic(patient.country,'getCountry')}}
          </span>
          <span style="margin-left: 12px; ">（年龄不足1周岁的）年龄</span>
          <span
              style="width: 20px;padding-left: 5px; border-bottom: 1px solid black"
          >
            {{patient.infAge}}
          </span>月
          <span style="margin-left: 12px; ">（新生儿年龄≤28天）年龄</span>
          <span
              style="width: 20px;padding-left: 5px; border-bottom: 1px solid black"
          >
            {{patient.ageDays}}
          </span>天
        </div>
        <div style="display: flex;align-items: end;margin-top: 4px; ">
          新生儿出生体重 （一孩
          <span
              style="width: 40px;padding-left: 5px; border-bottom: 1px solid black"
          >
            {{patient.newBornWeight1}}
          </span>克
          <span style="margin-left: 12px; ">二孩</span>
          <span
              style="width: 40px;padding-left: 5px; border-bottom: 1px solid black"
          >
            {{patient.newBornWeight2}}
          </span>克）
          <span style="margin-left: 12px; ">
              新生儿入院体重
            </span>
          <span
              style="width: 50px;padding-left: 5px; border-bottom: 1px solid black"
          >{{patient.newBornAdmissWeight}}</span>克
        </div>
        <div style="display: flex;align-items: end;margin-top: 4px; ">
          身份证件类型
          <span style="width: 50px;padding-left: 5px;border-bottom: 1px solid black">
            {{patient.psnCertificateType}}
          </span>
          <span style="margin-left: 12px; ">身份证件号码</span>
          <span style="width: 160px;padding-left: 5px; border-bottom: 1px solid black">
            {{patient.socialNo}}
          </span>
        </div>
        <div style="display: flex;align-items: end;margin-top: 4px; ">
          身份证件不详的具体原因
          <span style="width: 30px;padding-left: 5px; border-bottom: 1px solid black">
            {{patient.noCertReason}}
          </span>
          <span v-for="(item,index) in dics.noCertReasons">
              <template v-if="index > 0">{{ item.code }}.{{ item.name }}</template>
            </span>
          其他
          <span
              
              style="width: 120px;padding-left: 5px;margin-left: 12px; border-bottom: 1px solid black"
          >
            {{patient.noCertReasonInput}}
          </span>
        </div>
        <div style="display: flex;align-items: end;margin-top: 4px; ">
          <div style="display: flex;align-items: end">
            <div style="width: 50px">出生地</div>
            <span style="width: 260px;padding-left: 5px; border-bottom: 1px solid black"
            >{{patient.birthPlaceName}}</span>
            </div>
          
          <div style="display: flex;align-items: end;margin-left: 12px; ">
            <div style="width: 40px">
              籍贯
            </div>
            <span
                style="width: 180px;padding-left: 5px; border-bottom: 1px solid black"
            >{{patient.nativePlaceName}}</span>
          </div>
          <div style="display: flex;align-items: end;margin-left: 12px; ">
              <div style="width: 50px">
                民族
              </div>
              <span
                  style="width: 60px;padding-left: 5px; border-bottom: 1px solid black"
              >{{filterNameInDic(patient.nation, 'getNation')}}</span>
          </div>
        </div>
        <div style="display: flex;align-items: end;margin-top: 4px; ">
          
          <div style="width: 30px">职业</div>
          <span style="padding-left: 5px;width: 300px; border-bottom: 1px solid black">
            {{filterNameInDic(patient.occupation,'getOccupation')}}
          </span>
          <span style="margin-left: 12px; ">婚姻</span>
          <span style="width: 80px;padding-left: 5px; border-bottom: 1px solid black">
            {{patient.marriage}}
          </span>
          <span v-for="item in dics.getMarriageCode">
              {{ item.code }}.{{ item.name }}
            </span>
        </div>
        <div style="display: flex;align-items: end;margin-top: 4px; ">
          <div style="display: flex;align-items: end">
            现住址
            <div
                style="width: 350px;padding-left: 5px; border-bottom: 1px solid black"
            >{{patient.livePlace}}</div>
          </div>
          <span style="margin-left: 12px; ">电话</span>
          <span style="width: 90px;padding-left: 5px; border-bottom: 1px solid black">{{patient.phone}}</span>
          <span style="margin-left: 12px; ">邮编</span>
          <span
              style="width: 70px;padding-left: 5px; border-bottom: 1px solid black"
          >{{patient.addrZipCode}}</span>
        </div>

        <div style="margin: 6px 8px 6px 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: 6px 8px 6px 0">
          工作单位及地址:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding: 0 4px;
              border-bottom: 1px solid black;
              margin-right: 0;
              width: 330px;
            "
          >
          {{ patient.unitPlace  }}
            <!-- {{transUnitInfo(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: 6px 8px 6px 0">
          联系人姓名:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding: 0 4px;
              border-bottom: 1px solid black;
              width: 200px;
            "
            >{{ 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: 6px 8px 6px 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: 6px 8px 6px 0">
          入院途径:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding: 0 4px;
              border-bottom: 1px solid black;
            "
            >{{ patient.zyAdmissWay }}</span
          >
          <span v-for="item in dics.getAdmissWay">
              {{ item.code }}.{{ item.name }}
            </span>&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
        <div style="margin: 10px 0">
          入院时间:
          <span
            style="
              display: inline-block;
              margin-right: 6px;
              padding-left: 2px;
              border-bottom: 1px solid black;
              width: 122px;
            "
          >
            {{ patient.admissDate }}
          </span>
          入院科别:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding-left: 4px;
              border-bottom: 1px solid black;
              width: 126px;
            "
          >
            {{ 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-left: 4px;
              border-bottom: 1px solid black;
              width: 126px;
            "
            >{{ patient.transDept }}</span
          >
        </div>
        <div style="margin: 10px 0">
          出院时间:
          <span
            style="
              display: inline-block;
              margin-right: 6px;
              padding-left: 2px;
              border-bottom: 1px solid black;
              width: 122px;
            "
          >
            {{ patient.dismissDate }}
          </span>
          出院科别:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding-left: 4px;
              border-bottom: 1px solid black;
              width: 126px;
            "
          >
            {{ 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;
              padding-left: 4px;
              border-bottom: 1px solid black;
              width: 126px;
            "
            >{{ patient.admissDays }}</span
          >
        </div>
        <div style="margin: 6px 8px 6px 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: 6px 8px 6px 0">
          损伤、中毒的外部原因:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding: 0 4px;
              border-bottom: 1px solid black;
              width: 340px;
            "
            >{{ 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: 6px 8px 6px 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: 6px 8px 6px 0">
          药物过敏:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding: 0 4px;
              border-bottom: 1px solid black;
            "
            >{{ patient.allergy }}</span
          >
          <span v-for="item in dics.getHaveOrNot">
              {{ item.code }}.{{ item.name }}
            </span>&nbsp;&nbsp;&nbsp;&nbsp;
          过敏药物:
          <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;
            "
            >{{ patient.autopsy }}</span
          >
          <span v-for="item in dics.getHaveOrNot">
              {{ item.code }}.{{ item.name }}
            </span>&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
        <div style="margin: 6px 8px 6px 0">
          血型:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding: 0 4px;
              border-bottom: 1px solid black;
            "
            >{{ patient.bloodType}}</span
          >
          <span v-for="item in dics.getBloodType">
              {{ item.code }}.{{ item.name }}
            </span>&nbsp;&nbsp;&nbsp;&nbsp;
          Rh:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding: 0 4px;
              border-bottom: 1px solid black;
            "
            >{{ patient.rh }}</span
          >
          <span v-for="item in dics.getHbsag">
              {{ item.code }}.{{ item.name }}
            </span>&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
        <div style="margin: 6px 8px 6px 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: 6px 8px 6px 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: 6px 8px 6px 0">
          病案质量:
          <span
            style="
              display: inline-block;
              margin-right: 8px;
              padding: 0 4px;
              border-bottom: 1px solid black;
            "
          >
            {{
              patient.qualityControlLevel
            }}
          </span>
          <span v-for="item in dics.getQualityLevel">
              {{ item.code }}.{{ item.name }}
            </span>&nbsp;&nbsp;&nbsp;&nbsp;
          质控医师:
          <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 setup>
import env from "../../../utils/setting";

const props = defineProps({
  patient: {
    type: Object,
    required: true,
  },
  dics: {
    type: Object,
    required: true,
  },
});

const transUnitInfo = (val1, val2) => {
  if ((!val1 && !val2) || (val1 == '-' && val2 == '-')) {
    return "-";
  } else {
    return `${val1}/${val2}`
  }
  
};
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 "-";
};

function filterAdmStatus(val) {
  if (!val) {
    return "";
  }
  switch (val) {
    case 1:
      return "危";
    case 2:
      return "急";
    case 3:
      return "一般";
  }
  return "";
}
</script>

<style scoped>
table,
th,
td {
  border: 1px solid black;
  border-collapse: collapse;
}

td,
th {
  height: 24px;
  padding-left: 4px;
}
</style>
