syntax = "proto3";
import "base.proto";
package com.ywt.gapi.medicalrecord;

option java_multiple_files = true;
option java_package = "com.ywt.gapi.medicalrecord";
option java_outer_classname = "MedicalrecordProto";

//检查结果报告
message InspectionReport{
    string reportId = 1;            //检查报告单id
    string reportTitle = 2;         //检查报告单标题名称
    int64 reportDate = 3;           //检查报告单审核日期（YYYY-MM-DD HH:MM:SS）
    int32 status = 4;               //报告状态 0 未审核 1已审核
    string patientName = 5;         //患者姓名
    string patientAge = 6;          //患者年龄
    int32 sex = 7;                  //性别
    string clinicalDiagnosis = 8;   //临床诊断
    string clinicSeq = 9;           //门诊就诊流水号
    string inpatientId = 10;        //住院流水号
    int32 id = 11;                  //主键Id
    int32 hospitalId = 12;
    string reportNum = 13;			//检查单号
    string reportType = 14;			//检查类型，CT/MR
}

//检查结果详情
message InspectionReportDetail{
    string deptName = 1;            //申请科室名称
    string reportDoctorName = 2;    //报告医生姓名
    string checkParts = 3;          //检查部位
    string examination = 4;         //检查所见
    string diagnosis = 5;           //诊断结果
    string checkDoctorName = 6;     //检查医生（技师）姓名
    int64 examinationDate = 7;      //检查日期（YYYY-MM-DD HH:MM:SS）
    int64 verifyDate = 8;           //审核日期
    string verifyDocName = 9;       //审核医生
    string appDocName = 10;         //开单医生
    int32 id = 11;                  //主键Id
    string reportId = 12;           //检查报告单id
}

//检验结果报告
message LaboratoryReport {
    string inspectionId = 1;        //检验报告单id
    string inspectionName = 2;      //检验报告单标题名称
    int64 inspectionDate = 3;       //检验报告单审核日期（YYYY-MM-DD HH:MM:SS）
    int32 status = 4;               //报告状态 0 未审核 1已审核
    string patientName = 5;         //患者姓名
    string patientAge = 6;          //患者年龄
    int32 sex = 7;                  //性别
    string deptName = 8;            //申请科室名称
    string clinicalDiagnosis = 9;   //临床诊断
    string reportDoctorName = 10;   //报告医生姓名
    string clinicSeq = 11;          //门诊就诊流水号
    string inpatientId = 12;        //住院号
    string checkDoctorName = 13;    //审核医生姓名
    int32 id = 14;                  //主键
}

//检验结果报告详情
message LaboratoryReportDetail {
    string itemId = 1;          //检验指标代码
    string itemName = 2;        //检验指标中文名称
    string orderNo = 3;         //排序号，不需要排序的话可设成全部为0
    string testResult = 4;      //检测结果
    string unit = 5;            //剂量单位
    string itemRef = 6;         //参考值范围
    int64 testDate = 7;         //检查日期（YYYY-MM-DD HH:MM:SS）
    string testEngName = 8;     //检验指标英文名称
    string specimType = 9;      //检验标本
    string resultFlag = 10;     //异常标识
    int32 id = 11;              //主键
}

//病历详情
message MedicalRecord{
    int32 recordId = 1;                                     //主键
    string typeName = 2;
    string desc = 3;
    repeated string imageUrl = 4;                           //图片
    int32 doctorId = 5;
    int32 patientId = 6;
    int64 createTime = 7;
    string mobile = 8;
    int32 age = 9;
    int32 sex = 10;
    string patientName = 11;                                //患者姓名
    int32 userId = 12;
    string admTime = 13;                                    //患者入院日期
    string hospitalName = 14;                               //医院名称
    string doctorName = 15;                                 //医生名字
    string selfReport = 16;                                 //主诉
    string phyExam = 17;                                    //体格检查
    string diagnose = 18;                                   //诊断结果
    string suggestion = 19;                                 //意见
    string advice = 20;                                     //门急诊医嘱
    repeated LaboratoryReport laboratoryReport = 21;        //化验报告
    repeated InspectionReport inspectionReport = 22;        //检查报告
    string presentHistory = 23;                             //现病史
    string pastHistory = 24;                             //既往史
    string allergicHistory = 25;                             //过敏史
    string personalHistory = 26;                             //个人史
    string bodyTemperature = 27;                             //病人体温
    string accessoryExamination = 28;                             //辅助检查
    string specialCondition = 29;                             //专科情况
    string single = 30;                             //单病种，1-是，0-否
    string disposition = 31;                             //病人去向
    string treatmentCase = 32;                             //抢救病人
    string treatmentStatus = 33;                             //是否抢救成功
    string diseaseTime = 34;                             //发病时间
    string diseaseEvaluation = 35;                             //病情评估
    string icdCode = 36;                             //ICD编码
    string management = 37;                             //处置
    string doctorTitle = 38;                            //医生职称
    string clinicCode = 39;                            //就诊流水号
    int32 hospitalId = 40;// 医院 id
}

//根据病历Id获取病历详情请求
message GetMedicalRecordByIdRequest{
    int32 recordId = 1;
}

//根据病历Id获取病历详情响应
message GetMedicalRecordByIdResponse{
    Result result = 1;
    MedicalRecord medicalRecord = 2;    //病历详情
}

//获取门诊病历列表请求
message GetOutpatientRecordListRequest{
    int32 medicalCardId = 1;
    int32 pageIndex = 2;
    int32 pageSize = 3;
    int32 userId = 4;
    string hisPatientId = 5;    //门诊Id
}

//获取门诊病历列表响应
message GetOutpatientRecordListResponse{
    Result result = 1;
    repeated MedicalRecord medicalRecord = 2;
    int32 count = 3;
    int32 totalPages = 4;
}

//根据诊疗卡Id同步检验检查结果请求
message SyncReportRequest{
    int32 medicalCardId = 1;
    int64 startDate = 2;    // 开始时间
}

//获取门诊病历列表请求
message GetOutpatientRecordListByHisPatientIdRequest{
    string hisPatientId = 1;    //门诊Id
    int32 pageIndex = 2;
    int32 pageSize = 3;
}

//获取门诊病历列表响应
message GetOutpatientRecordListByHisPatientIdResponse{
    int32 code = 1;
    repeated MedicalRecord medicalRecord = 2;
    int32 count = 3;
    int32 totalPages = 4;
    string msg = 5;
}

//删除病历模板请求
message DeleteMedicalRecordTemplateRequest{
    int32 id = 1;       //模板Id
    int32 doctorId = 2;
}
//删除病历模板
message DeleteMedicalRecordTemplateResponse{
    int32 code = 1;
    string msg = 2;
}

// 对应 rpc 项目的 MedicalRecordServiceImpl 类
service MedicalRecordService{
    //根据病历Id获取病历详情
    rpc getMedicalRecordById(GetMedicalRecordByIdRequest) returns (GetMedicalRecordByIdResponse);

    //获取门诊病历列表
    rpc getOutpatientRecordList(GetOutpatientRecordListRequest) returns (GetOutpatientRecordListResponse);

    //根据诊疗卡Id同步检验检查结果
    rpc syncReport(SyncReportRequest) returns (Result);

    //获取门诊病历列表
    rpc getOutpatientRecordListByHisPatientId(GetOutpatientRecordListByHisPatientIdRequest) returns (GetOutpatientRecordListByHisPatientIdResponse);

    //删除病历模板
    rpc deleteMedicalRecordTemplate(DeleteMedicalRecordTemplateRequest) returns (DeleteMedicalRecordTemplateResponse);
}
