Kaynağa Gözat

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

csx 4 yıl önce
ebeveyn
işleme
555edba82f

+ 141 - 4
controllers/sz/sz_his_api_controller.go Dosyayı Görüntüle

278
 
278
 
279
 	//退费
279
 	//退费
280
 	beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
280
 	beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
281
+
282
+	beego.Router("/sz/api/readcard", &SZHisApiController{}, "get:ReadCard")
283
+
284
+	beego.Router("sz/api/refundnumber/get", &SZHisApiController{}, "get:RefundNumber")
285
+
281
 	beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
286
 	beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
282
 	//查询交易
287
 	//查询交易
283
 	beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
288
 	beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
324
 	ItemId           int64
329
 	ItemId           int64
325
 }
330
 }
326
 
331
 
332
+func (c *SZHisApiController) ReadCard() {
333
+	id_card_type, _ := c.GetInt64("id_card_type")
334
+	adminInfo := c.GetAdminUserInfo()
335
+	if id_card_type != 1 {
336
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorNoReadCardException)
337
+		return
338
+	}
339
+	month := time.Unix(1557042972, 0).Format("1")
340
+	year := time.Now().Format("2006")
341
+	month = time.Now().Format("01")
342
+	day := time.Now().Format("02")
343
+
344
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
345
+	number := miConfig.Code + year + month + day +
346
+		fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
347
+	id_card_number, health_card_no, _, ret4 := ReadBasCard("MZ002" + "|" + number + "|" + miConfig.Code + "|")
348
+	if ret4 == 0 {
349
+		patient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
350
+		if patient.ID == 0 {
351
+			patient.HealthCareNo = health_card_no
352
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
353
+			return
354
+		} else {
355
+			c.ServeSuccessJSON(map[string]interface{}{
356
+				"patient": patient,
357
+			})
358
+		}
359
+	} else {
360
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
361
+		return
362
+	}
363
+
364
+}
365
+
327
 //获取读卡信息 -- 门诊挂号
366
 //获取读卡信息 -- 门诊挂号
328
 //func (c *SZHisApiController) GetRegisterInfo() {
367
 //func (c *SZHisApiController) GetRegisterInfo() {
329
 //	adminInfo := c.GetAdminUserInfo()
368
 //	adminInfo := c.GetAdminUserInfo()
1111
 	}
1150
 	}
1112
 }
1151
 }
1113
 
1152
 
1153
+func (c *SZHisApiController) RefundNumber() {
1154
+	order_id, _ := c.GetInt64("order_id")
1155
+	record_time := c.GetString("record_time")
1156
+	patient_id, _ := c.GetInt64("patient_id")
1157
+	admin_user_id, _ := c.GetInt64("admin_user_id")
1158
+	timeLayout := "2006-01-02"
1159
+	loc, _ := time.LoadLocation("Local")
1160
+	adminUser := c.GetAdminUserInfo()
1161
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
1162
+	fmt.Println(err)
1163
+	if err != nil {
1164
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1165
+		return
1166
+	}
1167
+	recordDateTime := theTime.Unix()
1168
+	fmt.Println(recordDateTime)
1169
+	var order models.HisOrder
1170
+	order, _ = service.GetHisOrderByID(order_id)
1171
+	if order.ID == 0 {
1172
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
1173
+		return
1174
+	}
1175
+	his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
1176
+	roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
1177
+	miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
1178
+	//结算流程
1179
+	var doctor_name string
1180
+	var doctor_code string
1181
+	if roles.ID == 0 {
1182
+		doctor_name = "管理员"
1183
+		doctor_code = "01"
1184
+	} else {
1185
+		doctor_name = roles.UserName
1186
+		doctor_code = strconv.FormatInt(admin_user_id, 10)
1187
+
1188
+	}
1189
+	month := time.Unix(1557042972, 0).Format("1")
1190
+	year := time.Now().Format("2006")
1191
+	month = time.Now().Format("01")
1192
+	day := time.Now().Format("02")
1193
+	//number := miConfig.Code  + year + month + day + "1367866"
1194
+	number := miConfig.Code + year + month + day +
1195
+		fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
1196
+	//number := miConfig.Code + year + month + day + "1590003"
1197
+
1198
+	//流水号
1199
+	//number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
1200
+	verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
1201
+	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
1202
+	if config.IsOpen == 1 { //对接了医保,走医保流程
1203
+		result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, his.MzNumber, order.Number, verifyCode, number, version_code)
1204
+		var dat map[string]interface{}
1205
+		if err := json.Unmarshal([]byte(result), &dat); err == nil {
1206
+			fmt.Println(dat)
1207
+		} else {
1208
+			fmt.Println(err)
1209
+		}
1210
+		userJSONBytes, _ := json.Marshal(dat)
1211
+		var res ResultThree
1212
+		if err := json.Unmarshal(userJSONBytes, &res); err != nil {
1213
+			utils.ErrorLog("解析失败:%v", err)
1214
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1215
+			return
1216
+		}
1217
+		if res.Transreturncode == "00000000" {
1218
+			service.UpdataHisStatusSZ(adminUser.CurrentOrgId, his.MzNumber, his.Number, result)
1219
+			c.ServeSuccessJSON(map[string]interface{}{
1220
+				"msg": "退号成功",
1221
+			})
1222
+		} else {
1223
+			c.ServeSuccessJSON(map[string]interface{}{
1224
+				"failed_code": -10,
1225
+				"msg":         res.Transreturnmessage,
1226
+			})
1227
+
1228
+		}
1229
+	}
1230
+
1231
+}
1232
+
1114
 //上传明细----结算----确认订单
