syntax = "proto3";

package com.ywt.gapi.third.taihe;

option java_multiple_files = true;
option java_package = "com.ywt.gapi.third.taihe";
option java_outer_classname = "ThirdTaiheProto";


//患者基本信息
message PatientInfo{
	string patientId = 1;
	string patientName = 2;
	int32 sex = 3;
	string birthday = 4;
	string phoneNumber = 5;
	string mobile = 6;
	string address = 7;
	string idNo = 8;
	string insureCardNo = 9;
	string cardNo = 10;
	string patientType = 11;
}

//获取患者基本信息请求
message GetPatientInfoRequest{
	string patientCard = 1;     //诊疗卡号
	string patientId = 2;       //患者Id
	string idNo = 3;            //身份证号
	string patientName = 4;     //患者姓名
	int32 hospitalId = 5;
	string cardType = 6;	// 卡类型，默认1, 1-居民身份证,2-居民户口簿,3-护照,4-军官证,5-驾驶证,6-老年证,7-优抚证,8-残疾证,9-港澳台身份证,10-其他
}

//获取患者基本信息响应
message GetPatientInfoResponse{
	int32 code = 1;
	string msg = 2;
	PatientInfo patientInfo = 3;
}

message CreatePatInfoRequest {
	string phoneNo = 1;//手机号
	string idNo = 2;//身份证号
	string patientName = 3;//患者姓名
	string city = 4;//在线建卡市区
	string address = 5;//详细地址
	string isInsu = 6;//建卡患者是否是医保  1 ：广州医保 空值：非医保
	int32 hospitalId = 7;
}

message CreatePatInfoResponse {
	int32 code = 1;
	string info = 2;
	string patientId = 3;// 病人ID
	string regNo = 4;// 病人登记号
	string patientCard = 5;// 卡号
	string cardType = 6;// 卡类型
}

// 缴费项目明细（东华）
message PayDetailItem {
	string itemCode = 1;
	string itemName = 2;
	string itemType = 3;
	int32 itemPrice = 4;
	string itemNumber = 5;
	int32 itemTotalFee = 6;
	string itemUnit = 7;
	string itemSpec = 8;
}

//缴费项目
message PaymentItem{
	string hisOrdNum = 1;	//医院订单号，可以是就诊登记号等，用来唯一标识一笔缴费
	string payName = 2;		//缴费项名称
	string deptName = 3;	//接诊科室名称
	string doctorName = 4;	//接诊医生姓名
	int32 totalFee = 5;		//缴费总额（单位：分）
	int32 medInsFee = 6;	//医保部分金额（单位：分）
	int32 selfFee = 7;		//自费部分金额（单位：分）
	string payMode = 8;		//支付方式
	string prescriptionDate = 9;	//处方日期，格式：yyyy-MM-dd HH:mm:ss
	string patientName = 10;
	int32 patientAge = 11;
	int32 patientSex = 12;
	string clinicCode = 13;
	string orderInsuFlag = 14;
	string orderInsType = 15;
	repeated PayDetailItem itemList = 16;
	string doctorCode = 17;
	string invDate = 18;
	string invTime = 19;
	string invoiceNo = 20;
	string invoiceType = 21; //发票类型
	string invoiceTypeName = 22; //发票类型名称
	int32 orderId = 23;
}

//查询门诊缴费记录请求
message GetOutpatientListRequest{
	string patientId = 1;
	int32 type = 2;			//类型：1-门诊待缴费记录 2-门诊已缴费记录 3-门诊已退费记录
	int32 hospitalId = 3;
	string clinicCode = 4; //就诊号
	string startDate = 5;  //开始查询时间YYYY-MM-DD  如果查询范围用病人ID和时间范围
	string endDate = 6; //结束查询时间YYYY-MM-DD
}

//查询门诊缴费记录响应
message GetOutpatientListResponse{
	int32 code = 1;
	string msg = 2;
	repeated PaymentItem payment = 3;	//缴费项目列表
}


// 锁号请求
message LockOrderRequest {
	string scheduleItemCode = 1;
	string cardNo = 2;
	string patID = 3;
	string startTime = 4;
	string endTime = 5;
	string lockQueueNo = 6;
	string availableNumStr = 7;
	int32 hospitalId = 8;
}

// 锁号响应
message LockOrderResponse {
	int32 code = 1;
	string msg = 2;
	string seqCode = 3;
	string regFee = 4;
	string admitRange = 5;
	string admitAddress = 6;
	string orderContent = 7;
	string orderCode = 8;
}

//支付（挂号费大于0情况）请求
message PayRequest{
	string orderCode = 1;		//预约单号
	string transactionId = 2;	//交易流水号（微信支付）
	string patientId = 3;		//病人ID（CardNo为空时必填）
	string cardNo = 4;			//卡号（PatID为空时，必填）
	string payMode = 5;			//支付方式（wxPay：微信支付）
	int32 payAmount = 6;		//支付金额（单位：分，自费部分金额）
	string payTime = 7;			//支付时间（格式：yyyy-MM-dd HH:mm:ss）
	int32 hospitalId = 8;
}

//支付（挂号费大于0情况）响应
message PayResponse{
	int32 code = 1;
	string msg = 2;
	string seqCode = 3;
	int32 regFee = 4;
	string admitRange = 5;
	string admitAddress = 6;
	string transactionId = 7;
	string payOrderId = 8;
	string admNo = 9;
}

