syntax = "proto3";

package com.ywt.gapi.nfyy;

option java_multiple_files = true;
option java_package = "com.ywt.gapi.nfyy";
option java_outer_classname = "NfyyProto";

//南方医院医生信息
message Doctor{
	string doctorCode = 1;
	string doctorName = 2;
	string doctorTitleCode = 3;
	string doctorTitle = 4;
	string doctorBriefIntro = 5;
	string doctorSpec = 6;
	string doctorSessTypeCode = 7;
	string doctorSessType = 8;
	string imageUrl = 9;
	string departmentCode = 10;
	string firstLetter = 11;
	string letters = 12;
}

//医生分组
message DoctorGroup{
	string letter = 1;
	repeated Doctor doctors = 3;
}

message GetDoctorListRequest{
	string departmentCode = 1;
	string doctorName = 2;
	int32 type = 3;
}

message GetDoctorListResponse{
	int32 code = 1;
	string msg = 2;
 	repeated DoctorGroup doctorGroup = 3;
	int32 total = 4;
}

//获取医生列表（不分组）请求
message GetDoctorListNoGroupRequest{
	string departmentCode = 1;
	string doctorName = 2;
	int32 type = 3;
}

//获取医生列表（不分组）响应
message GetDoctorListNoGroupResponse{
	int32 code = 1;
	string msg = 2;
 	repeated Doctor doctors = 3;
	int32 total = 4;
}

//排班记录
message Schedule{
	string scheduleItemCode	= 1; 		//门诊排班项记录标识
	string serviceDate = 2;				//门诊排班日期(YYYY-MM-DD)
	string weekDay = 3;					//星期数(1-7)
	string sessionCode = 4;				//排班时段代码
	string sessionName = 5;				//排班时段名称
	string departmentCode = 6;			//科室代码
	string departmentName = 7;			//科室名称
	string clinicRoomCode = 8;			//诊室代码
	string clinicRoomName = 9;			//诊室名称
	string doctorCode = 10;				//医生代码
	string doctorName = 11;				//医生名称
	string imageUrl = 12;				//医生图片链接
	string doctorTitleCode = 13;		//医生职称代码
	string doctorTitle = 14; 			//医生职称
	string doctorSpec = 15; 			//医生专长
	string doctorSessTypeCode = 16;		//出诊级别代码
	string doctorSessType = 17;			//出诊级别
	string serviceCode = 18;			//专业代码
	string serviceName = 19; 			//专业名称
	string fee = 20;					//预约挂号总费用
	string regFee = 21;					//挂号费
	string checkupFee = 22;				//诊查费
	string serviceFee = 23;				//服务费
	string otherFee = 24;				//其它费
	string availableNumStr = 25;		//剩余号信息串
	string admitAddress = 26;			//就诊地址
	string admitTimeRange = 27;			//候诊时间范围
	string note	= 28; 					//备注
	string startTime = 29; 				//班别开始时间，格式：HH:MI
	string endTime = 30;				//班别结束时间，格式：HH:MI
	string timeRangeFlag = 31;			//时段是否可预约
	string scheduleStatus = 32;			//出诊状态
	string availableTotalNum = 33;		//该时段可预约的总号源数
	string availableLeftNum = 34;		//该时段剩余号源数
}

message GetScheduleListRequest{
	string departmentCode = 1;			//科室代码
	string startDate = 2;				//开始日期(YYYY-MM-DD)
	string endDate = 3;					//结束日期(YYYY-MM-DD)不允许查询多天的排版，请保持与开始日期一致
	string doctorCode = 4;				//医生代码
	string RBASSessionCode = 5;			//出诊时段代码 S：上午 X：下午 W：晚上
	int32 type = 6;
}

message GetScheduleListResponse{
	int32 code = 1;
	string msg = 2;
	int32 total = 3;
	repeated Schedule schedules = 4;
}

