syntax = "proto3";

import "base.proto";

package com.ywt.gapi.system;

//option java_generic_services = true;
option java_multiple_files = true;
option java_package = "com.ywt.gapi.system";
option java_outer_classname = "SystemProto";

message Hospital{
	int32 hospitalId = 1;		//医院Id
	string hospitalName = 2;	//医院名称
	string areaIds = 3;			//地区Id
	int32 level = 4;			//医院等级
	string logo = 5;			//医院Logo
	string address = 6;			//详细地址
	int32 registerable = 7;	    //能否挂号
	int32 status = 8;           //状态(暂用于表示用户是否关注)
	int32 parentId = 9;			//父ID
}

message Dept{
	int32 deptId = 1;
	string deptName = 2;
	string deptCode = 3;
	string yiDaCode = 4;	//医达科室code
	int32 parentId = 5;
	int32 subHospitalId = 6;
}

message Doctor{
	int32 doctorId = 1;				//医生ID
	string doctorName = 2;			//医生名称
	string doctorTitle = 3;			//医生职称
	string doctorSpeciality = 4;	//医生擅长
	string doctorIntro = 5;			//医生简介
	string doctorDept = 6;			//医生科室
	string doctorAvatar = 7;		//医生头像
}

message HospitalDept{
	int32 deptId = 1;
	string deptName = 2;
	repeated Dept deptList = 3;
	string deptCode = 4;
}

message HospitalListRequest{
	int32 pageIndex = 1;
	int32 pageSize = 2;
}

message HospitalListResponse{
	Result result = 1;
	repeated Hospital hospitalList = 2;
	int32 count = 3;
	int32 totalPages = 4;
}


//根据条件查找医院列表Request
message GetHospitalListRequest{
	int32 pageIndex = 1;
	int32 pageSize = 2;
	string name = 3;        //医院名称
	string areaIds = 4;     //医院地址
	int32 userId = 5;		//用户ID
}

message DeptListRequest{
	int32 hospitalId = 1;
}

message DeptListResponse{
	Result result = 1;
	repeated Dept deptList = 2;
}

message HospitalDeptListRequest{
	int32 hospitalId = 1;
	int32 subHospitalId = 2;
	string name = 3;
}

message HospitalDeptListResponse{
	Result result = 1;
	repeated HospitalDept hospitalDeptList = 2;
}

message CheckAppVersionRequest{
	int32 clientType = 1;
	string appVersion = 2;
}

message CheckAppVersionResponse{
	int32 clientType = 1;	//客户端类型
	string version = 2;		//最新版本号
	string detail = 3;		//更新内容
	string downloadUrl = 4;	//下载地址
	int32 updateStatus = 5;	//是否强制更新
}

//地区
message Area{
	int32 id = 1; 			//唯一标识
	string name = 2;		//名称
	int32 weight = 3;		//权重
	int32 status = 4;		//状态
	int32 parentId = 5;		//上级Id
	int32 display = 6;		//显示
	int32 level = 7;		//地区级别
}

//获取地区列表请求
message GetAreaListRequest{

}

//获取地区列表响应
message GetAreaListResponse{
	Result result = 1;
	repeated Area area = 2;	//地区列表
}

//地址
message Address{
	int32 id = 1;			//唯一标识
	string province = 2;	//省
	string city = 3;		//市
	string area = 4;		//区
	string address = 5;		//详细地址
	string contact = 6;		//联系人
	string appellation = 7;	//称呼
	string mobile = 8;		//联系手机号
	int32 userId = 9;		//用户Id
	int32 status = 10;		//状态
	int64 createTime = 11;	//添加时间
	int64 updateTime = 12;	//修改时间
	int32 provinceId = 13;	//省Id
	int32 cityId = 14;		//市Id
	int32 areaId = 15;		//区Id
}

//获取地址列表请求
message GetAddressListRequest{
	int32 userId = 1;
}

//获取地址列表响应
message GetAddressListResponse{
	Result result = 1;
	repeated Address address = 2;
}