//挂号无须支付 请求
message PayFreeRequest{
	string orderCode = 1;	//预约单号
	string patientId = 2;	//病人Id
	int32 hospitalId = 3;
}

//挂号无须支付 响应
message PayFreeResponse{
	int32 code = 1;
	string msg = 2;
}


//排班记录
message Schedule{
	string scheduleItemCode	= 1; 		//门诊排班项记录标识
	string serviceDate = 2;				//门诊排班日期(YYYY-MM-DD)
	int32 datePeriod = 3;				//排班时段代码
	string datePeriodName = 4;			//排班时段名称
	string deptCode = 5;				//科室代码
	string deptName = 6;				//科室名称
	string doctorCode = 7;				//医生代码
	string doctorName = 8;				//医生名称
	string avatar = 9;					//医生图片链接
	string doctorTitle = 10; 			//医生职称
	string doctorSpec = 11; 			//医生专长
	int32 fee = 12;						//预约挂号总费用
	int32 regFee = 13;					//挂号费
	int32 checkupFee = 14;				//诊查费
	int32 serviceFee = 15;				//服务费
	int32 otherFee = 16;				//其它费
	string admitAddress = 17;			//就诊地址
	int32 scheduleStatus = 18;			//出诊状态（1-可预约 0-已满 2-停诊 3-其它(不可预约)）
	int32 availableTotalNum = 19;		//该时段可预约的总号源数
	int32 availableLeftNum = 20;		//该时段剩余号源数
	string serviceCode = 21;
	string serviceName = 22;
	string startTime = 23;
	string endTime = 24;
	string availableNumStr = 25;
	string doctorSessTypeCode = 26;		// 出诊级别code
	string doctorSessTypeName = 27;		// 出诊级别name
}

//获取医生排班记录请求
message GetScheduleListRequest{
	string serviceDate = 1;		//出诊日期，格式：yyyy-MM-dd
	string doctorCode = 2;		//医生代码
	string deptCode = 3;			//科室代码
	int32 hospitalId = 4;
	string serviceEndDate = 5;
	string serviceCode = 6;
}

//获取医生排班记录响应
message GetScheduleListResponse{
	int32 code = 1;
	string msg = 2;
	int32 total = 3;
	repeated Schedule schedules = 4;
}



//在线取号请求
message TakeRequest{
	string orderCode = 1;		//预约单号
	string patientId = 2;		//病人Id
	int32 hospitalId = 3;
}

//在线取号响应
message TakeResponse{
	int32 code = 1;
	string msg = 2;
	string registrationId = 3;	//就诊流水号
}


//取消预约请求
message CancelRequest{
	string orderCode = 1;	//预约单号
	string patId = 2;
	string cardNo = 3;
	string clinicCode = 4;
	int32 hospitalId = 5;
	string transactionId = 6;// HIS 交易流水号，供 HIS 对账用
	string payMode = 7;		// 支付方式："WECHATPAY","ALIPAY"
}

//取消预约响应
message CancelResponse{
	int32 code = 1;
	string msg = 2;
}

message GetDiagnoseRecordRequest {
	string clinicCode = 1;
	int32 hospitalId = 2;
}

message GetDiagnoseRecordResponse {
	int32 code = 1;
	string info = 2;
}


//预约挂号请求
message RegisterRequest{
	string scheduleItemCode = 1;//门诊排班项代码
	string patientId = 2;		//病人ID(CardNo为空时必填)
	string cardNo = 3;			//卡号(PatientID为空时，必填）
	string startTime = 7;		//开始时间(09:00)
	string endTime = 8;			//结束时间(09:30)
	int32 hospitalId = 9;
}

//预约挂号响应
message RegisterResponse{
	int32 code = 1;
	string msg = 2;
	string seqCode = 3;			//挂号序号
	int32 regFee = 4;			//挂号费（单位：分）
	string admitRange = 5;		//就诊时间段
	string admitAddress = 6;	//就诊地点
	string orderContent = 7;	//预约单内容（内容说明：卡号^病人Rowid^病人姓名^性别^挂号序号(班别)^挂号序号^科室名称^医生姓名^预约日期^时间^候诊日期^^）
	// string transactionId = 8;	//交易流水号
	string orderCode = 8;		//预约单号
}
// 对应 central-control-service 项目的 provider/taihe.js 文件
service TaiheService{

	//获取患者基本信息
	rpc getPatientInfo(GetPatientInfoRequest) returns (GetPatientInfoResponse);

	// 创建病人主索引
	rpc createPatInfo(CreatePatInfoRequest) returns (CreatePatInfoResponse);

	//查询门诊缴费记录
	rpc getOutpatientList(GetOutpatientListRequest) returns (GetOutpatientListResponse);

	// 东华 HIS 挂号锁号
	rpc lockOrder(LockOrderRequest) returns (LockOrderResponse);

	//挂号支付
	rpc pay(PayRequest) returns (PayResponse);

	//挂号无须支付
	rpc payFree(PayFreeRequest) returns (PayFreeResponse);

	//获取排班记录
	rpc getScheduleList(GetScheduleListRequest) returns (GetScheduleListResponse);

	//在线取号
	rpc take(TakeRequest) returns (TakeResponse);

	//取消预约
	rpc cancel(CancelRequest) returns (CancelResponse);

	// 获取患者诊断详情
	rpc getDiagnoseRecord (GetDiagnoseRecordRequest) returns (GetDiagnoseRecordResponse);


	//挂号
	rpc register(RegisterRequest) returns (RegisterResponse);
}