//医生号源分时信息
message ScheduleTimeInfo{
	string scheduleItemCode = 1;		//门诊排班项记录标识
	string serviceDate = 2;				//门诊排班日期(YYYY-MM-DD)
	string weekDay = 3;					//星期数(1-7)
	string sessionCode = 4;				//排班时段代码
	string sessionName = 5;				//排班时段名称
	string startTime = 6;				//班别开始时间，格式：HH:MI
	string endTime = 7;					//班别结束时间，格式：HH:MI
	string availableTotalNum = 8;		//该时段可预约的总号源数
	string availableLeftNum = 9;		//该时段剩余号源数
	repeated TimeInfo timeInfos = 10;	//分时信息
}

message TimeInfo{
	string availableNo = 1;				//某个时间点上的可预约号码
	string availableNoTime = 2;			//单个可预约的号码的时间点
	string availableFlag = 3;			//可否预约标识（Y:可预约，N:不可预约）
}

message GetScheduleTimeInfoRequest{
	string departmentCode = 1;
	string doctorCode = 2;
	string serviceDate = 3;
	string RBASSessionCode = 4;
	int32 type = 5;	
}

message GetScheduleTimeInfoResponse{
	int32 code = 1;
	string msg = 2;
	repeated ScheduleTimeInfo scheduleTimeInfos = 3;
}

message GetReportListRequest {
	int32 clinicSeq = 1;
}

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

message GetReportListResponse {
	int32 code = 1;
	string msg = 2;
	repeated Report report = 3;
}


//患者基本信息
message PatientInfo{
	string patientId = 1;
	string patientName = 2;
	int32 sex = 3;
	string birthday = 4;
	string telephoneNo = 5;
	string mobile = 6;
	string documentId = 7;
	string address = 8;
	string idTypeCode = 9;
	string idTypeDesc = 10;
	string idNo = 11;
	string insureCardNo = 12;
	string accInfo = 13;
	string cardNo = 14;
	string cardType = 15;
	string patientType = 16;
	double balance = 17;
}

message GetPatientInfoRequest{
	string patientCard = 1;
	string patientId = 2;
	string idNo = 3;
	string patientName = 4;
	int32 type = 5;		
}

message GetPatientInfoResponse{
	int32 code = 1;
	string msg = 2;
	PatientInfo patientInfo = 3;
}

//排队信息
message QueueInfo {
	string patName = 1;//病人姓名
	string admLoc = 2;//就诊科室
	string admDoc = 3;//就诊医生
	string waitingNumber = 4;//排队号
}

message GetQueueInfoRequest {
	int32 admNo = 1;
}

message GetQueueInfoResponse {
	int32 code = 1;
	string msg = 2;
	QueueInfo queueInfo = 3;
}

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

message GetReportDetailRequest {
	string inspectionId = 1;
}

message GetReportDetailResponse {
	int32 code = 1;
	string msg = 2;
	repeated ReportDetail reportDetailList = 3;
}

//就诊信息
message ClinicInfo {
	string patientID = 1;//ID号
	string admLoc = 2;//就诊科室
	string admDoc = 3;//就诊医生
	string admitDate = 4;//就诊日期(YYYY-MM-DD)
	string diagnosis = 5;//诊断描述

}

message GetClinicInfoRequest {
	int32 admNo = 1;
}

message GetClinicInfoResponse {
	int32 code = 1;
	string msg = 2;
	ClinicInfo clinicInfo = 3;
}

message GetMedicalCaseDetailRequest {
	int32 clinicSeq = 1;	
}

message GetMedicalCaseDetailResponse {
	int32 code = 1;
	string msg = 2;
	MedCase data = 3;
}

//门诊病历
message MedCase {
	string id = 1;//id
	string title = 2;//标题
	string effectiveTime = 3;//时间（YYYYMMDD)
	string author = 4;//医生姓名
	string doctorId = 5;//医生ID
	string custodian = 6;//医院名称
	MedCasePatInfo patient = 7;//患者信息
	MedRecordDetail detail = 8;//病历记录
}