//保存收货地址请求
message SaveAddressRequest{
	int32 userId = 1;		//用户Id
	string province = 2;	//省
	string city = 3;		//市
	string area = 4;		//区
	string address = 5;		//详细地址
	string contact = 6;		//联系人
	string appellation = 7;	//称呼
	string mobile = 8;		//联系手机号
	int32 id = 9;			//地址Id，大于0时表示修改，为0表示新增
	int32 provinceId = 10;	//省Id
	int32 cityId = 11;		//市Id
	int32 areaId = 12;		//区Id
}

//删除收货地址请求
message DeleteAddressRequest{
	int32 userId = 1;		//用户Id
	int32 addressId = 2;	//地址唯一标识
}

//获取地址详情请求
message GetAddressRequest{
	int32 addressId = 1;
	string province = 2;
	string city = 3;
	string area = 4;
	string address = 5;
	string contact = 6;
	string appellation = 7;
	string mobile = 8;
	int32 userId = 9;
}

//获取地址详情响应
message GetAddressResponse{
	Result result = 1;
	Address address = 2;
}

//树结点
message TreeNode{
	int32 id = 1;
	string label = 2;
	int32 parentId = 3;
	repeated TreeNode children = 4;
}

//获取地区列表（树状结构）请求
message GetAreaTreeNodeListRequest{

}

//获取地区列表（树状结构）响应
message GetAreaTreeNodeListResponse{
	Result result = 1;
	string treeString = 2;
	repeated TreeNode area = 3;

}

message AreaHospital{
	int32 hospitalId = 1;
	string hospitalName = 2;
	string areaIds = 3;
}

// 根据地区获取医院
message AreaHospitalListRequest{
	int32 pageIndex = 1;
	int32 pageSize = 2;
	string areaIds = 3;
}
//根据地区返回医院
message AreaHospitalListResponse{
	Result result = 1;
	repeated AreaHospital areaHospitalList = 2;
	int32 count = 3;
	int32 totalPages = 4;
}

//获取地区列表请求--APP专用
message AreaListRequest{

}

//获取地区列表响应--APP专用
message AreaListResponse{
	Result result = 1;
	repeated Area area = 2;	//地区列表
}

//微信相关配置
message WeChatConfig{
	string appId = 1;				//患者端公众号appId（南方医务通）
	string secret = 2;				//患者端公众号secret（南方医务通）
	string doctorAppId = 3;			//医生端公众号appId（我的工作站）
	string doctorSecret = 4;		//医生端公众号secret（我的工作站）
}

//获取微信配置请求
message GetWeChatConfigRequest{

}

//获取微信配置响应
message GetWeChatConfigResponse{
	Result result = 1;
	WeChatConfig config = 2;
}

//根据医达科室Code获取科室信息请求
message GetDeptByYiDaCodeRequest{
	string yiDaCode = 1;
}

//根据医达科室Code获取科室信息响应
message GetDeptByYiDaCodeResponse{
	Result result = 1;
	Dept dept = 2;
}

message YiDaDoctorCode{
	string doctorId = 1;
	string yiDaDoctorCode = 2;
	string yiDaDoctorName = 3;
}

//获取医达医生Id请求
message GetYiDaDoctorCodeRequest{
	repeated string doctorId = 1;
}

//获取医达医生Id响应
message GetYiDaDoctorCodeResponse{
	Result result = 1;
	repeated YiDaDoctorCode doctorCode = 2;
}

//国际疾病分类(International Classification of Diseases，ICD)
message IcdCode{
	int32 id = 1;					//唯一标识
	string code = 2;				//icd编码
	string name = 3;				//名称
	string pyCode = 4;				//拼音编码
	string dCode = 5;				//自定义编码
	int32 flag = 6;					//标志，0-诊断
	int32 icdVer = 7;				//icd版本
	string wbCode = 8;				//五笔编码
	string parentCode = 9;			//上级code
	int32 sortSn = 10;				//排序
}

//获取国际疾病分类请求
message GetIcdCodeListRequest{

}

