|
@@ -9,6 +9,7 @@ import (
|
9
|
9
|
"encoding/json"
|
10
|
10
|
"fmt"
|
11
|
11
|
"github.com/astaxie/beego"
|
|
12
|
+ "github.com/jinzhu/gorm"
|
12
|
13
|
"io/ioutil"
|
13
|
14
|
"math/rand"
|
14
|
15
|
"net/http"
|
|
@@ -100,6 +101,8 @@ func (c *HisApiController) GetHisPatientList() {
|
100
|
101
|
func (c *HisApiController) GetHisPatientInfo() {
|
101
|
102
|
patient_id, _ := c.GetInt64("patient_id")
|
102
|
103
|
record_date := c.GetString("record_date")
|
|
104
|
+ number := c.GetString("number")
|
|
105
|
+
|
103
|
106
|
timeLayout := "2006-01-02"
|
104
|
107
|
loc, _ := time.LoadLocation("Local")
|
105
|
108
|
theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
@@ -116,6 +119,7 @@ func (c *HisApiController) GetHisPatientInfo() {
|
116
|
119
|
case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
117
|
120
|
patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
118
|
121
|
lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
|
122
|
+ order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
|
119
|
123
|
|
120
|
124
|
c.ServeSuccessJSON(map[string]interface{}{
|
121
|
125
|
"his_info": his_patient_info,
|
|
@@ -124,6 +128,7 @@ func (c *HisApiController) GetHisPatientInfo() {
|
124
|
128
|
"case_history": case_history,
|
125
|
129
|
"info": patientPrescriptionInfo,
|
126
|
130
|
"last_info": lastPatientPrescriptionInfo,
|
|
131
|
+ "order": order,
|
127
|
132
|
})
|
128
|
133
|
return
|
129
|
134
|
|
|
@@ -1094,76 +1099,13 @@ func (c *HisApiController) GetRegisterInfo() {
|
1094
|
1099
|
}
|
1095
|
1100
|
|
1096
|
1101
|
//org, _ := service.GetOrgById(adminInfo.CurrentOrgId)
|
|
1102
|
+ config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
|
1097
|
1103
|
|
1098
|
|
- api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code
|
1099
|
|
- resp, requestErr := http.Get(api)
|
1100
|
|
-
|
1101
|
|
- if requestErr != nil {
|
1102
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1103
|
|
- return
|
1104
|
|
- }
|
1105
|
|
- defer resp.Body.Close()
|
1106
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
1107
|
|
- if ioErr != nil {
|
1108
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
1109
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1110
|
|
- return
|
1111
|
|
- }
|
1112
|
|
- var respJSON map[string]interface{}
|
1113
|
|
-
|
1114
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
1115
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
1116
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1117
|
|
- return
|
1118
|
|
- }
|
1119
|
|
-
|
1120
|
|
- userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
1121
|
|
- userJSONBytes, _ := json.Marshal(userJSON)
|
1122
|
|
- var res ResultTwo
|
1123
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
1124
|
|
- utils.ErrorLog("解析失败:%v", err)
|
1125
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1126
|
|
- return
|
1127
|
|
- }
|
1128
|
|
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
1129
|
|
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
1130
|
|
- infoStr := string(Iinfos)
|
1131
|
|
- idetinfoStr := string(Idetinfos)
|
1132
|
|
-
|
1133
|
|
- his := models.VMHisPatient{
|
1134
|
|
- PsnNo: res.Output.Baseinfo.PsnNo,
|
1135
|
|
- PsnCertType: res.Output.Baseinfo.PsnCertType,
|
1136
|
|
- Certno: res.Output.Baseinfo.Certno,
|
1137
|
|
- PsnName: res.Output.Baseinfo.PsnName,
|
1138
|
|
- Gend: res.Output.Baseinfo.Gend,
|
1139
|
|
- Naty: res.Output.Baseinfo.Naty,
|
1140
|
|
- Brdy: res.Output.Baseinfo.Brdy,
|
1141
|
|
- Age: res.Output.Baseinfo.Age,
|
1142
|
|
- Iinfo: infoStr,
|
1143
|
|
- Idetinfo: idetinfoStr,
|
1144
|
|
- PatientId: patient.ID,
|
1145
|
|
- RecordDate: theTime.Unix(),
|
1146
|
|
- }
|
1147
|
|
- fmt.Println(his)
|
1148
|
|
-
|
1149
|
|
- if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
|
1150
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
|
1151
|
|
- return
|
1152
|
|
- }
|
|
1104
|
+ if config.IsOpen == 1 {
|
1153
|
1105
|
|
1154
|
|
- timestamp := time.Now().Unix()
|
1155
|
|
- tempTime := time.Unix(timestamp, 0)
|
1156
|
|
- timeFormat := tempTime.Format("20060102150405")
|
1157
|
|
- chrgBchno := rand.Intn(100000) + 10000
|
1158
|
|
- ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
1159
|
|
-
|
1160
|
|
- count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
|
1161
|
|
- if count <= 0 {
|
1162
|
|
- api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
|
1163
|
|
- res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
|
1164
|
|
- "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
|
1165
|
|
- "&dept=" + patientPrescription.Departments + "&fixmedins_code=" + miConfig.Code
|
|
1106
|
+ api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code
|
1166
|
1107
|
resp, requestErr := http.Get(api)
|
|
1108
|
+
|
1167
|
1109
|
if requestErr != nil {
|
1168
|
1110
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1169
|
1111
|
return
|
|
@@ -1176,50 +1118,65 @@ func (c *HisApiController) GetRegisterInfo() {
|
1176
|
1118
|
return
|
1177
|
1119
|
}
|
1178
|
1120
|
var respJSON map[string]interface{}
|
|
1121
|
+
|
1179
|
1122
|
if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
1180
|
1123
|
utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
1181
|
1124
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1182
|
1125
|
return
|
1183
|
1126
|
}
|
1184
|
1127
|
|
1185
|
|
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
1186
|
|
- userJSONBytes, _ := json.Marshal(respJSON)
|
1187
|
|
- var res ResultThree
|
|
1128
|
+ userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
1129
|
+ userJSONBytes, _ := json.Marshal(userJSON)
|
|
1130
|
+ var res ResultTwo
|
1188
|
1131
|
if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
1189
|
1132
|
utils.ErrorLog("解析失败:%v", err)
|
1190
|
1133
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1191
|
1134
|
return
|
1192
|
1135
|
}
|
1193
|
|
- if res.Infcode == -1 {
|
1194
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
|
1136
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
1137
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
1138
|
+ infoStr := string(Iinfos)
|
|
1139
|
+ idetinfoStr := string(Idetinfos)
|
|
1140
|
+
|
|
1141
|
+ his := models.VMHisPatient{
|
|
1142
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
1143
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
1144
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
1145
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
1146
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
1147
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
1148
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
1149
|
+ Age: res.Output.Baseinfo.Age,
|
|
1150
|
+ Iinfo: infoStr,
|
|
1151
|
+ Idetinfo: idetinfoStr,
|
|
1152
|
+ PatientId: patient.ID,
|
|
1153
|
+ RecordDate: theTime.Unix(),
|
|
1154
|
+ }
|
|
1155
|
+ fmt.Println(his)
|
|
1156
|
+
|
|
1157
|
+ if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
|
|
1158
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
|
1195
|
1159
|
return
|
1196
|
1160
|
}
|
1197
|
|
- fmt.Println("000!!!!!!")
|
1198
|
|
- fmt.Println(res)
|
1199
|
|
- fmt.Println(res.Output.Data.MdtrtID)
|
1200
|
|
- fmt.Println(res.Output.Data.PsnNo)
|
1201
|
|
- fmt.Println(res.Output.Data.IptOtpNo)
|
1202
|
|
-
|
1203
|
|
- his.Number = res.Output.Data.MdtrtID
|
1204
|
|
- his.PsnNo = res.Output.Data.PsnNo
|
1205
|
|
- his.IptOtpNo = res.Output.Data.IptOtpNo
|
1206
|
|
- his.IdCardNo = patient.IdCardNo
|
1207
|
|
- his.PhoneNumber = patient.Phone
|
1208
|
|
- his.UserOrgId = adminInfo.CurrentOrgId
|
1209
|
|
- his.Status = 1
|
1210
|
|
- his.Ctime = time.Now().Unix()
|
1211
|
|
- his.Mtime = time.Now().Unix()
|
1212
|
|
- err := service.CreateHisPatientTwo(&his)
|
1213
|
|
- if err == nil {
|
1214
|
|
- api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
|
1215
|
|
- "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + patientPrescription.Departments +
|
1216
|
|
- "&diag=" + patientPrescription.Diagnosis + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code
|
|
1161
|
+
|
|
1162
|
+ timestamp := time.Now().Unix()
|
|
1163
|
+ tempTime := time.Unix(timestamp, 0)
|
|
1164
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
1165
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
1166
|
+ ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
|
1167
|
+
|
|
1168
|
+ count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
|
|
1169
|
+ if count <= 0 {
|
|
1170
|
+ api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" +
|
|
1171
|
+ res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
|
|
1172
|
+ "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
|
|
1173
|
+ "&dept=" + patientPrescription.Departments + "&fixmedins_code=" + miConfig.Code
|
1217
|
1174
|
resp, requestErr := http.Get(api)
|
1218
|
1175
|
if requestErr != nil {
|
1219
|
1176
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1220
|
1177
|
return
|
1221
|
1178
|
}
|
1222
|
|
-
|
|
1179
|
+ defer resp.Body.Close()
|
1223
|
1180
|
body, ioErr := ioutil.ReadAll(resp.Body)
|
1224
|
1181
|
if ioErr != nil {
|
1225
|
1182
|
utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
@@ -1235,10 +1192,7 @@ func (c *HisApiController) GetRegisterInfo() {
|
1235
|
1192
|
|
1236
|
1193
|
respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
1237
|
1194
|
userJSONBytes, _ := json.Marshal(respJSON)
|
1238
|
|
- fmt.Println(respJSON)
|
1239
|
|
- fmt.Println(userJSONBytes)
|
1240
|
|
-
|
1241
|
|
- var res ResultSix
|
|
1195
|
+ var res ResultThree
|
1242
|
1196
|
if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
1243
|
1197
|
utils.ErrorLog("解析失败:%v", err)
|
1244
|
1198
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
@@ -1248,14 +1202,91 @@ func (c *HisApiController) GetRegisterInfo() {
|
1248
|
1202
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
1249
|
1203
|
return
|
1250
|
1204
|
}
|
|
1205
|
+ fmt.Println("000!!!!!!")
|
|
1206
|
+ fmt.Println(res)
|
|
1207
|
+ fmt.Println(res.Output.Data.MdtrtID)
|
|
1208
|
+ fmt.Println(res.Output.Data.PsnNo)
|
|
1209
|
+ fmt.Println(res.Output.Data.IptOtpNo)
|
|
1210
|
+
|
|
1211
|
+ his.Number = res.Output.Data.MdtrtID
|
|
1212
|
+ his.PsnNo = res.Output.Data.PsnNo
|
|
1213
|
+ his.IptOtpNo = res.Output.Data.IptOtpNo
|
|
1214
|
+ his.IdCardNo = patient.IdCardNo
|
|
1215
|
+ his.PhoneNumber = patient.Phone
|
|
1216
|
+ his.UserOrgId = adminInfo.CurrentOrgId
|
|
1217
|
+ his.Status = 1
|
|
1218
|
+ his.Ctime = time.Now().Unix()
|
|
1219
|
+ his.Mtime = time.Now().Unix()
|
|
1220
|
+ err := service.CreateHisPatientTwo(&his)
|
|
1221
|
+ if err == nil {
|
|
1222
|
+ api := "http://127.0.0.1:9531/" + "gdyb/four?psn_no=" + his.PsnNo +
|
|
1223
|
+ "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + patientPrescription.Departments +
|
|
1224
|
+ "&diag=" + patientPrescription.Diagnosis + "&org_name=" + miConfig.OrgName + "&med_type=" + "11" + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code
|
|
1225
|
+ resp, requestErr := http.Get(api)
|
|
1226
|
+ if requestErr != nil {
|
|
1227
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1228
|
+ return
|
|
1229
|
+ }
|
|
1230
|
+
|
|
1231
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
1232
|
+ if ioErr != nil {
|
|
1233
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
1234
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1235
|
+ return
|
|
1236
|
+ }
|
|
1237
|
+ var respJSON map[string]interface{}
|
|
1238
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
1239
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
1240
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1241
|
+ return
|
|
1242
|
+ }
|
|
1243
|
+
|
|
1244
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
1245
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
1246
|
+ fmt.Println(respJSON)
|
|
1247
|
+ fmt.Println(userJSONBytes)
|
|
1248
|
+
|
|
1249
|
+ var res ResultSix
|
|
1250
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1251
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1252
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1253
|
+ return
|
|
1254
|
+ }
|
|
1255
|
+ if res.Infcode == -1 {
|
|
1256
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
|
1257
|
+ return
|
|
1258
|
+ }
|
|
1259
|
+
|
|
1260
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1261
|
+ "his_info": his,
|
|
1262
|
+ })
|
|
1263
|
+ } else {
|
|
1264
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1265
|
+ return
|
|
1266
|
+ }
|
|
1267
|
+ }
|
1251
|
1268
|
|
1252
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1253
|
|
- "his_info": his,
|
1254
|
|
- })
|
1255
|
|
- } else {
|
1256
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1257
|
|
- return
|
|
1269
|
+ } else {
|
|
1270
|
+ his, err := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
|
|
1271
|
+ if err == gorm.ErrRecordNotFound || his.ID == 0 {
|
|
1272
|
+ patient := models.XtHisPatient{
|
|
1273
|
+ Age: patient.Age,
|
|
1274
|
+ Birthday: patient.Birthday,
|
|
1275
|
+ AdminUserId: adminInfo.AdminUser.Id,
|
|
1276
|
+ IdCardNo: patient.IdCardNo,
|
|
1277
|
+ Name: patient.Name,
|
|
1278
|
+ Gender: patient.Gender,
|
|
1279
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
1280
|
+ Status: 1,
|
|
1281
|
+ RecordDate: recordDateTime,
|
|
1282
|
+ IsReturn: 1,
|
|
1283
|
+ PatientId: patient.ID,
|
|
1284
|
+ }
|
|
1285
|
+ service.CreateHisPatient(&patient)
|
1258
|
1286
|
}
|
|
1287
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1288
|
+ "his_info": patient,
|
|
1289
|
+ })
|
1259
|
1290
|
|
1260
|
1291
|
}
|
1261
|
1292
|
|