1233
 //上传明细----结算----确认订单
1115
 func (c *SZHisApiController) GetSettleInfo() {
1234
 func (c *SZHisApiController) GetSettleInfo() {
1116
 	pay_way, _ := c.GetInt64("pay_way")
1235
 	pay_way, _ := c.GetInt64("pay_way")
2570
 	return "", ""
2689
 	return "", ""
2571
 }
2690
 }
2572
 
2691
 
2573
-////读卡
2692
+////获取卡信息
2574
 func ReadBasCardGetNumber(request string) (string, string, string, string, error, int64) {
2693
 func ReadBasCardGetNumber(request string) (string, string, string, string, error, int64) {
2575
 	DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
2694
 	DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
2576
 	readCards := DllDef2.MustFindProc("iReadCardBas")
2695
 	readCards := DllDef2.MustFindProc("iReadCardBas")
2597
 	return "", "", "", "", err, -10
2716
 	return "", "", "", "", err, -10
2598
 }
2717
 }
2599
 
2718
 
2719
+//读卡
2720
+func ReadBasCard(request string) (string, string, error, int64) {
2721
+	DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
2722
+	readCards := DllDef2.MustFindProc("iReadCardBas")
2723
+	str := request
2724
+	str3 := make([]byte, 1024)
2725
+	ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
2726
+	fmt.Println(":", string(str3))
2727
+	fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
2728
+	if ret4 == 0 {
2729
+		result := string(str3)
2730
+		result_arr := strings.Split(result, "|")
2731
+		//根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
2732
+		id_card_number := result_arr[1]
2733
+		health_card_no := result_arr[2]
2734
+
2735
+		return id_card_number, health_card_no, err, 0
2736
+	}
2737
+	return "", "", err, -10
2738
+}
2739
+
2600
 //
2740
 //
2601
 ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication ---  	iReadCardBas_HSM_Step2
2741
 ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication ---  	iReadCardBas_HSM_Step2
2602
 //func ReadCardBasHSM(number string) string {
2742
 //func ReadCardBasHSM(number string) string {
2872
 						RetailPrice:            item.RetailPrice, //协议机构内部项目收费价格
3012
 						RetailPrice:            item.RetailPrice, //协议机构内部项目收费价格
2873
 						LimitRemark:            item.LimitRemark,
3013
 						LimitRemark:            item.LimitRemark,
2874
 						MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
3014
 						MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
2875
-
2876
 					}
3015
 					}