//获取国际疾病分类响应
message GetIcdCodeListResponse{
	Result result = 1;
	repeated IcdCode code = 2;
}

//修改默认地址Request create by daiyihua
message SettingDefaultAddressRequest{
	int32 userId = 1;
	int32 addressId = 2;
}


//消息模板
message MsgTpl{
	int32 id = 1;			//id
	string title = 2;		//模板名称
	string content = 3;		//模板内容
	int32 type = 4;			//类型
	int32 module = 5;		//模块
	int64 createTime = 6;	//创建时间
	bool format = 7; 		//是否格式化参数
}

//获取消息模板列表请求
message GetMsgTplListByModuleRequest{
	int32 module = 1;
}

//获取消息模板列表响应
message GetMsgTplListByModuleResponse{
	Result result = 1;
	repeated MsgTpl msgTpl = 2;
}

//得到医生地址Request create by daiyihua
message GetDoctorAddressRequest{
	int32 userId = 1;
}

//得到医生默认或最近添加地地址
message GetDoctorDefaultAddressResponse{
	Result result = 1;
	Address address = 2;
}

//通过medicalCardId同步诊疗卡信息
message SynchronizingInformationRequest{
	int32 medicalCardId = 1;	//诊疗卡表主键ID
}

//得到医院信息Request		create by daiyihua
message GetHospitalRequest{
	int32 hospitalId = 1;
}

//得到医院信息Response		create by daiyihua
message GetHospitalResponse{
	Result result = 1;
	Hospital hospital = 2;
}

//同步太和检查结果请求
message SyncTaiheInspectionReportRequest{
	string hisPatientId = 1;
	int32 registrationId = 2;
	int32 hospitalId = 3;
}

//同步太和检验结果请求
message SyncTaiheLaboratoryReportRequest{
	string hisPatientId = 1;
	int32 registrationId = 2;
	int32 hospitalId = 3;
}

//
message CreateHisAddRegisteredFlagRequest{
	string hisPatientId = 1;
	string hisCardNo = 2;
}

//医生团队（展示的）领衔医生所在的一级科室
message GetTeamDeptListRequest{

}

//医生团队（展示的）领衔医生所在的一级科室
message GetTeamDeptListResponse{
	int32 code = 1;
	string msg = 2;
	repeated Dept dept = 3;
}

//保存收获地址Respose
message SaveAddressResponse{
	int32 code = 1;
	string msg = 2;
	int32 addressId = 3;
}

message SaveMiniProgramLogRequest{
	string type = 1;
	string apiInfo = 2;
	string sysInfo = 3;
	string openId = 4;
	string unionId = 5;
	int32 userId = 6;
}

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

//获取科室Request
message GetDeptRequest{
	int32 deptId = 1;
}
//获取科室Response
message GetDeptResponse{
	int32 code = 1;
	string msg = 2;
	Dept dept = 3;
}

// 云平台首页医院列表
message CloudPlatformHospitalListResponse{
	message CloudPlatformHospital{
		int32 hospitalId = 1;		//医院Id
		string hospitalName = 2;	//医院名称
		string logo = 3;			//医院Logo
		string address = 4;			//详细地址
		int32 skipType = 5;		//跳转方式，0-不跳转（显示），1-本地，2-其他小程序
		string skipAddress = 6;		//跳转地址
		int32 authorizedType = 7;	//授权方式，0-不用授权，1-手机授权，2-基本信息授权
	}
	Result result = 1;
	repeated CloudPlatformHospital hospitalList = 2;
	int32 count = 3;
	int32 totalPages = 4;
}

message GetSystemDicTypeItemListByTypeCodeRequest {
	string typeCode = 1;
}

message SystemDictTypeItem {
	int32 id = 1;
	string name = 2;
	int32 value = 3;
	string code = 4;
	string otherName = 5;
}

message GetSystemDicTypeItemListByTypeCodeResponse {
	int32 code = 1;
	string message = 2;
	repeated SystemDictTypeItem items = 3;
}

message InvalidateCacheRequest {
	string key = 1;
	int32 cacheType = 2;
	int32 keyType = 3;
}