//门诊病历患者信息
message MedCasePatInfo {
	string medicareNo = 1;//卡号
	string admvisitNo = 2;//门诊流水号
	string healthCardNo = 3;//
	string addr = 4;//地址
	string name = 5;//姓名
	string telecom = 6;//电话
	string administrativeGender = 7;//性别
	string ethnicGroup = 8;//民族
	string age = 9;//年龄
}

//门诊病历纪录详情
message MedRecordDetail {
	string depId = 1;//科室id
	string depName = 2;//科室名称
	string patId = 3;//患者ID
	string feeType = 4;//费别代码
	string feeTypeName = 5;//费别名称
	string admData = 6;//患者入院日期
	string clinicCount = 7;//门诊次数
	string selfReport = 8;//主诉
	string phyExam = 9;//体格检查
	string diagnose = 10;//门诊诊断
	string suggesion = 11;//意见
	string docAdvice = 12;//门急诊医嘱
}



//预约挂号请求
message CreateOrderRequest{
	string scheduleItemCode = 1;//门诊排班项代码
	string patientId = 2;		//病人ID
	string cardNo = 3;			//卡号
	string cardType = 4;		//卡类型
	string payModeCode = 5;		//支付方式代码
	string payFee = 6;			//个人支付费用
	string startTime = 7;		//开始时间(09:00)
	string endTime = 8;			//结束时间(09:30)
	int32 type = 9;		
	string patientName = 10;
}

//预约挂号响应
message CreateOrderResponse{
	int32 code = 1;
	string msg = 2;
	string seqCode = 3;			//挂号序号
	string regFee = 4;			//挂号费
	string admitRange = 5;		//就诊时间段
	string admitAddress = 6;	//就诊地点
	string orderContent = 7;	//预约单内容（内容说明：卡号^病人Rowid^病人姓名^性别^挂号序号(班别)^挂号序号^科室名称^医生姓名^预约日期^时间^候诊日期^^）
	string transactionId = 8;	//交易流水号
	string orderCode = 9;		//预约单号
}

//病人取号确认请求
message ConfirmRequest{
	string orderCode = 1;		//预约单号（预约成功后返回的）
	string patientId = 2;		//取号人ID号
	string payModeCode = 3;		//支付方式代码
	string payAmt = 4;			//交易金额
}

//病人取号确认响应
message ConfirmResponse{
	int32 code = 1;
	string msg = 2;
	string seqCode = 3;			//挂号序号
	string regFee = 4;			//挂号费
	string admitRange = 5;		//就诊时间段
	string admitAddress = 6;	//就诊地点
	string transactionId = 7;	//交易流水号
	string admNo = 8;			//就诊号
}

//取消没有支付的预约记录请求
message CancelOrderRequest{
	string orderCode = 1;		//预约单号
	int32 type = 2;
}

//取消没有支付的预约记录响应
message CancelOrderResponse{
	int32 code = 1;
	string msg = 2;
}

//退号请求
message CancelRegRequest{
	string admNo = 1;			//挂号ID（就诊流水号）
}

//退号响应
message CancelRegResponse{
	int32 code = 1;
	string msg = 2;
	string transactionId = 3;	//His返回的交易流水号
	string returnFee = 4;		//退费金额
}

