<template>
  <el-button @click="clickQuery">
    出院患者
  </el-button>

  <xc-dialog-v2 v-model="dialog" title="出院患者信息">
    <xc-table :local-data="list" :final-height="500" @rowClick="rowClick">
      <el-table-column prop="name" label="姓名"/>
      <el-table-column prop="admissTimes" label="住院次数"/>
      <el-table-column prop="admissDate" label="入院时间"/>
      <el-table-column prop="disDate" label="出院时间"/>
      <el-table-column prop="zkWard" label="科室"/>
      <el-table-column prop="admissWard" label="入院科室"/>
      <el-table-column prop="disWard" label="出院科室"/>
    </xc-table>
  </xc-dialog-v2>

</template>

<script setup name='EmrLeaveHospitalPatient'>
// 电子病历中查询出院患者信息
import {stringIsBlank} from "@/utils/blank-utils";
import {xcMessage} from "@/utils/xiaochan-element-plus";
import {getListOfDischargedPatients} from "@/api/zhu-yuan-yi-sheng/emr-patient";
import XcDialogV2 from "@/components/xiao-chan/dialog/XcDialogV2.vue";
import XcTable from "@/components/xiao-chan/xc-table/XcTable.vue";
import {query} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";

let dialog = $ref(false)
let list = $ref([])

const emit = defineEmits(['rowClick'])
let patNo = '1'
const clickQuery = () => {
  if (stringIsBlank(query.value.patNo)) return xcMessage.error('请输入住院号')
  if (patNo === query.value.patNo) return dialog = true
  getListOfDischargedPatients(query.value.patNo).then(res => {
    patNo = query.value.patNo
    list = res
    dialog = true
  })
}

const rowClick = ({inpatientNo, admissTimes}) => {
  query.value.patNo = inpatientNo
  query.value.times = admissTimes
  emit('rowClick')
  dialog = false
}


</script>

<style scoped lang="scss">

</style>
