|
@@ -43,15 +43,17 @@ func HisManagerApiRegistRouters() {
|
43
|
43
|
beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
|
44
|
44
|
beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
|
45
|
45
|
beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
|
46
|
|
- //beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
|
47
|
46
|
|
48
|
47
|
beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
|
49
|
|
-
|
50
|
48
|
beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
|
51
|
49
|
|
52
|
50
|
beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
|
53
|
51
|
beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
|
54
|
52
|
|
|
53
|
+ beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
|
|
54
|
+
|
|
55
|
+ beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
|
|
56
|
+
|
55
|
57
|
}
|
56
|
58
|
|
57
|
59
|
func (c *HisApiController) GetHisPatientList() {
|
|
@@ -151,7 +153,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
151
|
153
|
record_date := c.GetString("record_date")
|
152
|
154
|
fmt.Println("record_date", record_date)
|
153
|
155
|
patient_id, _ := c.GetInt64("patient_id")
|
154
|
|
- reg_type, _ := c.GetInt64("reg_type")
|
|
156
|
+ reg_type := c.GetString("reg_type")
|
155
|
157
|
|
156
|
158
|
diagnose := c.GetString("diagnose")
|
157
|
159
|
sick_history := c.GetString("sick_history")
|
|
@@ -176,16 +178,17 @@ func (c *HisApiController) CreateHisPrescription() {
|
176
|
178
|
adminInfo := c.GetAdminUserInfo()
|
177
|
179
|
recordDateTime := theTime.Unix()
|
178
|
180
|
|
179
|
|
- var randNum int
|
180
|
|
- randNum = rand.Intn(10000) + 1000
|
181
|
|
- timestamp := time.Now().Unix()
|
182
|
|
- tempTime := time.Unix(timestamp, 0)
|
183
|
|
- timeFormat := tempTime.Format("20060102150405")
|
184
|
|
- number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
|
185
|
|
-
|
186
|
181
|
info, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
|
|
182
|
+ var hpInfo models.HisPrescriptionInfo
|
187
|
183
|
if info.ID == 0 {
|
188
|
|
- hpInfo := models.HisPrescriptionInfo{
|
|
184
|
+ var randNum int
|
|
185
|
+ randNum = rand.Intn(10000) + 1000
|
|
186
|
+ timestamp := time.Now().Unix()
|
|
187
|
+ tempTime := time.Unix(timestamp, 0)
|
|
188
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
189
|
+ p_number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
|
|
190
|
+
|
|
191
|
+ hpInfo = models.HisPrescriptionInfo{
|
189
|
192
|
UserOrgId: adminInfo.CurrentOrgId,
|
190
|
193
|
RecordDate: theTime.Unix(),
|
191
|
194
|
PatientId: patient_id,
|
|
@@ -198,26 +201,31 @@ func (c *HisApiController) CreateHisPrescription() {
|
198
|
201
|
SickHistory: sick_history,
|
199
|
202
|
Departments: department,
|
200
|
203
|
RegisterType: reg_type,
|
201
|
|
- PrescriptionNumber: number,
|
|
204
|
+ PrescriptionNumber: p_number,
|
|
205
|
+ PrescriptionStatus: 1,
|
|
206
|
+ Doctor: doctor,
|
202
|
207
|
}
|
203
|
208
|
service.SavePatientPrescriptionInfo(hpInfo)
|
204
|
209
|
|
205
|
210
|
} else {
|
206
|
|
- hpInfo := models.HisPrescriptionInfo{
|
207
|
|
- ID: info.ID,
|
208
|
|
- UserOrgId: adminInfo.CurrentOrgId,
|
209
|
|
- RecordDate: info.RecordDate,
|
210
|
|
- PatientId: info.PatientId,
|
211
|
|
- Status: 1,
|
212
|
|
- Ctime: info.Ctime,
|
213
|
|
- Mtime: time.Now().Unix(),
|
214
|
|
- Creator: info.Creator,
|
215
|
|
- Modifier: adminInfo.AdminUser.Id,
|
216
|
|
- Diagnosis: diagnose,
|
217
|
|
- SickHistory: sick_history,
|
218
|
|
- Departments: department,
|
219
|
|
- RegisterType: reg_type,
|
|
211
|
+ hpInfo = models.HisPrescriptionInfo{
|
|
212
|
+ ID: info.ID,
|
|
213
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
214
|
+ RecordDate: info.RecordDate,
|
|
215
|
+ PatientId: info.PatientId,
|
|
216
|
+ Status: 1,
|
|
217
|
+ Ctime: info.Ctime,
|
|
218
|
+ Mtime: time.Now().Unix(),
|
|
219
|
+ Creator: info.Creator,
|
|
220
|
+ Modifier: adminInfo.AdminUser.Id,
|
|
221
|
+ Diagnosis: diagnose,
|
|
222
|
+ SickHistory: sick_history,
|
|
223
|
+ Departments: department,
|
|
224
|
+ RegisterType: reg_type,
|
|
225
|
+
|
220
|
226
|
PrescriptionNumber: info.PrescriptionNumber,
|
|
227
|
+ Doctor: doctor,
|
|
228
|
+ PrescriptionStatus: info.PrescriptionStatus,
|
221
|
229
|
}
|
222
|
230
|
service.SavePatientPrescriptionInfo(hpInfo)
|
223
|
231
|
}
|
|
@@ -244,20 +252,21 @@ func (c *HisApiController) CreateHisPrescription() {
|
244
|
252
|
|
245
|
253
|
ctime := time.Now().Unix()
|
246
|
254
|
prescription := &models.HisPrescription{
|
247
|
|
- ID: id,
|
248
|
|
- PatientId: patient_id,
|
249
|
|
- UserOrgId: adminInfo.CurrentOrgId,
|
250
|
|
- RecordDate: recordDateTime,
|
251
|
|
- Ctime: ctime,
|
252
|
|
- Mtime: ctime,
|
253
|
|
- Type: types,
|
254
|
|
- Modifier: adminInfo.AdminUser.Id,
|
255
|
|
- Creator: adminInfo.AdminUser.Id,
|
256
|
|
- Status: 1,
|
257
|
|
- Doctor: doctor,
|
258
|
|
- HisPatientId: his_patient_id,
|
259
|
|
- IsFinish: 1,
|
260
|
|
- BatchNumber: "",
|
|
255
|
+ ID: id,
|
|
256
|
+ PatientId: patient_id,
|
|
257
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
258
|
+ RecordDate: recordDateTime,
|
|
259
|
+ Ctime: ctime,
|
|
260
|
+ Mtime: ctime,
|
|
261
|
+ Type: types,
|
|
262
|
+ Modifier: adminInfo.AdminUser.Id,
|
|
263
|
+ Creator: adminInfo.AdminUser.Id,
|
|
264
|
+ Status: 1,
|
|
265
|
+ Doctor: doctor,
|
|
266
|
+ HisPatientId: his_patient_id,
|
|
267
|
+ OrderStatus: 1,
|
|
268
|
+ BatchNumber: "",
|
|
269
|
+ PrescriptionNumber: hpInfo.PrescriptionNumber,
|
261
|
270
|
}
|
262
|
271
|
service.SaveHisPrescription(prescription)
|
263
|
272
|
|
|
@@ -1053,6 +1062,17 @@ type ResultFive struct {
|
1053
|
1062
|
Insutype string `json:"insutype"`
|
1054
|
1063
|
}
|
1055
|
1064
|
|
|
1065
|
+type Custom struct {
|
|
1066
|
+ DetItemFeeSumamt string
|
|
1067
|
+ Cut string
|
|
1068
|
+ FeedetlSn string
|
|
1069
|
+ Price string
|
|
1070
|
+ MedListCodg string
|
|
1071
|
+ Type int64
|
|
1072
|
+ AdviceId int64
|
|
1073
|
+ ProjectId int64
|
|
1074
|
+}
|
|
1075
|
+
|
1056
|
1076
|
func (c *HisApiController) GetUploadInfo() {
|
1057
|
1077
|
id, _ := c.GetInt64("id")
|
1058
|
1078
|
record_time := c.GetString("record_time")
|
|
@@ -1093,34 +1113,180 @@ func (c *HisApiController) GetUploadInfo() {
|
1093
|
1113
|
for _, item := range prescriptions {
|
1094
|
1114
|
ids = append(ids, item.ID)
|
1095
|
1115
|
}
|
|
1116
|
+ config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
1096
|
1117
|
|
1097
|
|
- bytesData, _ := json.Marshal(data)
|
1098
|
|
- req, _ := http.NewRequest("POST", "http://127.0.0.1:9531/"+"gdyb/five", bytes.NewReader(bytesData))
|
1099
|
|
- resp, _ := client.Do(req)
|
1100
|
|
- defer resp.Body.Close()
|
1101
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
1102
|
|
- if ioErr != nil {
|
1103
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
1104
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1105
|
|
- return
|
1106
|
|
- }
|
1107
|
|
- var respJSON map[string]interface{}
|
1108
|
|
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
1109
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
1110
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1111
|
|
- return
|
1112
|
|
- }
|
|
1118
|
+ if config.IsOpen == 1 {
|
|
1119
|
+ bytesData, _ := json.Marshal(data)
|
|
1120
|
+ req, _ := http.NewRequest("POST", "http://127.0.0.1:9531/"+"gdyb/five", bytes.NewReader(bytesData))
|
|
1121
|
+ resp, _ := client.Do(req)
|
|
1122
|
+ defer resp.Body.Close()
|
|
1123
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
1124
|
+ if ioErr != nil {
|
|
1125
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
1126
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1127
|
+ return
|
|
1128
|
+ }
|
|
1129
|
+ var respJSON map[string]interface{}
|
|
1130
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
1131
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
1132
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1133
|
+ return
|
|
1134
|
+ }
|
1113
|
1135
|
|
1114
|
|
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
1115
|
|
- userJSONBytes, _ := json.Marshal(respJSON)
|
1116
|
|
- var res ResultFour
|
1117
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
1118
|
|
- utils.ErrorLog("解析失败:%v", err)
|
1119
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1120
|
|
- return
|
1121
|
|
- }
|
|
1136
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
1137
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
1138
|
+ var res ResultFour
|
|
1139
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1140
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1141
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1142
|
+ return
|
|
1143
|
+ }
|
|
1144
|
+
|
|
1145
|
+ if res.Infcode == 0 {
|
|
1146
|
+ order := &models.HisOrder{
|
|
1147
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
1148
|
+ HisPatientId: his.ID,
|
|
1149
|
+ PatientId: his.PatientId,
|
|
1150
|
+ SettleAccountsDate: recordDateTime,
|
|
1151
|
+ Ctime: time.Now().Unix(),
|
|
1152
|
+ Mtime: time.Now().Unix(),
|
|
1153
|
+ Status: 1,
|
|
1154
|
+ Number: chrg_bchno,
|
|
1155
|
+ Infcode: res.Infcode,
|
|
1156
|
+ WarnMsg: res.WarnMsg,
|
|
1157
|
+ Cainfo: res.Cainfo,
|
|
1158
|
+ ErrMsg: res.ErrMsg,
|
|
1159
|
+ RespondTime: res.RefmsgTime,
|
|
1160
|
+ InfRefmsgid: res.InfRefmsgid,
|
|
1161
|
+ OrderStatus: 1,
|
|
1162
|
+ }
|
|
1163
|
+ err = service.CreateOrder(order)
|
|
1164
|
+ if err != nil {
|
|
1165
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
|
1166
|
+ return
|
|
1167
|
+ }
|
|
1168
|
+
|
|
1169
|
+ for _, item := range res.Output.Result {
|
|
1170
|
+ temp := strings.Split(item.FeedetlSn, "-")
|
|
1171
|
+ var advice_id int64 = 0
|
|
1172
|
+ var project_id int64 = 0
|
|
1173
|
+ var types int64 = 0
|
|
1174
|
+
|
|
1175
|
+ id, _ := strconv.ParseInt(temp[2], 10, 64)
|
|
1176
|
+ types, _ = strconv.ParseInt(temp[1], 10, 64)
|
|
1177
|
+
|
|
1178
|
+ if temp[1] == "1" {
|
|
1179
|
+ advice_id = id
|
|
1180
|
+ project_id = 0
|
|
1181
|
+ } else if temp[1] == "2" {
|
|
1182
|
+ advice_id = 0
|
|
1183
|
+ project_id = id
|
|
1184
|
+ }
|
|
1185
|
+
|
|
1186
|
+ info := &models.HisOrderInfo{
|
|
1187
|
+ OrderNumber: order.Number,
|
|
1188
|
+ FeedetlSn: item.FeedetlSn,
|
|
1189
|
+ UploadDate: time.Now().Unix(),
|
|
1190
|
+ AdviceId: advice_id,
|
|
1191
|
+ DetItemFeeSumamt: item.DetItemFeeSumamt,
|
|
1192
|
+ Cnt: item.Cnt,
|
|
1193
|
+ Pric: float64(item.Pric),
|
|
1194
|
+ PatientId: his.PatientId,
|
|
1195
|
+ PricUplmtAmt: item.PricUplmtAmt,
|
|
1196
|
+ SelfpayProp: item.SelfpayProp,
|
|
1197
|
+ FulamtOwnpayAmt: item.FulamtOwnpayAmt,
|
|
1198
|
+ OverlmtAmt: item.OverlmtAmt,
|
|
1199
|
+ PreselfpayAmt: item.PreselfpayAmt,
|
|
1200
|
+ BasMednFlag: item.BasMednFlag,
|
|
1201
|
+ MedChrgitmType: item.MedChrgitmType,
|
|
1202
|
+ HiNegoDrugFlag: item.HiNegoDrugFlag,
|
|
1203
|
+ Status: 1,
|
|
1204
|
+ Memo: item.Memo,
|
|
1205
|
+ Mtime: time.Now().Unix(),
|
|
1206
|
+ InscpScpAmt: item.InscpScpAmt,
|
|
1207
|
+ DrtReimFlag: item.DrtReimFlag,
|
|
1208
|
+ Ctime: time.Now().Unix(),
|
|
1209
|
+ ListSpItemFlag: item.ListSpItemFlag,
|
|
1210
|
+ ChldMedcFlag: item.ChldMedcFlag,
|
|
1211
|
+ LmtUsedFlag: item.LmtUsedFlag,
|
|
1212
|
+ ChrgitmLv: item.ChrgitmLv,
|
|
1213
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
1214
|
+ HisPatientId: his.ID,
|
|
1215
|
+ OrderId: order.ID,
|
|
1216
|
+ ProjectId: project_id,
|
|
1217
|
+ Type: types,
|
|
1218
|
+ }
|
|
1219
|
+ service.CreateOrderInfo(info)
|
|
1220
|
+ }
|
|
1221
|
+
|
|
1222
|
+ service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
|
|
1223
|
+ service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
|
|
1224
|
+
|
|
1225
|
+ var total float64
|
|
1226
|
+ for _, item := range prescriptions {
|
|
1227
|
+ if item.Type == 1 { //药品
|
|
1228
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
1229
|
+ total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
1230
|
+ }
|
|
1231
|
+ }
|
|
1232
|
+ if item.Type == 2 { //项目
|
|
1233
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
1234
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
1235
|
+ }
|
|
1236
|
+ }
|
|
1237
|
+ }
|
|
1238
|
+
|
|
1239
|
+ org, _ := service.GetOrgById(adminUser.CurrentOrgId)
|
|
1240
|
+ patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
|
1241
|
+ allTotal := fmt.Sprintf("%.2f", total)
|
|
1242
|
+ if res.Infcode == 0 {
|
|
1243
|
+ var rf []*ResultFive
|
|
1244
|
+ json.Unmarshal([]byte(his.Iinfo), &rf)
|
|
1245
|
+ psn_no := his.PsnNo
|
|
1246
|
+ mdtrt_id := his.Number
|
|
1247
|
+ chrg_bchno := chrg_bchno
|
|
1248
|
+ cert_no := his.Certno
|
|
1249
|
+ insutype := rf[0].Insutype
|
|
1250
|
+ api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
|
|
1251
|
+ insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
|
|
1252
|
+ "&total=" + allTotal + "&org_name=" + org.OrgName + "&doctor=" + patientPrescription.Doctor
|
|
1253
|
+ resp, requestErr := http.Get(api)
|
|
1254
|
+
|
|
1255
|
+ if requestErr != nil {
|
|
1256
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1257
|
+ return
|
|
1258
|
+ }
|
|
1259
|
+ defer resp.Body.Close()
|
|
1260
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
1261
|
+ if ioErr != nil {
|
|
1262
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
1263
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1264
|
+ return
|
|
1265
|
+ }
|
|
1266
|
+ var respJSON map[string]interface{}
|
|
1267
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
1268
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
1269
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1270
|
+ return
|
|
1271
|
+ }
|
|
1272
|
+ fmt.Println(respJSON)
|
|
1273
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
1274
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
1275
|
+ var res ResultFour
|
|
1276
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1277
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1278
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1279
|
+ return
|
|
1280
|
+ }
|
|
1281
|
+ } else {
|
1122
|
1282
|
|
1123
|
|
- if res.Infcode == 0 {
|
|
1283
|
+ }
|
|
1284
|
+
|
|
1285
|
+ } else {
|
|
1286
|
+
|
|
1287
|
+ }
|
|
1288
|
+
|
|
1289
|
+ } else {
|
1124
|
1290
|
order := &models.HisOrder{
|
1125
|
1291
|
UserOrgId: adminUser.CurrentOrgId,
|
1126
|
1292
|
HisPatientId: his.ID,
|
|
@@ -1129,66 +1295,81 @@ func (c *HisApiController) GetUploadInfo() {
|
1129
|
1295
|
Ctime: time.Now().Unix(),
|
1130
|
1296
|
Mtime: time.Now().Unix(),
|
1131
|
1297
|
Status: 1,
|
1132
|
|
- Number: chrg_bchno,
|
1133
|
|
- Infcode: res.Infcode,
|
1134
|
|
- WarnMsg: res.WarnMsg,
|
1135
|
|
- Cainfo: res.Cainfo,
|
1136
|
|
- ErrMsg: res.ErrMsg,
|
1137
|
|
- RespondTime: res.RefmsgTime,
|
1138
|
|
- InfRefmsgid: res.InfRefmsgid,
|
1139
|
|
- OrderStatus: 1,
|
|
1298
|
+ OrderStatus: 2,
|
1140
|
1299
|
}
|
1141
|
1300
|
|
1142
|
1301
|
err = service.CreateOrder(order)
|
|
1302
|
+
|
1143
|
1303
|
if err != nil {
|
1144
|
1304
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
1145
|
1305
|
return
|
1146
|
1306
|
}
|
1147
|
1307
|
|
1148
|
|
- for _, item := range res.Output.Result {
|
1149
|
|
- temp := strings.Split(item.FeedetlSn, "-")
|
|
1308
|
+ var customs []*Custom
|
|
1309
|
+
|
|
1310
|
+ for _, item := range prescriptions {
|
|
1311
|
+ if item.Type == 1 { //药品
|
|
1312
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
1313
|
+ cus := &Custom{
|
|
1314
|
+ AdviceId: subItem.ID,
|
|
1315
|
+ ProjectId: 0,
|
|
1316
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
|
|
1317
|
+ Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
|
|
1318
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
1319
|
+ Price: fmt.Sprintf("%.2f", subItem.Price),
|
|
1320
|
+ MedListCodg: subItem.MedListCodg,
|
|
1321
|
+ Type: 1,
|
|
1322
|
+ }
|
|
1323
|
+ customs = append(customs, cus)
|
|
1324
|
+ }
|
|
1325
|
+ }
|
|
1326
|
+
|
|
1327
|
+ if item.Type == 2 { //项目
|
|
1328
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
1329
|
+ cus := &Custom{
|
|
1330
|
+ AdviceId: 0,
|
|
1331
|
+ ProjectId: subItem.ID,
|
|
1332
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
|
|
1333
|
+ Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
|
|
1334
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
1335
|
+ Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
|
|
1336
|
+ MedListCodg: subItem.MedListCodg,
|
|
1337
|
+ Type: 2,
|
|
1338
|
+ }
|
|
1339
|
+
|
|
1340
|
+ customs = append(customs, cus)
|
|
1341
|
+ }
|
|
1342
|
+ }
|
|
1343
|
+ }
|
|
1344
|
+
|
|
1345
|
+ for _, item := range customs {
|
1150
|
1346
|
var advice_id int64 = 0
|
1151
|
1347
|
var project_id int64 = 0
|
1152
|
1348
|
var types int64 = 0
|
1153
|
1349
|
|
1154
|
|
- id, _ := strconv.ParseInt(temp[2], 10, 64)
|
1155
|
|
- types, _ = strconv.ParseInt(temp[1], 10, 64)
|
1156
|
|
-
|
1157
|
|
- if temp[1] == "1" {
|
1158
|
|
- advice_id = id
|
|
1350
|
+ if item.Type == 1 {
|
|
1351
|
+ advice_id = item.AdviceId
|
1159
|
1352
|
project_id = 0
|
1160
|
|
- } else if temp[1] == "2" {
|
|
1353
|
+ } else if item.Type == 2 {
|
1161
|
1354
|
advice_id = 0
|
1162
|
|
- project_id = id
|
|
1355
|
+ project_id = item.ProjectId
|
1163
|
1356
|
}
|
1164
|
1357
|
|
|
1358
|
+ detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
|
|
1359
|
+ cut, _ := strconv.ParseFloat(item.Cut, 32)
|
|
1360
|
+ pric, _ := strconv.ParseFloat(item.Price, 32)
|
|
1361
|
+
|
1165
|
1362
|
info := &models.HisOrderInfo{
|
1166
|
1363
|
OrderNumber: order.Number,
|
1167
|
|
- FeedetlSn: item.FeedetlSn,
|
1168
|
1364
|
UploadDate: time.Now().Unix(),
|
1169
|
1365
|
AdviceId: advice_id,
|
1170
|
|
- DetItemFeeSumamt: item.DetItemFeeSumamt,
|
1171
|
|
- Cnt: item.Cnt,
|
1172
|
|
- Pric: float64(item.Pric),
|
|
1366
|
+ DetItemFeeSumamt: detItemFeeSumamt,
|
|
1367
|
+ Cnt: cut,
|
|
1368
|
+ Pric: pric,
|
1173
|
1369
|
PatientId: his.PatientId,
|
1174
|
|
- PricUplmtAmt: item.PricUplmtAmt,
|
1175
|
|
- SelfpayProp: item.SelfpayProp,
|
1176
|
|
- FulamtOwnpayAmt: item.FulamtOwnpayAmt,
|
1177
|
|
- OverlmtAmt: item.OverlmtAmt,
|
1178
|
|
- PreselfpayAmt: item.PreselfpayAmt,
|
1179
|
|
- BasMednFlag: item.BasMednFlag,
|
1180
|
|
- MedChrgitmType: item.MedChrgitmType,
|
1181
|
|
- HiNegoDrugFlag: item.HiNegoDrugFlag,
|
1182
|
1370
|
Status: 1,
|
1183
|
|
- Memo: item.Memo,
|
1184
|
1371
|
Mtime: time.Now().Unix(),
|
1185
|
|
- InscpScpAmt: item.InscpScpAmt,
|
1186
|
|
- DrtReimFlag: item.DrtReimFlag,
|
1187
|
1372
|
Ctime: time.Now().Unix(),
|
1188
|
|
- ListSpItemFlag: item.ListSpItemFlag,
|
1189
|
|
- ChldMedcFlag: item.ChldMedcFlag,
|
1190
|
|
- LmtUsedFlag: item.LmtUsedFlag,
|
1191
|
|
- ChrgitmLv: item.ChrgitmLv,
|
1192
|
1373
|
UserOrgId: adminUser.CurrentOrgId,
|
1193
|
1374
|
HisPatientId: his.ID,
|
1194
|
1375
|
OrderId: order.ID,
|
|
@@ -1197,73 +1378,8 @@ func (c *HisApiController) GetUploadInfo() {
|
1197
|
1378
|
}
|
1198
|
1379
|
service.CreateOrderInfo(info)
|
1199
|
1380
|
}
|
1200
|
|
-
|
1201
|
1381
|
service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
|
1202
|
|
-
|
1203
|
|
- var total float64
|
1204
|
|
- for _, item := range prescriptions {
|
1205
|
|
- if item.Type == 1 { //药品
|
1206
|
|
- for _, subItem := range item.HisDoctorAdviceInfo {
|
1207
|
|
- total = total + (subItem.Price * subItem.PrescribingNumber)
|
1208
|
|
- }
|
1209
|
|
- }
|
1210
|
|
- if item.Type == 2 { //项目
|
1211
|
|
- for _, subItem := range item.HisPrescriptionProject {
|
1212
|
|
- total = total + (subItem.Price * float64(subItem.Count))
|
1213
|
|
- }
|
1214
|
|
- }
|
1215
|
|
- }
|
1216
|
|
-
|
1217
|
|
- org, _ := service.GetOrgById(adminUser.CurrentOrgId)
|
1218
|
|
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
1219
|
|
- allTotal := fmt.Sprintf("%.2f", total)
|
1220
|
|
- if res.Infcode == 0 {
|
1221
|
|
- var rf []*ResultFive
|
1222
|
|
- json.Unmarshal([]byte(his.Iinfo), &rf)
|
1223
|
|
- psn_no := his.PsnNo
|
1224
|
|
- mdtrt_id := his.Number
|
1225
|
|
- chrg_bchno := chrg_bchno
|
1226
|
|
- cert_no := his.Certno
|
1227
|
|
- insutype := rf[0].Insutype
|
1228
|
|
- api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
|
1229
|
|
- insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
|
1230
|
|
- "&total=" + allTotal + "&org_name=" + org.OrgName + "&doctor=" + patientPrescription.Doctor
|
1231
|
|
- resp, requestErr := http.Get(api)
|
1232
|
|
-
|
1233
|
|
- if requestErr != nil {
|
1234
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1235
|
|
- return
|
1236
|
|
- }
|
1237
|
|
- defer resp.Body.Close()
|
1238
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
1239
|
|
- if ioErr != nil {
|
1240
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
1241
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1242
|
|
- return
|
1243
|
|
- }
|
1244
|
|
- var respJSON map[string]interface{}
|
1245
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
1246
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
1247
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1248
|
|
- return
|
1249
|
|
- }
|
1250
|
|
- fmt.Println(respJSON)
|
1251
|
|
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
1252
|
|
- userJSONBytes, _ := json.Marshal(respJSON)
|
1253
|
|
- var res ResultFour
|
1254
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
1255
|
|
- utils.ErrorLog("解析失败:%v", err)
|
1256
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1257
|
|
- return
|
1258
|
|
- }
|
1259
|
|
- } else {
|
1260
|
|
-
|
1261
|
|
- }
|
1262
|
|
- } else {
|
1263
|
|
-
|
1264
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1265
|
|
- "msg": res.ErrMsg,
|
1266
|
|
- })
|
|
1382
|
+ service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
|
1267
|
1383
|
|
1268
|
1384
|
}
|
1269
|
1385
|
}
|
|
@@ -1318,16 +1434,49 @@ func (c *HisApiController) GetHisPrescriptionList() {
|
1318
|
1434
|
}
|
1319
|
1435
|
|
1320
|
1436
|
func (c *HisApiController) GetHisPrescriptionInfo() {
|
1321
|
|
- patient_id, _ := c.GetInt64("patient_id")
|
1322
|
|
- his_patient_id, _ := c.GetInt64("his_patient_id")
|
|
1437
|
+ id, _ := c.GetInt64("id")
|
1323
|
1438
|
adminInfo := c.GetAdminUserInfo()
|
1324
|
|
- prescriptionOrder, err := service.GetHisPrescriptionOrderInfo(patient_id, his_patient_id, adminInfo.CurrentOrgId)
|
|
1439
|
+ prescriptionOrder, err := service.GetHisPrescriptionOrderInfo(id, adminInfo.CurrentOrgId)
|
|
1440
|
+ prescription, err := service.GetHisPrescriptionFour(adminInfo.CurrentOrgId, prescriptionOrder.PatientId, prescriptionOrder.RecordDate, prescriptionOrder.PrescriptionNumber)
|
1325
|
1441
|
if err == nil {
|
1326
|
1442
|
c.ServeSuccessJSON(map[string]interface{}{
|
1327
|
|
- "order": prescriptionOrder,
|
|
1443
|
+ "order": prescriptionOrder,
|
|
1444
|
+ "prescription": prescription,
|
1328
|
1445
|
})
|
1329
|
1446
|
} else {
|
1330
|
1447
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
1331
|
1448
|
return
|
1332
|
1449
|
}
|
1333
|
1450
|
}
|
|
1451
|
+
|
|
1452
|
+func (c *HisApiController) Refund() {
|
|
1453
|
+ order_id, _ := c.GetInt64("order_id")
|
|
1454
|
+ number := c.GetString("number")
|
|
1455
|
+
|
|
1456
|
+ adminUser := c.GetAdminUserInfo()
|
|
1457
|
+ config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
|
1458
|
+ if config.IsOpen == 1 { //对接了医保,走医保流程
|
|
1459
|
+
|
|
1460
|
+ } else {
|
|
1461
|
+ err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
|
|
1462
|
+ if err == nil {
|
|
1463
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1464
|
+ "msg": "退费成功",
|
|
1465
|
+ })
|
|
1466
|
+ } else {
|
|
1467
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1468
|
+ return
|
|
1469
|
+ }
|
|
1470
|
+
|
|
1471
|
+ }
|
|
1472
|
+
|
|
1473
|
+}
|
|
1474
|
+
|
|
1475
|
+func (c *HisApiController) GetMedicalInsuranceConfig() {
|
|
1476
|
+ adminUser := c.GetAdminUserInfo()
|
|
1477
|
+ config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
|
1478
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1479
|
+ "config": config,
|
|
1480
|
+ })
|
|
1481
|
+
|
|
1482
|
+}
|