message RegisteredRecord{
	string regId = 1;			//挂号ID
	string regDate = 2;			//挂号日期(YYYY-MM-DD)
	string status = 3;			//状态
	string patName = 4;			//患者姓名
	string patientId = 5;		//病人ID
	string admitDate = 6;		//就诊日期(YYYY-MM-DD)
	string hospitalName	= 7;	//医院
	string departmentCode = 8;	//科室代码
	string department = 9;		//就诊科室
	string doctorCode = 10;		//医生代码
	string doctor = 11;			//医生
	string doctorTitle = 12;	//医生职称
	string regFee = 13;			//总费用
	string seqCode = 14;		//就诊序号
	string admitAddress	= 15;	//候诊地点
	string sessionName = 16;	//就诊时段
	string admitRange = 17;		//候诊时间
	string serviceName = 18;	//专业名称
	string insuRegInfo = 19;	//医保退号适用串(以&分割的N个入参)，有值时退号需调用医保注销接口
	string returnFlag = 20;		//可退号标志(Y/N)
	string startime	= 21;		//开始时间
	string endtime = 22;		//结束时间
	string transactionId = 23;	//交易流水号
}

//获取挂号记录请求
message GetRegisteredRecordListRequest{
	string startDate = 1;	//开始时间
	string endDate = 2;		//结束时间
	string patientId = 3;	//就诊卡Id
}

//获取挂号记录响应
message GetRegisteredRecordListResponse{
	int32 code = 1;
	string msg = 2;
	repeated RegisteredRecord record = 3;	//挂号记录
}


//检查结果
message InspectionReport{
	string reportId	= 1;			//检查报告单id
	string reportTitle = 2;			//检查报告单标题名称
	string 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;		//住院流水号
}

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

//获取检查报告列表请求
message GetInspectionReportListRequest{
	string clinicSeq = 1;		//门诊就诊流水号
}

//获取检查报告列表响应
message GetInspectionReportListResponse{
	int32 code = 1;
	string msg = 2;
	repeated InspectionReport inspectionReport = 3;
}

//获取检查报告请求
message GetInspectionReportDetailRequest{
	string reportId = 1;
}

//获取检查报告响应
message GetInspectionReportDetailResponse{
	int32 code = 1;
	string msg = 2;
	repeated InspectionReportDetail detail = 3;
}

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

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

//获取化验报告列表请求
message GetLaboratoryReportListRequest{
	string clinicSeq = 1;		//门诊就诊流水号
}

//获取化验报告列表响应
message GetLaboratoryReportListResponse{
	int32 code = 1;
	string msg = 2;
	repeated LaboratoryReport report = 3;	//化验报告
}

//获取化验报告详情请求
message GetLaboratoryReportDetailRequest{
	string inspectionId = 1;	//检验报告单id
}

//获取化验报告详情响应
message GetLaboratoryReportDetailResponse{
	int32 code = 1;
	string msg = 2;
	repeated LaboratoryReportDetail detail = 3;	//化验报告详情
}

//建索引请求
message SavePatientCardRequest{
	string patientType = 1;		//患者类型
	string patientName = 2;		//患者姓名
	int32 sex = 3;				//性别
	string birthday = 4;		//出生日期 yyyy-MM-dd
	string idType = 5;			//证件类型
	string idNo = 6;			//证件号
	string mobile = 7;			//手机号(个人电话,)
}

//建索引响应
message SavePatientCardResponse{
	int32 code = 1;			//0–成功、-1–失败、-50此卡号已建卡、-51已有同类型的卡
	string msg = 2;			//错误信息
	string activeFlag = 3;	//是否需要激活标志(0—不需要激活就能正常使用；1—存在多个患者ID，需要激活后才能在医院内使用；2—医保患者身份需确认、激活后才能在医院内使用；)
	string patientId = 4;	//患者Id
}

message YiDaDepartment{
	string id = 1;		//部门ID
	string name = 2;	//部门名称
}

//医生统计数据
message YiDaDoctorStatsData{
	//治疗疾病
	message Disease{
		string id = 1;				//疾病ID
        string name = 2;			//疾病名称
        int32 treatCount = 3;		//疾病数量
	}

	string doctorId = 1;			//医生ID
	int32 totalTreat = 2;			//治疗总数
	repeated Disease disease = 3;	//疾病列表
}