message InvalidateCacheResponse {
	int32 code = 1;
	string message = 2;
}

message GetCacheKeysRequest {

}

message CacheKey {
	int32 id = 1;
	string keyName = 2;// 缓存键名称
	int32 cacheType = 3;// 缓存类型：0-GuavaCache, 1-Redis
	int32 callType = 4;// 调用方式：0-local, 1-grpc, 2-rest
	string methodName = 5;// grpc/rest 调用需要指定服务方法名称
	int32 keyType = 6;// 键匹配模式：0-match, 1-pattern
	string alias = 7;// 别名
	string remark = 8;// 备注
}

message GetCacheKeysResponse {
	int32 code = 1;
	string message = 2;
	repeated CacheKey keys = 3;
}
message GetConfigByTypeRequest {
	int32 configType = 1;	// 对应config表type
}
message GetConfigByTypeResponse {
	int32 code = 1;
	string message = 2;
	string configContent = 3;	// config的内容
	string customContent = 4;	// 自定义内容
}
message GetHospitalByHospitalIdsRequest{
	repeated int32 hospitalId = 1;
}
message GetHospitalByHospitalIdsResponse{
	int32 code = 1;
	string message = 2;
	repeated Hospital hospital = 3;
}

//保存GPS日志记录Request
message SaveGPSRecordRequest{
	double longitude = 1;      // 经度
	double latitude = 2;       // 纬度
	string ip = 3;          // ip地址
	int32 userId = 4;
}

//保存GPS日志记录Response
message SaveGPSRecordResponse{
	int32 code = 1;
	string info = 2;
}

//根据配置ID获取配置信息Request
message GetConfigByIdRequest{
	int32 configId = 1;      // 配置ID
}

//根据配置ID获取配置信息Response
message GetConfigByIdResponse{
	int32 code = 1;
	string info = 2;
	string configContent = 3;	// config的内容
	string customContent = 4;	// 自定义内容
}
message SearchDeptListByNameRequest{
	int32 hospitalId = 1;
	string deptName = 2;
}

message SearchDeptListByNameResponse{
	int32 code = 1;
	string info = 2;
	repeated Dept dept = 3;
}

message SearchDoctorListByNameRequest{
	int32 hospitalId = 1;
	string doctorName = 2;
}

message SearchDoctorByNameFromMultiHospRequest{
	repeated int32 hospitalId = 1;
	string doctorName = 2;
}

message SearchDoctorListByNameResponse{
	int32 code = 1;
	string info = 2;
	repeated Doctor doctor = 3;
}
// 得到预约挂号公告信息Request
message RetRegisteredAnnouncementRequest{
	int32 hospitalId = 1;
	int32 type = 2;// 公告类型：1-预约挂号，2-疫苗挂号
	int32 deptId = 3;
}
// 得到预约挂号公告信息Response
message RetRegisteredAnnouncementResponse{
	int32 code = 1;
	string info = 2;
	string title = 3;
	string content = 4;
	int32 announcementId = 5;		// 公告ID
}
// 判断是否有救护车的权限Request
message CheckHasAmbulanceRightRequest{
	int32 userId = 1;
}
// 保存救护车位置Request
message SaveAmbulanceLocationRequest{
	int32 userId = 1;
	double lat = 2;	// 纬度
	double lng = 3;	// 经度
}

//展示公告须知
message CommonAnnouncementRequest{
	int32 type = 1;
	int32 hospitalId = 2;
	int32 terminal = 3;
}

//展示公告须知
message CommonAnnouncementResponse{
	int32 code = 1;
	string info = 2;
	string title = 3;
	string content = 4;
	int32 id = 5;
}

message GuideListRequest{
	int32 pageIndex = 1;
	int32 pageSize = 2;
	int32 Hospital = 3;
}

message GuideListResponse{
	int32 code = 1;
	string info = 2;
	repeated Guide response = 3;
	int32 count = 4;                //总条数
	int32 totalPages = 5;           //总页数
}

