Преглед изворни кода

Merge branch '20211122' of http://git.shengws.com/csx/XT_New into 20211122

csx пре 3 година
родитељ
комит
e3ab41ce85

+ 1 - 1
conf/app.conf Прегледај датотеку

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 10 - 9
controllers/dialysis_record_api_controller.go Прегледај датотеку

@@ -77,7 +77,7 @@ func (this *DialysisRecordAPIController) GetSchedules() {
77 77
 	redis := service.RedisClient()
78 78
 	defer redis.Close()
79 79
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
80
-	patients, _ := service.GetAllPcPatientListByListSeven(orgID)
80
+	patients, _ := service.GetAllPcPatientListByListEight(orgID)
81 81
 	scheduals_json_str, _ := redis.Get(key).Result()
82 82
 
83 83
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -277,6 +277,7 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
277 277
 
278 278
 	go func() {
279 279
 		doctorAdvices, _ = service.MobileGetDoctorAdvices(adminInfo.CurrentOrgId, patientID, date.Unix())
280
+
280 281
 		ch <- struct{}{}
281 282
 	}()
282 283
 
@@ -388,13 +389,6 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
388 389
 
389 390
 	dialysisSolution, _ := service.GetDialysisSolution(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
390 391
 
391
-	//
392
-	//if getDialysisSolutionErr != nil {
393
-	//	this.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
394
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
395
-	//	return
396
-	//}
397
-
398 392
 	lastDialysisPrescribe, _ := service.GetLastDialysisPrescribeByModeId(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
399 393
 
400 394
 	systemDialysisPrescribe, _ := service.GetSystemDialysisPrescribeByModeId(adminInfo.CurrentOrgId, schedual.ModeId)
@@ -409,10 +403,15 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
409 403
 	headNurses, _ := service.GetAllSpecialPermissionAdminUsersWithoutStatus(adminInfo.CurrentOrgId, adminInfo.CurrentAppId, models.SpecialPermissionTypeHeadNurse)
410 404
 
411 405
 	var his_advices []*models.HisDoctorAdviceInfo
412
-	fmt.Println("hhh2333223322323223", is_open_config.IsOpen)
406
+
413 407
 	if is_open_config.IsOpen == 1 {
414 408
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
415 409
 	}
410
+	//查询是否是开起
411
+	adviceConfig, _ := service.FindAdviceSettingById(adminInfo.CurrentOrgId)
412
+	if adviceConfig.IsAdviceOpen == 1 {
413
+		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
414
+	}
416 415
 
417 416
 	_, errcode := service.GetOrgFollowIsExist(adminInfo.CurrentOrgId)
418 417
 	if errcode == gorm.ErrRecordNotFound {
@@ -447,6 +446,7 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
447 446
 			"prepare":                     prepare,
448 447
 			"lastAssessment":              lastAssessment,
449 448
 			"information":                 information,
449
+			"is_advice_open":              adviceConfig,
450 450
 		}
451 451
 		this.ServeSuccessJSON(returnData)
452 452
 
@@ -482,6 +482,7 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
482 482
 			"prepare":                     prepare,
483 483
 			"lastAssessment":              lastAssessment,
484 484
 			"information":                 information,
485
+			"is_advice_open":              adviceConfig,
485 486
 		}
486 487
 		this.ServeSuccessJSON(returnData)
487 488
 	}

+ 138 - 63
controllers/his_api_controller.go Прегледај датотеку

@@ -1869,16 +1869,17 @@ func (c *HisApiController) DeletePrescription() {
1869 1869
 					total, _ := service.FindAllCancelStockTotal(c.GetAdminUserInfo().CurrentOrgId)
1870 1870
 					total = total + 1
1871 1871
 					orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1872
-
1872
+					houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
1873 1873
 					cancelStock := models.CancelStock{
1874
-						OrderNumber: orderNumber,
1875
-						OperaTime:   operation_time,
1876
-						OrgId:       c.GetAdminUserInfo().CurrentOrgId,
1877
-						Creater:     creater,
1878
-						Ctime:       time.Now().Unix(),
1879
-						Status:      1,
1880
-						ReturnTime:  item.RecordDate,
1881
-						Type:        1,
1874
+						OrderNumber:  orderNumber,
1875
+						OperaTime:    operation_time,
1876
+						OrgId:        c.GetAdminUserInfo().CurrentOrgId,
1877
+						Creater:      creater,
1878
+						Ctime:        time.Now().Unix(),
1879
+						Status:       1,
1880
+						ReturnTime:   item.RecordDate,
1881
+						Type:         1,
1882
+						StorehouseId: houseConfig.StorehouseOutInfo,
1882 1883
 					}
1883 1884
 					_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
1884 1885
 					if msgerrkonde == gorm.ErrRecordNotFound {
@@ -1914,6 +1915,7 @@ func (c *HisApiController) DeletePrescription() {
1914 1915
 							WarehouseInfoId: info.WarehouseInfotId,
1915 1916
 							PatientId:       info.PatientId,
1916 1917
 							RecordDate:      info.SysRecordTime,
1918
+							StorehouseId:    houseConfig.StorehouseOutInfo,
1917 1919
 						}
1918 1920
 
1919 1921
 						service.CreateCancelStockInfoOne(&cancelStockInfo)
@@ -1950,6 +1952,7 @@ func (c *HisApiController) DeletePrescription() {
1950 1952
 							CancelOutDetailId:       cancelInfo.ID,
1951 1953
 							ProductDate:             info.ProductDate,
1952 1954
 							ExpireDate:              info.ExpiryDate,
1955
+							StorehouseId:            houseConfig.StorehouseOutInfo,
1953 1956
 						}
1954 1957
 						service.CreateStockFlowOne(flow)
1955 1958
 
@@ -2002,6 +2005,7 @@ func (c *HisApiController) DeletePrescription() {
2002 2005
 									Manufacturer:            0,
2003 2006
 									Type:                    1,
2004 2007
 									IsSys:                   1,
2008
+									StorehouseId:            houseConfig.StorehouseOutInfo,
2005 2009
 								}
2006 2010
 								err := service.AddSigleWarehouseOut(&warehouseOut)
2007 2011
 								if err != nil {
@@ -2009,24 +2013,26 @@ func (c *HisApiController) DeletePrescription() {
2009 2013
 									return
2010 2014
 								}
2011 2015
 								prepare := &models.DialysisBeforePrepare{
2012
-									UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2013
-									PatientId:  info.PatientId,
2014
-									RecordDate: info.SysRecordTime,
2015
-									GoodId:     item.ProjectId,
2016
-									GoodTypeId: info.GoodTypeId,
2017
-									Count:      cha_count,
2016
+									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2017
+									PatientId:    info.PatientId,
2018
+									RecordDate:   info.SysRecordTime,
2019
+									GoodId:       item.ProjectId,
2020
+									GoodTypeId:   info.GoodTypeId,
2021
+									Count:        cha_count,
2022
+									StorehouseId: houseConfig.StorehouseOutInfo,
2018 2023
 								}
2019 2024
 								//出库
2020 2025
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2021 2026
 							} else if err == nil {
2022 2027
 
2023 2028
 								prepare := &models.DialysisBeforePrepare{
2024
-									UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2025
-									PatientId:  info.PatientId,
2026
-									RecordDate: info.SysRecordTime,
2027
-									GoodId:     item.ProjectId,
2028
-									GoodTypeId: info.GoodTypeId,
2029
-									Count:      cha_count,
2029
+									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2030
+									PatientId:    info.PatientId,
2031
+									RecordDate:   info.SysRecordTime,
2032
+									GoodId:       item.ProjectId,
2033
+									GoodTypeId:   info.GoodTypeId,
2034
+									Count:        cha_count,
2035
+									StorehouseId: houseConfig.StorehouseOutInfo,
2030 2036
 								}
2031 2037
 								//出库
2032 2038
 								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
@@ -2087,7 +2093,7 @@ func (c *HisApiController) DeletePrescription() {
2087 2093
 						total, _ := service.FindAllDrugCancelStockTotal(adminUserInfo.CurrentOrgId)
2088 2094
 						total = total + 1
2089 2095
 						orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2090
-
2096
+						houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2091 2097
 						cancelStock := models.DrugCancelStock{
2092 2098
 							OrderNumber:  orderNumber,
2093 2099
 							OperaTime:    operation_time,
@@ -2099,6 +2105,7 @@ func (c *HisApiController) DeletePrescription() {
2099 2105
 							Dealer:       info.Dealer,
2100 2106
 							Manufacturer: info.Manufacturer,
2101 2107
 							Type:         1,
2108
+							StorehouseId: houseConfig.DrugStorehouseOut,
2102 2109
 						}
2103 2110
 						service.AddSigleDrugCancelStock(&cancelStock)
2104 2111
 
@@ -2127,6 +2134,7 @@ func (c *HisApiController) DeletePrescription() {
2127 2134
 							ProductDate:      info.ProductDate,
2128 2135
 							ExpiryDate:       info.ExpiryDate,
2129 2136
 							BatchNumberId:    info.WarehouseInfoId,
2137
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2130 2138
 						}
2131 2139
 
2132 2140
 						flow := models.DrugFlow{
@@ -2162,6 +2170,7 @@ func (c *HisApiController) DeletePrescription() {
2162 2170
 							MaxUnit:                 info.CountUnit,
2163 2171
 							MinUnit:                 "",
2164 2172
 							AdviceId:                info.AdviceId,
2173
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2165 2174
 						}
2166 2175
 						service.CreatedCancelStock(cancelStockInfo)
2167 2176
 						service.CreateDrugFlowOne(flow)
@@ -2171,6 +2180,7 @@ func (c *HisApiController) DeletePrescription() {
2171 2180
 						//删除流水
2172 2181
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, item.ID)
2173 2182
 					} else {
2183
+						houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2174 2184
 						floatPrescrip := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 32)
2175 2185
 
2176 2186
 						prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
@@ -2205,6 +2215,7 @@ func (c *HisApiController) DeletePrescription() {
2205 2215
 							Dealer:       info.Dealer,
2206 2216
 							Manufacturer: info.Manufacturer,
2207 2217
 							Type:         1,
2218
+							StorehouseId: houseConfig.DrugStorehouseOut,
2208 2219
 						}
2209 2220
 						service.AddSigleDrugCancelStock(&cancelStock)
2210 2221
 
@@ -2234,6 +2245,7 @@ func (c *HisApiController) DeletePrescription() {
2234 2245
 							ProductDate:      info.ProductDate,
2235 2246
 							ExpiryDate:       info.ExpiryDate,
2236 2247
 							BatchNumberId:    info.WarehouseInfoId,
2248
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2237 2249
 						}
2238 2250
 
2239 2251
 						flow := models.DrugFlow{
@@ -2270,6 +2282,7 @@ func (c *HisApiController) DeletePrescription() {
2270 2282
 							MaxUnit:                 info.CountUnit,
2271 2283
 							MinUnit:                 "",
2272 2284
 							AdviceId:                info.AdviceId,
2285
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2273 2286
 						}
2274 2287
 						service.CreatedCancelStock(cancelStockInfo)
2275 2288
 						service.CreateDrugFlowOne(flow)
@@ -2350,7 +2363,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2350 2363
 						total, _ := service.FindAllDrugCancelStockTotal(adminUserInfo.CurrentOrgId)
2351 2364
 						total = total + 1
2352 2365
 						orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2353
-
2366
+						houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
2354 2367
 						cancelStock := models.DrugCancelStock{
2355 2368
 							OrderNumber:  orderNumber,
2356 2369
 							OperaTime:    operation_time,
@@ -2362,6 +2375,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2362 2375
 							Dealer:       info.Dealer,
2363 2376
 							Manufacturer: info.Manufacturer,
2364 2377
 							Type:         1,
2378
+							StorehouseId: houseConfig.DrugStorehouseOut,
2365 2379
 						}
2366 2380
 						service.AddSigleDrugCancelStock(&cancelStock)
2367 2381
 
@@ -2390,6 +2404,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2390 2404
 							ProductDate:      info.ProductDate,
2391 2405
 							ExpiryDate:       info.ExpiryDate,
2392 2406
 							BatchNumberId:    info.WarehouseInfoId,
2407
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2393 2408
 						}
2394 2409
 
2395 2410
 						flow := models.DrugFlow{
@@ -2425,6 +2440,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2425 2440
 							MaxUnit:                 info.CountUnit,
2426 2441
 							MinUnit:                 "",
2427 2442
 							AdviceId:                info.AdviceId,
2443
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2428 2444
 						}
2429 2445
 						service.CreatedCancelStock(cancelStockInfo)
2430 2446
 						service.CreateDrugFlowOne(flow)
@@ -2434,7 +2450,8 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2434 2450
 						//删除流水
2435 2451
 						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID)
2436 2452
 					} else {
2437
-
2453
+						adminUserInfo := c.GetAdminUserInfo()
2454
+						houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
2438 2455
 						floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
2439 2456
 
2440 2457
 						prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
@@ -2447,7 +2464,6 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2447 2464
 
2448 2465
 						}
2449 2466
 
2450
-						adminUserInfo := c.GetAdminUserInfo()
2451 2467
 						operation_time := time.Now().Unix()
2452 2468
 						creater := adminUserInfo.AdminUser.Id
2453 2469
 
@@ -2469,6 +2485,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2469 2485
 							Dealer:       info.Dealer,
2470 2486
 							Manufacturer: info.Manufacturer,
2471 2487
 							Type:         1,
2488
+							StorehouseId: houseConfig.DrugStorehouseOut,
2472 2489
 						}
2473 2490
 						service.AddSigleDrugCancelStock(&cancelStock)
2474 2491
 
@@ -2497,6 +2514,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2497 2514
 							ProductDate:      info.ProductDate,
2498 2515
 							ExpiryDate:       info.ExpiryDate,
2499 2516
 							BatchNumberId:    info.WarehouseInfoId,
2517
+							StorehouseId:     houseConfig.DrugStorehouseOut,
2500 2518
 						}
2501 2519
 
2502 2520
 						flow := models.DrugFlow{
@@ -2532,6 +2550,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2532 2550
 							MaxUnit:                 info.CountUnit,
2533 2551
 							MinUnit:                 "",
2534 2552
 							AdviceId:                info.AdviceId,
2553
+							StorehouseId:            houseConfig.DrugStorehouseOut,
2535 2554
 						}
2536 2555
 						service.CreatedCancelStock(cancelStockInfo)
2537 2556
 						service.CreateDrugFlowOne(flow)
@@ -2574,6 +2593,7 @@ func (c *HisApiController) DeleteProject() {
2574 2593
 			fmt.Println(err)
2575 2594
 		}
2576 2595
 		if project.Type == 3 {
2596
+			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2577 2597
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2578 2598
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2579 2599
 			good.Total = good.Total + f_count
@@ -2589,14 +2609,15 @@ func (c *HisApiController) DeleteProject() {
2589 2609
 			orderNumber := "CKTKD" + strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2590 2610
 
2591 2611
 			cancelStock := models.CancelStock{
2592
-				OrderNumber: orderNumber,
2593
-				OperaTime:   operation_time,
2594
-				OrgId:       adminInfo.CurrentOrgId,
2595
-				Creater:     creater,
2596
-				Ctime:       time.Now().Unix(),
2597
-				Status:      1,
2598
-				ReturnTime:  project.RecordDate,
2599
-				Type:        1,
2612
+				OrderNumber:  orderNumber,
2613
+				OperaTime:    operation_time,
2614
+				OrgId:        adminInfo.CurrentOrgId,
2615
+				Creater:      creater,
2616
+				Ctime:        time.Now().Unix(),
2617
+				Status:       1,
2618
+				ReturnTime:   project.RecordDate,
2619
+				Type:         1,
2620
+				StorehouseId: houseConfig.StorehouseOutInfo,
2600 2621
 			}
2601 2622
 			_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(project.RecordDate, adminInfo.CurrentOrgId)
2602 2623
 			if msgerrkonde == gorm.ErrRecordNotFound {
@@ -2633,6 +2654,7 @@ func (c *HisApiController) DeleteProject() {
2633 2654
 					WarehouseInfoId: info.WarehouseInfotId,
2634 2655
 					PatientId:       info.PatientId,
2635 2656
 					RecordDate:      info.SysRecordTime,
2657
+					StorehouseId:    houseConfig.StorehouseOutInfo,
2636 2658
 				}
2637 2659
 
2638 2660
 				service.CreateCancelStockInfoOne(&cancelStockInfo)
@@ -2669,6 +2691,7 @@ func (c *HisApiController) DeleteProject() {
2669 2691
 					CancelOutDetailId:       cancelInfo.ID,
2670 2692
 					ProductDate:             info.ProductDate,
2671 2693
 					ExpireDate:              info.ExpiryDate,
2694
+					StorehouseId:            houseConfig.StorehouseOutInfo,
2672 2695
 				}
2673 2696
 				service.CreateStockFlowOne(flow)
2674 2697
 
@@ -2721,6 +2744,7 @@ func (c *HisApiController) DeleteProject() {
2721 2744
 							Manufacturer:            0,
2722 2745
 							Type:                    1,
2723 2746
 							IsSys:                   1,
2747
+							StorehouseId:            houseConfig.StorehouseOutInfo,
2724 2748
 						}
2725 2749
 						err := service.AddSigleWarehouseOut(&warehouseOut)
2726 2750
 						if err != nil {
@@ -2728,23 +2752,25 @@ func (c *HisApiController) DeleteProject() {
2728 2752
 							return
2729 2753
 						}
2730 2754
 						prepare := &models.DialysisBeforePrepare{
2731
-							UserOrgId:  adminInfo.CurrentOrgId,
2732
-							PatientId:  info.PatientId,
2733
-							RecordDate: info.SysRecordTime,
2734
-							GoodId:     project.ProjectId,
2735
-							GoodTypeId: info.GoodTypeId,
2736
-							Count:      cha_count,
2755
+							UserOrgId:    adminInfo.CurrentOrgId,
2756
+							PatientId:    info.PatientId,
2757
+							RecordDate:   info.SysRecordTime,
2758
+							GoodId:       project.ProjectId,
2759
+							GoodTypeId:   info.GoodTypeId,
2760
+							Count:        cha_count,
2761
+							StorehouseId: houseConfig.StorehouseOutInfo,
2737 2762
 						}
2738 2763
 						//出库
2739 2764
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2740 2765
 					} else if err == nil {
2741 2766
 						prepare := &models.DialysisBeforePrepare{
2742
-							UserOrgId:  adminInfo.CurrentOrgId,
2743
-							PatientId:  info.PatientId,
2744
-							RecordDate: info.SysRecordTime,
2745
-							GoodId:     project.ProjectId,
2746
-							GoodTypeId: info.GoodTypeId,
2747
-							Count:      cha_count,
2767
+							UserOrgId:    adminInfo.CurrentOrgId,
2768
+							PatientId:    info.PatientId,
2769
+							RecordDate:   info.SysRecordTime,
2770
+							GoodId:       project.ProjectId,
2771
+							GoodTypeId:   info.GoodTypeId,
2772
+							Count:        cha_count,
2773
+							StorehouseId: houseConfig.StorehouseOutInfo,
2748 2774
 						}
2749 2775
 						//出库
2750 2776
 						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
@@ -4521,9 +4547,40 @@ func (c *HisApiController) GetUploadInfo() {
4521 4547
 	reg_type, _ := c.GetInt64("p_type")
4522 4548
 	order_id, _ := c.GetInt64("order_id")
4523 4549
 
4524
-	his, _ := service.GetHisPatientByIdThree(his_patient_id)
4550
+	dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
4551
+	tmp_decimal := c.GetString("tmp_decimal")
4552
+	var decimal float64 //本次使用的押金
4553
+	var errmsg error
4554
+	tx := service.XTWriteDB().Begin() //开了事务
4555
+	//只检测扣费函数SpendDeposit有没有返回错误,如果有则回滚所有以TX结尾的方法(去掉TX即为原先的方法)
4556
+	defer func() {
4557
+		if errmsg != nil {
4558
+			utils.ErrorLog("事务失败,原因为: %v", errmsg.Error())
4559
+			tx.Rollback()
4560
+		} else {
4561
+			tx.Commit()
4562
+		}
4563
+	}()
4564
+	if dec_way == "true" && tmp_decimal == "0" && tmp_decimal == "" {
4565
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
4566
+		return
4567
+	}
4568
+	if len(tmp_decimal) > 0 {
4569
+		if tmp_decimal[0] == 45 {
4570
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
4571
+			return
4572
+		}
4573
+	}
4574
+	tt, errs := strconv.ParseFloat(tmp_decimal, 64)
4575
+	if errs != nil {
4576
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
4577
+		return
4578
+	}
4579
+	decimal = tt
4525 4580
 
4526
-	tempOrder, _ := service.GetHisOrderByID(order_id)
4581
+	his, _ := service.GetHisPatientByIdThreeTX(his_patient_id, tx)
4582
+
4583
+	tempOrder, _ := service.GetHisOrderByIDTX(order_id, tx)
4527 4584
 
4528 4585
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
4529 4586
 	if err != nil {
@@ -4544,9 +4601,9 @@ func (c *HisApiController) GetUploadInfo() {
4544 4601
 
4545 4602
 			if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
4546 4603
 
4547
-				prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
4604
+				prescriptions, _ = service.GetPrescriptionByIdsTX(ids_arr, adminUser.CurrentOrgId, tx)
4548 4605
 			} else {
4549
-				prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
4606
+				prescriptions, _ = service.GetSettleHisPrescriptionTX(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type, tx)
4550 4607
 			}
4551 4608
 		} else { //月结
4552 4609
 
@@ -4568,9 +4625,8 @@ func (c *HisApiController) GetUploadInfo() {
4568 4625
 			}
4569 4626
 			recordEndTime := theEndTime.Unix()
4570 4627
 			end_time = recordEndTime
4571
-			prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
4628
+			prescriptions, _ = service.GetMonthHisPrescriptionTX(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type, tx)
4572 4629
 		}
4573
-
4574 4630
 		timestamp := time.Now().Unix()
4575 4631
 		tempTime := time.Unix(timestamp, 0)
4576 4632
 		timeFormat := tempTime.Format("20060102150405")
@@ -4612,7 +4668,7 @@ func (c *HisApiController) GetUploadInfo() {
4612 4668
 
4613 4669
 		allTotal := fmt.Sprintf("%.4f", total)
4614 4670
 		totals, _ := strconv.ParseFloat(allTotal, 64)
4615
-		order := &models.HisOrder{
4671
+		order := &models.HisOrder{ //
4616 4672
 			UserOrgId:             adminUser.CurrentOrgId,
4617 4673
 			HisPatientId:          his.ID,
4618 4674
 			PatientId:             id,
@@ -4642,8 +4698,9 @@ func (c *HisApiController) GetUploadInfo() {
4642 4698
 			Diagnosis:             diagnosis_id,
4643 4699
 			PType:                 2,
4644 4700
 			SetlTime:              tm.Format("2006-01-02 15:04:05"),
4701
+			Decimal:               decimal,
4645 4702
 		}
4646
-		err = service.CreateOrder(order)
4703
+		err = service.CreateOrderTX(order, tx)
4647 4704
 		if err != nil {
4648 4705
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
4649 4706
 			return
@@ -4739,16 +4796,28 @@ func (c *HisApiController) GetUploadInfo() {
4739 4796
 				Type:             types,
4740 4797
 				ItemId:           item_id,
4741 4798
 			}
4742
-			service.CreateOrderInfo(info)
4799
+			service.CreateOrderInfoTX(info, tx)
4743 4800
 		}
4744 4801
 		his.Diagnosis = diagnosis_id
4745 4802
 		his.SickType = sick_type
4746 4803
 		his.RegisterType = reg_type
4747 4804
 		his.MedicalTreatmentType = reg_type
4748
-		service.UpdataHisPateint(&his)
4749
-		err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
4750
-		err = service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime, his_patient_id)
4751
-		err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
4805
+		service.UpdataHisPateintTX(&his, tx)
4806
+		err = service.UpDatePrescriptionNumberTX(adminUser.CurrentOrgId, ids, chrg_bchno, tx)
4807
+		err = service.UpDateHisPrescriptionInfoNumberTX(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime, his_patient_id, tx)
4808
+		err = service.UpdataOrderStatusTwoTX(chrg_bchno, adminUser.CurrentOrgId, tx)
4809
+		//判断是否使用了押金
4810
+		if dec_way == "true" {
4811
+
4812
+			tmpstring := strconv.FormatInt(order.ID, 10)
4813
+			//扣押金
4814
+			errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
4815
+			if errmsg != nil {
4816
+				c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
4817
+				//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
4818
+				return
4819
+			}
4820
+		}
4752 4821
 		if err == nil {
4753 4822
 			c.ServeSuccessJSON(map[string]interface{}{
4754 4823
 				"msg": "结算成功",
@@ -4793,15 +4862,21 @@ func (c *HisApiController) Refund() {
4793 4862
 	order_id, _ := c.GetInt64("order_id")
4794 4863
 	order, _ := service.GetHisOrderByID(order_id)
4795 4864
 	adminUser := c.GetAdminUserInfo()
4865
+	orgid := c.GetAdminUserInfo().CurrentOrgId
4796 4866
 	err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId)
4797
-	if err == nil {
4798
-		c.ServeSuccessJSON(map[string]interface{}{
4799
-			"msg": "退费成功",
4800
-		})
4801
-	} else {
4867
+	if err != nil {
4868
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4869
+		return
4870
+	}
4871
+	tmp := strconv.FormatInt(order.ID, 10)
4872
+	err = service.MoneyIncrease(orgid, order.HisPatientId, tmp, order.Decimal)
4873
+	if err != nil {
4802 4874
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4803 4875
 		return
4804 4876
 	}
4877
+	c.ServeSuccessJSON(map[string]interface{}{
4878
+		"msg": "退费成功",
4879
+	})
4805 4880
 }
4806 4881
 
4807 4882
 func (c *HisApiController) RefundNumber() {

+ 544 - 30
controllers/his_deposit_controller.go Прегледај датотеку

@@ -9,6 +9,7 @@ import (
9 9
 	"fmt"
10 10
 	"github.com/astaxie/beego"
11 11
 	"github.com/shopspring/decimal"
12
+	"strconv"
12 13
 	"strings"
13 14
 	"time"
14 15
 )
@@ -18,27 +19,45 @@ type HisDepositApiController struct {
18 19
 }
19 20
 
20 21
 func HisDepositApiRegistRouters() {
21
-	beego.Router("/api/his/ttt", &HisDepositApiController{}, "get:TTT")                         //测试接口
22
-	beego.Router("/api/his/gethisuser", &HisDepositApiController{}, "get:GetHisUser")           //获取病例中心,有效患者名称
23
-	beego.Router("/api/his/adddeposit", &HisDepositApiController{}, "post:AddDeposit")          //新增押金
24
-	beego.Router("/api/his/getdepositcode", &HisDepositApiController{}, "get:GetDepositCode")   //获取新增押金编号
25
-	beego.Router("/api/his/getdeletecode", &HisDepositApiController{}, "get:GetDeleteCode")     //获取退款编号
26
-	beego.Router("/api/his/rechargedetails", &HisDepositApiController{}, "get:RechargeDetails") //充值明细列表
27
-	beego.Router("/api/his/updeposit", &HisDepositApiController{}, "get:UpDeposit")             //审核
28
-	beego.Router("/api/his/deletehistory", &HisDepositApiController{}, "get:DeleteHistory")     //删除
29
-	beego.Router("/api/his/rechargesummary", &HisDepositApiController{}, "get:RechargeSummary") //充值汇总列表
30
-	beego.Router("/api/his/getuserlist", &HisDepositApiController{}, "get:GetUserList")         //获取患者押金列表
31
-	beego.Router("/api/his/depositflow", &HisDepositApiController{}, "get:DepositFlow")         //根据患者id获取押金流水
32
-}
33
-func (this *HisDepositApiController) TTT() {
34
-	id, _ := this.GetInt64("id")
35
-	err := service.DelDecimalHistory(id)
36
-	this.ServeSuccessJSON(map[string]interface{}{
37
-		"list": err,
38
-	})
39
-	return
22
+	//beego.Router("/api/his/ttt", &HisDepositApiController{}, "get:TTT")                         //测试接口
23
+	beego.Router("/api/his/gethisuser", &HisDepositApiController{}, "get:GetHisUser")                //获取病例中心,有效患者名称
24
+	beego.Router("/api/his/adddeposit", &HisDepositApiController{}, "post:AddDeposit")               //新增押金
25
+	beego.Router("/api/his/getdepositcode", &HisDepositApiController{}, "get:GetDepositCode")        //获取新增押金编号
26
+	beego.Router("/api/his/getdeletecode", &HisDepositApiController{}, "get:GetDeleteCode")          //获取退款编号
27
+	beego.Router("/api/his/rechargedetails", &HisDepositApiController{}, "get:RechargeDetails")      //充值明细列表
28
+	beego.Router("/api/his/updeposit", &HisDepositApiController{}, "get:UpDeposit")                  //押金审核
29
+	beego.Router("/api/his/deletehistory", &HisDepositApiController{}, "get:DeleteHistory")          //押金删除
30
+	beego.Router("/api/his/rechargesummary", &HisDepositApiController{}, "get:RechargeSummary")      //充值汇总列表
31
+	beego.Router("/api/his/getuserlist", &HisDepositApiController{}, "get:GetUserList")              //获取患者押金列表
32
+	beego.Router("/api/his/depositflow", &HisDepositApiController{}, "get:DepositFlow")              //根据患者id获取押金流水
33
+	beego.Router("/api/his/deductiondetails", &HisDepositApiController{}, "get:DeductionDetails")    //扣费明细查询
34
+	beego.Router("/api/his/desummary", &HisDepositApiController{}, "get:DeSummary")                  //扣费汇总
35
+	beego.Router("/api/his/idtobalance", &HisDepositApiController{}, "get:IdToBalance")              //根据患者id查询患者的余额
36
+	beego.Router("/api/his/refundapplication", &HisDepositApiController{}, "post:RefundApplication") //新增一条退款申请
37
+	beego.Router("/api/his/refundreview", &HisDepositApiController{}, "get:RefundReview")            //退款审核通过/拒绝
38
+	beego.Router("/api/his/deleterefund", &HisDepositApiController{}, "get:DeleteRefund")            //退款删除
39
+	beego.Router("/api/his/changerefund", &HisDepositApiController{}, "post:ChangeRefund")           //更改退款申请
40
+	beego.Router("/api/his/refundlist", &HisDepositApiController{}, "get:RefundList")                //退款分页
41
+	beego.Router("/api/his/getorgname", &HisDepositApiController{}, "get:GetorgName")                //获取供应商名字
42
+	beego.Router("/api/his/getweektime", &HisDepositApiController{}, "get:GetWeekTime")              //获取本周时间
43
+	beego.Router("/api/his/getmonthtime", &HisDepositApiController{}, "get:GetMonthTime")            //获取本月时间
40 44
 }
41 45
 
46
+//func (this *HisDepositApiController) TTT() {
47
+//	orgid := this.GetAdminUserInfo().CurrentOrgId
48
+//	id, _ := this.GetInt64("id")
49
+//	code := this.GetString("code")
50
+//	deposit,_ := this.GetInt64("depostit")
51
+//	err := service.MoneyIncrease(orgid,id,code,deposit)
52
+//	if err != nil {
53
+//
54
+//	}
55
+//	this.ServeSuccessJSON(map[string]interface{}{
56
+//		"list": "成功",
57
+//	})
58
+//	return
59
+//}
60
+
42 61
 //获取病例中心,有效患者名称
43 62
 func (this *HisDepositApiController) GetHisUser() {
44 63
 	orgid := this.GetAdminUserInfo().CurrentOrgId
@@ -67,19 +86,43 @@ func (this *HisDepositApiController) AddDeposit() {
67 86
 	case dataBody["code"] == nil:
68 87
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金编号不能为空")
69 88
 		return
70
-	case dataBody["his_patient_id"] == nil:
89
+	case dataBody["his_patient_id"] == nil || dataBody["his_patient_id"] == "":
71 90
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患者名称不能为空")
72 91
 		return
73
-	case dataBody["deposit"] == nil:
92
+	case dataBody["deposit"] == nil || dataBody["deposit"] == "":
74 93
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额不能为空")
75 94
 		return
76
-	case dataBody["trial_status"] == nil:
95
+	case dataBody["trial_status"] == nil || dataBody["trial_status"] == "":
77 96
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "审核状态不能为空")
78 97
 		return
79 98
 	}
80
-	code := dataBody["code"].(string)                              //押金编号
81
-	his_patient_id := int64(dataBody["his_patient_id"].(float64))  //患者编号
82
-	deposit := decimal.NewFromFloat(dataBody["deposit"].(float64)) //押金金额
99
+	code := dataBody["code"].(string)                             //押金编号
100
+	his_patient_id := int64(dataBody["his_patient_id"].(float64)) //患者编号
101
+	var tmps float64
102
+	switch dataBody["deposit"].(type) {
103
+	case string:
104
+		t_deposit := dataBody["deposit"].(string)
105
+		if len(t_deposit) > 0 {
106
+			if t_deposit[0] == 45 {
107
+				this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
108
+				return
109
+			}
110
+		}
111
+		tt, errs := strconv.ParseFloat(t_deposit, 64)
112
+		if errs != nil {
113
+			this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
114
+			return
115
+		} else {
116
+			tmps = tt
117
+		}
118
+	default:
119
+		tmps = dataBody["deposit"].(float64)
120
+	}
121
+	if tmps == 0 {
122
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额不能为0")
123
+		return
124
+	}
125
+	deposit := decimal.NewFromFloat(tmps) //押金金额
83 126
 	var remarks string
84 127
 	if dataBody["remarks"] == nil {
85 128
 		remarks = ""
@@ -149,11 +192,11 @@ func (this *HisDepositApiController) RechargeDetails() {
149 192
 
150 193
 	namemap := make(map[int64]string)
151 194
 	slicekey := make([]int64, 0)
195
+	lists, _ := service.GetHisUser(orgid)
196
+	for _, v := range lists {
197
+		namemap[v.ID] = v.Name
198
+	}
152 199
 	if len(keyword) > 0 {
153
-		list, _ := service.GetHisUser(orgid)
154
-		for _, v := range list {
155
-			namemap[v.ID] = v.Name
156
-		}
157 200
 		for k, v := range namemap {
158 201
 			res := strings.Contains(v, keyword)
159 202
 			if res == true {
@@ -181,6 +224,8 @@ func (this *HisDepositApiController) RechargeDetails() {
181 224
 			sum = sum.Add(list[i].Deposit)
182 225
 		}
183 226
 		list[i].Name = service.GetCreateidName(list[i].CreateId)
227
+		list[i].HisName = namemap[list[i].HisPatientId]
228
+		list[i].Starttime = fmt.Sprintf(time.Unix(list[i].Ctime, 0).Format("2006-01-02"))
184 229
 	}
185 230
 	this.ServeSuccessJSON(map[string]interface{}{
186 231
 		"list": list,
@@ -366,6 +411,13 @@ func (this *HisDepositApiController) DepositFlow() {
366 411
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
367 412
 		return
368 413
 	}
414
+	for i := 0; i < len(deposirhistory); i++ {
415
+		//如果为扣费,或退费 则把订单id变为就诊号
416
+		if deposirhistory[i].DepositStatus == 2 || deposirhistory[i].DepositStatus == 4 {
417
+			tmpcode, _ := strconv.ParseInt(deposirhistory[i].DepositCode, 10, 64)
418
+			deposirhistory[i].DepositCode = service.FindcodeToid(tmpcode)
419
+		}
420
+	}
369 421
 
370 422
 	this.ServeSuccessJSON(map[string]interface{}{
371 423
 		"list":    deposirhistory,
@@ -375,7 +427,7 @@ func (this *HisDepositApiController) DepositFlow() {
375 427
 	return
376 428
 }
377 429
 
378
-//
430
+//获取患者押金列表
379 431
 func (this *HisDepositApiController) GetUserList() {
380 432
 	orgid := this.GetAdminUserInfo().CurrentOrgId
381 433
 	keyword := this.GetString("keyword")
@@ -420,6 +472,468 @@ func (this *HisDepositApiController) GetUserList() {
420 472
 	return
421 473
 }
422 474
 
475
+//扣费明细查询
476
+func (this *HisDepositApiController) DeductionDetails() {
477
+	orgid := this.GetAdminUserInfo().CurrentOrgId
478
+	timeLayout := "2006-01-02"
479
+	loc, _ := time.LoadLocation("Local")
480
+	keyword := this.GetString("keyword")
481
+	start_time := this.GetString("start_time")
482
+	end_time := this.GetString("end_time")
483
+	var stime int64 //开始时间
484
+	var etime int64 //结束时间
485
+
486
+	namemap := make(map[int64]string)
487
+	slicekey := make([]int64, 0)
488
+	lists, _ := service.GetHisUser(orgid)
489
+	for _, v := range lists {
490
+		namemap[v.ID] = v.Name
491
+	}
492
+	if len(keyword) > 0 {
493
+		for k, v := range namemap {
494
+			res := strings.Contains(v, keyword)
495
+			if res == true {
496
+				slicekey = append(slicekey, k)
497
+			}
498
+		}
499
+	}
500
+	if start_time == "" && end_time == "" {
501
+		stime, etime = service.GetMondayOfWeek()
502
+	} else {
503
+		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
504
+		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
505
+		stime = stmp.Unix()
506
+		etime = etmp.Unix()
507
+	}
508
+	list, err := service.DeductionList(orgid, stime, etime, keyword, slicekey)
509
+	if err != nil {
510
+		utils.ErrorLog(err.Error())
511
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
512
+		return
513
+	}
514
+
515
+	var sum decimal.Decimal
516
+	var detailslist []models.Details
517
+	var details models.Details
518
+	for i := 0; i < len(list); i++ {
519
+		sum = sum.Add(list[i].Deposit)
520
+		tmp_id, _ := strconv.ParseInt(list[i].DepositCode, 10, 64)
521
+		details.ID = tmp_id
522
+		details.Code = service.FindcodeToid(tmp_id)
523
+		details.NameId = list[i].HisPatientId
524
+		details.Name = namemap[list[i].HisPatientId]
525
+		details.Number = service.FindnumberToid(tmp_id)
526
+		details.Decimal = list[i].Deposit
527
+		details.ChargeDate = fmt.Sprintf(time.Unix(list[i].Ctime, 0).Format("2006-01-02 15:04:05"))
528
+		details.Chargetype = service.CodeToChargetype(orgid, details.Code)
529
+		details.Total = service.MedicalTotal(orgid, list[i].HisPatientId, details.Code)
530
+		detailslist = append(detailslist, details)
531
+	}
532
+
533
+	this.ServeSuccessJSON(map[string]interface{}{
534
+		"list": detailslist,
535
+		"sum":  sum,
536
+	})
537
+	return
538
+}
539
+
540
+//扣费汇总
541
+func (this *HisDepositApiController) DeSummary() {
542
+	orgid := this.GetAdminUserInfo().CurrentOrgId
543
+	timeLayout := "2006-01-02"
544
+	loc, _ := time.LoadLocation("Local")
545
+	keyword := this.GetString("keyword")
546
+	start_time := this.GetString("start_time")
547
+	end_time := this.GetString("end_time")
548
+	var stime int64 //开始时间
549
+	var etime int64 //结束时间
550
+
551
+	namemap := make(map[int64]string)
552
+	slicekey := make([]int64, 0)
553
+	lists, _ := service.GetHisUser(orgid)
554
+	for _, v := range lists {
555
+		namemap[v.ID] = v.Name
556
+	}
557
+	if len(keyword) > 0 {
558
+		for k, v := range namemap {
559
+			res := strings.Contains(v, keyword)
560
+			if res == true {
561
+				slicekey = append(slicekey, k)
562
+			}
563
+		}
564
+	}
565
+	if start_time == "" && end_time == "" {
566
+		stime, etime = service.GetMondayOfWeek()
567
+	} else {
568
+		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
569
+		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
570
+		stime = stmp.Unix()
571
+		etime = etmp.Unix()
572
+	}
573
+	list, err := service.DeductionList(orgid, stime, etime, keyword, slicekey)
574
+	if err != nil {
575
+		utils.ErrorLog(err.Error())
576
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
577
+		return
578
+	}
579
+	var sum decimal.Decimal
580
+	var detailslist []models.DeductionSummary
581
+	var details models.DeductionSummary
582
+	for i := 0; i < len(list); i++ {
583
+		sum = sum.Add(list[i].Deposit)
584
+		details.Name = namemap[list[i].HisPatientId]
585
+		details.Decimal = list[i].Deposit
586
+		details.Total = service.MedicalTotal(orgid, list[i].HisPatientId, list[i].DepositCode)
587
+		detailslist = append(detailslist, details)
588
+	}
589
+	maplist := make(map[string]models.DeductionSummary)
590
+	Finlist := []models.DeductionSummary{}
591
+	tmpslice := make([]string, 0)
592
+	for i := 0; i < len(detailslist); i++ {
593
+		if k, ok := maplist[detailslist[i].Name]; ok {
594
+			k.Total = k.Total.Add(detailslist[i].Total)
595
+			k.Decimal = k.Decimal.Add(detailslist[i].Decimal)
596
+			maplist[detailslist[i].Name] = models.DeductionSummary{
597
+				detailslist[i].Name,
598
+				k.Total,
599
+				k.Decimal,
600
+			}
601
+		} else {
602
+			maplist[detailslist[i].Name] = models.DeductionSummary{
603
+				detailslist[i].Name,
604
+				detailslist[i].Total,
605
+				detailslist[i].Decimal,
606
+			}
607
+			tmpslice = append(tmpslice, detailslist[i].Name)
608
+		}
609
+	}
610
+	for i := 0; i < len(tmpslice); i++ {
611
+		Finlist = append(Finlist, maplist[tmpslice[i]])
612
+	}
613
+	this.ServeSuccessJSON(map[string]interface{}{
614
+		"list": detailslist,
615
+		"sum":  sum,
616
+	})
617
+	return
618
+}
619
+
620
+//根据患者id查询患者的余额
621
+func (this *HisDepositApiController) IdToBalance() {
622
+	check := map[string][]string{
623
+		"his_patient_id": {"must", "int", "his_patient_id"},
624
+	}
625
+	_, err := checks(this, &check)
626
+	if err != nil {
627
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
628
+		return
629
+	}
630
+	orgid := this.GetAdminUserInfo().CurrentOrgId
631
+	his_patient_id, _ := this.GetInt64("his_patient_id")
632
+	tmp := service.GetUserMoney(his_patient_id, orgid)
633
+	this.ServeSuccessJSON(map[string]interface{}{
634
+		"list": tmp,
635
+	})
636
+	return
637
+}
638
+
639
+//新增一条退款申请
640
+func (this *HisDepositApiController) RefundApplication() {
641
+	orgid := this.GetAdminUserInfo().CurrentOrgId
642
+	createid := this.GetAdminUserInfo().AdminUser.Id
643
+	dataBody := make(map[string]interface{}, 0)
644
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
645
+	if err != nil {
646
+		utils.ErrorLog(err.Error())
647
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
648
+		return
649
+	}
650
+	switch {
651
+	case dataBody["code"] == nil:
652
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "申请编号不能为空")
653
+		return
654
+	case dataBody["his_patient_id"] == nil:
655
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患者名称不能为空")
656
+		return
657
+	case dataBody["deposit"] == nil || dataBody["deposit"] == "":
658
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额不能为空")
659
+		return
660
+	case dataBody["trial_status"] == nil:
661
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "审核状态不能为空")
662
+		return
663
+	}
664
+	code := dataBody["code"].(string)                             //申请编号
665
+	his_patient_id := int64(dataBody["his_patient_id"].(float64)) //患者编号
666
+	//deposit := decimal.NewFromFloat(dataBody["deposit"].(float64)) //退款金额
667
+	var tmps float64
668
+	switch dataBody["deposit"].(type) {
669
+	case string:
670
+		t_deposit := dataBody["deposit"].(string)
671
+		if len(t_deposit) > 0 {
672
+			if t_deposit[0] == 45 {
673
+				this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额错误")
674
+				return
675
+			}
676
+		}
677
+		tt, errs := strconv.ParseFloat(t_deposit, 64)
678
+		if errs != nil {
679
+			this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额错误")
680
+			return
681
+		} else {
682
+			tmps = tt
683
+		}
684
+	default:
685
+		tmps = dataBody["deposit"].(float64)
686
+	}
687
+	if tmps == 0 {
688
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额不能为0")
689
+		return
690
+	}
691
+	deposit := decimal.NewFromFloat(tmps)                     //押金金额
692
+	trial_status := int64(dataBody["trial_status"].(float64)) //审核状态
693
+
694
+	err = service.RefundApplication(orgid, his_patient_id, trial_status, createid, code, deposit)
695
+	if err != nil {
696
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
697
+		return
698
+	}
699
+	this.ServeSuccessJSON(map[string]interface{}{
700
+		"list": "新增成功",
701
+	})
702
+	return
703
+
704
+}
705
+
706
+//退款审核通过/拒绝
707
+func (this *HisDepositApiController) RefundReview() {
708
+	check := map[string][]string{
709
+		"ids":          {"must", "string", "ids"},
710
+		"trial_status": {"must", "int", "trial_status"},
711
+	}
712
+	_, err := checks(this, &check)
713
+	if err != nil {
714
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
715
+		return
716
+	}
717
+	orgid := this.GetAdminUserInfo().CurrentOrgId
718
+	ids := this.GetString("ids") //很多id
719
+
720
+	trial_status, _ := this.GetInt64("trial_status")
721
+	if trial_status != 1 && trial_status != 2 {
722
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数trial_status值错误")
723
+		return
724
+	}
725
+	err = service.RefundReviewMore(orgid, trial_status, ids)
726
+	if err != nil {
727
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
728
+		return
729
+	}
730
+	var tmplist string
731
+	if trial_status == 1 {
732
+		tmplist = "审核通过"
733
+	} else {
734
+		tmplist = "审核拒绝"
735
+	}
736
+	this.ServeSuccessJSON(map[string]interface{}{
737
+		"list": tmplist,
738
+	})
739
+	return
740
+}
741
+
742
+//退款删除
743
+func (this *HisDepositApiController) DeleteRefund() {
744
+	check := map[string][]string{
745
+		"id": {"must", "int", "id"},
746
+	}
747
+	_, err := checks(this, &check)
748
+	if err != nil {
749
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
750
+		return
751
+	}
752
+	orgid := this.GetAdminUserInfo().CurrentOrgId
753
+	id, _ := this.GetInt64("id")
754
+	err = service.DeleteRefund(orgid, id)
755
+	if err != nil {
756
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
757
+		return
758
+	}
759
+	this.ServeSuccessJSON(map[string]interface{}{
760
+		"list": "删除成功",
761
+	})
762
+	return
763
+}
764
+
765
+//更改退款申请
766
+func (this *HisDepositApiController) ChangeRefund() {
767
+	orgid := this.GetAdminUserInfo().CurrentOrgId
768
+	dataBody := make(map[string]interface{}, 0)
769
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
770
+	if err != nil {
771
+		utils.ErrorLog(err.Error())
772
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
773
+		return
774
+	}
775
+	switch {
776
+	case dataBody["id"] == nil:
777
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "id不能为空")
778
+		return
779
+	case dataBody["code"] == nil:
780
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "申请编号不能为空")
781
+		return
782
+	case dataBody["his_patient_id"] == nil:
783
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患者名称不能为空")
784
+		return
785
+	case dataBody["deposit"] == nil || dataBody["deposit"] == "":
786
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额不能为空")
787
+		return
788
+	case dataBody["trial_status"] == nil:
789
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "审核状态不能为空")
790
+		return
791
+	}
792
+	id := int64(dataBody["id"].(float64))
793
+	code := dataBody["code"].(string)                             //申请编号
794
+	his_patient_id := int64(dataBody["his_patient_id"].(float64)) //患者编号
795
+	//deposit := decimal.NewFromFloat(dataBody["deposit"].(float64)) //退款金额
796
+	var tmps float64
797
+	switch dataBody["deposit"].(type) {
798
+	case string:
799
+		t_deposit := dataBody["deposit"].(string)
800
+		if len(t_deposit) > 0 {
801
+			if t_deposit[0] == 45 {
802
+				this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额错误")
803
+				return
804
+			}
805
+		}
806
+		tt, errs := strconv.ParseFloat(t_deposit, 64)
807
+		if errs != nil {
808
+			this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额错误")
809
+			return
810
+		} else {
811
+			tmps = tt
812
+		}
813
+	default:
814
+		tmps = dataBody["deposit"].(float64)
815
+	}
816
+	if tmps == 0 {
817
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额不能为0")
818
+		return
819
+	}
820
+	deposit := decimal.NewFromFloat(tmps)                     //押金金额
821
+	trial_status := int64(dataBody["trial_status"].(float64)) //审核状态
822
+	err = service.ChangeRefund(orgid, his_patient_id, trial_status, id, code, deposit)
823
+	if err != nil {
824
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
825
+		return
826
+	}
827
+	this.ServeSuccessJSON(map[string]interface{}{
828
+		"list": "保存成功",
829
+	})
830
+	return
831
+}
832
+
833
+//退款分页
834
+func (this *HisDepositApiController) RefundList() {
835
+	check := map[string][]string{
836
+		"refundtype":  {"must", "int", "refundtype"},
837
+		"examinetype": {"must", "int", "examinetype"},
838
+	}
839
+	_, err := checks(this, &check)
840
+	if err != nil {
841
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
842
+		return
843
+	}
844
+	orgid := this.GetAdminUserInfo().CurrentOrgId
845
+	timeLayout := "2006-01-02"
846
+	loc, _ := time.LoadLocation("Local")
847
+	keyword := this.GetString("keyword")           //获取搜索框
848
+	refundtype, _ := this.GetInt64("refundtype")   //获取退款类型
849
+	examinetype, _ := this.GetInt64("examinetype") //获取审核状态
850
+	start_time := this.GetString("start_time")
851
+	end_time := this.GetString("end_time")
852
+	var stime int64 //开始时间
853
+	var etime int64 //结束时间
854
+
855
+	namemap := make(map[int64]string)
856
+	slicekey := make([]int64, 0)
857
+	lists, _ := service.GetHisUser(orgid)
858
+	for _, v := range lists {
859
+		namemap[v.ID] = v.Name
860
+	}
861
+	if len(keyword) > 0 {
862
+		for k, v := range namemap {
863
+			res := strings.Contains(v, keyword)
864
+			if res == true {
865
+				slicekey = append(slicekey, k)
866
+			}
867
+		}
868
+	}
869
+	if start_time == "" && end_time == "" {
870
+		stime, etime = service.GetMondayOfWeek()
871
+	} else {
872
+		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
873
+		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
874
+		stime = stmp.Unix()
875
+		etime = etmp.Unix()
876
+	}
877
+	depo := []models.RefundList{}
878
+	depo, err = service.RefundList(orgid, stime, etime, refundtype, examinetype, keyword, slicekey)
879
+	if err != nil {
880
+		utils.ErrorLog("查询失败,原因为:", err.Error())
881
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
882
+		return
883
+	}
884
+	for i := 0; i < len(depo); i++ {
885
+		depo[i].Name = service.GetCreateidName(depo[i].CreateId)
886
+		depo[i].HisName = namemap[depo[i].HisPatientId]
887
+		if depo[i].Mtime > depo[i].Ctime {
888
+			depo[i].Starttime = fmt.Sprintf(time.Unix(depo[i].Mtime, 0).Format("2006-01-02 15:04:05"))
889
+		} else {
890
+			depo[i].Starttime = fmt.Sprintf(time.Unix(depo[i].Ctime, 0).Format("2006-01-02 15:04:05"))
891
+		}
892
+		if depo[i].DepositStatus == 4 {
893
+			depo[i].Name = "-"
894
+		}
895
+	}
896
+	this.ServeSuccessJSON(map[string]interface{}{
897
+		"list": depo,
898
+	})
899
+	return
900
+}
901
+
902
+func (this *HisDepositApiController) GetorgName() {
903
+	orgid := this.GetAdminUserInfo().CurrentOrgId
904
+	name := service.GetorgName(orgid)
905
+	this.ServeSuccessJSON(map[string]interface{}{
906
+		"list": name,
907
+	})
908
+	return
909
+}
910
+
911
+//获取本月时间
912
+func (this *HisDepositApiController) GetMonthTime() {
913
+	stime, etime := service.GetMonth()
914
+	srart_time := fmt.Sprintf(time.Unix(stime, 0).Format("2006-01-02"))
915
+	end_time := fmt.Sprintf(time.Unix(etime, 0).Format("2006-01-02"))
916
+
917
+	this.ServeSuccessJSON(map[string]interface{}{
918
+		"srart_time": srart_time,
919
+		"end_time":   end_time,
920
+	})
921
+	return
922
+}
923
+
924
+//获取本周时间
925
+func (this *HisDepositApiController) GetWeekTime() {
926
+	stime, etime := service.GetMondayOfWeek()
927
+	srart_time := fmt.Sprintf(time.Unix(stime, 0).Format("2006-01-02"))
928
+	end_time := fmt.Sprintf(time.Unix(etime, 0).Format("2006-01-02"))
929
+
930
+	this.ServeSuccessJSON(map[string]interface{}{
931
+		"srart_time": srart_time,
932
+		"end_time":   end_time,
933
+	})
934
+	return
935
+}
936
+
423 937
 //判断前端参数是否为空
424 938
 func checks(this *HisDepositApiController, m *map[string][]string) (map[string]string, error) {
425 939
 	tmp := make(map[string]string)

+ 4 - 0
controllers/his_project_api_controller.go Прегледај датотеку

@@ -1117,6 +1117,9 @@ func (this *HisProjectApiController) GetPatientcaseHistory() {
1117 1117
 	history, _ := service.GetPatientCaseHistory(patient_id)
1118 1118
 	hispatient, _ := service.GetHisPatientById(patient_id)
1119 1119
 
1120
+	//获取患者最后一次的血管通路
1121
+	accessList, _ := service.GetPatientVascularAccess(patient_id)
1122
+
1120 1123
 	if err != nil {
1121 1124
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1122 1125
 		return
@@ -1125,6 +1128,7 @@ func (this *HisProjectApiController) GetPatientcaseHistory() {
1125 1128
 		"patient":    patient,
1126 1129
 		"history":    history,
1127 1130
 		"hispatient": hispatient,
1131
+		"accessList": accessList,
1128 1132
 	})
1129 1133
 }
1130 1134
 

+ 7 - 29
controllers/mobile_api_controllers/dialysis_api_controller.go Прегледај датотеку

@@ -197,20 +197,6 @@ func (this *DialysisAPIController) Scheduals() {
197 197
 				project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
198 198
 			}
199 199
 
200
-			//获取今日透析准备的数据
201
-			//goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())
202
-
203
-			//list, err := service.MobileGetDialysisGoodsSix(orgID, date.Unix())
204
-
205
-			//autoList, _ := service.GetMobileAutoReduce(orgID, date.Unix())
206
-			//for _, item := range goodList {
207
-			//	for _, it := range list {
208
-			//		if item.RecordDate == it.RecordDate && item.PatientId == it.PatientId {
209
-			//			item.Children = append(item.Children, it)
210
-			//		}
211
-			//	}
212
-			//}
213
-			//fmt.Println("goodlist888888888888888888888", goodList, err)
214 200
 			this.ServeSuccessJSON(map[string]interface{}{
215 201
 				"scheduals": scheduals,
216 202
 				"project":   project,
@@ -580,19 +566,10 @@ func (this *DialysisAPIController) DialysisRecord() {
580 566
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
581 567
 	}
582 568
 
583
-	//获取今日透析准备的数据
584
-	//goodList, _ := service.MobileGetDialysisGoodsSeven(adminInfo.Org.Id, date.Unix())
585
-	//list, _ := service.MobileGetDialysisGoodsSix(adminInfo.Org.Id, date.Unix())
586
-	//
587
-	//autoList, _ := service.GetMobileAutoReduce(adminInfo.Org.Id, date.Unix())
588
-	//for _, item := range goodList {
589
-	//	for _, it := range list {
590
-	//		if item.RecordDate == it.RecordDate && item.PatientId == it.PatientId {
591
-	//			item.Children = append(item.Children, it)
592
-	//		}
593
-	//	}
594
-	//}
595
-
569
+	is_advice_open, _ := service.FindAdviceSettingById(adminInfo.Org.Id)
570
+	if is_advice_open.IsAdviceOpen == 1 {
571
+		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
572
+	}
596 573
 	returnData := map[string]interface{}{
597 574
 		"patient":                        patient,
598 575
 		"schedual":                       schedual,
@@ -623,8 +600,7 @@ func (this *DialysisAPIController) DialysisRecord() {
623 600
 		"is_project_open_config":         is_project_open_config,
624 601
 		"project":                        projects,
625 602
 		"team_projects":                  team_projects,
626
-		//"goodList":                       goodList,
627
-		//"autoList":                       autoList,
603
+		"is_advice_open":                 is_advice_open,
628 604
 	}
629 605
 	this.ServeSuccessJSON(returnData)
630 606
 }
@@ -3277,6 +3253,7 @@ func (c *DialysisAPIController) GetLongAdvice() {
3277 3253
 	adminUserInfo := c.GetMobileAdminUserInfo()
3278 3254
 	_, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.Org.Id)
3279 3255
 	_, hisConfig := service.FindXTHisRecordByOrgId(adminUserInfo.Org.Id)
3256
+	is_advice_open, _ := service.FindAdviceSettingById(adminUserInfo.Org.Id)
3280 3257
 	//patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
3281 3258
 	if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有	不开启推送功能,不做任何处理
3282 3259
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -3358,6 +3335,7 @@ func (c *DialysisAPIController) GetLongAdvice() {
3358 3335
 				"advices_two":     RemoveRepeatedElement(advice_three),
3359 3336
 				"is_open_remind":  config.IsOpenRemind,
3360 3337
 				"his_config_open": hisConfig.IsOpen,
3338
+				"is_advice_open":  is_advice_open.IsAdviceOpen,
3361 3339
 			})
3362 3340
 		}
3363 3341
 	}

+ 2 - 2
controllers/mobile_api_controllers/mobile_api_base_controller.go Прегледај датотеку

@@ -59,8 +59,7 @@ type MobileBaseAPIAuthController struct {
59 59
 func (this *MobileBaseAPIAuthController) Prepare() {
60 60
 	token := this.Ctx.GetCookie("token_cookie")
61 61
 	logout_cookie := this.Ctx.GetCookie("logout_cookie")
62
-	fmt.Println("token232232232323232332232332323322332232323", token)
63
-	fmt.Println("login232232232323232332232332323322332232323", logout_cookie)
62
+
64 63
 	//if len(token) == 0{
65 64
 	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
66 65
 	//	this.StopRun()
@@ -76,6 +75,7 @@ func (this *MobileBaseAPIAuthController) Prepare() {
76 75
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeLogOut)
77 76
 			this.StopRun()
78 77
 		} else {
78
+
79 79
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeLoginTimeout)
80 80
 			this.StopRun()
81 81
 		}

+ 2 - 0
controllers/mobile_api_controllers/patient_api_controller.go Прегледај датотеку

@@ -628,6 +628,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
628 628
 			//清空key 值
629 629
 			redis.Set(key, "", time.Second)
630 630
 			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
631
+
631 632
 			redis.Set(keyTwo, "", time.Second)
632 633
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
633 634
 			redis.Set(keyThree, "", time.Second)
@@ -648,6 +649,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
648 649
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
649 650
 			redis := service.RedisClient()
650 651
 			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
652
+
651 653
 			redis.Set(keyTwo, "", time.Second)
652 654
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
653 655
 			redis.Set(keyThree, "", time.Second)

+ 1 - 0
controllers/new_mobile_api_controllers/new_login_api_controller.go Прегледај датотеку

@@ -23,6 +23,7 @@ type NewLoginApiController struct {
23 23
 
24 24
 func (this *NewLoginApiController) GetLogin() {
25 25
 	token_cookie := this.Ctx.GetCookie("token_cookie")
26
+
26 27
 	if len(token_cookie) == 0 {
27 28
 		this.ServeSuccessJSON(map[string]interface{}{
28 29
 			"isLogin": false,

+ 5 - 1
controllers/patient_api_controller.go Прегледај датотеку

@@ -735,7 +735,11 @@ func (c *PatientApiController) EditLapseto() {
735 735
 	err = service.EditPatientLapseto(&patient, &lapseto)
736 736
 
737 737
 	if lapseto.LapsetoType == 3 || lapseto.LapsetoType == 2 {
738
-		service.UpdateScheduleByDeathTime(id, lapsetoTimeUnix.Unix())
738
+		timeStr := time.Now().Format("2006-01-02")
739
+		timeLayout := "2006-01-02 15:04:05"
740
+		timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
741
+		timenow := timeStringToTime.Unix()
742
+		service.UpdateScheduleByDeathTime(id, timenow)
739 743
 		service.UpdateScheduleItemByPatientId(id)
740 744
 	}
741 745
 

+ 20 - 1
controllers/schedule_api_controller.go Прегледај датотеку

@@ -1894,7 +1894,16 @@ func (this *ScheduleApiController) ExportScheduleTemplate() {
1894 1894
 				for _, item := range schedules {
1895 1895
 					service.CreateScheduleTemplate(item)
1896 1896
 				}
1897
-
1897
+				//查询已经转出或者死亡的患者
1898
+				patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
1899
+				for _, it := range patientList {
1900
+					timeStr := time.Now().Format("2006-01-02")
1901
+					timeLayout := "2006-01-02 15:04:05"
1902
+					timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
1903
+					timenow := timeStringToTime.Unix()
1904
+					service.UpdateScheduleByDeathTime(it.ID, timenow)
1905
+					service.UpdateScheduleItemByPatientId(it.ID)
1906
+				}
1898 1907
 				log := models.ExportLog{
1899 1908
 					LogType:    3,
1900 1909
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
@@ -2217,6 +2226,16 @@ func (this *ScheduleApiController) GetCopyPatientSchedules() {
2217 2226
 		}
2218 2227
 
2219 2228
 		err := service.AddPatientSchedule(&schedule)
2229
+		patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
2230
+		for _, it := range patientList {
2231
+			timeStr := time.Now().Format("2006-01-02")
2232
+			timeLayout := "2006-01-02 15:04:05"
2233
+			timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
2234
+			timenow := timeStringToTime.Unix()
2235
+			service.UpdateScheduleByDeathTime(it.ID, timenow)
2236
+			service.UpdateScheduleItemByPatientId(it.ID)
2237
+		}
2238
+
2220 2239
 		if err != nil {
2221 2240
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2222 2241
 			return

+ 66 - 2
models/his_deposit_models.go Прегледај датотеку

@@ -23,7 +23,7 @@ type DepositHistory struct {
23 23
 	DepositCode    string          `gorm:"column:deposit_code" json:"deposit_code" form:"deposit_code"`
24 24
 	Deposit        decimal.Decimal `gorm:"column:deposit" json:"deposit" form:"deposit"`                         //本次操作金额
25 25
 	SurplusDeposit decimal.Decimal `gorm:"column:surplus_deposit" json:"surplus_deposit" form:"surplus_deposit"` //剩余金额
26
-	DepositStatus  int64           `gorm:"column:deposit_status" json:"deposit_status" form:"deposit_status"`    //1:充值,2:扣费,3:退费
26
+	DepositStatus  int64           `gorm:"column:deposit_status" json:"deposit_status" form:"deposit_status"`    //1:充值,2:扣费,3:退款,4:退
27 27
 	Status         int64           `gorm:"column:status" json:"status" form:"status"`
28 28
 	CreateId       int64           `gorm:"column:create_id" json:"create_id" form:"create_id"`
29 29
 	Ctime          int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
@@ -52,7 +52,7 @@ type DepositHistoryname struct {
52 52
 	DepositCode    string          `gorm:"column:deposit_code" json:"deposit_code" form:"deposit_code"`
53 53
 	Deposit        decimal.Decimal `gorm:"column:deposit" json:"deposit" form:"deposit"`                         //本次操作金额
54 54
 	SurplusDeposit decimal.Decimal `gorm:"column:surplus_deposit" json:"surplus_deposit" form:"surplus_deposit"` //剩余金额
55
-	DepositStatus  int64           `gorm:"column:deposit_status" json:"deposit_status" form:"deposit_status"`    //1:充值,2:扣费,3:退费
55
+	DepositStatus  int64           `gorm:"column:deposit_status" json:"deposit_status" form:"deposit_status"`    //1:充值,2:扣费,3:退款,4:退
56 56
 	Status         int64           `gorm:"column:status" json:"status" form:"status"`
57 57
 	CreateId       int64           `gorm:"column:create_id" json:"create_id" form:"create_id"`
58 58
 	Ctime          int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
@@ -60,12 +60,36 @@ type DepositHistoryname struct {
60 60
 	TrialStatus    int64           `gorm:"column:trial_status" json:"trial_status" form:"trial_status"` //审核状态0:未审核 ,1:已审核
61 61
 	Remarks        string          `gorm:"column:remarks" json:"remarks" form:"remarks"`                //备注
62 62
 	Name           string          ` json:"name" `
63
+	HisName        string          `json:"his_name"`
64
+	Starttime      string          `json:"starttime"` //创建时间
63 65
 }
64 66
 
65 67
 func (DepositHistoryname) TableName() string {
66 68
 	return "sgj_xt.his_deposit_history"
67 69
 }
68 70
 
71
+type RefundList struct {
72
+	ID             int64           `gorm:"column:id" json:"id" form:"id"`
73
+	UserOrgId      int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`          //机构id
74
+	HisPatientId   int64           `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"` //his病人id
75
+	DepositCode    string          `gorm:"column:deposit_code" json:"deposit_code" form:"deposit_code"`
76
+	Deposit        decimal.Decimal `gorm:"column:deposit" json:"deposit" form:"deposit"`                         //本次操作金额
77
+	SurplusDeposit decimal.Decimal `gorm:"column:surplus_deposit" json:"surplus_deposit" form:"surplus_deposit"` //剩余金额
78
+	DepositStatus  int64           `gorm:"column:deposit_status" json:"deposit_status" form:"deposit_status"`    //1:充值,2:扣费,3:退款,4:退费
79
+	Status         int64           `gorm:"column:status" json:"status" form:"status"`
80
+	CreateId       int64           `gorm:"column:create_id" json:"create_id" form:"create_id"`
81
+	Ctime          int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
82
+	Mtime          int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
83
+	TrialStatus    int64           `gorm:"column:trial_status" json:"trial_status" form:"trial_status"` //审核状态0:未审核 ,1:已审核
84
+	Starttime      string          `json:"starttime"`                                                   //申请时间
85
+	Name           string          ` json:"name" `                                                      //申请人
86
+	HisName        string          `json:"his_name"`
87
+}
88
+
89
+func (RefundList) TableName() string {
90
+	return "sgj_xt.his_deposit_history"
91
+}
92
+
69 93
 type CreateUser struct {
70 94
 	ID   int64  `gorm:"column:id" json:"id" form:"id"`
71 95
 	Name string `gorm:"column:name" json:"name" form:"name"`
@@ -95,3 +119,43 @@ type Deposit1 struct {
95 119
 func (Deposit1) TableName() string {
96 120
 	return "sgj_xt.his_deposit"
97 121
 }
122
+
123
+//扣费明细列表
124
+type Details struct {
125
+	ID         int64           `json:"id"`          //原始code
126
+	Code       string          `json:"code"`        //就诊号
127
+	Number     string          `json:"number"`      //批号,用来跳转用的
128
+	NameId     int64           `json:"name_id"`     //患者id
129
+	Name       string          `json:"name"`        //患者名字
130
+	Chargetype string          `json:"chargetype"`  //医收费类型
131
+	Total      decimal.Decimal `json:"total"`       //医疗费总额
132
+	Decimal    decimal.Decimal `json:"decimal"`     //押金支付金额
133
+	ChargeDate string          `json:"charge_date"` //收费日期
134
+}
135
+
136
+//扣费汇总
137
+type DeductionSummary struct {
138
+	Name    string          `json:"name"`    //患者名字
139
+	Total   decimal.Decimal `json:"total"`   //医疗费总额
140
+	Decimal decimal.Decimal `json:"decimal"` //押金支付金额
141
+}
142
+
143
+type GetorgName struct {
144
+	ID      int64  `json:"id"`
145
+	OrgName string `json:"org_name"`
146
+}
147
+
148
+func (GetorgName) TableName() string {
149
+	return "sgj_users.sgj_user_org"
150
+}
151
+
152
+//获取就诊号
153
+type GetMdtrtId struct {
154
+	Id      int64  `json:"id"`
155
+	MdtrtId string `json:"mdtrt_id"`
156
+	Number  string `json:"number"`
157
+}
158
+
159
+func (GetMdtrtId) TableName() string {
160
+	return "sgj_xt.his_order"
161
+}

+ 1 - 0
models/his_models.go Прегледај датотеку

@@ -1022,6 +1022,7 @@ type HisOrder struct {
1022 1022
 	DoctorName            string    `gorm:"-" json:"doctor_name" form:"doctor_name"`
1023 1023
 	Creator               int64     `gorm:"column:creator" json:"creator" form:"creator"`
1024 1024
 	PType                 int64     `gorm:"column:p_type" json:"p_type" form:"p_type"`
1025
+	Decimal               float64   `gorm:"column:decimal" json:"decimal" form:"decimal"`
1025 1026
 
1026 1027
 	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
1027 1028
 	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`

+ 1 - 0
service/admin_service.go Прегледај датотеку

@@ -30,6 +30,7 @@ func GetTotalOrgCount() (int, error) {
30 30
 		return 0, err
31 31
 	}
32 32
 	return count, nil
33
+
33 34
 }
34 35
 
35 36
 // 获取一段时间内注册的机构数量

+ 7 - 0
service/dialysis_service.go Прегледај датотеку

@@ -1433,6 +1433,13 @@ func GetAllPcPatientListByListSeven(orgID int64) (patients []*MSchedualPatientVM
1433 1433
 	return patients, err
1434 1434
 }
1435 1435
 
1436
+func GetAllPcPatientListByListEight(orgID int64) (patients []*MSchedualPatientVMList, err error) {
1437
+
1438
+	err = readDb.Where("user_org_id=? and status=1", orgID).Find(&patients).Error
1439
+
1440
+	return patients, err
1441
+}
1442
+
1436 1443
 func GetAllPcPatientListByList(orgID int64) (patients []*MSchedualPatientVMList, err error) {
1437 1444
 	redis := RedisClient()
1438 1445
 	defer redis.Close()

+ 474 - 13
service/his_deposit_service.go Прегледај датотеку

@@ -4,9 +4,11 @@ import (
4 4
 	"XT_New/models"
5 5
 	"XT_New/utils"
6 6
 	"fmt"
7
+	"github.com/jinzhu/gorm"
7 8
 	"github.com/shopspring/decimal"
8 9
 	"math/rand"
9 10
 	"strconv"
11
+	"strings"
10 12
 	"time"
11 13
 )
12 14
 
@@ -42,6 +44,7 @@ func UpDeposit(code, remarks string, his_patient_id, orgid, trial_status, create
42 44
 			UserOrgId:    orgid,
43 45
 			HisPatientId: his_patient_id,
44 46
 			Ctime:        time.Now().Unix(),
47
+			Mtime:        time.Now().Unix(),
45 48
 			Status:       1,
46 49
 		}
47 50
 		i, d, err := AddDeposit(de)
@@ -52,6 +55,7 @@ func UpDeposit(code, remarks string, his_patient_id, orgid, trial_status, create
52 55
 		tmp = i
53 56
 		tmpdeposit = d
54 57
 	}
58
+	s_deposit := tmpdeposit
55 59
 	if trial_status == 1 {
56 60
 		de := models.Deposit{
57 61
 			ID:      tmp,
@@ -63,13 +67,14 @@ func UpDeposit(code, remarks string, his_patient_id, orgid, trial_status, create
63 67
 			utils.ErrorLog("添加用户押金失败: %v", err.Error())
64 68
 			return
65 69
 		}
70
+		s_deposit = deposit.Add(tmpdeposit)
66 71
 	}
67 72
 	dehistory := models.DepositHistory{
68 73
 		UserOrgId:      orgid,
69 74
 		HisPatientId:   his_patient_id,
70 75
 		DepositCode:    code,
71
-		Deposit:        deposit,                 //本次操作的押金
72
-		SurplusDeposit: tmpdeposit.Add(deposit), //剩余金额
76
+		Deposit:        deposit,   //本次操作的押金
77
+		SurplusDeposit: s_deposit, //剩余金额
73 78
 		DepositStatus:  1,
74 79
 		Status:         1,
75 80
 		CreateId:       createid,
@@ -197,6 +202,7 @@ func GetMonth() (int64, int64) {
197 202
 	timeMonthEndUnix1 := timeToday.AddDate(0, 1, -timeToday.Day()+1).Unix() - 1                            // 获取下个月第一天/ 本月最后一天24点 时间戳类型
198 203
 	return timeMonthStartUnix1, timeMonthEndUnix1
199 204
 }
205
+
200 206
 func GetCreateidName(id int64) string {
201 207
 	var tmp models.CreateUser
202 208
 	XTReadDB().Select("name").Where("id = ?", id).Find(&tmp)
@@ -209,7 +215,7 @@ func UpDecimalHistory(id int64) (err error) {
209 215
 	tx := XTWriteDB().Begin()
210 216
 	defer func() {
211 217
 		if err != nil {
212
-			utils.ErrorLog("事务失败,原因为", err)
218
+			utils.ErrorLog("事务失败,原因为: %v", err)
213 219
 			tx.Rollback()
214 220
 		} else {
215 221
 			tx.Commit()
@@ -261,7 +267,10 @@ func GetDecimalHistoryOne(id int64) (history models.DepositHistory, err error) {
261 267
 //根据患者id获取该患者当前剩余的押金
262 268
 func GetUserMoney(id, orgid int64) decimal.Decimal {
263 269
 	tmp := models.Deposit{}
264
-	XTReadDB().Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&tmp)
270
+	err := XTReadDB().Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&tmp).Error
271
+	if err != nil {
272
+		return decimal.NewFromFloat(0)
273
+	}
265 274
 	return tmp.Deposit
266 275
 }
267 276
 
@@ -282,23 +291,475 @@ func GetFlowList(id, orgid, stime, etime, deposit_status int64) (deposit []model
282 291
 	return
283 292
 }
284 293
 
294
+//获取患者押金列表
285 295
 func GetUserList(page, limit, orgid int64, keyword string, slicekey []int64) (m []models.Deposit1, total int64, err error) {
286 296
 	db := XTReadDB().Model(&models.Deposit{}).Where("status = 1 and user_org_id = ? ", orgid)
287 297
 	offset := (page - 1) * limit
288
-	if len(slicekey) > 0 {
289
-		tmp := ""
290
-		for i := 0; i < len(slicekey); i++ {
291
-			tmp = tmp + " his_patient_id = " + strconv.FormatInt(slicekey[i], 10)
292
-			if i < len(slicekey)-1 {
293
-				tmp = tmp + " or "
298
+	if len(keyword) > 0 {
299
+		db = db.Where(" his_patient_id = ? ", keyword)
300
+	}
301
+	err = db.Count(&total).Offset(offset).Order("mtime desc").Find(&m).Error
302
+	return
303
+}
304
+
305
+//扣费明细列表
306
+func DeductionList(orgid, stime, etime int64, keyword string, slicekey []int64) (deposithistory []models.DepositHistory, err error) {
307
+	db := XTReadDB().Model(&models.DepositHistory{}).Where("status = 1 and user_org_id = ? and deposit_status = 2 ", orgid).Where("ctime >= ? and ctime <= ?", stime, etime)
308
+	if len(keyword) > 0 {
309
+		var tmp string = "deposit_code like ?"
310
+		if len(slicekey) > 0 {
311
+			for i := 0; i < len(slicekey); i++ {
312
+				tmp = tmp + " or his_patient_id = " + strconv.FormatInt(slicekey[i], 10)
294 313
 			}
295 314
 		}
296
-		db = db.Where(tmp)
315
+		keyword = "%" + keyword + "%"
316
+		db = db.Where(tmp, keyword)
317
+	}
318
+	err = db.Order("ctime desc").Find(&deposithistory).Error
319
+	return
320
+}
321
+
322
+//获取医疗费总额
323
+func MedicalTotal(orgid, patient_id int64, code string) decimal.Decimal {
324
+	tmp := models.HisChargeSettleOrder{}
325
+	XTReadDB().Model(&models.HisChargeSettleOrder{}).Where("mdtrt_id = ? and patient_id = ? and user_org_id = ? and status = 1 and order_status = 2", code, patient_id, orgid).Find(&tmp)
326
+	return decimal.NewFromFloat(tmp.MedfeeSumamt)
327
+}
328
+
329
+//根据就诊号查询出医收费类型
330
+func CodeToChargetype(orgid int64, code string) (s string) {
331
+	tmp := models.HisPrintPatient{}
332
+	XTReadDB().Model(&models.HisPrintPatient{}).Where("number = ? and user_org_id = ?", code, orgid).Find(&tmp)
333
+	//tmp.BalanceAccountsType
334
+	switch tmp.BalanceAccountsType {
335
+	case 1:
336
+		s = "医保"
337
+	case 2:
338
+		s = "自费"
339
+	case 3:
340
+		s = "公费"
341
+	case 4:
342
+		s = "农保"
343
+	case 5:
344
+		s = "会员"
345
+	case 6:
346
+		s = "职工"
347
+	case 7:
348
+		s = "合同"
349
+	case 8:
350
+		s = "医保自费"
351
+	default:
352
+		s = "类型未定义"
353
+	}
354
+	return
355
+}
356
+
357
+//扣除患者的押金,并生成一条扣费历史记录
358
+//orgid 机构id;
359
+//his_user_id	患者id;
360
+//create_id		创建者id;
361
+//code		就诊号;
362
+//deposit	本次使用的押金金额,支持float64、int、int64、decimal.Decimal类型
363
+func SpendDeposit(orgid, his_user_id, create_id int64, code string, deposit interface{}) (err error) {
364
+	tmp_deposit := decimal.Decimal{} //本次患者使用的押金
365
+	tmp_deposit, err = ToDecimal(deposit)
366
+	if err != nil {
367
+		return
368
+	}
369
+	//开事务
370
+	tx := XTWriteDB().Begin()
371
+	defer func() {
372
+		if err != nil {
373
+			utils.ErrorLog("事务失败,原因为: %v", err.Error())
374
+			tx.Rollback()
375
+		} else {
376
+			tx.Commit()
377
+		}
378
+	}()
379
+	//查询患者押金
380
+	tmp := models.Deposit{}
381
+	err = tx.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_user_id, orgid).Find(&tmp).Error
382
+	if err != nil {
383
+		err = fmt.Errorf("押金余额不足")
384
+		return
385
+	}
386
+	//判断能否扣除
387
+	if tmp.Deposit.Cmp(tmp_deposit) == -1 {
388
+		err = fmt.Errorf("押金余额不足")
389
+		return
390
+	}
391
+	//扣除患者押金
392
+	err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", tmp.ID).Updates(map[string]interface{}{
393
+		"mtime":   time.Now().Unix(),
394
+		"deposit": tmp.Deposit.Sub(tmp_deposit),
395
+	}).Error
396
+	if err != nil {
397
+		return
398
+	}
399
+	//生成一条历史记录
400
+	dehistory := models.DepositHistory{
401
+		UserOrgId:      orgid,
402
+		HisPatientId:   his_user_id,
403
+		DepositCode:    code,
404
+		Deposit:        tmp_deposit,
405
+		SurplusDeposit: tmp.Deposit.Sub(tmp_deposit),
406
+		DepositStatus:  2,
407
+		Status:         1,
408
+		CreateId:       create_id,
409
+		Ctime:          time.Now().Unix(),
410
+		Mtime:          time.Now().Unix(),
411
+		TrialStatus:    1,
412
+	}
413
+	err = tx.Create(&dehistory).Error
414
+	return
415
+}
416
+
417
+//新增一条退款申请
418
+func RefundApplication(orgid, his_patient_id, trial_status, createid int64, code string, deposit decimal.Decimal) (err error) {
419
+	//开事务
420
+	tx := XTWriteDB().Begin()
421
+	defer func() {
422
+		if err != nil {
423
+			utils.ErrorLog("事务失败,原因为: %v", err.Error())
424
+			tx.Rollback()
425
+		} else {
426
+			tx.Commit()
427
+		}
428
+	}()
429
+	//获取患者当前余额
430
+	tmp := models.Deposit{}
431
+	err = tx.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_patient_id, orgid).Find(&tmp).Error
432
+	if err != nil {
433
+		return
434
+	}
435
+	//判断是否可以退款
436
+	if tmp.Deposit.Cmp(deposit) == -1 {
437
+		err = fmt.Errorf("退款金额不得大于押金余额!")
438
+		return
439
+	}
440
+	s_deposit := tmp.Deposit
441
+	//判断是否审核通过,通过更新当前押金,否则只新增一条历史记录
442
+	if trial_status == 1 {
443
+		//更新患者当前押金余额
444
+		err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", tmp.ID).Updates(map[string]interface{}{
445
+			"mtime":   time.Now().Unix(),
446
+			"deposit": tmp.Deposit.Sub(deposit),
447
+		}).Error
448
+		if err != nil {
449
+			return
450
+		}
451
+		s_deposit = tmp.Deposit.Sub(deposit)
452
+	}
453
+	//生成一条历史记录
454
+	dehistory := models.DepositHistory{
455
+		UserOrgId:      orgid,
456
+		HisPatientId:   his_patient_id,
457
+		DepositCode:    code,
458
+		Deposit:        deposit,
459
+		SurplusDeposit: s_deposit,
460
+		DepositStatus:  3, //3退款,4退费
461
+		Status:         1,
462
+		CreateId:       createid,
463
+		Ctime:          time.Now().Unix(),
464
+		Mtime:          time.Now().Unix(),
465
+		TrialStatus:    trial_status,
466
+	}
467
+	err = tx.Create(&dehistory).Error
468
+	return
469
+}
470
+
471
+//退款审核通过/拒绝批量处理
472
+func RefundReviewMore(orgid, trial_status int64, ids string) (err error) {
473
+	//处理下字符串
474
+	t_ids := ""
475
+	if ids[len(ids)-1] == 44 {
476
+		t_ids = ids[:len(ids)-1]
297 477
 	} else {
298
-		if len(keyword) > 0 {
478
+		t_ids = ids
479
+	}
480
+	tmp_id := strings.Split(t_ids, ",")
481
+	//开事务
482
+	tx := XTWriteDB().Begin()
483
+	defer func() {
484
+		if err != nil {
485
+			utils.ErrorLog("事务失败,原因为: %v", err.Error())
486
+			tx.Rollback()
487
+		} else {
488
+			tx.Commit()
489
+		}
490
+	}()
491
+	//循环处理id
492
+	for i := 0; i < len(tmp_id); i++ {
493
+		var id int64
494
+		id, err = strconv.ParseInt(tmp_id[i], 10, 64)
495
+		if err != nil {
496
+			return err
497
+		}
498
+		err = RefundReview(orgid, id, trial_status, tx)
499
+		if err != nil {
500
+			return err
501
+		}
502
+	}
503
+	return err
504
+}
505
+
506
+//退款审核通过/拒绝
507
+func RefundReview(orgid, id, trial_status int64, tx *gorm.DB) (err error) {
508
+	//根据id查询该条历史记录
509
+	history := models.DepositHistory{}
510
+	err = tx.Model(&models.DepositHistory{}).Where("id = ? and status = 1", id).Find(&history).Error
511
+	if err != nil {
512
+		return err
513
+	}
514
+	//判断状态是否为未审核
515
+	if history.TrialStatus != 0 {
516
+		err = fmt.Errorf("所选单据中包含了无需审核的单据")
517
+		return err
518
+	}
519
+	//判断类型是否为3,3代表退款,4为退费
520
+	if history.DepositStatus != 3 {
521
+		err = fmt.Errorf("所选单据中包含了无需审核的单据")
522
+		return err
523
+	}
524
+	up := make(map[string]interface{})
525
+	//通过
526
+	if trial_status == 1 {
527
+		//拿患者的id和机构id在去查患者的余额
528
+		tt := models.Deposit{}
529
+		err = tx.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", history.HisPatientId, orgid).Find(&tt).Error
530
+		if err != nil {
531
+			return err
532
+		}
533
+		//判断是否可以修改患者押金
534
+		if tt.Deposit.Cmp(history.Deposit) == -1 {
535
+			err = fmt.Errorf("当前押金余额小于退款金额,无法完成退款")
536
+			return err
537
+		}
538
+		//修改患者押金
539
+		err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", tt.ID).Updates(map[string]interface{}{
540
+			"mtime":   time.Now().Unix(),
541
+			"deposit": tt.Deposit.Sub(history.Deposit),
542
+		}).Error
543
+		if err != nil {
544
+			return err
545
+		}
546
+		up = map[string]interface{}{
547
+			"mtime":           time.Now().Unix(),
548
+			"surplus_deposit": tt.Deposit.Sub(history.Deposit),
549
+			"trial_status":    1,
550
+		}
551
+	} else {
552
+		up = map[string]interface{}{
553
+			"mtime":        time.Now().Unix(),
554
+			"trial_status": 2,
555
+		}
556
+	}
557
+	//修改一条历史记录
558
+	err = tx.Model(&models.DepositHistory{}).Where("id = ? and status = 1", id).Updates(up).Error
559
+	return err
560
+}
561
+
562
+//退款删除
563
+func DeleteRefund(orgid, id int64) (err error) {
564
+	//根据id查询历史记录
565
+	history := models.DepositHistory{}
566
+	err = XTReadDB().Model(&models.DepositHistory{}).Where("id = ?", id).Find(&history).Error
567
+	if err != nil {
568
+		return
569
+	}
570
+	//判断是否可以删除
571
+	if history.TrialStatus == 1 || history.DepositStatus != 3 {
572
+		err = fmt.Errorf("当前状态不可删除!")
573
+		return
574
+	}
575
+	//删除
576
+	err = XTWriteDB().Model(&models.DepositHistory{}).Where("id = ?", id).Updates(map[string]interface{}{
577
+		"mtime":  time.Now().Unix(),
578
+		"status": 0,
579
+	}).Error
580
+
581
+	return
582
+}
583
+
584
+//更改退款申请
585
+func ChangeRefund(orgid, his_patient_id, trial_status, id int64, code string, deposit decimal.Decimal) (err error) {
586
+	//开事务
587
+	tx := XTWriteDB().Begin()
588
+	defer func() {
589
+		if err != nil {
590
+			utils.ErrorLog("事务失败,原因为: %v", err.Error())
591
+			tx.Rollback()
592
+		} else {
593
+			tx.Commit()
594
+		}
595
+	}()
596
+	//获取患者当前余额
597
+	tmp := models.Deposit{}
598
+	err = tx.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_patient_id, orgid).Find(&tmp).Error
599
+	if err != nil {
600
+		return
601
+	}
602
+	//判断是否可以退款
603
+	if tmp.Deposit.Cmp(deposit) == -1 {
604
+		err = fmt.Errorf("退款金额不得大于押金余额!")
605
+		return
606
+	}
607
+	up := make(map[string]interface{})
608
+	//判断是否审核通过,通过更新当前押金,否则只新增一条历史记录
609
+	if trial_status == 1 {
610
+		//更新患者当前押金余额
611
+		err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", tmp.ID).Updates(map[string]interface{}{
612
+			"mtime":   time.Now().Unix(),
613
+			"deposit": tmp.Deposit.Sub(deposit),
614
+		}).Error
615
+		if err != nil {
299 616
 			return
300 617
 		}
618
+		up = map[string]interface{}{
619
+			"mtime":           time.Now().Unix(),
620
+			"deposit_code":    code,
621
+			"his_patient_id":  his_patient_id,
622
+			"surplus_deposit": tmp.Deposit.Sub(deposit),
623
+			"deposit":         deposit,
624
+			"trial_status":    trial_status,
625
+		}
626
+	} else {
627
+		up = map[string]interface{}{
628
+			"mtime":          time.Now().Unix(),
629
+			"deposit_code":   code,
630
+			"his_patient_id": his_patient_id,
631
+			"deposit":        deposit,
632
+			"trial_status":   trial_status,
633
+		}
634
+	}
635
+	//更新一条历史记录
636
+	err = tx.Model(&models.DepositHistory{}).Where("id = ? and status = 1", id).Updates(up).Error
637
+	return
638
+}
639
+
640
+//退款分页
641
+func RefundList(orgid, stime, etime, refundtype, examinetype int64, keyword string, slicekey []int64) (depo []models.RefundList, err error) {
642
+	db := XTReadDB().Model(&models.DepositHistory{}).Where("status = 1 and user_org_id = ? ", orgid).Where("ctime >= ? and ctime <= ?", stime, etime)
643
+	//退款类型
644
+	switch refundtype {
645
+	case 0:
646
+		db = db.Where(" deposit_status in (3,4) ")
647
+	case 3, 4:
648
+		db = db.Where(" deposit_status = ? ", refundtype)
649
+	default:
650
+		err = fmt.Errorf("退款类型错误")
651
+		return
652
+	}
653
+	//审核状态
654
+	switch examinetype {
655
+	case 0, 1, 2:
656
+		db = db.Where(" trial_status = ? ", examinetype)
657
+	case 3: //代表查询全部
658
+		db = db
659
+	default:
660
+		err = fmt.Errorf("审核状态错误")
661
+		return
662
+	}
663
+	if len(keyword) > 0 {
664
+		tmp := "deposit_code like ? "
665
+		if len(slicekey) > 0 {
666
+			for i := 0; i < len(slicekey); i++ {
667
+				tmp = tmp + " or his_patient_id = " + strconv.FormatInt(slicekey[i], 10)
668
+			}
669
+		}
670
+		keyword = "%" + keyword + "%"
671
+		db = db.Where(tmp, keyword)
672
+	}
673
+	err = db.Order("ctime desc").Find(&depo).Error
674
+	return
675
+
676
+}
677
+
678
+//退回患者的押金,并生成一条退费历史记录
679
+//orgid 机构id
680
+//his_user_id 患者id
681
+//code 编号
682
+//deposit 本次退费的金额,支持float64、int、int64、decimal.Decimal类型
683
+func MoneyIncrease(orgid, his_user_id int64, code string, deposit interface{}) (err error) {
684
+	tmp_deposit := decimal.Decimal{}
685
+	tmp_deposit, err = ToDecimal(deposit)
686
+	if err != nil {
687
+		return
688
+	}
689
+	//开事务
690
+	tx := XTWriteDB().Begin()
691
+	defer func() {
692
+		if err != nil {
693
+			utils.ErrorLog("事务失败,原因为: %v", err.Error())
694
+			tx.Rollback()
695
+		} else {
696
+			tx.Commit()
697
+		}
698
+	}()
699
+	//获取当前患者押金
700
+	tmp := models.Deposit{}
701
+	err = tx.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_user_id, orgid).Find(&tmp).Error
702
+	if err != nil {
703
+		return
704
+	}
705
+	//退回患者押金
706
+	err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", tmp.ID).Updates(map[string]interface{}{
707
+		"mtime":   time.Now().Unix(),
708
+		"deposit": tmp.Deposit.Add(tmp_deposit),
709
+	}).Error
710
+	if err != nil {
711
+		return
712
+	}
713
+	//生成一条退费记录
714
+	dehistory := models.DepositHistory{
715
+		UserOrgId:      orgid,
716
+		HisPatientId:   his_user_id,
717
+		DepositCode:    code,
718
+		Deposit:        tmp_deposit,
719
+		SurplusDeposit: tmp.Deposit.Add(tmp_deposit),
720
+		DepositStatus:  4,
721
+		Status:         1,
722
+		CreateId:       0,
723
+		Ctime:          time.Now().Unix(),
724
+		Mtime:          time.Now().Unix(),
725
+		TrialStatus:    1,
726
+	}
727
+	err = tx.Create(&dehistory).Error
728
+	return
729
+}
730
+func GetorgName(orgid int64) (name string) {
731
+	tmp := models.GetorgName{}
732
+	XTReadDB().Model(&models.GetorgName{}).Where("id = ? ", orgid).Find(&tmp)
733
+	return tmp.OrgName
734
+}
735
+
736
+//根据id查询就诊号
737
+func FindcodeToid(id int64) (code string) {
738
+	tmp := models.GetMdtrtId{}
739
+	XTReadDB().Model(&models.GetMdtrtId{}).Where("id = ?", id).Find(&tmp)
740
+	return tmp.MdtrtId
741
+}
742
+
743
+//根据id查询就诊号
744
+func FindnumberToid(id int64) (number string) {
745
+	tmp := models.GetMdtrtId{}
746
+	XTReadDB().Model(&models.GetMdtrtId{}).Where("id = ?", id).Find(&tmp)
747
+	return tmp.Number
748
+}
749
+
750
+//把其他的类型转换成decimal.Decimal类型
751
+func ToDecimal(i interface{}) (d decimal.Decimal, err error) {
752
+	switch i.(type) {
753
+	case float64:
754
+		d = decimal.NewFromFloat(i.(float64))
755
+	case decimal.Decimal:
756
+		d = i.(decimal.Decimal)
757
+	case int64:
758
+		d = decimal.NewFromFloat(float64(i.(int64)))
759
+	case int:
760
+		d = decimal.NewFromFloat(float64(i.(int)))
761
+	default:
762
+		err = fmt.Errorf("类型解析错误")
301 763
 	}
302
-	err = db.Count(&total).Offset(offset).Order("mtime desc").Find(&m).Error
303 764
 	return
304 765
 }

+ 11 - 0
service/his_project_service.go Прегледај датотеку

@@ -748,6 +748,11 @@ func GetHisPatientByIdThree(id int64) (models.HisPatient, error) {
748 748
 	err := XTReadDB().Model(&patient).Where("id = ? and status = 1", id).First(&patient).Error
749 749
 	return patient, err
750 750
 }
751
+func GetHisPatientByIdThreeTX(id int64, tx *gorm.DB) (models.HisPatient, error) {
752
+	patient := models.HisPatient{}
753
+	err := tx.Model(&patient).Where("id = ? and status = 1", id).First(&patient).Error
754
+	return patient, err
755
+}
751 756
 
752 757
 func GetLastHisPatient(patient_id int64, org_id int64) (his models.HisPatient, err error) {
753 758
 	err = XTReadDB().Model(&models.HisPatient{}).Where("user_org_id = ? AND patient_id = ? and status = 1 AND patient_info <> ''", org_id, patient_id).First(&his).Error
@@ -758,3 +763,9 @@ func GetNewAdminUserES(orgID int64) (es []*models.AdminUserElectronicSignature,
758 763
 	err = readUserDb.Model(&models.AdminUserElectronicSignature{}).Where("org_id=?  and status=1", orgID).Find(&es).Error
759 764
 	return
760 765
 }
766
+
767
+func GetPatientVascularAccess(patient_id int64) (models.XtPatientVascularAccess, error) {
768
+	access := models.XtPatientVascularAccess{}
769
+	err = XTReadDB().Where("patient_id = ? and status = 1", patient_id).Last(&access).Error
770
+	return access, err
771
+}

+ 77 - 1
service/his_service.go Прегледај датотеку

@@ -514,6 +514,21 @@ func GetSettleHisPrescription(org_id int64, patient_id int64, his_patient_id int
514 514
 		Find(&prescription).Error
515 515
 	return
516 516
 }
517
+func GetSettleHisPrescriptionTX(org_id int64, patient_id int64, his_patient_id int64, record_date int64, med_type int64, tx *gorm.DB) (prescription []*models.HisPrescription, err error) {
518
+	err = tx.Model(&models.HisPrescription{}).
519
+		Preload("HisAdditionalCharge", func(tx *gorm.DB) *gorm.DB {
520
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
521
+		}).
522
+		Preload("HisDoctorAdviceInfo", func(tx *gorm.DB) *gorm.DB {
523
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
524
+		}).
525
+		Preload("HisPrescriptionProject", func(tx *gorm.DB) *gorm.DB {
526
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
527
+		}).
528
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND his_patient_id = ? AND p_type <> 1 AND med_type = ?", org_id, record_date, patient_id, his_patient_id, med_type).
529
+		Find(&prescription).Error
530
+	return
531
+}
517 532
 
518 533
 func GetMonthHisPrescription(org_id int64, patient_id int64, start_date int64, end_date int64, med_type int64) (prescription []*models.HisPrescription, err error) {
519 534
 	err = readDb.Model(&models.HisPrescription{}).
@@ -530,6 +545,21 @@ func GetMonthHisPrescription(org_id int64, patient_id int64, start_date int64, e
530 545
 		Find(&prescription).Error
531 546
 	return
532 547
 }
548
+func GetMonthHisPrescriptionTX(org_id int64, patient_id int64, start_date int64, end_date int64, med_type int64, tx *gorm.DB) (prescription []*models.HisPrescription, err error) {
549
+	err = tx.Model(&models.HisPrescription{}).
550
+		Preload("HisAdditionalCharge", func(tx *gorm.DB) *gorm.DB {
551
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
552
+		}).
553
+		Preload("HisDoctorAdviceInfo", func(tx *gorm.DB) *gorm.DB {
554
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
555
+		}).
556
+		Preload("HisPrescriptionProject", func(tx *gorm.DB) *gorm.DB {
557
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
558
+		}).
559
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 AND med_type = ?", org_id, start_date, end_date, patient_id, med_type).
560
+		Find(&prescription).Error
561
+	return
562
+}
533 563
 
534 564
 func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
535 565
 	err = readDb.Model(&models.HisPrescription{}).
@@ -842,11 +872,19 @@ func CreateOrder(order *models.HisOrder) (err error) {
842 872
 	err = writeDb.Create(&order).Error
843 873
 	return
844 874
 }
875
+func CreateOrderTX(order *models.HisOrder, tx *gorm.DB) (err error) {
876
+	err = tx.Create(&order).Error
877
+	return
878
+}
845 879
 
846 880
 func CreateOrderInfo(order *models.HisOrderInfo) (err error) {
847 881
 	err = writeDb.Create(&order).Error
848 882
 	return
849 883
 }
884
+func CreateOrderInfoTX(order *models.HisOrderInfo, tx *gorm.DB) (err error) {
885
+	err = tx.Create(&order).Error
886
+	return
887
+}
850 888
 
851 889
 func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64, p_type int64, his_patient_id int64) (info models.HisPrescriptionInfo, err error) {
852 890
 	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? AND his_patient_id = ? ", org_id, record_date, patient_id, p_type, his_patient_id).First(&info).Error
@@ -966,6 +1004,10 @@ func UpDatePrescriptionNumber(user_org_id int64, ids []int64, number string) (er
966 1004
 	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
967 1005
 	return
968 1006
 }
1007
+func UpDatePrescriptionNumberTX(user_org_id int64, ids []int64, number string, tx *gorm.DB) (err error) {
1008
+	err = tx.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
1009
+	return
1010
+}
969 1011
 
970 1012
 func UpDateAddtionNumber(user_org_id int64, ids []int64, number string) (err error) {
971 1013
 	err = writeDb.Model(&models.HisAdditionalCharge{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
@@ -983,6 +1025,11 @@ func UpDateHisPrescriptionInfoNumber(user_org_id int64, id int64, number string,
983 1025
 
984 1026
 	return
985 1027
 }
1028
+func UpDateHisPrescriptionInfoNumberTX(user_org_id int64, id int64, number string, record_time int64, his_patient_id int64, tx *gorm.DB) (err error) {
1029
+	err = tx.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND his_patient_id = ? AND record_date = ?", user_org_id, his_patient_id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
1030
+
1031
+	return
1032
+}
986 1033
 
987 1034
 func UpDateHospitalHisPrescriptionInfoNumber(user_org_id int64, number string, start_time int64, end_time int64) (err error) {
988 1035
 	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1  AND record_date <= ? AND record_date >= ? ", user_org_id, end_time, start_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
@@ -1208,6 +1255,11 @@ func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
1208 1255
 	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": 3, "mtime": time.Now().Unix()}).Error
1209 1256
 	return
1210 1257
 }
1258
+func UpdataOrderStatusTwoTX(number string, user_org_id int64, tx *gorm.DB) (err error) {
1259
+	err = tx.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 2, "mtime": time.Now().Unix()}).Error
1260
+	err = tx.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 3, "mtime": time.Now().Unix()}).Error
1261
+	return
1262
+}
1211 1263
 
1212 1264
 func CreateErrMsgLog(log *models.HisOrderError) {
1213 1265
 	writeDb.Model(&models.HisOrderError{}).Create(&log)
@@ -1438,6 +1490,10 @@ func GetHisOrderByID(order_id int64) (order models.HisOrder, err error) {
1438 1490
 	err = readDb.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
1439 1491
 	return
1440 1492
 }
1493
+func GetHisOrderByIDTX(order_id int64, tx *gorm.DB) (order models.HisOrder, err error) {
1494
+	err = tx.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
1495
+	return
1496
+}
1441 1497
 
1442 1498
 func GetHisOrderInfoByNumber(order_number string) (order []*models.HisOrderInfo, err error) {
1443 1499
 	err = readDb.Model(&models.HisOrderInfo{}).Where("order_number = ? AND status = 1", order_number).Find(&order).Error
@@ -2243,7 +2299,9 @@ func GetChargeMonthHisPrescriptionFive(org_id int64, patient_id int64, order_num
2243 2299
 
2244 2300
 func UpdataHisPateint(his *models.HisPatient) {
2245 2301
 	writeDb.Save(&his)
2246
-
2302
+}
2303
+func UpdataHisPateintTX(his *models.HisPatient, tx *gorm.DB) {
2304
+	tx.Save(&his)
2247 2305
 }
2248 2306
 
2249 2307
 func SaveHisOrder(his *models.HisOrder) (err error) {
@@ -2269,6 +2327,24 @@ func GetPrescriptionByIds(ids []string, org_id int64) (prescription []*models.Hi
2269 2327
 
2270 2328
 	return
2271 2329
 }
2330
+func GetPrescriptionByIdsTX(ids []string, org_id int64, tx *gorm.DB) (prescription []*models.HisPrescription, err error) {
2331
+	err = tx.Model(&models.HisPrescription{}).
2332
+		Preload("HisAdditionalCharge", func(tx *gorm.DB) *gorm.DB {
2333
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
2334
+		}).
2335
+		Preload("HisDoctorAdviceInfo", func(tx *gorm.DB) *gorm.DB {
2336
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
2337
+		}).
2338
+		Preload("HisPrescriptionProject", func(tx *gorm.DB) *gorm.DB {
2339
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
2340
+		}).Preload("TempHisOrder", func(tx *gorm.DB) *gorm.DB {
2341
+		return tx.Where("status = 1 AND user_org_id = ?", org_id)
2342
+	}).
2343
+		Where("id in (?) AND user_org_id = ? AND status = 1", ids, org_id).
2344
+		Find(&prescription).Error
2345
+
2346
+	return
2347
+}
2272 2348
 
2273 2349
 func GetNewAllUnChargeHisPatientListTwo(org_id int64, keywords string, record_date int64) (patients []*NewTempPatients, err error) {
2274 2350
 	db := readDb.Model(&NewTempPatients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)

+ 6 - 0
service/schedule_service.go Прегледај датотеку

@@ -1154,3 +1154,9 @@ func GetSolutionScheduleBySchedule(orgid int64, zonid int64, classtype int64, sc
1154 1154
 	}).Find(&schedule).Error
1155 1155
 	return schedule, err
1156 1156
 }
1157
+
1158
+func GetDeathPatient(orgid int64) (patient []*models.XtPatients, err error) {
1159
+
1160
+	err = XTReadDB().Where("user_org_id = ? and (lapseto = 2 || lapseto = 3) and status = 1", orgid).Find(&patient).Error
1161
+	return patient, err
1162
+}

+ 4 - 0
service/self_drug_service.go Прегледај датотеку

@@ -547,6 +547,10 @@ type Drugs struct {
547 547
 	HospApprFlag          int64    `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
548 548
 	LmtUsedFlag           int64    `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
549 549
 	PrescribingNumberUnit string   `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
550
+	MinNumber             int64    `gorm:"column:min_number" json:"min_number" form:"min_number"`
551
+	Dose                  float64  `gorm:"column:dose" json:"dose" form:"dose"`
552
+	DoseUnit              string   `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
553
+	MaxUnit               string   `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
550 554
 }
551 555
 
552 556
 func (Drugs) TableName() string {