syntax = "proto3";

package com.ywt.gapi.taihe.register;

option java_multiple_files = true;
option java_package = "com.ywt.gapi.taihe.register";
option java_outer_classname = "TaiheRegisterProto";


//挂号Request
message CreateRegisteredRequest{
	string doctorTitle = 1;		    //医生职称
	string deptCode = 2;			//科室Code
	string deptName = 3;			//科室名称
	string doctorCode = 4;			//医生Code
	string doctorName = 5;			//医生名称
	int32 total = 6;				//预约挂号总费用
	int32 registeredFee = 7;		//挂号费
	int32 medicalFee = 8;			//诊查费
	int64 registeredDate = 9;		//预约日期
	int32 period = 10;				//预约时间段
	string startTime = 11;			//预约开始时间：HH:MI
	string endTime = 12;			//预约结束时间：HH:MI
	int32 userId = 13;				//用户ID
	int32 medicalCardId = 14;		//诊疗卡ID
	string scheduleItemCode = 15;	//门诊排班项记录标识
	int32 paymentChannel = 16;		//支付渠道
	int32 source = 17;				//订单来源
	int32 deptId = 18;				//科室ID
	string lockQueueNo = 19;
	string availableNumStr = 20;
	int32 hospitalId = 21;
	int32 subHospitalId = 22;       // 分院 id
	string doctorSessTypeCode = 23;	// 出诊级别code
	string doctorSessTypeName = 24; // 出诊级别name
}

//挂号Response 	
message CreateRegisteredResponse{
    int32 code = 1;
    string msg = 2;
	int32 orderType = 3;
	int32 status = 4;
	int32 hisClinicCode = 5;	//就诊流水号
	string mobile = 6;
	string name = 7;
	string idNo = 8;
	int32 orderId = 9;
	string orderNo = 10;
    int32 doctorId = 11;
    int32 regId = 12;           //预约挂号订单（registered_order）主键
}

//取消预约Request 	
message CancelRegisteredRequest{
	int32 orderId = 1;
	int32 userId = 2;
	int32 hospitalId = 3;
}

//取消预约Response
message CancelRegisteredResponse{
    int32 code = 1;
    string msg = 2;
    int32 status = 3;   //预约挂号单支付状态：1-订单未支付 2-订单已支付
}

//订单支付成功通知消息
message PayCallbackRequest{
    string orderNo = 1;
    int32 orderId = 2;
    int32 payType = 3; //1: 微信; 2: 管理员线下收费
    string custom = 4; //回发创建单时设置的自定义数据
    int32 bizId = 5;
    string paymentNo = 6; //订单中心支付流水号
    int32 userId = 7;//用户id
    string prepayId = 8; //本次支付微信 prepay_id
    int32 terminal = 9;  //发起支付终端
    string openid = 10; //完成微信支付的微信用户 openid
    int32 paymentChannel = 11;
    string oneTimeCustom = 12;//本次操作自定义数据
    string wxTransactionId = 13; //本次微信支付交易流水号
    int64 payFinishDate = 14; //支付完成时间，单位：秒
}
//订单支付成功通知响应消息
message PayCallbackResponse{
    int32 code = 1;
    string info = 2;
}

//退款回调
message RefundCallbackRequest{
    int32 amount = 1;       //已退金额
    int32 bizId = 2;
    int32 orderId = 3;
    string orderNo = 4;
    string refundNo = 5;    //退款单号
    int32 refundStatus = 6; //退款状态 1: 退款成功，2: 退款异常，3: 退款关闭
    string custom = 7;      //回发 custom 数据
}

message RefundCallbackResponse{
	int32 code = 1;
	string msg = 2;
}

message RegisterRequest{
    int32 regId = 1;    //挂号订单主键
}

message RegisterResponse{
    int32 code = 1;
    string msg = 2;
}

//取号Request
message TakeRequest{
	int32 orderId = 1;        //预约挂号订单ID
	int32 userId = 2;
	int32 hospitalId = 3;
}

//取号Response
message TakeResponse{
    int32 code = 1;
    string msg = 2;
    string hisClinicCode = 3;   //就诊流水号
}

//获取候诊订单列表Request
message GetQueueListRequest{
	int32 userId = 1;
	int32 hospitalId = 2;
}

