<template>
<div id='prescription-print'>
    <div class="prescription-print">
        <div class="printTitle">{{orgname}} &nbsp;&nbsp; 门诊病历</div>
        <div class="infoTitle">
            <div>姓名：{{patient.name?patient.name:''}}</div>
            <div>性别：
                <span v-if="patient.gender == 1">男</span>
                <span v-if="patient.gender == 2">女</span>
            </div>
            <div>年龄：{{patient.age?patient.age:''}}岁</div>
        </div>
        <div class="infoTitle">
            <div>婚姻状况：
              <span v-if="patient.marital_status == 1">已婚 </span>
              <span v-if="patient.marital_status == 2">未婚 </span>
            </div>
            <div>职业：{{getProfession(patient.profession)?getProfession(patient.profession):''}}</div>
        </div>
        <div class="otherInfo">
            <div>医保号：</div>
            <div style="flex:1;">{{patient.health_care_no?patient.health_care_no:''}}</div>
        </div>
        <div class="otherInfo">
            <div>联系电话：</div>
            <div style="flex:1;">{{patient.phone?patient.phone:''}}</div>
        </div>
        <div class="otherInfo">
            <div>通讯地址：</div>
            <div style="flex:1;">{{patient.home_address?patient.home_address:''}}</div>
        </div>
        <div class="otherInfo">
            <div>药物过敏史：</div>
            <div style="flex:1;">{{patient.past_history?patient.past_history:''}}</div>
        </div>
        <div class="otherInfo">
            <div>病历编号：</div>
            <div style="flex:1;">{{patient.id?patient.id:''}}</div>
        </div>
        <div style="page-break-after:always;margin-top:50px;"></div>
    </div>

    <div class="prescription-print">
        <div class="printTitle">病历内容</div>
        <div class="recordTitle">
            <div>科别：{{getDeparment(hispatient.departments)?getDeparment(hispatient.departments):''}}</div>
            <div>姓名：{{patient.name?patient.name:''}}</div>
            <div>性别：
                <span v-if="patient.gender == 1">男</span>
                <span v-if="patient.gender == 2">女</span>
            </div>
            <div>年龄：{{patient.age?patient.age:''}}岁</div>
        </div>
        <div class="otherInfo">
            <div class="otherName">主诉：</div>
            <div style="flex:1;">{{history.chief_conplaint?history.chief_conplaint:''}}</div>
        </div>
        <div class="otherInfo">
            <div class="otherName">现病史：</div>
            <div style="flex:1;">{{history.history_of_present_illness?history.history_of_present_illness:''}}</div>
        </div>
        <div class="otherInfo">
            <div class="otherName">既往史：</div>
            <div style="flex:1;">{{history.past_history?history.past_history:''}}</div>
        </div>
        <div class="otherInfo">
            <div class="otherName">药物过敏史：</div>
            <div style="flex:1;">{{history.past_history?history.past_history:''}}</div>
        </div>
        <div class="otherInfo">
            <div class="otherName">个人史：</div>
            <div style="flex:1;">{{history.personal_history?history.personal_history:''}}</div>
        </div>
        <div class="otherInfo">
            <div class="otherName">家族史：</div>
            <div style="flex:1;">{{history.family_history?history.family_history:''}}</div>
        </div>
        <div class="otherInfo">
            <div class="otherName">体格检查：</div>
            <div style="flex:1;">无</div>
        </div>
        <div class="otherInfo">
            <div class="otherName">门诊诊断：</div>
            <div style="flex:1;">{{history.diagnostic?history.diagnostic:''}}</div>
        </div>
        <div class="otherInfo">
            <div class="otherName">门诊医嘱：</div>
            <div style="flex:1;">{{history.doctor_advice?history.doctor_advice:''}}</div>
        </div>
        <div style="margin-top:20px;text-align:right;">
            医生签名：{{getDoctor(history.doctor)?getDoctor(history.doctor):''}}
        </div>
    </div>
</div>
</template>
<script>

import { getDataConfig } from "@/utils/data";
import { getAllDoctorList,getPatientCaseHistory } from "@/api/project/project"
export default {
    props:{
      patient:Object,
      hispatient:Object,
      patientid:Number
    //   history:Object,
    },
    data(){
        return{
            educationOptions:[],
            departmentList:[],
            orgname:'',
            history:{}
        }                   
    },
    methods:{
      getProfession(id){
        var name = ""
        for(let i=0;i<this.educationOptions.length;i++){
            if(id == this.educationOptions[i].id){
                name = this.educationOptions[i].name
            }
        }
        return name
      },
      getAllDoctorList(){
           getAllDoctorList().then(response=>{
             if(response.data.state == 1){
               var doctor =  response.data.data.doctor

               this.doctorList = doctor
               var department = response.data.data.department
               console.log("department",department)
               this.departmentList = department
             }
           })   
       },
      getDoctor(id){
        var name = ""
        for(let i=0;i<this.doctorList.length;i++){
          if(id == this.doctorList[i].admin_user_id){
              name = this.doctorList[i].user_name
          }
        }
        return name
      },
      getPatientCaseHistory(){

        const params = {
          patient_id:this.patientid
        }
      console.log("病历22222",params)
      getPatientCaseHistory(params).then(response=>{
         if(response.data.state == 1){
           var patient = response.data.data.patient
        //    console.log("patinet",patient)
           this.patient = patient
           var history = response.data.data.history
           console.log("中国history222222",history)
           this.history = history
           var hispatient = response.data.data.hispatient
        //    console.log("hispatient",hispatient)
           this.hispatient = hispatient
         }
      })
    },
    getDeparment(id){
  
     var name = ''
     for(let i=0;i<this.departmentList.length;i++){
         if(id == this.departmentList[i].id){
            name = this.departmentList[i].name
         }
      }
      return name
    }
    },
    created(){
      this.educationOptions = getDataConfig("patient", "education_types");
      console.log("22222",this.educationOptions)
      this.getAllDoctorList()
      this.getPatientCaseHistory()

     var xtuser = this.$store.getters.xt_user
     this.orgname = xtuser.org.org_name
    }
}
</script>


<style lang="scss" scoped>
.prescription-print{
    -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 60px rgba(0, 0, 0, 0.06) inset;
    -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset; 
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
    margin-bottom: 20px;
    padding:20px 10px;
}
.printTitle{
    font-size: 22px;
    text-align: center;
    font-weight: bold;
}
.infoTitle{
    display: flex;
    margin-top:10px;
    line-height: 24px;
    padding:0 10px;
}
.infoTitle div{
    width: 200px;
}
.otherInfo{
    display: flex;
    margin-top:10px;
    line-height: 24px;
    padding:0 10px;
}
.recordTitle{
    display: flex;
    margin-top:10px;
    line-height: 24px;
    padding:0 10px;
    border-bottom: 2px solid #000;
}
.recordTitle div{
    width: 200px;
}

</style>