message Guide {
	string title = 1;
	string content = 2;
	int32 id = 3;
}

message GetHospitalListByTypeRequest{
	int32 pageIndex = 1;
	int32 pageSize = 2;
	string areaIds = 3;
	int32 userId = 4;
	int32 type = 5;		// 1-表示我的关注医生列表，2-线上问诊医生列表
	int32 terminal = 6;
}

// 得到科室介绍信息Request
message IntroduceRequest{
	int32 hospitalId = 1;
	int32 type = 2;// 公告类型：1-门诊科室，2-住院科室，3 医院
	int32 deptId = 3;
}

message IntroduceResponse{
	int32 code = 1;
	string info = 2;
	string content = 4;
	int32 id = 5;
}

message HospitalMedicalDeptListRequest{
	int32 hospitalId = 1;
	int32 subHospitalId = 2;
	string name = 3;
}

message HospitalMedicalDeptListResponse{
	Result result = 1;
	repeated Dept deptList = 3;
}



// 对应 rpc 项目的 SystemServiceImpl 类
service SystemService{
	rpc getHospitalList(HospitalListRequest) returns (HospitalListResponse);	//获取医院列表
	rpc getDeptList(DeptListRequest) returns (DeptListResponse);	//获取医院科室列表
	rpc getHospitalDeptList(HospitalDeptListRequest) returns (HospitalDeptListResponse);	//获取医院所有科室列表
	rpc checkAppVersion(CheckAppVersionRequest) returns (CheckAppVersionResponse);	//检测APP是否需要更新
	rpc getAreaList(GetAreaListRequest) returns (GetAreaListResponse);	//获取地区列表
	rpc getAddressList(GetAddressListRequest) returns (GetAddressListResponse);	//获取地址列表
	rpc saveAddress(SaveAddressRequest) returns (SaveAddressResponse);	//保存收货地址
	rpc deleteAddress(DeleteAddressRequest) returns (Result);	//删除收货地址
	rpc getAddress(GetAddressRequest) returns (GetAddressResponse); //获取地址详情
	rpc getAreaTreeNodeList(GetAreaTreeNodeListRequest) returns (GetAreaTreeNodeListResponse);	//获取地区列表（树状结构）
	rpc getAppAreaList(AreaListRequest) returns (AreaListResponse);	//获取地区
	rpc getAreaHospitalList(AreaHospitalListRequest) returns (AreaHospitalListResponse);	//根据地区获取医院列表
	rpc getWeChatConfig(GetWeChatConfigRequest) returns (GetWeChatConfigResponse);		//获取微信配置

	//根据医达科室Code获取科室信息
	rpc getDeptByYiDaCode(GetDeptByYiDaCodeRequest) returns (GetDeptByYiDaCodeResponse);

	//
	rpc getYiDaDoctorCode(GetYiDaDoctorCodeRequest) returns (GetYiDaDoctorCodeResponse);

	//获取国际疾病分类
	rpc getIcdCodeList(GetIcdCodeListRequest) returns (GetIcdCodeListResponse);

	//得到所有地区集合，包括区、县
	rpc getAllAreaList(GetAreaListRequest) returns (GetAreaListResponse);

	//获取医生地址列表 create by daiyihua
	rpc getDoctorAddressList(GetAddressListRequest) returns (GetAddressListResponse);

	//医生保存地址 create by daiyihua
	rpc doctorSaveAddress(SaveAddressRequest) returns (Result);

	//医生设置默认地址 create by daiyihua
	rpc settingDefaultAddress(SettingDefaultAddressRequest) returns (Result);

	//获取消息模板列表
	rpc getMsgTplListByModule(GetMsgTplListByModuleRequest) returns (GetMsgTplListByModuleResponse);

	//得到医生默认或最近添加的地址  create by daiyhua
	rpc getDoctorDefaultAddress(GetDoctorAddressRequest) returns (GetDoctorDefaultAddressResponse);

	//同步诊疗卡信息		create by daiyihua
	rpc synchronizingInformation(SynchronizingInformationRequest) returns (Result);

	//根据医院ID得到医院信息		create by daiyihua
	rpc getHospital(GetHospitalRequest) returns (GetHospitalResponse);

	//同步太和检查结果
	rpc syncTaiheInspectionReport(SyncTaiheInspectionReportRequest) returns (Result);

	//同步太和检验结果
	rpc syncTaiheLaboratoryReport(SyncTaiheLaboratoryReportRequest) returns (Result);

	//
	rpc createHisAddRegisteredFlag(CreateHisAddRegisteredFlagRequest) returns (Result);

	//医生团队（展示的）领衔医生所在的一级科室
	rpc getTeamDeptList(GetTeamDeptListRequest) returns (GetTeamDeptListResponse);

	//根据条件查找医院列表
	rpc findHospitalList(GetHospitalListRequest) returns (HospitalListResponse);

	//得到普通用户关注的医院列表
	rpc getGeneralAttentionHospitalList(GetHospitalListRequest) returns (HospitalListResponse);

	//保存小程序日志
	rpc saveMiniProgramLog(SaveMiniProgramLogRequest) returns (SaveMiniProgramLogResponse);

	//获取科室
	rpc getDept(GetDeptRequest) returns (GetDeptResponse);

	//得到医务通云平台首页医院列表
	rpc getCloudPlatformHospitalList(HospitalListRequest) returns (CloudPlatformHospitalListResponse);

	// 获取系统字典
	rpc getSystemDicTypeItemListByTypeCode(GetSystemDicTypeItemListByTypeCodeRequest) returns (GetSystemDicTypeItemListByTypeCodeResponse);
	// 清除缓存
	rpc invalidateCache(InvalidateCacheRequest) returns (InvalidateCacheResponse);
	// 获取缓存 keys
	rpc getCacheKeys(GetCacheKeysRequest) returns (GetCacheKeysResponse);
	// 获取配置的内容
	rpc getConfigByType(GetConfigByTypeRequest) returns (GetConfigByTypeResponse);
	// 根据医院IDs得到医院信息		
	rpc getHospitalByHospitalIds(GetHospitalByHospitalIdsRequest) returns (GetHospitalByHospitalIdsResponse);
	// 保存GPS记录
	rpc saveGPSRecord(SaveGPSRecordRequest) returns (SaveGPSRecordResponse);
	// 根据配置ID获取配置信息
	rpc getConfigById(GetConfigByIdRequest) returns (GetConfigByIdResponse);
	// 根据名称获取科室列表
	rpc searchDeptListByName(SearchDeptListByNameRequest) returns (SearchDeptListByNameResponse);
	// 根据名称获取医生列表
	rpc searchDoctorListByName(SearchDoctorListByNameRequest) returns (SearchDoctorListByNameResponse);
	// 根据姓名从多个医院查找医生
	rpc searchDoctorByNameFromMultiHosp(SearchDoctorByNameFromMultiHospRequest) returns (SearchDoctorListByNameResponse);
	// 得到预约挂号公告信息
	rpc getRegisteredAnnouncement(RetRegisteredAnnouncementRequest) returns (RetRegisteredAnnouncementResponse);
	// 判断是否有救护车的权限
	rpc checkHasAmbulanceRight(CheckHasAmbulanceRightRequest) returns (Result);
	// 记录救护车位置
	rpc saveAmbulanceLocation(SaveAmbulanceLocationRequest) returns (Result);
	//须知展示
	rpc showCommonAnnouncement(CommonAnnouncementRequest) returns (CommonAnnouncementResponse);
	//就诊指南
	rpc getGuideList(GuideListRequest) returns (GuideListResponse);
	// 根据条件获取医院列表
	rpc getHospitalListByType(GetHospitalListByTypeRequest) returns (AreaHospitalListResponse);
	//科室介绍
	rpc getIntroduce(IntroduceRequest) returns (IntroduceResponse);
	//住院科室列表
	rpc hospitalMedicalDeptList(HospitalMedicalDeptListRequest) returns (HospitalMedicalDeptListResponse);

}
