Browse Source

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

XMLWAN 3 years ago
parent
commit
4aa9905869

+ 20 - 4
controllers/common_api_controller.go View File

@@ -1102,6 +1102,8 @@ func (this *CommonApiController) GetNormData() {
1102 1102
 func (this *CommonApiController) GetFirstQuarter() {
1103 1103
 	orgid := this.GetAdminUserInfo().CurrentOrgId
1104 1104
 	lapseto, _ := this.GetInt64("lapseto")
1105
+	origin, _ := this.GetInt64("origin")
1106
+
1105 1107
 	fmt.Println("转归", lapseto)
1106 1108
 	startime := this.GetString("startime")
1107 1109
 
@@ -1116,17 +1118,17 @@ func (this *CommonApiController) GetFirstQuarter() {
1116 1118
 	entime := endDate.Unix()
1117 1119
 	fmt.Println("结束日期", entime)
1118 1120
 	//统计数值类型的数据
1119
-	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
1121
+	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto, origin)
1120 1122
 	//统计rang_type== 2
1121
-	countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto)
1123
+	countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto, origin)
1122 1124
 
1123 1125
 	//获取收缩压数据
1124
-	systolic, systolicTotal, parseDateErr := service.GetSystolicBloodPressure(orgid, statime, entime)
1126
+	systolic, systolicTotal, parseDateErr := service.GetSystolicBloodPressureTwo(orgid, statime, entime, lapseto, origin)
1125 1127
 	//统计收缩压合格的数据
1126 1128
 	//systolic, sysstandTotal, parseDateErr := service.GetStandSystolicBloodPressure(orgid, statime, entime)
1127 1129
 
1128 1130
 	//获取舒张压数据
1129
-	diastolic, diastotal, parseDateErr := service.GetDiastolicBloodPressure(orgid, statime, entime)
1131
+	diastolic, diastotal, parseDateErr := service.GetDiastolicBloodPressureTwo(orgid, statime, entime, lapseto, origin)
1130 1132
 	//获取合格舒张压数据
1131 1133
 	//diastolic, diasstandtotal, parseDateErr := service.GetDiastolicStandPressure(orgid, statime, entime)
1132 1134
 	normData, _ := service.GetNormData(orgid)
@@ -2142,3 +2144,17 @@ func (this *CommonApiController) GetRolloutCount() {
2142 2144
 		"rollout": rollout,
2143 2145
 	})
2144 2146
 }
2147
+
2148
+func (this *CommonApiController) GetCheckExamine() {
2149
+	//check_type, _ := this.GetInt64("check_type")
2150
+	//start_time, _ := this.GetInt64("start_time")
2151
+	//end_time, _ := this.GetInt64("end_time")
2152
+	//total, _ := service.GetAllPatientCount(this.GetAdminUserInfo().CurrentOrgId)
2153
+	//xcg_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 1)    //血常规
2154
+	//xysh_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 2)   //血液生化
2155
+	//ipth_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 3)   //全段甲状旁腺激素
2156
+	//xqtdb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 4)  //血清铁蛋白和转铁蛋白饱和度
2157
+	//xqqbdb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 5) //血清前白蛋白
2158
+	//cfydb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 6)  //c反应蛋白
2159
+	//
2160
+}

+ 5 - 0
controllers/common_api_router.go View File

@@ -59,4 +59,9 @@ func CommonApiControllersRegisterRouters() {
59 59
 	beego.Router("/com/api/getreatmodelist", &CommonApiController{}, "Get:GetTreatModeList")
60 60
 	beego.Router("/com/api/getcountmodeid", &CommonApiController{}, "Get:GetCountModeId")
61 61
 	beego.Router("/com/api/getrolloutcount", &CommonApiController{}, "Get:GetRolloutCount")
62
+
63
+	beego.Router("/com/api/getrolloutcount", &CommonApiController{}, "Get:GetRolloutCount")
64
+
65
+	beego.Router("/com/api/getcheckexamine", &CommonApiController{}, "Get:GetCheckExamine")
66
+
62 67
 }

+ 75 - 38
controllers/his_api_controller.go View File

@@ -105,10 +105,30 @@ func HisManagerApiRegistRouters() {
105 105
 
106 106
 	beego.Router("/api/orders", &HisApiController{}, "get:GetAllOrder")
107 107
 
108
+	beego.Router("/api/psn/ncds/delete", &HisApiController{}, "post:DeleteNCDS")
109
+
110
+	beego.Router("/api/bailin/export", &PublicApiController{}, "get:GetBaiLinExportData")
108 111
 	beego.Router("/api/his/gethistdoctoradviceinfo", &HisApiController{}, "get:GetHisDoctorAdviceInfo")
109 112
 
110 113
 }
111 114
 