//预约挂号订单详情
message RegisteredOrder{
	int32 orderId = 1;              //预约挂号订单ID
	int32 registeredId = 2;         
	int32 userId = 3;
	int32 hospitalId = 4;
	string hospitalName = 5;
	int64 registeredDate = 6;       //预约日期
	int32 registeredPeriod = 7;
	string startTime = 8;           //开始时间
	string endTime = 9;             //截止时间
	int32 medicalCardId = 10;
	string patientName = 11;        //患者姓名
	int32 paymentChannel = 12;
	int64 updateTime = 13;
	int64 createTime = 14;
	string doctorCode = 15;
	string deptCode = 16;
	string deptName = 17;           //预约科室
	int32 registeredFee = 18;
	int32 medicalFee = 19;
	int32 paymentStatus = 20;       //支付状态
	int32 registeredStatus = 21;
	string remark = 22;
	string orderNo = 23;
	string orderRemark = 24;
	int32 orderType = 25;
	int32 total = 26;
	string doctorName = 27;         //预约医生
	int32 sex = 28;
    string hisClinicCode = 29;      //就诊流水号
    string address = 30;            //就诊地点
    string statusName = 31;         //取号状态（文字）
    int32 status = 32;              //取号状态（数字）
	int64 paymentDate = 33;		    //支付日期
	int32 registeredType = 34;
	string hisSeqCode = 35;
}

//获取候诊订单列表Response
message GetQueueListResponse{
    int32 code = 1;
    string msg = 2;
    repeated RegisteredOrder order = 3;
}

//订单公共Model
message CommonOrder{
	int32 orderId = 1;
	string orderNo = 2;
	int32 hospitalId = 3;
	string hospitalName = 4;
	string deptName = 5;
	int32 amount = 6;	//单位：分
	string doctorName = 7;
	string patientName = 8;
	string doctorTitle = 9;
	string statusName = 10;
	string patientSex = 11;
	string registeredDate = 12;
	string startTime = 13;
	string endTime = 14;
	int32 orderType = 15;
	string orderTitle = 16;
	int64 createTime = 17;
	int32 cancel = 18;		//订单是否可以取消，1-是，0-否
	string deptCode = 19;
	int32 registeredType = 20;
	string hisAdmAddr = 21;// HIS 就诊地点
	string hisPatientId = 22;
	int32 subHospitalId = 23;
	string seqCode =24;
}

//获取太和门诊记录Request
message GetCommonOrderListRequest{
	int32 userId = 1;
	int64 endDate = 2;
	int32 pageIndex = 3;
	int32 pageSize = 4;
	int64 startDate = 5;
	int32 terminal = 6;
}

//获取太和门诊记录Response
message GetCommonOrderListResponse{
	int32 code = 1;
	string msg = 2;
	repeated CommonOrder order = 3;
	int32 totalPage = 4;
	int32 count = 5;
}

//获取挂号订单列表Request
message GetRegisteredListRequest{
	int32 userId = 1;
	int32 registeredType = 2;
	int32 hospitalId = 3;
	int32 pageIndex = 4;
	int32 pageSize = 5;
}
//获取挂号订单列表Response
message GetRegisteredListResponse{
	int32 code = 1;
	string msg = 2;
	repeated RegisteredOrder order = 3;
	int32 totalPage = 4;
	int32 count = 5;
}

//无诊疗卡挂号请求
message RegisterWithoutMedicalCardRequest{
	int32 deptId = 1;				//科室ID
	string deptCode = 2;			//科室Code
	string deptName = 3;			//科室名称
	string doctorCode = 4;			//医生Code
	string doctorName = 5;			//医生名称
	int32 total = 6;				//预约挂号总费用
	int32 registeredFee = 7;		//挂号费
	int32 medicalFee = 8;			//诊查费
	int64 registeredDate = 9;		//预约日期
	int32 period = 10;				//预约时间段
	string startTime = 11;			//预约开始时间：HH:MI
	string endTime = 12;			//预约结束时间：HH:MI
	int32 userId = 13;				//用户ID
	string scheduleItemCode = 14;	//门诊排班项记录标识
	string idType = 15;				//证件类型
	string idNo = 16;				//证件号码
	string patientName = 17;		//患者姓名
	string patientMobile = 18;		//患者手机号
	int32 patientSex = 19;			//患者性别
	int64 birthday = 20;			//患者出生日期
	int32 hospitalId = 21;
}

//无诊疗卡挂号响应
message RegisterWithoutMedicalCardResponse{
	int32 code = 1;
	string msg = 2;
}

message GetOfflineConsultInfoByDoctorIdRequest {
	int32 doctorId = 1;
	int32 hospitalId = 2;
}

message GetOfflineConsultInfoByDoctorIdResponse {
	int32 code = 1;
	string info = 2;
	string deptCode = 3;
	string doctorName = 4;
	string doctorHisCode = 5;
	int32 deptId = 6;
	string deptName = 7;
	int32 consultFee = 8;
}

message GetLatestRegOrderRequest {
	int32 doctorId = 1;
	int32 userId = 2;
	int32 hospitalId = 3;
}

message GetLatestRegOrderResponse {
	int32 code = 1;
	string info = 2;
	int64 registerDate = 3;
}

message CalAdditionalFeeRequest {
	int32 medicalCardId = 1;
	int32 medicalFee = 2;
	int32 registeredFee = 3;
	int32 userId = 4;
	int32 hospitalId = 5;
	int32 period = 6;
	string doctorSessTypeCode = 7;	// 出诊级别code
	string doctorSessTypeName = 8; // 出诊级别name
}