2877
 					customs = append(customs, detail)
3016
 					customs = append(customs, detail)
2878
 				}
3017
 				}
3477
 				IdentificationOutpatients:               "",                                //门诊大病医师标识
3616
 				IdentificationOutpatients:               "",                                //门诊大病医师标识
3478
 				OutpatientIllnessCategory:               item.OutpatientIllnessCategory,    //门诊大病类别
3617
 				OutpatientIllnessCategory:               item.OutpatientIllnessCategory,    //门诊大病类别
3479
 				StartTime:                               20201012,                          //开始日期
3618
 				StartTime:                               20201012,                          //开始日期
3480
-
3481
 			}
3619
 			}
3482
 			result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
3620
 			result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
3483
 			fmt.Println("reuslt9999999999999999", result)
3621
 			fmt.Println("reuslt9999999999999999", result)
3577
 				IdentificationOutpatients:               "1",      //门诊大病医师标识
3715
 				IdentificationOutpatients:               "1",      //门诊大病医师标识
3578
 				OutpatientIllnessCategory:               "血友病",    //门诊大病类别
3716
 				OutpatientIllnessCategory:               "血友病",    //门诊大病类别
3579
 				StartTime:                               20210311, //开始日期
3717
 				StartTime:                               20210311, //开始日期
3580
-
3581
 			}
3718
 			}
3582
 			result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, detail)
3719
 			result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, detail)
3583
 			fmt.Println("reuslt9999999999999999", result)
3720
 			fmt.Println("reuslt9999999999999999", result)

+ 4 - 0
enums/error_code.go Dosyayı Görüntüle

243
 	ErrorDrugPreSettleFaildParamWrong = 30002
243
 	ErrorDrugPreSettleFaildParamWrong = 30002
244
 	ErrorDrugReturnFaildParamWrong    = 30003
244
 	ErrorDrugReturnFaildParamWrong    = 30003
245
 	ErrorDoctorLoginFaildParamWrong   = 30004
245
 	ErrorDoctorLoginFaildParamWrong   = 30004
246
+
247
+	ErrorNoReadCardException = 30005
246
 )
248
 )
247
 
249
 
248
 var ErrCodeMsgs = map[int]string{
250
 var ErrCodeMsgs = map[int]string{
468
 	ErrorDrugPreSettleFaildParamWrong:  "备案失败",
470
 	ErrorDrugPreSettleFaildParamWrong:  "备案失败",
469
 	ErrorDrugReturnFaildParamWrong:     "撤销失败",
471
 	ErrorDrugReturnFaildParamWrong:     "撤销失败",
470
 	ErrorDoctorLoginFaildParamWrong:    "登记失败",
472
 	ErrorDoctorLoginFaildParamWrong:    "登记失败",
473
+
474
+	ErrorNoReadCardException: "无法读取除社保卡以外的卡",
471
 }
475
 }
472
 
476
 
473
 type SGJError struct {
477
 type SGJError struct {

+ 5 - 1
service/sz_his_service.go Dosyayı Görüntüle

1373
 	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0}).Error
1373
 	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0}).Error
1374
 	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
1374
 	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
1375
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
1375
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
1376
-	err = writeDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ? AND mz_number = ? AND number = ?", user_org_id, his_mz_number, his_number).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1377
 
1376
 
1378
 	return
1377
 	return
1379
 
1378
 
1380
 }
1379
 }
1381
 
1380
 
1381
+func UpdataHisStatusSZ(user_org_id int64, his_mz_number string, his_number string, result string) (err error) {
1382
+	err = writeDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ? AND mz_number = ? AND number = ?", user_org_id, his_mz_number, his_number).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix(), "refund_detail": result}).Error
1383
+	return
1384
+}
1385
+
1382
 func UpdataOrderlog(id int64, user_org_id int64, refund_log string) (err error) {
1386
 func UpdataOrderlog(id int64, user_org_id int64, refund_log string) (err error) {
1383
 	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0, "refund_log": refund_log}).Error
1387
 	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0, "refund_log": refund_log}).Error
1384
 
1388