115
+func (c *PublicApiController) GetBaiLinExportData() {
116
+	data := service.GetBaiLinOrderData()
117
+	fmt.Println(len(data))
118
+	var new_data []*models.NewCustomHisOrder
119
+	for _, item := range data {
120
+		if item.NewCustomHisOrderInfo.NewCustomHisPrescriptionProject.ID != 0 {
121
+			new_data = append(new_data, item)
122
+		}
123
+
124
+	}
125
+	fmt.Println(len(new_data))
126
+
127
+	c.ServeSuccessJSON(map[string]interface{}{
128
+		"list": new_data,
129
+	})
130
+}
131
+
112 132
 func (c *HisApiController) GetHisUnChargePatientList() {
113 133
 	record_date := c.GetString("record_date")
114 134
 	timeLayout := "2006-01-02"
@@ -734,7 +754,6 @@ func (c *HisApiController) CreateHisPrescription() {
734 754
 								//查询药品的所有库存
735 755
 								list, _ := service.GetDrugWarehouseInfoPrescription(drug_id, adminInfo.CurrentOrgId)
736 756
 								var total_count int64
737
-
738 757
 								for _, it := range list {
739 758
 									total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
740 759
 								}
@@ -958,7 +977,7 @@ func (c *HisApiController) CreateHisPrescription() {
958 977
 		redis.Set(keyOne, "", time.Second)
959 978
 		keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
960 979
 		redis.Set(keySeven, "", time.Second)
961
-		redis.Close()
980
+		defer redis.Close()
962 981
 	} else {
963 982
 		hpInfo = models.HisPrescriptionInfo{
964 983
 
@@ -992,7 +1011,7 @@ func (c *HisApiController) CreateHisPrescription() {
992 1011
 		redis.Set(keyOne, "", time.Second)
993 1012
 		keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
994 1013
 		redis.Set(keySeven, "", time.Second)
995
-		redis.Close()
1014
+		defer redis.Close()
996 1015
 	}
997 1016
 
998 1017
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
@@ -1085,7 +1104,7 @@ func (c *HisApiController) CreateHisPrescription() {
1085 1104
 					redis.Set(keyOne, "", time.Second)
1086 1105
 					keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
1087 1106
 					redis.Set(keySeven, "", time.Second)
1088
-					redis.Close()
1107
+					defer redis.Close()
1089 1108
 				} else {
1090 1109
 					tempPrescription.ID = id
1091 1110
 					tempPrescription.Type = types
@@ -1104,7 +1123,7 @@ func (c *HisApiController) CreateHisPrescription() {
1104 1123
 					redis.Set(keyOne, "", time.Second)
1105 1124
 					keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
1106 1125
 					redis.Set(keySeven, "", time.Second)
1107
-					redis.Close()
1126
+					defer redis.Close()
1108 1127
 				}
1109 1128
 				//service.SaveHisPrescription(prescription)
1110 1129
 				//更改患者挂号状态
@@ -1265,39 +1284,39 @@ func (c *HisApiController) CreateHisPrescription() {
1265 1284
 						}
1266 1285
 					}
1267 1286
 				}
1268
-				if items["addition"] != nil && reflect.TypeOf(items["addition"]).String() == "[]interface {}" {
1269
-					addition := items["addition"].([]interface{})
1270
-					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
1271
-					ctime := time.Now().Unix()
1272
-					mtime := ctime
1273
-					if len(addition) > 0 {
1274
-						for _, item := range addition {
1275
-							var s models.HisAdditionalCharge
1276
-							s.PrescriptionId = tempPrescription.ID
1277
-							s.Status = 1
1278
-							s.UserOrgId = adminInfo.CurrentOrgId
1279
-							s.RecordDate = recordDateTime
1280
-							s.CreatedTime = ctime
1281
-							s.UpdatedTime = mtime
1282
-							s.PatientId = patient_id
1283
-							s.HisPatientId = his_patient_id
1284
-							errcode := c.setAddtionWithJSON(&s, item.(map[string]interface{}), adminInfo.CurrentOrgId)
1285
-							if errcode > 0 {
1286
-								c.ServeFailJSONWithSGJErrorCode(errcode)
1287
-								return
1288
-							}
1289
-							service.CreateAdditionalCharge(&s)
1290
-							var randNum int
1291
-							randNum = rand.Intn(10000) + 1000
1292
-							timestamp := time.Now().Unix()
1293
-							tempTime := time.Unix(timestamp, 0)
1294
-							timeFormat := tempTime.Format("20060102150405")
1295
-							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "3" + "-" + strconv.FormatInt(s.ID, 10)
1296
-							service.CreateAdditionalCharge(&s)
1297
-
1298
-						}
1299
-					}
1300
-				}
1287
+				//if items["addition"] != nil && reflect.TypeOf(items["addition"]).String() == "[]interface {}" {
1288
+				//	addition := items["addition"].([]interface{})
1289
+				//	//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
1290
+				//	ctime := time.Now().Unix()
1291
+				//	mtime := ctime
1292
+				//	if len(addition) > 0 {
1293
+				//		for _, item := range addition {
1294
+				//			var s models.HisAdditionalCharge
1295
+				//			s.PrescriptionId = tempPrescription.ID
1296
+				//			s.Status = 1
1297
+				//			s.UserOrgId = adminInfo.CurrentOrgId
1298
+				//			s.RecordDate = recordDateTime
1299
+				//			s.CreatedTime = ctime
1300
+				//			s.UpdatedTime = mtime
1301
+				//			s.PatientId = patient_id
1302
+				//			s.HisPatientId = his_patient_id
1303
+				//			errcode := c.setAddtionWithJSON(&s, item.(map[string]interface{}), adminInfo.CurrentOrgId)
1304
+				//			if errcode > 0 {
1305
+				//				c.ServeFailJSONWithSGJErrorCode(errcode)
1306
+				//				return
1307
+				//			}
1308
+				//			service.CreateAdditionalCharge(&s)
1309
+				//			var randNum int
1310
+				//			randNum = rand.Intn(10000) + 1000
1311
+				//			timestamp := time.Now().Unix()
1312
+				//			tempTime := time.Unix(timestamp, 0)
1313
+				//			timeFormat := tempTime.Format("20060102150405")
1314
+				//			s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "3" + "-" + strconv.FormatInt(s.ID, 10)
1315
+				//			service.CreateAdditionalCharge(&s)
1316
+				//
1317
+				//		}
1318
+				//	}
1319
+				//}
1301 1320
 
1302 1321
 			}
1303 1322
 		}
@@ -6195,6 +6214,10 @@ func (c *HisApiController) GetPrivateExpensesInfo() {
6195 6214
 	}
6196 6215
 
6197 6216
 	orderInfos = append(orderInfos, orderInfos_two...)
6217
+	if c.GetAdminUserInfo().CurrentOrgId != 10138 {
6218
+		orderInfos = append(orderInfos, orderInfos_three...)
6219
+
6220
+	}
6198 6221
 
6199 6222
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
6200 6223
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -6603,6 +6626,20 @@ func DeleteDrugWarehosueInfo(advice models.HisDoctorAdviceInfo) (err error) {
6603 6626
 	return err
6604 6627
 }
6605 6628
 
6629
+func (this *HisApiController) DeleteNCDS() {
6630
+	id, _ := this.GetInt64("id", 0)
6631
+	if id > 0 {
6632
+		service.DeletePsnNCDSRecordById(id)
6633
+		this.ServeSuccessJSON(map[string]interface{}{
6634
+			"msg": "删除成功",
6635
+		})
6636
+	} else {
6637
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRecordFailedException)
6638
+		return
6639
+	}
6640
+
6641
+}
6642
+
6606 6643
 func (c *HisApiController) GetHisDoctorAdviceInfo() {
6607 6644
 
6608 6645
 	id, _ := c.GetInt64("id")

+ 13 - 9
controllers/his_hospital_api_controller.go View File

@@ -197,6 +197,9 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
197 197
 	} else if order_status == 2 {
198 198
 		monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFour(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
199 199
 	}
200
+
201
+	settle_prescriptions, _ := service.GetSettleHisHospitalPrescription(admin.CurrentOrgId, patient_id, his_patient_id, his_patient_info.RecordDate)
202
+
200 203
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
201 204
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
202 205
 	order, _ := service.GetNewHisOrder(admin.CurrentOrgId, his_patient_info.Number, patient_id)
@@ -205,15 +208,16 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
205 208
 	department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
206 209
 
207 210
 	c.ServeSuccessJSON(map[string]interface{}{
208
-		"his_info":            his_patient_info,
209
-		"xt_info":             xt_patient_info,
210
-		"prescription":        prescriptions,
211
-		"case_history":        case_history,
212
-		"info":                patientPrescriptionInfo,
213
-		"month_prescriptions": monthPrescriptions,
214
-		"order":               order,
215
-		"doctors":             doctors,
216
-		"department":          department,
211
+		"his_info":             his_patient_info,
212
+		"xt_info":              xt_patient_info,
213
+		"prescription":         prescriptions,
214
+		"case_history":         case_history,
215
+		"info":                 patientPrescriptionInfo,
216
+		"month_prescriptions":  monthPrescriptions,
217
+		"order":                order,
218
+		"doctors":              doctors,
219
+		"department":           department,
220
+		"settle_prescriptions": settle_prescriptions,
217 221
 	})
218 222
 	return
219 223
 

+ 12 - 5
controllers/his_project_api_controller.go View File

@@ -1218,15 +1218,18 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1218 1218
 	his, _ := service.GetLastHisPatient(patient_id, adminUserInfo.CurrentOrgId)
1219 1219
 	//prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1220 1220
 	hisPatient, _ := service.GetHisPatientById(patient_id)
1221
+	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
1222
+
1221 1223
 	if err != nil {
1222 1224
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1223 1225
 		return
1224 1226
 	}
1225 1227
 	this.ServeSuccessJSON(map[string]interface{}{
1226
-		"advicePrint": advicePrint,
1227
-		"projectlist": projectlist,
1228
-		"hisPatient":  hisPatient,
1229
-		"his":         his,
1228
+		"advicePrint":       advicePrint,
1229
+		"projectlist":       projectlist,
1230
+		"hisPatient":        hisPatient,
1231
+		"his":               his,
1232
+		"hisHospitalRecord": hisHospitalRecord,
1230 1233
 	})
1231 1234
 }
