Bläddra i källkod

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 3 år sedan
förälder
incheckning
12b4f13d80
5 ändrade filer med 340 tillägg och 146 borttagningar
  1. 5 5
      conf/app.conf
  2. 269 135
      controllers/zh/zh_his_api_controller.go
  3. 1 0
      models/his_models.go
  4. 5 0
      service/his_service.go
  5. 60 6
      service/zh_his_service.go

+ 5 - 5
conf/app.conf Visa fil

@@ -45,7 +45,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
45 45
 
46 46
 
47 47
 [prod]
48
-org_id = 10138
48
+org_id = 10215
49 49
 mobile_token_expiration_second = 86400
50 50
 httpdomain = https://api.xt.kuyicloud.com
51 51
 sso_domain = https://sso.kuyicloud.com
@@ -53,13 +53,13 @@ call_domain = https://hf.sgjyun.com
53 53
 front_end_domain = "https://xt.kuyicloud.com/#"
54 54
 #url  = "http://192.168.1.228:17001/szsi-portal/transData"
55 55
 url = "http://192.168.1.88:6666/szsi-portal/transData"
56
-#gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
57
-gdyb_url="http://igb.hsa.gdgov.cn/ebus/sz_prd/hsa/hgs/"
56
+gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
57
+#gdyb_url="http://igb.hsa.gdgov.cn/ebus/sz_prd/hsa/hgs/"
58 58
 #gdyb_paasid = "sg03_prd"
59 59
 #gdyb_paasid = "jm_sc_yjyy"
60 60
 #gdyb_paasid = "zh_prd_yjyy"
61
-gdyb_paasid = "sz_prd_yjyy"
62
-#gdyb_paasid = "zq_prd_yjyy"
61
+#gdyb_paasid = "sz_prd_yjyy"
62
+gdyb_paasid = "zq_prd_yjyy"
63 63
 
64 64
 
65 65
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com

+ 269 - 135
controllers/zh/zh_his_api_controller.go Visa fil

@@ -1060,116 +1060,187 @@ func (c *ZHHisApiController) GetUploadInfo() {
1060 1060
 		}
1061 1061
 