//问诊接口，根据输入文本获取分诊建议
message InferenceRequest{
	int32 age = 1;			//年龄
	int32 sex = 2;			//性别
	string content = 3;		//内容
}

//问诊接口，根据输入文本获取分诊建议
message InferenceResponse{
	int32 code = 1;
	string msg = 2;
	repeated YiDaDepartment department = 3;	//科室列表
}

message StatsDoctorRequest{
	string departmentId = 1;		//科室ID
	repeated string doctorIds = 2;	//医生ID列表
	int32 topDiseaseCount = 3;		//每个医生显示的治疗疾病数量
	int32 start = 4;				//查询开始位置
	int32 size = 5;					//返回结果条数
}

message StatsDoctorResponse{
	int32 code = 1;
	string msg = 2;
	int32 total = 3;						//查询结果总条数
	int32 start = 4;						//查询开始位置
	int32 size = 5;							//返回结果条数
	repeated YiDaDoctorStatsData item = 6;	//医生统计数据列表
}

service NfyyService{
	rpc getDoctorList(GetDoctorListRequest) returns (GetDoctorListResponse);	//获取南方医院医生列表
	rpc getScheduleList(GetScheduleListRequest) returns (GetScheduleListResponse);	//获取排班记录
	rpc getScheduleTimeInfo(GetScheduleTimeInfoRequest) returns (GetScheduleTimeInfoResponse);	//获取医生号源分时信息
	rpc getReportList(GetReportListRequest) returns (GetReportListResponse);//获取检验报告列表
	rpc getPatientInfo(GetPatientInfoRequest) returns (GetPatientInfoResponse);	//获取患者基本信息
	rpc getQueueInfo(GetQueueInfoRequest) returns (GetQueueInfoResponse);//获取排队信息
	rpc getReportDetail(GetReportDetailRequest) returns (GetReportDetailResponse);//获取检验报告详情
	rpc getClinicInfo(GetClinicInfoRequest) returns (GetClinicInfoResponse);//查询就诊信息
	rpc getMedicalCaseDetail(GetMedicalCaseDetailRequest) returns (GetMedicalCaseDetailResponse);//门诊病历查询
	rpc createOrder(CreateOrderRequest) returns (CreateOrderResponse);	//预约挂号
	rpc confirm(ConfirmRequest) returns (ConfirmResponse);	//病人取号确认
	rpc cancelOrder(CancelOrderRequest) returns (CancelOrderResponse);	//取消没有支付的预约记录
	rpc cancelReg(CancelRegRequest) returns (CancelRegResponse);	//退号
	rpc getInspectionReportList(GetInspectionReportListRequest) returns (GetInspectionReportListResponse);//获取检查报告列表
	rpc getInspectionReportDetail(GetInspectionReportDetailRequest) returns (GetInspectionReportDetailResponse);//获取检查报告
	rpc getRegisteredRecordList(GetRegisteredRecordListRequest) returns (GetRegisteredRecordListResponse);//获取挂号记录
	rpc getLaboratoryReportList(GetLaboratoryReportListRequest) returns (GetLaboratoryReportListResponse);//获取化验报告列表
	rpc getLaboratoryReportDetail(GetLaboratoryReportDetailRequest) returns (GetLaboratoryReportDetailResponse);//

	//获取医生列表（不分组）
	rpc getDoctorListNoGroup(GetDoctorListNoGroupRequest) returns (GetDoctorListNoGroupResponse);

	//
	rpc savePatientCard(SavePatientCardRequest) returns(SavePatientCardResponse);
}

//医达大数逻辑Service
service YiDaService{
	//问诊接口，根据输入文本获取分诊建议
	rpc inference(InferenceRequest) returns (InferenceResponse);

	//医生统计接口，根据科室ID和医生ID列表获取医生的疾病治疗情况统计
	rpc statsDoctor(StatsDoctorRequest) returns (StatsDoctorResponse);
	
}