1232 1235
 
@@ -1533,12 +1536,16 @@ func (this *HisProjectApiController) GetHisPatientDetail() {
1533 1536
 	patient_id, _ := this.GetInt64("patient_id")
1534 1537
 
1535 1538
 	hisPatient, err := service.GetHisPatientById(patient_id)
1539
+	//service.GetLastHospitalRecordTwo(patient_id,this.GetAdminUserInfo().CurrentOrgId)
1540
+	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, this.GetAdminUserInfo().CurrentOrgId)
1541
+
1536 1542
 	if err != nil {
1537 1543
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1538 1544
 		return
1539 1545
 	}
1540 1546
 	this.ServeSuccessJSON(map[string]interface{}{
1541
-		"hisPatient": hisPatient,
1547
+		"hisPatient":        hisPatient,
1548
+		"hisHospitalRecord": hisHospitalRecord,
1542 1549
 	})
1543 1550
 }
1544 1551
 

+ 4 - 3
controllers/new_mobile_api_controllers/new_common_api_controller.go View File

@@ -534,6 +534,8 @@ func (this *NewCommonApiController) GetMobileFirstQuarter() {
534 534
 	adminUser := this.GetMobileAdminUserInfo()
535 535
 	orgid := adminUser.Org.Id
536 536
 	lapseto, _ := this.GetInt64("lapseto")
537
+	origin, _ := this.GetInt64("origin")
538
+
537 539
 	fmt.Println("转归", lapseto)
538 540
 	startime := this.GetString("startime")
539 541
 
@@ -547,13 +549,12 @@ func (this *NewCommonApiController) GetMobileFirstQuarter() {
547 549
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
548 550
 	entime := endDate.Unix()
549 551
 
550
-	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
551
-	countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto)
552
+	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto, origin)
553
+	countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto, origin)
552 554
 	//获取收缩压数据
553 555
 	systolic, systolicTotal, parseDateErr := service.GetSystolicBloodPressure(orgid, statime, entime)
554 556
 	//统计收缩压合格的数据
555 557
 	//systolic, sysstandTotal, parseDateErr := service.GetStandSystolicBloodPressure(orgid, statime, entime)
556
-
557 558
 	//获取舒张压数据
558 559
 	diastolic, diastotal, parseDateErr := service.GetDiastolicBloodPressure(orgid, statime, entime)
559 560
 	//获取合格舒张压数据

+ 4 - 0
enums/error_code.go View File

@@ -242,6 +242,8 @@ const ( // ErrorCode
242 242
 	ErrorCodeHospitalNoExistDataException = 30009
243 243
 
244 244
 	ErrorCodeHospitalExistDataException = 300010
245
+
246
+	ErrorCodeRecordFailedException = 300011
245 247
 )
246 248
 
