|
@@ -4014,106 +4014,63 @@ func (c *HisApiController) PsnUnPutOnRecord() {
|
4014
|
4014
|
|
4015
|
4015
|
}
|
4016
|
4016
|
func (c *HisApiController) PsnPutNCDSOnRecord() {
|
4017
|
|
- record_type, _ := c.GetInt64("type")
|
4018
|
4017
|
patient_id, _ := c.GetInt64("patient_id")
|
4019
|
|
- admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
4018
|
+ insutype := c.GetString("insutype")
|
|
4019
|
+ psn_no := c.GetString("psn_no")
|
|
4020
|
+ doctor_id, _ := c.GetInt64("doctor_id")
|
|
4021
|
+ sick_id, _ := c.GetInt64("sick_id")
|
|
4022
|
+ department_id, _ := c.GetInt64("department_id")
|
4020
|
4023
|
adminUser := c.GetAdminUserInfo()
|
4021
|
|
- var patients []*models.Patients
|
4022
|
|
- if record_type == 1 { //全部备案
|
4023
|
|
- patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
|
4024
|
|
- patients = append(patients, patient...)
|
4025
|
|
- } else { //单个备案
|
4026
|
|
- patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
|
4027
|
|
- patients = append(patients, patient)
|
4028
|
|
- }
|
|
4024
|
+ patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
|
4029
|
4025
|
miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
|
4030
|
4026
|
config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
4031
|
|
- var user_name string
|
4032
|
|
- role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
|
4033
|
|
- if role.ID == 0 {
|
4034
|
|
- user_name = "xxx"
|
4035
|
|
- } else {
|
4036
|
|
- user_name = role.UserName
|
4037
|
|
- }
|
4038
|
|
-
|
|
4027
|
+ sick, _ := service.FindSickById(sick_id)
|
|
4028
|
+ //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
|
|
4029
|
+ doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
|
4039
|
4030
|
if config.IsOpen == 1 {
|
4040
|
|
- for _, item := range patients {
|
4041
|
|
- api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + item.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + user_name + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
|
4042
|
|
- resp, requestErr := http.Get(api)
|
4043
|
|
- if requestErr != nil {
|
4044
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
4045
|
|
- return
|
4046
|
|
- }
|
4047
|
|
- defer resp.Body.Close()
|
4048
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
4049
|
|
- if ioErr != nil {
|
4050
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
4051
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
4052
|
|
- return
|
4053
|
|
- }
|
4054
|
|
- var respJSON map[string]interface{}
|
4055
|
|
-
|
4056
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
4057
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
4058
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
4059
|
|
- return
|
4060
|
|
- }
|
4061
|
|
-
|
4062
|
|
- userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
4063
|
|
- userJSONBytes, _ := json.Marshal(userJSON)
|
4064
|
|
- var res ResultTwo
|
4065
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
4066
|
|
- utils.ErrorLog("解析失败:%v", err)
|
4067
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
4068
|
|
- return
|
4069
|
|
- }
|
4070
|
|
-
|
4071
|
|
- if res.Infcode == 0 {
|
4072
|
|
- result := service.Gdyb2503(res.Output.Baseinfo.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, user_name, miConfig.Code, strconv.FormatInt(admin_user_id, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "慢性肾功能不全(血透治疗)", "M07803")
|
4073
|
|
- var dat map[string]interface{}
|
4074
|
|
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
|
4075
|
|
- fmt.Println(dat)
|
4076
|
|
- } else {
|
4077
|
|
- fmt.Println(err)
|
4078
|
|
- }
|
4079
|
|
-
|
4080
|
|
- userJSONBytes, _ := json.Marshal(dat)
|
4081
|
|
-
|
4082
|
|
- var res2 ResultThirteen
|
4083
|
|
- if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
|
4084
|
|
- utils.ErrorLog("解析失败:%v", err)
|
4085
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
4086
|
|
- return
|
4087
|
|
- }
|
4088
|
|
-
|
4089
|
|
- //patient, _ := service.GetPatientByIDCard(item.IdCardNo, adminUser.CurrentOrgId)
|
4090
|
|
-
|
4091
|
|
- if res2.Infcode == 0 {
|
4092
|
|
- psnResult := &models.GdybPsnNcdsRecord{
|
4093
|
|
- UserOrgId: adminUser.CurrentOrgId,
|
4094
|
|
- PatientId: item.ID,
|
4095
|
|
- PsnNo: res.Output.Baseinfo.PsnNo,
|
4096
|
|
- Ctime: time.Now().Unix(),
|
4097
|
|
- Mtime: time.Now().Unix(),
|
4098
|
|
- Status: 1,
|
4099
|
|
- IsCancel: 1,
|
4100
|
|
- TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
|
4101
|
|
- }
|
4102
|
|
- service.CreatePsnNCDSRecord(psnResult)
|
4103
|
|
-
|
4104
|
|
- } else {
|
4105
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
4106
|
|
- "failed_code": -10,
|
4107
|
|
- "msg": res2.ErrMsg,
|
4108
|
|
- })
|
4109
|
|
- return
|
4110
|
|
- }
|
|
4031
|
+ result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.CountryCode)
|
|
4032
|
+ var dat map[string]interface{}
|
|
4033
|
+ if err := json.Unmarshal([]byte(result), &dat); err == nil {
|
|
4034
|
+ fmt.Println(dat)
|
|
4035
|
+ } else {
|
|
4036
|
+ fmt.Println(err)
|
|
4037
|
+ }
|
|
4038
|
+ userJSONBytes, _ := json.Marshal(dat)
|
|
4039
|
+ var res2 ResultThirteen
|
|
4040
|
+ if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
|
|
4041
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
4042
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
4043
|
+ return
|
|
4044
|
+ }
|
|
4045
|
+ if res2.Infcode == 0 {
|
|
4046
|
+ psnResult := &models.GdybPsnNcdsRecord{
|
|
4047
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
4048
|
+ PatientId: patient.ID,
|
|
4049
|
+ PsnNo: psn_no,
|
|
4050
|
+ DoctorId: doctor.ID,
|
|
4051
|
+ DepartmentId: department_id,
|
|
4052
|
+ SickType: sick_id,
|
|
4053
|
+ Insutype: insutype,
|
|
4054
|
+ Ctime: time.Now().Unix(),
|
|
4055
|
+ Mtime: time.Now().Unix(),
|
|
4056
|
+ Status: 1,
|
|
4057
|
+ IsCancel: 1,
|
|
4058
|
+ TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
|
4111
|
4059
|
}
|
|
4060
|
+ service.CreatePsnNCDSRecord(psnResult)
|
|
4061
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
4062
|
+ "failed_code": 0,
|
|
4063
|
+ "msg": "备案成功",
|
|
4064
|
+ })
|
4112
|
4065
|
|
|
4066
|
+ } else {
|
|
4067
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
4068
|
+ "failed_code": -10,
|
|
4069
|
+ "msg": res2.ErrMsg,
|
|
4070
|
+ })
|
|
4071
|
+ return
|
4113
|
4072
|
}
|
4114
|
|
-
|
4115
|
4073
|
}
|
4116
|
|
-
|
4117
|
4074
|
}
|
4118
|
4075
|
func (c *HisApiController) PsnPutUnNCDSOnRecord() {
|
4119
|
4076
|
id, _ := c.GetInt64("id")
|