1062 1062
 		if isSuccess == true {
1063
-			var total float64
1064
-			for _, item := range prescriptions {
1065
-				if item.Type == 1 { //药品
1066
-					for _, subItem := range item.HisDoctorAdviceInfo {
1067
-						total = total + (subItem.Price * subItem.PrescribingNumber)
1063
+			if settle_accounts_type == 1 {
1064
+				for _, subItem := range ress {
1065
+					for _, item := range subItem.Output.Result {
1066
+						temp := strings.Split(item.FeedetlSn, "-")
1067
+						var advice_id int64 = 0
1068
+						var project_id int64 = 0
1069
+						var types int64 = 0
1070
+
1071
+						id, _ := strconv.ParseInt(temp[2], 10, 64)
1072
+						types, _ = strconv.ParseInt(temp[1], 10, 64)
1073
+
1074
+						if temp[1] == "1" {
1075
+							advice_id = id
1076
+							project_id = 0
1077
+						} else if temp[1] == "2" {
1078
+							advice_id = 0
1079
+							project_id = id
1080
+						}
1081
+						info := &models.HisOrderInfo{
1082
+							OrderNumber:      record.Number,
1083
+							FeedetlSn:        item.FeedetlSn,
1084
+							UploadDate:       time.Now().Unix(),
1085
+							AdviceId:         advice_id,
1086
+							DetItemFeeSumamt: item.DetItemFeeSumamt,
1087
+							Cnt:              item.Cnt,
1088
+							Pric:             float64(item.Pric),
1089
+							PatientId:        record.PatientId,
1090
+							PricUplmtAmt:     item.PricUplmtAmt,
1091
+							SelfpayProp:      item.SelfpayProp,
1092
+							FulamtOwnpayAmt:  item.FulamtOwnpayAmt,
1093
+							OverlmtAmt:       item.OverlmtAmt,
1094
+							PreselfpayAmt:    item.PreselfpayAmt,
1095
+							BasMednFlag:      item.BasMednFlag,
1096
+							MedChrgitmType:   item.MedChrgitmType,
1097
+							HiNegoDrugFlag:   item.HiNegoDrugFlag,
1098
+							Status:           1,
1099
+							Memo:             item.Memo,
1100
+							Mtime:            time.Now().Unix(),
1101
+							InscpScpAmt:      item.InscpScpAmt,
1102
+							DrtReimFlag:      item.DrtReimFlag,
1103
+							Ctime:            time.Now().Unix(),
1104
+							ListSpItemFlag:   item.ListSpItemFlag,
1105
+							ChldMedcFlag:     item.ChldMedcFlag,
1106
+							LmtUsedFlag:      item.LmtUsedFlag,
1107
+							ChrgitmLv:        item.ChrgitmLv,
1108
+							UserOrgId:        adminUser.CurrentOrgId,
1109
+							HisPatientId:     record.ID,
1110
+							OrderId:          0,
1111
+							ProjectId:        project_id,
1112
+							Type:             types,
1113
+							SettleType:       settle_accounts_type,
1114
+						}
1115
+						service.CreateOrderInfo(info)
1116
+					}
1117
+				}
1118
+				err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
1119
+				if err == nil {
1120
+					c.ServeSuccessJSON(map[string]interface{}{
1121
+						"msg": "上传费用明细成功",
1122
+					})
1123
+					return
1124
+				} else {
1125
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1126
+					return
1127
+				}
1128
+
1129
+			} else {
1130
+				var total float64
1131
+				for _, item := range prescriptions {
1132
+					if item.Type == 1 { //药品
1133
+						for _, subItem := range item.HisDoctorAdviceInfo {
1134
+							total = total + (subItem.Price * subItem.PrescribingNumber)
1135
+						}
1136
+					}
1137
+					if item.Type == 2 { //项目
1138
+						for _, subItem := range item.HisPrescriptionProject {
1139
+							total = total + (subItem.Price * float64(subItem.Count))
1140
+						}
1068 1141
 					}
1069 1142
 				}
1070
-				if item.Type == 2 { //项目
1071
-					for _, subItem := range item.HisPrescriptionProject {
1143
+				for _, item := range prescriptions {
1144
+					for _, subItem := range item.HisAdditionalCharge {
1072 1145
 						total = total + (subItem.Price * float64(subItem.Count))
1073 1146
 					}
1074 1147
 				}
1075
-			}
1076
-			for _, item := range prescriptions {
1077
-				for _, subItem := range item.HisAdditionalCharge {
1078
-					total = total + (subItem.Price * float64(subItem.Count))
1148
+				allTotal := fmt.Sprintf("%.2f", total)
1149
+				totals, _ := strconv.ParseFloat(allTotal, 64)
1150
+
1151
+				order := &models.HisOrder{
1152
+					UserOrgId:           adminUser.CurrentOrgId,
1153
+					HisPatientId:        record.ID,
1154
+					PatientId:           record.PatientId,
1155
+					SettleAccountsDate:  recordDateTime,
1156
+					Ctime:               time.Now().Unix(),
1157
+					Mtime:               time.Now().Unix(),
1158
+					Status:              1,
1159
+					Number:              record.Number,
1160
+					Infcode:             0,
1161
+					WarnMsg:             "",
1162
+					Cainfo:              "",
1163
+					ErrMsg:              "",
1164
+					RespondTime:         "",
1165
+					InfRefmsgid:         "",
1166
+					OrderStatus:         1,
1167
+					MdtrtId:             record.Number,
1168
+					IsMedicineInsurance: 1,
1169
+					SettleType:          settle_accounts_type,
1170
+					SettleStartTime:     start_time,
1171
+					SettleEndTime:       end_time,
1172
+					Creator:             roles.AdminUserId,
1173
+					Modify:              roles.AdminUserId,
1174
+					PType:               1,
1175
+					MedfeeSumamt:        totals,
1079 1176
 				}
1080
-			}
1081
-			allTotal := fmt.Sprintf("%.2f", total)
1082
-			totals, _ := strconv.ParseFloat(allTotal, 64)
1083
-
1084
-			order := &models.HisOrder{
1085
-				UserOrgId:           adminUser.CurrentOrgId,
1086
-				HisPatientId:        record.ID,
1087
-				PatientId:           record.PatientId,
1088
-				SettleAccountsDate:  recordDateTime,
1089
-				Ctime:               time.Now().Unix(),
1090
-				Mtime:               time.Now().Unix(),
1091
-				Status:              1,
1092
-				Number:              chrg_bchno,
1093
-				Infcode:             0,
1094
-				WarnMsg:             "",
1095
-				Cainfo:              "",
1096
-				ErrMsg:              "",
1097
-				RespondTime:         "",
1098
-				InfRefmsgid:         "",
1099
-				OrderStatus:         1,
1100
-				MdtrtId:             record.Number,
1101
-				IsMedicineInsurance: 1,
1102
-				SettleType:          settle_accounts_type,
1103
-				SettleStartTime:     start_time,
1104
-				SettleEndTime:       end_time,
1105
-				Creator:             roles.AdminUserId,
1106
-				Modify:              roles.AdminUserId,
1107
-				PType:               1,
1108
-				MedfeeSumamt:        totals,
1109
-			}
1110
-			err = service.CreateOrder(order)
1111
-			if err != nil {
1112
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
1113
-				return
1114
-			}
1115
-			for _, subItem := range ress {
1116
-				for _, item := range subItem.Output.Result {
1117
-					temp := strings.Split(item.FeedetlSn, "-")
1118
-					var advice_id int64 = 0
1119
-					var project_id int64 = 0
1120
-					var types int64 = 0
1121
-
1122
-					id, _ := strconv.ParseInt(temp[2], 10, 64)
1123
-					types, _ = strconv.ParseInt(temp[1], 10, 64)
1124
-
1125
-					if temp[1] == "1" {
1126
-						advice_id = id
1127
-						project_id = 0
1128
-					} else if temp[1] == "2" {
1129
-						advice_id = 0
1130
-						project_id = id
1131
-					}
1132
-					info := &models.HisOrderInfo{
1133
-						OrderNumber:      order.Number,
1134
-						FeedetlSn:        item.FeedetlSn,
1135
-						UploadDate:       time.Now().Unix(),
1136
-						AdviceId:         advice_id,
1137
-						DetItemFeeSumamt: item.DetItemFeeSumamt,
1138
-						Cnt:              item.Cnt,
1139
-						Pric:             float64(item.Pric),
1140
-						PatientId:        record.PatientId,
1141
-						PricUplmtAmt:     item.PricUplmtAmt,
1142
-						SelfpayProp:      item.SelfpayProp,
1143
-						FulamtOwnpayAmt:  item.FulamtOwnpayAmt,
1144
-						OverlmtAmt:       item.OverlmtAmt,
1145
-						PreselfpayAmt:    item.PreselfpayAmt,
1146
-						BasMednFlag:      item.BasMednFlag,
1147
-						MedChrgitmType:   item.MedChrgitmType,
1148
-						HiNegoDrugFlag:   item.HiNegoDrugFlag,
1149
-						Status:           1,
1150
-						Memo:             item.Memo,
1151
-						Mtime:            time.Now().Unix(),
1152
-						InscpScpAmt:      item.InscpScpAmt,
1153
-						DrtReimFlag:      item.DrtReimFlag,
1154
-						Ctime:            time.Now().Unix(),
1155
-						ListSpItemFlag:   item.ListSpItemFlag,
1156
-						ChldMedcFlag:     item.ChldMedcFlag,
1157
-						LmtUsedFlag:      item.LmtUsedFlag,
1158
-						ChrgitmLv:        item.ChrgitmLv,
1159
-						UserOrgId:        adminUser.CurrentOrgId,
1160
-						HisPatientId:     record.ID,
1161
-						OrderId:          order.ID,
1162
-						ProjectId:        project_id,
1163
-						Type:             types,
1177
+				err = service.CreateOrder(order)
1178
+				if err != nil {
1179
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
1180
+					return
1181
+				}
1182
+				for _, subItem := range ress {
1183
+					for _, item := range subItem.Output.Result {
1184
+						temp := strings.Split(item.FeedetlSn, "-")
1185
+						var advice_id int64 = 0
1186
+						var project_id int64 = 0
1187
+						var types int64 = 0
1188
+
1189
+						id, _ := strconv.ParseInt(temp[2], 10, 64)
1190
+						types, _ = strconv.ParseInt(temp[1], 10, 64)
1191
+
1192
+						if temp[1] == "1" {
1193
+							advice_id = id
1194
+							project_id = 0
1195
+						} else if temp[1] == "2" {
1196
+							advice_id = 0
1197
+							project_id = id
1198
+						}
1199
+						info := &models.HisOrderInfo{
1200
+							OrderNumber:      order.Number,
1201
+							FeedetlSn:        item.FeedetlSn,
1202
+							UploadDate:       time.Now().Unix(),
1203
+							AdviceId:         advice_id,
1204
+							DetItemFeeSumamt: item.DetItemFeeSumamt,
1205
+							Cnt:              item.Cnt,
1206
+							Pric:             float64(item.Pric),
1207
+							PatientId:        record.PatientId,
1208
+							PricUplmtAmt:     item.PricUplmtAmt,
1209
+							SelfpayProp:      item.SelfpayProp,
1210
+							FulamtOwnpayAmt:  item.FulamtOwnpayAmt,
1211
+							OverlmtAmt:       item.OverlmtAmt,
1212
+							PreselfpayAmt:    item.PreselfpayAmt,
1213
+							BasMednFlag:      item.BasMednFlag,
1214
+							MedChrgitmType:   item.MedChrgitmType,
1215
+							HiNegoDrugFlag:   item.HiNegoDrugFlag,
1216
+							Status:           1,
1217
+							Memo:             item.Memo,
1218
+							Mtime:            time.Now().Unix(),
1219
+							InscpScpAmt:      item.InscpScpAmt,
1220
+							DrtReimFlag:      item.DrtReimFlag,
1221
+							Ctime:            time.Now().Unix(),
1222
+							ListSpItemFlag:   item.ListSpItemFlag,
1223
+							ChldMedcFlag:     item.ChldMedcFlag,
1224
+							LmtUsedFlag:      item.LmtUsedFlag,
1225
+							ChrgitmLv:        item.ChrgitmLv,
1226
+							UserOrgId:        adminUser.CurrentOrgId,
1227
+							HisPatientId:     record.ID,
1228
+							OrderId:          order.ID,
1229
+							ProjectId:        project_id,
1230
+							Type:             types,
1231
+							SettleType:       settle_accounts_type,
1232
+						}
1233
+						service.CreateOrderInfo(info)
1164 1234
 					}
1165
-					service.CreateOrderInfo(info)
1166 1235
 				}
1236
+				service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
1237
+				service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
1238
+				c.ServeSuccessJSON(map[string]interface{}{
1239
+					"msg": "上传费用明细成功",
1240
+				})
1241
+
1167 1242
 			}
1168
-			service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
1169
-			service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
1170
-			c.ServeSuccessJSON(map[string]interface{}{
1171
-				"msg": "上传费用明细成功",
1172
-			})
1243
+
1173 1244
 		}
1174 1245
 
1175 1246
 	}
@@ -1233,34 +1304,111 @@ func (c *ZHHisApiController) ZHRefund() {
1233 1304
 
1234 1305
 }
1235 1306
 func (c *ZHHisApiController) ZHRefundDetail() {
1307
+	patient_id, _ := c.GetInt64("patient_id")
1308
+	his_patient_id, _ := c.GetInt64("his_patient_id")
1309
+	record_time := c.GetString("record_time")
1310
+	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
1236 1311
 	order_id, _ := c.GetInt64("order_id")
1237 1312
 	admin_user_id, _ := c.GetInt64("admin_user_id")
1313
+
1314
+	timeLayout := "2006-01-02"
1315
+	loc, _ := time.LoadLocation("Local")
1316
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1317
+	if err != nil {
1318
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1319
+		return
1320
+	}
1321
+	recordDateTime := theTime.Unix()
1238 1322
 	adminUser := c.GetAdminUserInfo()
1239
-	var order models.HisOrder
1240
-	order, _ = service.GetHisOrderByID(order_id)
1241
-	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1323
+
1324
+	//var prescriptions []*models.HisPrescription
1242 1325
 	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1243
-	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1244
-	if config.IsOpen == 1 { //对接了医保,走医保流程
1326
+	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1245 1327
 
1246
-		result := service.Gdyb2302(order.PsnNo, order.MdtrtId, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
1247
-		var dat map[string]interface{}
1248
-		if err := json.Unmarshal([]byte(result), &dat); err == nil {
1249
-			fmt.Println(dat)
1250
-		} else {
1251
-			fmt.Println(err)
1328
+	if settle_accounts_type == 1 { //日结
1329
+		infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
1330
+		record, _ := service.GetInHospitalRecord(his_patient_id)
1331
+		var isSuccess bool = true
1332
+
1333
+		for _, item := range infos {
1334
+			result := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
1335
+			var dat map[string]interface{}
1336
+			if err := json.Unmarshal([]byte(result), &dat); err == nil {
1337
+				fmt.Println(dat)
1338
+			} else {
1339
+				fmt.Println(err)
1340
+			}
1341
+			userJSONBytes, _ := json.Marshal(dat)
1342
+			var res2 ResultEmpty
1343
+			if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
1344
+				utils.ErrorLog("解析失败:%v", err)
1345
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1346
+				return
1347
+			}
1348
+			if res2.Infcode == -1 {
1349
+				isSuccess = false
1350
+			}
1252 1351
 		}
1352
+		if isSuccess {
1353
+			err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
1253 1354
 
1254
-		userJSONBytes, _ := json.Marshal(dat)
1355
+			if err != nil {
1356
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1357
+				return
1358
+			}
1359
+			err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
1360
+			if err1 != nil {
1361
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1362
+				return
1363
+			}
1364
+
1365
+			c.ServeSuccessJSON(map[string]interface{}{
1366
+				"msg": "撤销明细成功",
1367
+			})
1255 1368
 
1256
-		var res2 ResultEmpty
1257
-		if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
1258
-			utils.ErrorLog("解析失败:%v", err)
1259
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1260
-			return
1261 1369
 		}
1262
-		if res2.Infcode == 0 {
1263
-			err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", result)
1370
+
1371
+	} else {
1372
+		//prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
1373
+		var order models.HisOrder
1374
+		order, _ = service.GetHisOrderByID(order_id)
1375
+		config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1376
+		if config.IsOpen == 1 { //对接了医保,走医保流程
1377
+
1378
+			result := service.Gdyb2302(order.PsnNo, order.MdtrtId, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
1379
+			var dat map[string]interface{}
1380
+			if err := json.Unmarshal([]byte(result), &dat); err == nil {
1381
+				fmt.Println(dat)
1382
+			} else {
1383
+				fmt.Println(err)
1384
+			}
1385
+
1386
+			userJSONBytes, _ := json.Marshal(dat)
1387
+
1388
+			var res2 ResultEmpty
1389
+			if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
1390
+				utils.ErrorLog("解析失败:%v", err)
1391
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1392
+				return
1393
+			}
1394
+			if res2.Infcode == 0 {
1395
+				err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", result)
1396
+				if err == nil {
1397
+					c.ServeSuccessJSON(map[string]interface{}{
1398
+						"msg": "退费成功",
1399
+					})
1400
+				} else {
1401
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1402
+					return
1403
+				}
1404
+			} else {
1405
+				c.ServeSuccessJSON(map[string]interface{}{
1406
+					"code": -10,
1407
+					"msg":  res2.ErrMsg,
1408
+				})
1409
+			}
1410
+		} else {
1411
+			err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
1264 1412
 			if err == nil {
1265 1413
 				c.ServeSuccessJSON(map[string]interface{}{
1266 1414
 					"msg": "退费成功",
@@ -1269,22 +1417,8 @@ func (c *ZHHisApiController) ZHRefundDetail() {
1269 1417
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1270 1418
 				return
1271 1419
 			}
1272
-		} else {
1273
-			c.ServeSuccessJSON(map[string]interface{}{
1274
-				"code": -10,
1275
-				"msg":  res2.ErrMsg,
1276
-			})
1277
-		}
1278
-	} else {
1279
-		err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
1280
-		if err == nil {
1281
-			c.ServeSuccessJSON(map[string]interface{}{
1282
-				"msg": "退费成功",
1283
-			})
1284
-		} else {
1285
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1286
-			return
1287 1420
 		}
1421
+
1288 1422
 	}
1289 1423
 
1290 1424
 }

+ 1 - 0
models/his_models.go Visa fil

@@ -743,6 +743,7 @@ type HisOrderInfo struct {
743 743
 	AllowReimburse         float64                `gorm:"column:allow_reimburse" json:"allow_reimburse" form:"allow_reimburse"`
744 744
 	HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:AdviceId;AssociationForeignKey:ID" json:"advice"`
745 745
 	HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
746
+	SettleType             int64                  `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
746 747
 }
747 748
 
748 749
 func (HisOrderInfo) TableName() string {

+ 5 - 0
service/his_service.go Visa fil

@@ -564,6 +564,11 @@ func UpDatePrescriptionNumber(user_org_id int64, ids []int64, number string) (er
564 564
 	return
565 565
 }
566 566
 
567
+func UpDatePrescriptionOrderStatus(user_org_id int64, ids []int64) (err error) {
568
+	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"order_status": 4, "mtime": time.Now().Unix()}).Error
569
+	return
570
+}
571
+
567 572
 func UpDatePrescriptionInfoNumber(user_org_id int64, id int64, number string, record_time int64) (err error) {
568 573
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? AND record_date = ?", user_org_id, id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 2, "mtime": time.Now().Unix()}).Error
569 574
 

+ 60 - 6
service/zh_his_service.go Visa fil

@@ -644,7 +644,7 @@ func ZHGdyb2301(psnNo string, mdtrtId string, hisPrescription []*models.NewCusto
644 644
 }
645 645
 
646 646
 //  住院费用明细信息撤销
647
-func Gdyb2302(psnNo string, mdtrtId string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) string {
647
+func Gdyb2302(psnNo string, mdtrtId string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, number string, refund_type int64) string {
648 648
 	// 生成签名
649 649
 	nonce := GetRandomString(32)
650 650
 	timestamp := time.Now().Unix()
@@ -655,10 +655,15 @@ func Gdyb2302(psnNo string, mdtrtId string, org_name string, doctor string, insu
655 655
 	input := make(map[string]interface{})
656 656
 	inputData := make(map[string]interface{})
657 657
 	inputMessage["infno"] = "2302" // 交易编码
658
+	if refund_type == 1 {
659
+		inputData["feedetl_sn"] = number //
658 660
 
659
-	inputData["mdtrt_id"] = mdtrtId  // 就诊 ID
660
-	inputData["feedetl_sn"] = "0000" //
661
-	inputData["psn_no"] = psnNo      // 人员编号
661
+	} else {
662
+		inputData["feedetl_sn"] = "0000" //
663
+	}
664
+
665
+	inputData["mdtrt_id"] = mdtrtId // 就诊 ID
666
+	inputData["psn_no"] = psnNo     // 人员编号
662 667
 
663 668
 	input["data"] = inputData
664 669
 	inputMessage["input"] = input //交易输入
@@ -887,7 +892,7 @@ func GetZHHisPrescription(org_id int64, patient_id int64, record_date int64) (pr
887 892
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
888 893
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
889 894
 		}).
890
-		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type = 1", org_id, record_date, patient_id).
895
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND p_type = 1", org_id, record_date, patient_id).
891 896
 		Find(&prescription).Error
892 897
 	return
893 898
 }
@@ -903,7 +908,56 @@ func GetZHMonthHisPrescription(org_id int64, patient_id int64, start_time int64,
903 908
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
904 909
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
905 910
 		}).
906
-		Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
911
+		Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
912
+		Find(&prescription).Error
913
+	return
914
+}
915
+
916
+func GetZHHisUploadPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
917
+	err = readDb.Model(&models.HisPrescription{}).
918
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
919
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
920
+		}).
921
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
922
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
923
+		}).
924
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
925
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
926
+		}).
927
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 4 AND p_type = 1", org_id, record_date, patient_id).
928
+		Find(&prescription).Error
929
+	return
930
+}
931
+
932
+func GetZHMonthHisUploadPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
933
+	err = readDb.Model(&models.HisPrescription{}).
934
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
935
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
936
+		}).
937
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
938
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
939
+		}).
940
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
941
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
942
+		}).
943
+		Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status == 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
907 944
 		Find(&prescription).Error
908 945
 	return
909 946
 }
947
+
948
+func GetZHHisUploadOrderInfo(org_id int64, patient_id int64, record_date int64) (infos []*models.HisOrderInfo, err error) {
949
+	err = readDb.Model(&models.HisOrderInfo{}).
950
+		Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ? AND order_status = 4 AND p_type = 1", org_id, record_date, record_date, patient_id).
951
+		Find(&infos).Error
952
+	return
953
+}
954
+
955
+func UpDateOrderInfoStatus(patient_id int64, record_date int64, org_id int64) (err error) {
956
+	err = writeDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ?", org_id, record_date, record_date, patient_id).Updates(map[string]interface{}{"status": 0}).Error
957
+	return
958
+}
959
+
960
+func UpDatePrescriptionOrderStatusTwo(patient_id int64, record_date int64, org_id int64) (err error) {
961
+	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = 1", org_id, record_date, record_date, patient_id).Updates(map[string]interface{}{"order_status": 1}).Error
962
+	return
963
+}