247 249
 var ErrCodeMsgs = map[int]string{
@@ -473,6 +475,8 @@ var ErrCodeMsgs = map[int]string{
473 475
 	ErrorCodeHospitalNoExistDataException: "请先办理出院才能进行结算",
474 476
 
475 477
 	ErrorCodeHospitalExistDataException: "该患者已经入院,请选办理出院结算后再进行办理入院操作",
478
+
479
+	ErrorCodeRecordFailedException: "记录不存在",
476 480
 }
477 481
 
478 482
 type SGJError struct {

+ 21 - 0
models/his_charge_models.go View File

@@ -218,3 +218,24 @@ type HisFapiaoRecord struct {
218 218
 func (HisFapiaoRecord) TableName() string {
219 219
 	return "his_fapiao_record"
220 220
 }
221
+
222
+type GdybPsnNcdsRecord struct {
223
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
224
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
225
+	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
226
+	PsnNo         string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
227
+	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
228
+	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
229
+	Status        int64  `gorm:"column:status" json:"status" form:"status"`
230
+	IsCancel      int64  `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
231
+	TrtDclaDetlSn string `gorm:"column:trt_dcla_detl_sn" json:"trt_dcla_detl_sn" form:"trt_dcla_detl_sn"`
232
+	DoctorId      int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
233
+	DepartmentId  int64  `gorm:"column:department_id" json:"department_id" form:"department_id"`
234
+	Insutype      string `gorm:"column:insutype" json:"insutype" form:"insutype"`
235
+	SickType      int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
236
+	OrgName       string `gorm:"column:org_name" json:"org_name" form:"org_name"`
237
+}
238
+
239
+func (GdybPsnNcdsRecord) TableName() string {
240
+	return "gdyb_psn_ncds_record"
241
+}

+ 180 - 0
models/his_models.go View File

@@ -1636,6 +1636,7 @@ func (HisStockPriceConfig) TableName() string {
1636 1636
 	return "his_stock_price_config"
1637 1637
 }
1638 1638
 
1639
+
1639 1640
 type SgjAdmin struct {
1640 1641
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
1641 1642
 	Account      string `gorm:"column:account" json:"account" form:"account"`
@@ -1685,3 +1686,182 @@ type SgjOrgFollow struct {
1685 1686
 	Email       string `gorm:"column:email" json:"email" form:"email"`
1686 1687
 	WechatLink  string `gorm:"column:wechat_link" json:"wechat_link" form:"wechat_link"`
1687 1688
 }
1689
+
1690
+type NewCustomHisOrder struct {
1691
+	ID                    int64     `gorm:"column:id" json:"id" form:"id"`
1692
+	UserOrgId             int64     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1693
+	HisPatientId          int64     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1694
+	SettleAccountsDate    int64     `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
1695
+	Ctime                 int64     `gorm:"column:ctime" json:"ctime" form:"ctime"`
1696
+	Mtime                 int64     `gorm:"column:mtime" json:"mtime" form:"mtime"`
1697
+	Status                int64     `gorm:"column:status" json:"status" form:"status"`
1698
+	Number                string    `gorm:"column:number" json:"number" form:"number"`
1699
+	PatientId             int64     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1700
+	Infcode               int64     `gorm:"column:infcode" json:"infcode" form:"infcode"`
1701
+	WarnMsg               string    `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
1702
+	Cainfo                string    `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
1703
+	ErrMsg                string    `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
1704
+	RespondTime           string    `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
1705
+	InfRefmsgid           string    `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
1706
+	OrderStatus           int64     `gorm:"column:order_status" json:"order_status" form:"order_status"`
1707
+	MdtrtId               string    `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
1708
+	SetlId                string    `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
1709
+	PsnNo                 string    `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
1710
+	PsnName               string    `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
1711
+	PsnCertType           string    `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
1712
+	Certno                string    `gorm:"column:certno" json:"certno" form:"certno"`
1713
+	Gend                  string    `gorm:"column:gend" json:"gend" form:"gend"`
1714
+	Naty                  string    `gorm:"column:naty" json:"naty" form:"naty"`
1715
+	Brdy                  time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
1716
+	Age                   float64   `gorm:"column:age" json:"age" form:"age"`
1717
+	Insutype              string    `gorm:"column:insutype" json:"insutype" form:"insutype"`
1718
+	PsnType               string    `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
1719
+	CvlservFlag           string    `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
1720
+	SetlTime              string    `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
1721
+	MdtrtCertType         string    `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
1722
+	MedType               string    `gorm:"column:med_type" json:"med_type" form:"med_type"`
1723
+	MedfeeSumamt          float64   `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
1724
+	FulamtOwnpayAmt       float64   `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1725
+	OverlmtSelfPay        float64   `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
1726
+	PreselfpayAmt         float64   `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1727
+	InscpScpAmt           float64   `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1728
+	ActPayDedc            float64   `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
1729
+	HifpPay               float64   `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
1730
+	CvlservPay            float64   `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
1731
+	PoolPropSelfpay       float64   `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
1732
+	HifesPay              float64   `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
1733
+	HifmiPay              float64   `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
1734
+	HifobPay              float64   `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
1735
+	MafPay                float64   `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
1736
+	OthPay                float64   `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
1737
+	FundPaySumamt         float64   `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
1738
+	PsnPartAmt            float64   `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
1739
+	AcctPay               float64   `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
1740
+	PsnCashPay            float64   `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
1741
+	HospPartAmt           float64   `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
1742
+	Balc                  float64   `gorm:"column:balc" json:"balc" form:"balc"`
1743
+	AcctMulaidPay         float64   `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
1744
+	MedinsSetlId          string    `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
1745
+	ClrOptins             string    `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
1746
+	ClrWay                string    `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
1747
+	ClrType               string    `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
1748
+	SetlDetail            string    `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
1749
+	IsMedicineInsurance   int64     `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
1750
+	PayWay                int64     `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
1751
+	PayPrice              float64   `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
1752
+	PayCardNo             string    `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
1753
+	DiscountPrice         float64   `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
1754
+	PreferentialPrice     float64   `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
1755
+	RealityPrice          float64   `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
1756
+	FoundPrice            float64   `gorm:"column:found_price" json:"found_price" form:"found_price"`
1757
+	MedicalInsurancePrice float64   `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
1758
+	PrivatePrice          float64   `gorm:"column:private_price" json:"private_price" form:"private_price"`
1759
+	DepartmentName        string    `gorm:"-" json:"department_name" form:"department_name"`
1760
+	DoctorName            string    `gorm:"-" json:"doctor_name" form:"doctor_name"`
1761
+	Creator               int64     `gorm:"column:creator" json:"creator" form:"creator"`
1762
+	PType                 int64     `gorm:"column:p_type" json:"p_type" form:"p_type"`
1763
+
1764
+	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
1765
+	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
1766
+
1767
+	SettleType            int64                 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
1768
+	SettleStartTime       int64                 `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
1769
+	SettleEndTime         int64                 `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
1770
+	NewCustomHisOrderInfo NewCustomHisOrderInfo `gorm:"ForeignKey:Number;AssociationForeignKey:OrderNumber" json:"order_info"`
1771
+	Patients              Patients              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1772
+}
1773
+
1774
+func (NewCustomHisOrder) TableName() string {
1775
+	return "his_order"
1776
+}
1777
+
1778
+type NewCustomHisOrderInfo struct {
1779
+	ID                              int64                           `gorm:"column:id" json:"id" form:"id"`
1780
+	OrderNumber                     string                          `gorm:"column:order_number" json:"order_number" form:"order_number"`
1781
+	UploadDate                      int64                           `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
1782
+	AdviceId                        int64                           `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
1783
+	DetItemFeeSumamt                float64                         `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
1784
+	Cnt                             float64                         `gorm:"column:cnt" json:"cnt" form:"cnt"`
1785
+	Pric                            float64                         `gorm:"column:pric" json:"pric" form:"pric"`
1786
+	PatientId                       int64                           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1787
+	PricUplmtAmt                    float64                         `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
1788
+	SelfpayProp                     float64                         `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
1789
+	FulamtOwnpayAmt                 float64                         `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1790
+	OverlmtAmt                      float64                         `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
1791
+	PreselfpayAmt                   float64                         `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1792
+	BasMednFlag                     string                          `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
1793
+	MedChrgitmType                  string                          `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
1794
+	HiNegoDrugFlag                  string                          `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
1795
+	Status                          int64                           `gorm:"column:status" json:"status" form:"status"`
1796
+	Memo                            string                          `gorm:"column:memo" json:"memo" form:"memo"`
1797
+	FeedetlSn                       string                          `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1798
+	Mtime                           int64                           `gorm:"column:mtime" json:"mtime" form:"mtime"`
1799
+	InscpScpAmt                     float64                         `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1800
+	DrtReimFlag                     string                          `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
1801
+	Ctime                           int64                           `gorm:"column:ctime" json:"ctime" form:"ctime"`
1802
+	ListSpItemFlag                  string                          `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
1803
+	ChldMedcFlag                    string                          `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
1804
+	LmtUsedFlag                     string                          `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
1805
+	ChrgitmLv                       string                          `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
1806
+	UserOrgId                       int64                           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1807
+	HisPatientId                    int64                           `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1808
+	OrderId                         int64                           `gorm:"column:order_id" json:"order_id" form:"order_id"`
1809
+	ProjectId                       int64                           `gorm:"column:project_id" json:"project_id" form:"project_id"`
1810
+	Type                            int64                           `gorm:"column:type" json:"type" form:"type"`
1811
+	ItemId                          int64                           `gorm:"column:item_id" json:"item_id" form:"item_id"`
1812
+	NewCustomHisPrescriptionProject NewCustomHisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1813
+	//HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
1814
+}
1815
+
1816
+func (NewCustomHisOrderInfo) TableName() string {
1817
+	return "his_order_info"
1818
+}
1819
+
1820
+type NewCustomHisPrescriptionProject struct {
1821
+	ID                 int64      `gorm:"column:id" json:"id" form:"id"`
1822
+	ProjectId          int64      `gorm:"column:project_id" json:"project_id" form:"project_id"`
1823
+	Price              float64    `gorm:"column:price" json:"price" form:"price"`
1824
+	UserOrgId          int64      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1825
+	Status             int64      `gorm:"column:status" json:"status" form:"status"`
1826
+	Ctime              int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
1827
+	Mtime              int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
1828
+	PatientId          int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1829
+	HisPatientId       int64      `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1830
+	RecordDate         int64      `gorm:"column:record_date" json:"record_date" form:"record_date"`
1831
+	PrescriptionId     int64      `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1832
+	Count              string     `gorm:"column:count" json:"count" form:"count"`
1833
+	FeedetlSn          string     `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1834
+	MedListCodg        string     `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1835
+	SingleDose         string     `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1836
+	DeliveryWay        string     `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1837
+	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1838
+	Day                string     `gorm:"column:day" json:"day" form:"day"`
1839
+	HisProject         HisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
1840
+	GoodInfo           GoodInfo   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
1841
+
1842
+	Remark string `gorm:"column:remark" json:"remark" form:"remark"`
1843
+	Unit   string `gorm:"column:unit" json:"unit" form:"unit"`
1844
+	Type   int64  `gorm:"column:type" json:"type" form:"type"`
1845
+
1846
+	Doctor         int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
1847
+	ExecutionTime  int64 `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
1848
+	ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1849
+	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1850
+	CheckTime      int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
1851
+	CheckState     int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
1852
+	Checker        int64 `gorm:"column:checker" json:"checker" form:"checker"`
1853
+	StartTime      int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
1854
+	TeamId         int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
1855
+
1856
+	XtHisProjectTeam XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
1857
+
1858
+	FrequencyType int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
1859
+	DayCount      int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
1860
+	WeekDay       string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
1861
+	IsCheckTeam   int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
1862
+	HisOrderInfo  HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
1863
+}
1864
+
1865
+func (NewCustomHisPrescriptionProject) TableName() string {
1866
+	return "his_prescription_project"
1867
+}

+ 89 - 45
service/common_service.go View File

@@ -497,8 +497,6 @@ func GetDialysisList(startime int64, endtime int64, page int64, limit int64, org
497 497
 
498 498
 	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
499 499
 
500
-	d := XTReadDB().Table("xt_patients as p")
501
-	fmt.Println(d)
502 500
 	if orgid > 0 {
503 501
 		db = db.Where("o.user_org_id = ?", orgid)
504 502
 	}
@@ -509,7 +507,7 @@ func GetDialysisList(startime int64, endtime int64, page int64, limit int64, org
509 507
 		db = db.Where("o.dialysis_date<=?", endtime)
510 508
 	}
511 509
 	offset := (page - 1) * limit
512
-	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("left join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("left join  xt_patients as p on p.id = o.patient_id").Where("s.status = 1").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
510
+	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("join  xt_patients as p on p.id = o.patient_id").Where("s.status = 1").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
513 511
 	return order, total, err
514 512
 
515 513
 }
@@ -526,16 +524,14 @@ func GetAllDialysisList(startime int64, endtime int64, orgid int64) (order []*mo
526 524
 	if endtime > 0 {
527 525
 		db = db.Where("o.dialysis_date<=?", endtime)
528 526
 	}
529
-	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,s.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("left join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.status = 1 ").Scan(&order).Error
527
+	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,s.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("join xt_patients as p on p.id = o.patient_id").Where("s.status = 1 ").Scan(&order).Error
530 528
 	return order, err
531 529
 }
532 530
 
533 531
 func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int64, orgid int64) (order []*models.BloodDialysisOrder, total int64, err error) {
534 532
 
535 533
 	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
536
-	if orgid > 0 {
537
-		db = db.Where("o.user_org_id = ?", orgid)
538
-	}
534
+	db = db.Where("o.user_org_id = ?", orgid)
539 535
 	if startime > 0 {
540 536
 		db = db.Where("o.dialysis_date>=?", startime)
541 537
 	}
@@ -543,7 +539,7 @@ func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int
543 539
 		db = db.Where("o.dialysis_date<=?", endtime)
544 540
 	}
545 541
 	offset := (page - 1) * limit
546
-	err = db.Group("s.patient_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("left join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("left join  xt_patients as p on p.id = o.patient_id").Where("s.status =1 ").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
542
+	err = db.Group("s.patient_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0 AND s.status =1").Joins("join  xt_patients as p on p.id = o.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
547 543
 	return order, total, err
548 544
 }
549 545
 
@@ -644,9 +640,9 @@ func GetTreatList(orgid int64, startime int64, endtime int64, lapseto int64) (tt
644 640
 	if endtime > 0 {
645 641
 		db = db.Where("o.dialysis_date<=?", endtime)
646 642
 	}
647
-	if lapseto == 0 {
648
-		db = db.Where("p.lapseto = 1 or p.lapseto = 2")
649
-	}
643
+	//if lapseto == 0 {
644
+	//	db = db.Where("p.lapseto = 1 or p.lapseto = 2")
645
+	//}
650 646
 	if lapseto > 0 {
651 647
 		db = db.Where("p.lapseto = ?", lapseto)
652 648
 	}
@@ -659,7 +655,7 @@ func GetStatistics(orgID int64, startime int64, endtime int64, modeID int64) (dt
659 655
 	sql := "s.mode_id,from_unixtime(o.dialysis_date, '%Y%m%d') as date, count(o.dialysis_date) as number"
660 656
 	datesql := " o.dialysis_date as date"
661 657
 	group := "from_unixtime(o.dialysis_date, '%Y%m%d')"
662
-	db = db.Table(" xt_dialysis_order AS o").Joins("join xt_dialysis_prescription as s on o.patient_id = s.patient_id AND s.mode_id > 0").Where("s.record_date = o.dialysis_date and s.status =1")
658
+	db = db.Table(" xt_dialysis_order AS o").Joins("join xt_dialysis_prescription as s on o.patient_id = s.patient_id AND o.dialysis_date = s.record_date AND s.mode_id > 0")
663 659
 	if orgID > 0 {
664 660
 		db = db.Where("o.user_org_id = ?", orgID)
665 661
 	}
@@ -674,7 +670,7 @@ func GetStatistics(orgID int64, startime int64, endtime int64, modeID int64) (dt
674 670
 	}
675 671
 	db = db.Where("o.status=1")
676 672
 
677
-	err = db.Select("s.mode_id, count(s.mode_id) as number").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
673
+	err = db.Select("s.mode_id, count(s.mode_id) as number").Order("s.mode_id asc").Find(&ttd).Error
678 674
 	if err != nil {
679 675
 		return
680 676
 	}
@@ -871,12 +867,6 @@ func GetPatientListInfo(orgid int64, startime int64, endtime int64, limit int64,
871 867
 func GetPatientDetailCheck(id int64, orgid int64, startime int64, endtime int64) (projectCounts []*models.PatientInspectionProjectCount, err error) {
872 868
 
873 869
 	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
874
-	table := XTReadDB().Table("xt_inspection_reference as r")
875
-	fmt.Println(table)
876
-	d := XTReadDB().Table("xt_check_configuration as t").Where("t.status = 1")
877
-	pa := XTReadDB().Table("xt_patients as s")
878
-	fmt.Println(pa)
879
-	fmt.Println(d)
880 870
 	if id > 0 {
881 871
 		db = db.Where("s.id  = ?", id)
882 872
 	}
@@ -983,15 +973,10 @@ func GetFirstQuarter(orgid int64, startime int64, endtime int64) (inspection []*
983 973
 	return inspection, err
984 974
 }
985 975
 
986
-func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64) (inspection []*models.VmPatientInspectionTwo, err error) {
976
+func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (inspection []*models.VmPatientInspectionTwo, err error) {
987 977
 	fmt.Println(lapseto)
978
+	fmt.Println(origin)
988 979
 	db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
989
-	table := XTReadDB().Table("xt_inspection_reference as r")
990
-	fmt.Println(table)
991
-	//d := XTReadDB().Table("xt_patients as s")
992
-	//fmt.Println(d)
993
-	q := XTReadDB().Table("x.xt_quality_control_standard as q")
994
-	fmt.Println(q)
995 980
 	if orgid > 0 {
996 981
 		db = db.Where("x.org_id = ? and x.inspect_value+0 <> 0 and r.range_type = 1 and q.user_org_id = ? and q.is_status = 1", orgid, orgid)
997 982
 	}
@@ -1001,23 +986,18 @@ func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto in
1001 986
 	if endtime > 0 {
1002 987
 		db = db.Where("x.inspect_date <=?", endtime)
1003 988
 	}
1004
-	//if lapseto == 0 {
1005
-	//	db = db.Where("s.lapseto = 1 or s.lapseto = 2")
1006
-	//}
1007
-	//if lapseto > 0 {
1008
-	//	db = db.Where("s.lapseto = ?", lapseto)
1009
-	//}
989
+	if lapseto > 0 {
990
+		db = db.Joins("inner join xt_patients as p On p.id = x.patient_id AND p.lapseto = ?", lapseto)
991
+	}
992
+	if origin > 0 {
993
+		db = db.Joins("inner join xt_patients as p On p.id = x.patient_id AND p.source = ?", origin)
994
+	}
1010 995
 	err = db.Group("x.item_id").Select("sum(case when x.inspect_date >=? and x.inspect_date<=? then 1 else 0 end) as total,sum(case when x.inspect_value+0>=q.min_range+0 and x.inspect_value +0 <= q.large_range+0 and x.inspect_date >=? and x.inspect_date <=? then 1 else 0 end) as count,x.item_id,q.sort", startime, endtime, startime, endtime).Joins("left join xt_inspection_reference as r on ( r.item_id = x.item_id AND r.org_id > 0) OR ( x.item_id = r.id AND r.org_id = 0 ) ").Joins("left join xt_quality_control_standard as q on q.inspection_minor = x.item_id").Scan(&inspection).Error
1011 996
 	return inspection, err
1012 997
 }
1013 998
 
1014
-func GetQuarterTotalCountTwo(orgid int64, startime int64, endtime int64, lapseto int64) (inspection []*models.VmPatientInspectionTwo, err error) {
1015
-	fmt.Println(lapseto)
999
+func GetQuarterTotalCountTwo(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (inspection []*models.VmPatientInspectionTwo, err error) {
1016 1000
 	db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
1017
-	table := XTReadDB().Table("xt_inspection_reference as r")
1018
-	fmt.Println(table)
1019
-	//d := XTReadDB().Table("xt_patients as s")
1020
-	//fmt.Println(d)
1021 1001
 	q := XTReadDB().Table("x.xt_quality_control_standard as q")
1022 1002
 	fmt.Println(q)
1023 1003
 	if orgid > 0 {
@@ -1029,12 +1009,13 @@ func GetQuarterTotalCountTwo(orgid int64, startime int64, endtime int64, lapseto
1029 1009
 	if endtime > 0 {
1030 1010
 		db = db.Where("x.inspect_date <=?", endtime)
1031 1011
 	}
1032
-	//if lapseto == 0 {
1033
-	//	db = db.Where("s.lapseto = 1 or s.lapseto = 2")
1034
-	//}
1035
-	//if lapseto > 0 {
1036
-	//	db = db.Where("s.lapseto = ?", lapseto)
1037
-	//}
1012
+
1013
+	if lapseto > 0 {
1014
+		db = db.Joins("inner join xt_patients as p On p.id = x.patient_id AND p.lapseto = ?", lapseto)
1015
+	}
1016
+	if origin > 0 {
1017
+		db = db.Joins("inner join xt_patients as p On p.id = x.patient_id AND p.source = ?", origin)
1018
+	}
1038 1019
 	err = db.Group("x.item_id").Select("sum(case when x.inspect_date >=? and x.inspect_date<=? then 1 else 0 end) as total,sum(case when q.range_value = x.inspect_value and x.inspect_date >=? and x.inspect_date <=? then 1 else 0 end) as count,x.item_id,q.sort", startime, endtime, startime, endtime).Joins("left join xt_inspection_reference as r on ( r.item_id = x.item_id AND r.org_id > 0) OR ( x.item_id = r.id AND r.org_id = 0 ) ").Joins("left join xt_quality_control_standard as q on q.inspection_minor = x.item_id").Scan(&inspection).Error
1039 1020
 	return inspection, err
1040 1021
 }
@@ -2858,7 +2839,20 @@ func GetSystolicBloodPressure(orgid int64, startime int64, endtime int64) (recor
2858 2839
 	return record, total, err
2859 2840
 }
2860 2841
 
2861
-func GetStandSystolicBloodPressure(orgid int64, startime int64, endtime int64) (record []*models.XTMonitoringRecord, total int64, err error) {
2842
+func GetSystolicBloodPressureTwo(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (record []*models.VmMonitoringRecord, total int64, err error) {
2843
+
2844
+	db := XTReadDB().Table("xt_monitoring_record as x")
2845
+	if lapseto > 0 {
2846
+		db = db.Joins("inner join xt_patients as p on p.id = x.patient_id AND p.lapseto = ?", lapseto)
2847
+	}
2848
+	if origin > 0 {
2849
+		db = db.Joins("inner join xt_patients as p on p.id = x.patient_id AND p.source = ?", origin)
2850
+	}
2851
+	err = db.Select("x.id,x.systolic_blood_pressure").Where("x.user_org_id = ? and x.monitoring_date >=? and x.monitoring_date<=? and x.status = 1 and x.systolic_blood_pressure <> 0", orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
2852
+	return record, total, err
2853
+}
2854
+
2855
+func GetStandSystolicBloodPressure(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (record []*models.XTMonitoringRecord, total int64, err error) {
2862 2856
 
2863 2857
 	db := XTReadDB().Table("xt_monitoring_record as x").Where("x.status = 1")
2864 2858
 	err = db.Select("x.id,s.sort").Joins("left join xt_quality_control_standard as s on s.user_org_id = x.user_org_id").Where("s.status = 1 and s.is_status = 0 and s.user_org_id = ? and x.user_org_id =? and x.monitoring_date>=? and x.monitoring_date <=? and s.inspection_minor = -1 and s.inspection_major = 0 and x.systolic_blood_pressure <> 0 and x.systolic_blood_pressure +0 >= s.min_range +0 and x.systolic_blood_pressure +0 <= s.large_range +0", orgid, orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
@@ -2872,6 +2866,18 @@ func GetDiastolicBloodPressure(orgid int64, startime int64, endtime int64) (reco
2872 2866
 	return record, total, err
2873 2867
 }
2874 2868
 
2869
+func GetDiastolicBloodPressureTwo(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (record []*models.VmMonitoringRecord, total int64, err error) {
2870
+	db := XTReadDB().Table("xt_monitoring_record as x")
2871
+	if lapseto > 0 {
2872
+		db = db.Joins("inner join xt_patients as p on p.id = x.patient_id AND p.lapseto = ?", lapseto)
2873
+	}
2874
+	if origin > 0 {
2875
+		db = db.Joins("inner join xt_patients as p on p.id = x.patient_id AND p.source = ?", origin)
2876
+	}
2877
+	err = db.Select("x.id,x.diastolic_blood_pressure").Where("x.user_org_id = ? and x.monitoring_date >=? and x.monitoring_date<=? and x.status = 1 and x.diastolic_blood_pressure <> 0", orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
2878
+	return record, total, err
2879
+}
2880
+
2875 2881
 func GetDiastolicStandPressure(orgid int64, startime int64, endtime int64) (record []*models.XTMonitoringRecord, total int64, err error) {
2876 2882
 	db := XTReadDB().Table("xt_monitoring_record as x").Where("x.status = 1")
2877 2883
 	err = db.Select("x.id,s.sort").Joins("left join xt_quality_control_standard as s on s.user_org_id = x.user_org_id").Where("s.status = 1 and s.is_status = 0 and s.user_org_id = ? and x.user_org_id =? and x.monitoring_date>=? and x.monitoring_date <=? and s.inspection_minor = -2 and s.inspection_major = 0 and x.diastolic_blood_pressure <> 0 and x.diastolic_blood_pressure +0 >= s.min_range +0 and x.diastolic_blood_pressure +0 <= s.large_range +0", orgid, orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
@@ -3526,3 +3532,41 @@ func GetCountRollout(orgid int64, startime int64, endtime int64, lapsetotype int
3526 3532
 	}
3527 3533
 	return lapseto, err
3528 3534
 }
3535
+
3536
+func GetCheckExaminePercent(start_time int64, end_time int64, org_id int64, name_type int64) (total int64) {
3537
+
3538
+	switch name_type {
3539
+	case 1:
3540
+		key := "%" + "血常规" + "%"
3541
+		readDb.Model(&models.Inspection{}).Where("inspect_date >= ? AND inspect_date <= ? AND user_org_id = ? AND status = 1 AND (item_name Like ? Or project_name Like ?)", start_time, end_time, org_id, key).Group("patient_id").Count(&total)
3542
+
3543
+		break
3544
+	case 2:
3545
+		//key := "%" + "肝功能" + "%"
3546
+		//key1 := "%" + "肾功能" + "%"
3547
+		//key2 := "%" + "电解质" + "%"
3548
+		//key3 := "%" + "血脂" + "%"
3549
+		//readDb.Model(&models.Inspection{}).Where("inspect_date >= ? AND inspect_date <= ? AND user_org_id = ? AND status = 1 AND ((item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?))", start_time, end_time, org_id, key, key, key1, key1, key2, key2, key3, key3).Group("patient_id").Count(&total)
3550
+
3551
+		break
3552
+	case 3:
3553
+		//key := "%" + "肝功能" + "%"
3554
+		//readDb.Model(&models.Inspection{}).Where("inspect_date >= ? AND inspect_date <= ? AND user_org_id = ? AND status = 1 AND ((item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?))", start_time, end_time, org_id, key, key, key1, key1, key2, key2, key3, key3).Group("patient_id").Count(&total)
3555
+
3556
+		break
3557
+	case 4:
3558
+		break
3559
+	case 5:
3560
+		break
3561
+	case 6:
3562
+		break
3563
+
3564
+	}
3565
+
3566
+	return
3567
+}
3568
+
3569
+func GetAllPatientCount(orgid int64) (total int64, err error) {
3570
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Count(&total).Error
3571
+	return
3572
+}

+ 21 - 0
service/his_hospital_service.go View File

@@ -269,6 +269,11 @@ func GetLastHospitalRecord(id int64, user_org_id int64) (record models.HisHospit
269 269
 	return
270 270
 }
271 271
 
272
+func GetLastHospitalRecordTwo(patient_id int64, user_org_id int64) (record models.HisHospitalCheckRecord, err error) {
273
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("patient_id = ? AND status = 1 AND user_org_id = ? AND in_hospital_status = 1 AND out_hospital_status = 0", patient_id, user_org_id).Last(&record).Error
274
+	return
275
+}
276
+
272 277
 func FindDiagnoseByIds(ids []string) ([]*models.HisXtDiagnoseConfig, error) {
273 278
 	dealer := []*models.HisXtDiagnoseConfig{}
274 279
 	err := readDb.Model(&models.HisXtDiagnoseConfig{}).Where("id IN (?) AND status = 1", ids).Find(&dealer).Error
@@ -296,3 +301,19 @@ func GetHospitalMonthHisPrescription(org_id int64, patient_id int64, start_time
296 301
 		Find(&prescription).Error
297 302
 	return
298 303
 }
304
+
305
+func GetSettleHisHospitalPrescription(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
306
+	err = readDb.Model(&models.HisPrescription{}).
307
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
308
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
309
+		}).
310
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
311
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
312
+		}).
313
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
314
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
315
+		}).
316
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND patient_id = ? AND order_status = 4 ", org_id, record_date, patient_id).
317
+		Find(&prescription).Error
318
+	return
319
+}

+ 16 - 3
service/his_service.go View File

@@ -565,7 +565,7 @@ func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_
565 565
 		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
566 566
 		return db.Where("status = 1 AND user_org_id = ?", org_id)
567 567
 	}).
568
-		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  AND  order_status <> 2 AND order_status <> 3  AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
568
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  AND  order_status <> 2 AND order_status <> 3 AND order_status <> 4 AND p_type = ?", org_id, start_date, end_date, patient_id, p_type).
569 569
 		Find(&prescription).Error
570 570
 	return
571 571
 }
@@ -817,7 +817,7 @@ func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int
817 817
 }
818 818
 
819 819
 func FindPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64, p_type int64) (info models.HisPrescriptionInfo, err error) {
820
-	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ?  ", org_id, record_date, patient_id).First(&info).Error
820
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, p_type).First(&info).Error
821 821
 	return
822 822
 
823 823
 }
@@ -2035,7 +2035,7 @@ func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time
2035 2035
 }
2036 2036
 
2037 2037
 func GetHisPrescriptionTeamProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
2038
-	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1 AND team_id > 0", user_org_id, patient_id, record_time).Find(&projects).Error
2038
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("XtHisProjectTeam", "status = 1 AND user_org_id = ?", user_org_id).Preload("HisProject", "status = 1 AND user_org_id = ?", user_org_id).Preload("GoodInfo", "status = 1 AND org_id = ?", user_org_id).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1 AND team_id > 0", user_org_id, patient_id, record_time).Find(&projects).Error
2039 2039
 	return
2040 2040
 }
2041 2041
 
@@ -2225,6 +2225,19 @@ func CreateHisLabelRecord(label *models.HisLabelPrintInfo) error {
2225 2225
 	return err
2226 2226
 }
2227 2227
 
2228
+func DeletePsnNCDSRecordById(id int64) (err error) {
2229
+	err = writeDb.Model(&models.GdybPsnNcdsRecord{}).Where("id = ?", id).Updates(map[string]interface{}{"user_org_id": 1110000}).Error
2230
+	return
2231
+}
2232
+
2233
+func GetBaiLinOrderData() (order []*models.NewCustomHisOrder) {
2234
+	readDb.Model(&models.NewCustomHisOrder{}).Preload("Patients", "status = 1").Preload("NewCustomHisOrderInfo", func(db *gorm.DB) *gorm.DB {
2235
+		return db.Where("status = 1 AND project_id > 0").Preload("NewCustomHisPrescriptionProject", "(status = 1 and project_id = 1027 AND type = 2) OR (status = 1 AND project_id = 2036 AND type = 3)")
2236
+	}).Where("user_org_id = 10138 AND settle_accounts_date >= 1638288000 AND settle_accounts_date <= 1640880000 AND order_status = 2 AND status = 1 AND (medfee_sumamt = 50 OR medfee_sumamt = 40)").Find(&order)
2237
+	return
2238
+}
2239
+
2240
+
2228 2241
 func GetHisDoctorAdviceInfo(id int64) (models.HisDoctorAdviceInfo, error) {
2229 2242
 
2230 2243
 	info := models.HisDoctorAdviceInfo{}