message CalAdditionalFeeResponse {
	int32 payMedicalFee = 1;
	int32 payTotal = 2;
	bool isFreeMedicalTreat = 3;
	int32 code = 4;
	string info = 5;
}

message GetHisPatientIdByUserIdAndMobileRequest {
	int32 userId = 1;
	string mobile = 2;
	string cardNo = 3;
	string address = 4;
	string patientNo = 5;// 患者 id, 用于更新医生端开处方填入的身份证和地址
	string name = 6;// 患者真实姓名
	int32 hospitalId = 7;
	string cardType = 8;	// 卡类型，默认1, 1-居民身份证,2-居民户口簿,3-护照,4-军官证,5-驾驶证,6-老年证,7-优抚证,8-残疾证,9-港澳台身份证,10-其他
}

message GetHisPatientIdByUserIdAndMobileResponse {
	string hisPatientId = 1;
	int32 code = 2;
	string info = 3;
}

message CreateMedicalCardRequest {
	string phoneNo = 1;//手机号
	string idNo = 2;//身份证号
	string patientName = 3;//患者姓名
	string city = 4;//在线建卡市区
	string address = 5;//详细地址
	string isInsu = 6;//建卡患者是否是医保  1 ：广州医保 空值：非医保
	int32 hospitalId = 7;
	int32 userId = 8;
    int32 relationship = 9; // 关系:1-本人,6-父母,7-子女,5-其他
	string cardType = 10;	// 卡类型，默认1, 1-居民身份证,2-居民户口簿,3-护照,4-军官证,5-驾驶证,6-老年证,7-优抚证,8-残疾证,9-港澳台身份证,10-其他
	int32 terminal = 11;
}

message CreateMedicalCardResponse {
	int32 code = 1;
	string info = 2;
	int32 medicalCardId = 3;
	string medicalCardNo = 4;	// 诊疗卡号
}


message RegisterCheckInMessageRequest {
	string cardNo = 1;//卡号
	string areaCode = 2; //报到区域代码，由东华URL里获取
	string patName = 3;//患者姓名
	string queueNo = 4;//排队号
	string admArriveDate = 5;//报道时间
	int32 userId = 6;
	int32 hospitalId = 7;
	string admBoroughDesc = 8;//就诊区
	string admLoc = 9;//就诊科室
	string admDoc = 10; //医生姓名
	string rangTime = 11;//时间范围

}

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



//太和医院预约挂号业务类 // 对应 taihe-rpc 项目 TaiheRegisterService 类
service TaiheRegisterService{
    //预约挂号
    rpc createRegistered(CreateRegisteredRequest) returns (CreateRegisteredResponse);

    //取消预约
    rpc cancelRegistered(CancelRegisteredRequest) returns (CancelRegisteredResponse);

    //订单支付成功通知
    rpc payCallback(PayCallbackRequest) returns (PayCallbackResponse);

    //退款回调
    rpc refundCallback(RefundCallbackRequest) returns (RefundCallbackResponse);

    //挂号（挂号信息已先保存至数据表中）
    rpc register(RegisterRequest) returns (RegisterResponse);

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

    //获取候诊订单列表
	rpc getQueueList(GetQueueListRequest) returns (GetQueueListResponse);
	
	//获取太和门诊记录
	rpc getCommonOrderList(GetCommonOrderListRequest) returns (GetCommonOrderListResponse);

	//获取挂号订单列表
	rpc getRegisteredList(GetRegisteredListRequest) returns (GetRegisteredListResponse);

	//无诊疗卡挂号
	rpc registerWithoutMedicalCard(RegisterWithoutMedicalCardRequest) returns (RegisterWithoutMedicalCardResponse);

	// 根据医生 id 获取下线问诊相关信息
	rpc getOfflineConsultInfoByDoctorId(GetOfflineConsultInfoByDoctorIdRequest) returns (GetOfflineConsultInfoByDoctorIdResponse);

	// 获取最近一次挂号订单
	rpc getLatestRegOrder(GetLatestRegOrderRequest) returns (GetLatestRegOrderResponse);

	// 计算加收费用
	rpc calAdditionalFee(CalAdditionalFeeRequest) returns (CalAdditionalFeeResponse);

	// 根据 userId & mobile 获取 hisPatientId
	rpc getHisPatientIdByUserIdAndMobile(GetHisPatientIdByUserIdAndMobileRequest) returns (GetHisPatientIdByUserIdAndMobileResponse);
	// HIS 建档并在系统创建诊疗卡
	rpc createMedicalCard (CreateMedicalCardRequest) returns (CreateMedicalCardResponse);
    // 扫码报道发送信息
	rpc registerCheckInMessage (RegisterCheckInMessageRequest) returns (RegisterCheckInMessageResponse);
}

