Browse Source

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

XMLWAN 3 years ago
parent
commit
d64ab7979d

+ 52 - 32
controllers/his_api_controller.go View File

@@ -27,41 +27,28 @@ type HisApiController struct {
27 27
 func HisManagerApiRegistRouters() {
28 28
 
29 29
 	beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
30
-	//beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
31
-
32 30
 	beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
33 31
 	beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
34
-
35 32
 	beego.Router("/api/hisprescription/delete", &HisApiController{}, "post:DeletePrescription")
36 33
 	beego.Router("/api/advice/delete", &HisApiController{}, "post:DeleteDoctorAdvice")
37 34
 	beego.Router("/api/project/delete", &HisApiController{}, "post:DeleteProject")
38 35
 	beego.Router("/api/addition_charge/delete", &HisApiController{}, "post:DeleteAddition")
39
-
40 36
 	beego.Router("/api/hisprescription/list", &HisApiController{}, "get:GetHisPrescriptionList")
41 37
 	beego.Router("/api/hisprescription/info", &HisApiController{}, "get:GetHisPrescriptionInfo")
42
-
43 38
 	beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
44 39
 	beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
45
-
46 40
 	beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
47 41
 	beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
48 42
 	beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
49
-
50 43
 	beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
51
-
52 44
 	beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
53
-
54 45
 	beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
55
-
56 46
 	beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
57
-
58 47
 	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
59 48
 	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
60 49
 	beego.Router("/api/presettle/get", &HisApiController{}, "get:PreSettle")
61
-
62 50
 	beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
63 51
 	beego.Router("/api/refundnumber/post", &HisApiController{}, "post:RefundNumber")
64
-
65 52
 	beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
66 53
 	beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
67 54
 
@@ -79,15 +66,12 @@ func HisManagerApiRegistRouters() {
79 66
 	beego.Router("/api/orderdetaicollect/get", &HisApiController{}, "get:GetAllOrderDetailCollect")
80 67
 	beego.Router("/api/cost/compare", &HisApiController{}, "get:GetMedicalInsuranceCostCompareList")
81 68
 	beego.Router("/api/record/list", &HisApiController{}, "get:GetPutOnRecordList")
82
-
83 69
 	beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
84 70
 	beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
85
-
86 71
 	beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
87 72
 
88 73
 	beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
89 74
 	//beego.Router("/api/editprojectinformation", &HisApiController{}, "post:EditProjectInformation")
90
-
91 75
 	beego.Router("/api/hisprescriptiontemplate/create", &HisApiController{}, "post:CreateHisPrescriptionTemplate")
92 76
 
93 77
 	beego.Router("/api/privateexpenses/get", &HisApiController{}, "get:GetPrivateExpensesInfo")
@@ -3704,6 +3688,7 @@ func (c *HisApiController) GetHisOrderList() {
3704 3688
 	types, _ := c.GetInt64("type", 0)
3705 3689
 	keywords := c.GetString("keywords")
3706 3690
 	p_type, _ := c.GetInt64("p_type", 0)
3691
+	sort_type, _ := c.GetInt64("sort_type", 0)
3707 3692
 
3708 3693
 	timeLayout := "2006-01-02"
3709 3694
 	loc, _ := time.LoadLocation("Local")
@@ -3730,7 +3715,7 @@ func (c *HisApiController) GetHisOrderList() {
3730 3715
 
3731 3716
 	adminUser := c.GetAdminUserInfo()
3732 3717
 	org_id := adminUser.CurrentOrgId
3733
-	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type)
3718
+	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type)
3734 3719
 
3735 3720
 	for _, item := range order {
3736 3721
 		info, _ := service.GetHisPrescriptionByPatientID(item.PatientId, item.UserOrgId)
@@ -4407,6 +4392,7 @@ func (c *HisApiController) GetUploadInfo() {
4407 4392
 			FaPiaoNumber:          fapiao_number,
4408 4393
 			Diagnosis:             diagnosis_id,
4409 4394
 			PType:                 2,
4395
+			//SetlTime:			t
4410 4396
 		}
4411 4397
 		err = service.CreateOrder(order)
4412 4398
 		if err != nil {
@@ -5253,7 +5239,7 @@ func (c *HisApiController) GetFaPiaoData() {
5253 5239
 				laboratoryCostSelfTotal = laboratoryCostTotal
5254 5240
 			}
5255 5241
 
5256
-			if item.MedChrgitmType == "05" { //治疗费
5242
+			if item.MedChrgitmType == "05" || item.MedChrgitmType == "14" { //治疗费
5257 5243
 				treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
5258 5244
 				treatCostSelfTotal = treatCostTotal
5259 5245
 			}
@@ -5278,7 +5264,7 @@ func (c *HisApiController) GetFaPiaoData() {
5278 5264
 				chineseTraditionalMedicineCostSelfTotal = chineseTraditionalMedicineCostTotal
5279 5265
 			}
5280 5266
 
5281
-			if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
5267
+			if item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
5282 5268
 				otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
5283 5269
 				otherCostSelfTotal = otherCostTotal
5284 5270
 			}
@@ -5305,7 +5291,7 @@ func (c *HisApiController) GetFaPiaoData() {
5305 5291
 				laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
5306 5292
 			}
5307 5293
 
5308
-			if item.MedChrgitmType == "05" { //治疗费
5294
+			if item.MedChrgitmType == "05" || item.MedChrgitmType == "14" { //治疗费
5309 5295
 				treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
5310 5296
 				treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
5311 5297
 				treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
@@ -5335,7 +5321,7 @@ func (c *HisApiController) GetFaPiaoData() {
5335 5321
 				chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
5336 5322
 			}
5337 5323
 
5338
-			if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
5324
+			if item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
5339 5325
 				otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
5340 5326
 				otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
5341 5327
 				otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
@@ -6439,22 +6425,56 @@ func (c *HisApiController) GetPrivateExpensesInfo() {
6439 6425
 
6440 6426
 func (this *HisApiController) ChangeMedType() {
6441 6427
 	med_type := this.GetString("med_type")
6442
-	id, _ := this.GetInt64("id")
6428
+	old_med_type := this.GetString("old_med_type")
6429
+	ids := this.GetString("ids")
6430
+	settle_type, _ := this.GetInt64("settle_type")
6431
+	start_time := this.GetString("start_time")
6432
+	end_time := this.GetString("end_time")
6433
+	ids_arr := strings.Split(ids, ",")
6434
+	if settle_type == 1 { //日结
6435
+		id, _ := strconv.ParseInt(ids_arr[0], 10, 64)
6436
+		prescription, _ := service.GetPrescriptionById(id, this.GetAdminUserInfo().CurrentOrgId)
6437
+		prescription.MedType = med_type
6438
+		err := service.SaveHisPrescription(&prescription)
6443 6439
 
6444
-	prescription, _ := service.GetPrescriptionById(id, this.GetAdminUserInfo().CurrentOrgId)
6445
-	prescription.MedType = med_type
6446
-	err := service.SaveHisPrescription(&prescription)
6440
+		if err == nil {
6441
+			this.ServeSuccessJSON(map[string]interface{}{
6442
+				"msg": "修改成功",
6443
+			})
6447 6444
 
6448
-	if err == nil {
6449
-		this.ServeSuccessJSON(map[string]interface{}{
6450
-			"msg": "修改成功",
6451
-		})
6445
+		} else {
6452 6446
 
6453
-	} else {
6447
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
6448
+			return
6454 6449
 
6455
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
6456
-		return
6450
+		}
6457 6451
 
6452
+	} else if settle_type == 2 {
6453
+		timeLayout := "2006-01-02"
6454
+		loc, _ := time.LoadLocation("Local")
6455
+		theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6456
+		if err != nil {
6457
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6458
+			return
6459
+		}
6460
+		recordStartTime := theStartTime.Unix()
6461
+		start_time_timestamp := recordStartTime
6462
+		theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
6463
+		if err != nil {
6464
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6465
+			return
6466
+		}
6467
+		recordEndTime := theEndTime.Unix()
6468
+		end_time_timestamp := recordEndTime
6469
+		updateErr := service.UpdateBatchHisPrescriptionMedType(ids_arr, med_type, start_time_timestamp, end_time_timestamp, this.GetAdminUserInfo().CurrentOrgId, old_med_type)
6470
+		if updateErr == nil {
6471
+			this.ServeSuccessJSON(map[string]interface{}{
6472
+				"msg": "修改成功",
6473
+			})
6474
+		} else {
6475
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
6476
+			return
6477
+		}
6458 6478
 	}
6459 6479
 
6460 6480
 }

+ 15 - 0
controllers/his_charge_api_controller.go View File

@@ -28,6 +28,8 @@ func HisChargeApiRegistRouters() {
28 28
 	beego.Router("/api/fapiao", &HisChargeApiController{}, "get:GetFaPiaoRecord")
29 29
 	beego.Router("/api/fapiao/is_use", &HisChargeApiController{}, "post:UpdateFaPiaoRecordIsUse")
30 30
 
31
+	beego.Router("/api/his/getyidiclear", &HisChargeApiController{}, "get:GetHisYidiClearRecord")
32
+
31 33
 }
32 34
 
33 35
 func (c *HisChargeApiController) UpdateFaPiaoRecordIsUse() {
@@ -301,3 +303,16 @@ func (c *HisChargeApiController) GetHisInspectionInfo() {
301 303
 		return
302 304
 	}
303 305
 }
306
+
307
+func (c *HisChargeApiController) GetHisYidiClearRecord() {
308
+	records, err := service.FindHisYidiClearRecord(c.GetAdminUserInfo().CurrentOrgId)
309
+	if err == nil {
310
+		c.ServeSuccessJSON(map[string]interface{}{
311
+			"list": records,
312
+		})
313
+		return
314
+	} else {
315
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
316
+		return
317
+	}
318
+}

+ 53 - 0
controllers/his_print_api_controller.go View File

@@ -0,0 +1,53 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"github.com/astaxie/beego"
7
+	"strings"
8
+	"time"
9
+)
10
+
11
+type HisPrintApiController struct {
12
+	BaseAuthAPIController
13
+}
14
+
15
+func HisPrintApiRegistRouters() {
16
+	beego.Router("/api/his/prescription/print", &HisPrintApiController{}, "get:GetBatchHisPrescriptionData")
17
+}
18
+
19
+func (c *HisPrintApiController) GetBatchHisPrescriptionData() {
20
+	record_date := c.GetString("record_date")
21
+	patient_ids := c.GetString("patient_ids")
22
+	print_type, _ := c.GetInt64("type")
23
+	timeLayout := "2006-01-02"
24
+	loc, _ := time.LoadLocation("Local")
25
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
26
+	if err != nil {
27
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
28
+		return
29
+	}
30
+	recordDateTime := theTime.Unix()
31
+	adminInfo := c.GetAdminUserInfo()
32
+	ids := strings.Split(patient_ids, ",")
33
+	switch print_type {
34
+	case 1:
35
+		patients, _ := service.GetBatchDrugHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
36
+		c.ServeSuccessJSON(map[string]interface{}{
37
+			"patients": patients,
38
+		})
39
+		break
40
+	case 2:
41
+		patients, _ := service.GetBatchProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
42
+		c.ServeSuccessJSON(map[string]interface{}{
43
+			"patients": patients,
44
+		})
45
+		break
46
+	case 3:
47
+		patients, _ := service.GetBatchInspectionProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
48
+		c.ServeSuccessJSON(map[string]interface{}{
49
+			"patients": patients,
50
+		})
51
+		break
52
+	}
53
+}

+ 12 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -189,7 +189,12 @@ func (this *DialysisAPIController) Scheduals() {
189 189
 			}
190 190
 
191 191
 			//获取今日所有的处方开的耗材
192
-			project, _ := service.GetAllHisProjectPrescription(orgID, date.Unix())
192
+			_, configs := service.FindXTHisProjectByOrgId(orgID)
193
+			project := make([]*models.HisPrescriptionProjectTwo, 0)
194
+
195
+			if configs.ID > 0 && configs.IsOpen == 1 {
196
+				project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
197
+			}
193 198
 
194 199
 			//获取今日透析准备的数据
195 200
 			//goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())
@@ -220,7 +225,12 @@ func (this *DialysisAPIController) Scheduals() {
220 225
 
221 226
 		}
222 227
 		//获取今日所有的处方开的耗材
223
-		project, _ := service.GetAllHisProjectPrescription(orgID, date.Unix())
228
+		_, configs := service.FindXTHisProjectByOrgId(orgID)
229
+		project := make([]*models.HisPrescriptionProjectTwo, 0)
230
+
231
+		if configs.ID > 0 && configs.IsOpen == 1 {
232
+			project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
233
+		}
224 234
 
225 235
 		//获取今日透析准备的数据
226 236
 		//goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())

+ 240 - 2
controllers/supply_order_api_contorller.go View File

@@ -20,12 +20,21 @@ type SupplyOrderApiController struct {
20 20
 }
21 21
 
22 22
 func SupplyOrderApiRegistRouters() {
23
-
23
+	//获取供应商列表GetSupplyList
24
+	beego.Router("/api/supply/getsupplylist", &SupplyOrderApiController{}, "get:GetSupplyList")
25
+	//保存供应商及联系人(用于更改)
26
+	beego.Router("/api/supply/updatesupply", &SupplyOrderApiController{}, "post:UpdateSupply")
27
+	//删除单条联系人
28
+	beego.Router("/api/supply/delcontactone", &SupplyOrderApiController{}, "get:DelContactOne")
29
+	//获取单条供应商和涉及到的联系人记录
30
+	beego.Router("/api/supply/getsupplyandcontactone", &SupplyOrderApiController{}, "get:GetSupplyAndContactOne")
31
+	//获取供应商类别
32
+	beego.Router("/api/supply/getsupplytype", &SupplyOrderApiController{}, "get:GetSupplyType")
24 33
 	//删除供应商及联系人
25 34
 	beego.Router("/api/supply/delsupply", &SupplyOrderApiController{}, "post:DelSupply")
26 35
 	//获取供应商编码
27 36
 	beego.Router("/api/supply/getsupplycode", &SupplyOrderApiController{}, "get:GetSupplyCode")
28
-	//保存供应商及联系人
37
+	//保存供应商及联系人(用于新增)
29 38
 	beego.Router("/api/supply/savesupply", &SupplyOrderApiController{}, "post:SaveSupply")
30 39
 
31 40
 	beego.Router("/api/supply/getinitorder", &SupplyOrderApiController{}, "get:GetInitOrder")
@@ -81,6 +90,210 @@ func SupplyOrderApiRegistRouters() {
81 90
 	beego.Router("/api/supply/getsupplywarehouseoutbyid", &SupplyOrderApiController{}, "Get:GetSupplyWarehouseById")
82 91
 }
83 92
 
93
+//获取供应商列表GetSupplyList
94
+func (this *SupplyOrderApiController) GetSupplyList() {
95
+	ctype, _ := this.GetInt64("ctype") //供应商类别
96
+	page, _ := this.GetInt64("page")   //页码
97
+	limit, _ := this.GetInt64("limit") //每一页查出来的条数
98
+	if page == 0 || limit == 0 {
99
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "page或limit参数不能为空")
100
+		return
101
+	}
102
+	code := this.GetString("code")   //供应商编号
103
+	sname := this.GetString("sname") //供应商名称
104
+	cname := this.GetString("cname") //联系人名字
105
+	orgId := this.GetAdminUserInfo().CurrentOrgId
106
+	//获取分页的数据
107
+	list, total, err := service.GetSupplyList(ctype, page, limit, code, sname, cname)
108
+	//获取供应商类别
109
+	costClassify := "供应商类别"
110
+	drugTypeParent, _ := service.GetDrugDataConfig(0, costClassify)
111
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
112
+	tmpmap := make(map[int64]string)    //储存供应商类别
113
+	namemap := make(map[string]string)  //储存首要联系人
114
+	phonemap := make(map[string]string) //手机号
115
+	for i := 0; i < len(drugTypeList); i++ {
116
+		k := int64(drugTypeList[i].Value)
117
+		v := drugTypeList[i].Name
118
+		tmpmap[k] = v
119
+	}
120
+	if err == nil {
121
+		for i := 0; i < len(list); i++ {
122
+			code := list[i].SupplierCode
123
+			fistname, errs := service.FindName(code)
124
+			if errs != nil && errs.Error() != "record not found" {
125
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
126
+				return
127
+			}
128
+			namemap[code] = fistname.Name
129
+			phonemap[code] = fistname.Phone
130
+		}
131
+		type SpSupplierNameList struct { //基于SpSupplierName结构体修改的,为了方便前端取数据整合了一下,删除了几个用不到的字段,添加了联系人名字和供应商类别两个字段
132
+			ID           int64
133
+			SupplierCode string
134
+			SupplierName string
135
+			SupplierType int64
136
+			VatRate      float64
137
+			Number       string
138
+			Bank         string
139
+			BankAccount  string
140
+			UserOrgId    int64
141
+			Status       int64
142
+			ContactsId   int64
143
+			ConName      string //供应商主要联系人名字
144
+			TypeName     string //供应商类别
145
+			Phone        string //电话
146
+		}
147
+		//初始化该结构体
148
+		tmplist := []*SpSupplierNameList{}
149
+		for i := 0; i < len(list); i++ {
150
+			var typename string //类别名称
151
+			if list[i].SupplierType == 0 {
152
+				typename = ""
153
+			} else {
154
+				typename = tmpmap[list[i].SupplierType]
155
+			}
156
+			tlist := &SpSupplierNameList{
157
+				list[i].ID,
158
+				list[i].SupplierCode,
159
+				list[i].SupplierName,
160
+				list[i].SupplierType,
161
+				list[i].VatRate,
162
+				list[i].Number,
163
+				list[i].Bank,
164
+				list[i].BankAccount,
165
+				list[i].UserOrgId,
166
+				list[i].Status,
167
+				list[i].ContactsId,
168
+				namemap[list[i].SupplierCode],
169
+				typename,
170
+				phonemap[list[i].SupplierCode],
171
+			}
172
+			tmplist = append(tmplist, tlist)
173
+
174
+		}
175
+		this.ServeSuccessJSON(map[string]interface{}{
176
+			"list":  tmplist,
177
+			"total": total,
178
+		})
179
+	} else {
180
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
181
+	}
182
+}
183
+
184
+//保存供应商及联系人(用于更改)
185
+func (this *SupplyOrderApiController) UpdateSupply() {
186
+	supplierName := this.GetString("suppliername") //供应商名称
187
+	if supplierName == "" {
188
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称不能为空")
189
+		return
190
+	}
191
+	supplierCode := this.GetString("suppliercode") //供应商编码
192
+	if supplierCode == "" {
193
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
194
+		return
195
+	}
196
+	supplierid, _ := this.GetInt64("id") //供应商id
197
+	if supplierid == 0 {
198
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商id不能为空")
199
+		return
200
+	}
201
+	//查询供应商的信息
202
+	supply, err := service.GetSupplyOne(supplierid)
203
+	if err != nil {
204
+		utils.ErrorLog(err.Error())
205
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
206
+		return
207
+	}
208
+	if supplierName != supply.SupplierName {
209
+		//判断供应商名称是否有重复的
210
+		sbool, _ := service.FindSupplierName(supplierName)
211
+		if sbool { //有重复的
212
+			this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称重复")
213
+			return
214
+		}
215
+	}
216
+	if supplierCode != supply.SupplierCode {
217
+		//判断供应商编号是否有重复的
218
+		codebool, _ := service.FindSupplierCode(supplierCode)
219
+		if codebool {
220
+			this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号重复")
221
+			return
222
+		}
223
+	}
224
+	supplierType, _ := this.GetInt64("suppliertype") //供应商类别
225
+	vatRate, _ := this.GetFloat("vatrate")           //增值税税率
226
+	number := this.GetString("number")               //纳税人识别号
227
+	bank := this.GetString("bank")                   //开户银行
228
+	bankAccount := this.GetString("bankAccount")     //银行账号
229
+	orgId := this.GetAdminUserInfo().CurrentOrgId
230
+	//contacts := this.Get("contacts")//联系人
231
+	dataBody := make(map[string]interface{}, 0)
232
+	err = json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
233
+	if err != nil {
234
+		utils.ErrorLog(err.Error())
235
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
236
+		return
237
+	}
238
+	//保存联系人
239
+	if dataBody["contacts"] != nil && reflect.TypeOf(dataBody["contacts"]).String() == "[]interface {}" {
240
+		thisStockIn, _ := dataBody["contacts"].([]interface{})
241
+		if len(thisStockIn) > 0 {
242
+			if len(thisStockIn) == 1 {
243
+				for _, item := range thisStockIn {
244
+					items := item.(map[string]interface{})
245
+					items["IsFirst"] = 1
246
+				}
247
+			}
248
+			tmodify := this.GetAdminUserInfo().AdminUser.Id
249
+			err = service.UpdateSupplyAndContact(thisStockIn, supplierid, orgId, supplierType, tmodify, supplierCode, supplierName, number, bank, bankAccount, vatRate)
250
+			if err != nil {
251
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
252
+				return
253
+			}
254
+		} else {
255
+			this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "联系人不能为空")
256
+			return
257
+		}
258
+	}
259
+	this.ServeSuccessJSON(map[string]interface{}{
260
+		"list": "保存成功",
261
+	})
262
+	return
263
+}
264
+
265
+//获取单条供应商和涉及到的联系人记录
266
+func (this *SupplyOrderApiController) GetSupplyAndContactOne() {
267
+	id, _ := this.GetInt64("id")
268
+	if id == 0 {
269
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商id不能为空")
270
+		return
271
+	}
272
+	supply, contact, err := service.GetSupplyAndContactOne(id)
273
+	if err != nil {
274
+		utils.ErrorLog(err.Error())
275
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
276
+		return
277
+	}
278
+	this.ServeSuccessJSON(map[string]interface{}{
279
+		"supply":  supply,
280
+		"contact": contact,
281
+	})
282
+	return
283
+}
284
+
285
+//获取供应商类别
286
+func (this *SupplyOrderApiController) GetSupplyType() {
287
+	orgId := this.GetAdminUserInfo().CurrentOrgId
288
+	costClassify := "供应商类别"
289
+	drugTypeParent, _ := service.GetDrugDataConfig(0, costClassify)
290
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
291
+	this.ServeSuccessJSON(map[string]interface{}{
292
+		"list": drugTypeList,
293
+	})
294
+	return
295
+}
296
+
84 297
 //删除供应商及联系人
85 298
 func (this *SupplyOrderApiController) DelSupply() {
86 299
 	//拿到供应商的id
@@ -104,6 +317,25 @@ func (this *SupplyOrderApiController) DelSupply() {
104 317
 	return
105 318
 }
106 319
 
320
+//删除单条联系人记录
321
+func (this *SupplyOrderApiController) DelContactOne() {
322
+	id, _ := this.GetInt64("id")
323
+	if id == 0 {
324
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "联系人id不能为空")
325
+		return
326
+	}
327
+	err := service.DelContactOne(id)
328
+	if err != nil {
329
+		utils.ErrorLog(err.Error())
330
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
331
+		return
332
+	}
333
+	this.ServeSuccessJSON(map[string]interface{}{
334
+		"list": "删除成功",
335
+	})
336
+	return
337
+}
338
+
107 339
 //获取供应商编码
108 340
 func (this *SupplyOrderApiController) GetSupplyCode() {
109 341
 	supply, err := service.GetSuppliyCode()
@@ -154,6 +386,12 @@ func (this *SupplyOrderApiController) SaveSupply() {
154 386
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
155 387
 		return
156 388
 	}
389
+	//判断供应商编号是否有重复的
390
+	codebool, _ := service.FindSupplierCode(supplierCode)
391
+	if codebool {
392
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号重复")
393
+		return
394
+	}
157 395
 	supplierType, _ := this.GetInt64("suppliertype") //供应商类别
158 396
 	vatRate, _ := this.GetFloat("vatrate")           //增值税税率
159 397
 	number := this.GetString("number")               //纳税人识别号

+ 47 - 0
models/his_models.go View File

@@ -1168,6 +1168,8 @@ type MedicalInsuranceOrgConfig struct {
1168 1168
 	MdtrtareaAdmvs string `gorm:"column:mdtrtarea_admvs" json:"mdtrtarea_admvs" form:"mdtrtarea_admvs"`
1169 1169
 	InsuplcAdmdvs  string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
1170 1170
 	SecretKey      string `gorm:"column:secret_key" json:"secret_key" form:"secret_key"`
1171
+	AccessKey      string `gorm:"column:access_key" json:"access_key" form:"access_key"`
1172
+	Cainfo         string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
1171 1173
 }
1172 1174
 
1173 1175
 func (MedicalInsuranceOrgConfig) TableName() string {
@@ -1875,3 +1877,48 @@ type NewCustomHisPrescriptionProject struct {
1875 1877
 func (NewCustomHisPrescriptionProject) TableName() string {
1876 1878
 	return "his_prescription_project"
1877 1879
 }
1880
+
1881
+type HisYidiClearRecord struct {
1882
+	ID              int64   `gorm:"column:id" json:"id" form:"id"`
1883
+	UserOrgId       int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1884
+	Ctime           int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1885
+	Mtime           int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1886
+	Status          int64   `gorm:"column:status" json:"status" form:"status"`
1887
+	Certno          string  `gorm:"column:certno" json:"certno" form:"certno"`
1888
+	MdtrtId         string  `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
1889
+	MdtrtSetlTime   string  `gorm:"column:mdtrt_setl_time" json:"mdtrt_setl_time" form:"mdtrt_setl_time"`
1890
+	SetlSn          string  `gorm:"column:setl_sn" json:"setl_sn" form:"setl_sn"`
1891
+	MedfeeSumant    float64 `gorm:"column:medfee_sumant" json:"medfee_sumant" form:"medfee_sumant"`
1892
+	OptinsPaySumamt float64 `gorm:"column:optins_pay_sumamt" json:"optins_pay_sumamt" form:"optins_pay_sumamt"`
1893
+	CnfmFlag        int64   `gorm:"column:cnfm_flag" json:"cnfm_flag" form:"cnfm_flag"`
1894
+	MsgId           string  `gorm:"column:msg_id" json:"msg_id" form:"msg_id"`
1895
+}
1896
+
1897
+func (HisYidiClearRecord) TableName() string {
1898
+	return "his_yidi_clear_record"
1899
+}
1900
+
1901
+type HisPrescriptionProjectTwo struct {
1902
+	ID             int64   `gorm:"column:id" json:"id" form:"id"`
1903
+	ProjectId      int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1904
+	Price          float64 `gorm:"column:price" json:"price" form:"price"`
1905
+	UserOrgId      int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1906
+	Status         int64   `gorm:"column:status" json:"status" form:"status"`
1907
+	PatientId      int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1908
+	RecordDate     int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1909
+	PrescriptionId int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1910
+	Count          string  `gorm:"column:count" json:"count" form:"count"`
1911
+	FeedetlSn      string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1912
+	Type           int64   `gorm:"column:type" json:"type" form:"type"`
1913
+	Doctor         int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
1914
+	ExecutionTime  int64   `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
1915
+	ExecutionStaff int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1916
+	ExecutionState int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1917
+	CheckTime      int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
1918
+	CheckState     int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
1919
+	Checker        int64   `gorm:"column:checker" json:"checker" form:"checker"`
1920
+}
1921
+
1922
+func (HisPrescriptionProjectTwo) TableName() string {
1923
+	return "his_prescription_project"
1924
+}

+ 123 - 0
models/his_print_models.go View File

@@ -0,0 +1,123 @@
1
+package models
2
+
3
+type PrintPatient struct {
4
+	ID                     int64                   `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId              int64                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	Name                   string                  `gorm:"column:name" json:"name" form:"name"`
7
+	Age                    string                  `gorm:"column:age" json:"age" form:"age"`
8
+	Gender                 int64                   `gorm:"column:gender" json:"gender" form:"gender"`
9
+	HomeAddress            string                  `gorm:"column:home_address" json:"home_address" form:"home_address"`
10
+	Phone                  string                  `gorm:"column:phone" json:"phone" form:"phone"`
11
+	Lapseto                int64                   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
12
+	Status                 int64                   `gorm:"column:status" json:"status" form:"status"`
13
+	HisPrintPatient        HisPrintPatient         `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
14
+	HisHospitalCheckRecord HisHospitalCheckRecord  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_record_patient"`
15
+	HisPrescriptionInfoTwo HisPrescriptionInfoTwo  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"info"`
16
+	HisPrintPrescription   []*HisPrintPrescription `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"prescriptions"`
17
+}
18
+
19
+func (PrintPatient) TableName() string {
20
+	return "xt_patients"
21
+}
22
+
23
+type HisPrintPatient struct {
24
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
25
+	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
26
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
27
+	Name                   string  `gorm:"column:name" json:"name" form:"name"`
28
+	Gender                 int64   `gorm:"column:gender" json:"gender" form:"gender"`
29
+	IdType                 int64   `gorm:"column:id_type" json:"id_type" form:"id_type"`
30
+	RecordDate             int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
31
+	PhoneNumber            string  `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
32
+	IdCardNo               string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
33
+	RegisterType           int64   `gorm:"column:register_type" json:"register_type" form:"register_type"`
34
+	AdminUserId            int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
35
+	Departments            int64   `gorm:"column:departments" json:"departments" form:"departments"`
36
+	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
37
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
38
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
39
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
40
+	Number                 string  `gorm:"column:number" json:"number" form:"number"`
41
+	Doctor                 int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
42
+	IsReturn               int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
43
+	PsnNo                  string  `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
44
+	PsnCertType            string  `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
45
+	Certno                 string  `gorm:"column:certno" json:"certno" form:"certno"`
46
+	PsnName                string  `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
47
+	Gend                   string  `gorm:"column:gend" json:"gend" form:"gend"`
48
+	Naty                   string  `gorm:"column:naty" json:"naty" form:"naty"`
49
+	Brdy                   string  `gorm:"column:brdy" json:"brdy" form:"brdy"`
50
+	Iinfo                  string  `gorm:"column:iinfo" json:"iinfo" form:"iinfo"`
51
+	Idetinfo               string  `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
52
+	IptOtpNo               string  `gorm:"column:ipt_otp_no" json:"ipt_otp_no" form:"ipt_otp_no"`
53
+	Phone                  string  `gorm:"column:phone" json:"phone" form:"phone"`
54
+	SocialType             int64   `gorm:"column:social_type" json:"social_type" form:"social_type"`
55
+	IdCardType             int64   `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
56
+	PType                  int64   `gorm:"column:p_type" json:"p_type" form:"p_type"`
57
+	Diagnosis              string  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
58
+	SickType               int64   `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
59
+	PatientInfo            string  `gorm:"column:patient_info" json:"patient_info" form:"patient_info"`
60
+}
61
+
62
+func (HisPrintPatient) TableName() string {
63
+	return "his_patient"
64
+}
65
+
66
+type HisPrintPrescription struct {
67
+	ID                     int64                     `gorm:"column:id" json:"id" form:"id"`
68
+	UserOrgId              int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
69
+	RecordDate             int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
70
+	PatientId              int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
71
+	HisPatientId           int64                     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
72
+	Status                 int64                     `gorm:"column:status" json:"status" form:"status"`
73
+	Ctime                  int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
74
+	Mtime                  int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
75
+	Number                 string                    `gorm:"column:number" json:"number" form:"number"`
76
+	Type                   int64                     `gorm:"column:type" json:"type" form:"type"`
77
+	Doctor                 string                    `gorm:"column:doctor" json:"doctor" form:"doctor"`
78
+	Creator                int64                     `gorm:"column:creator" json:"creator" form:"creator"`
79
+	Modifier               int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
80
+	OrderStatus            int64                     `gorm:"column:order_status" json:"order_status" form:"order_status"`
81
+	PreTime                int64                     `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
82
+	BatchNumber            string                    `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
83
+	PrescriptionNumber     string                    `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
84
+	Patients               Patients                  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
85
+	HisPatient             VMHisPatient              `gorm:"ForeignKey:PatientId;AssociationForeignKey:patient_id" json:"hisPatient"`
86
+	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
87
+	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
88
+	Total                  string                    `gorm:"-" json:"total" form:"total"`
89
+	PType                  int64                     `gorm:"column:p_type" json:"p_type" form:"p_type"`
90
+	MedType                string                    `gorm:"column:med_type" json:"med_type" form:"med_type"`
91
+}
92
+
93
+func (HisPrintPrescription) TableName() string {
94
+	return "his_prescription"
95
+}
96
+
97
+type HisPrescriptionInfoTwo struct {
98
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
99
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
100
+	RecordDate         int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
101
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
102
+	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
103
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
104
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
105
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
106
+	Creator            int64  `gorm:"column:creator" json:"creator" form:"creator"`
107
+	Modifier           int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
108
+	Diagnosis          string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
109
+	RegisterType       int64  `gorm:"column:register_type" json:"register_type" form:"register_type"`
110
+	Doctor             string `gorm:"column:doctor" json:"doctor" form:"doctor"`
111
+	Departments        string `gorm:"column:departments" json:"departments" form:"departments"`
112
+	SickHistory        string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
113
+	PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
114
+	BatchNumber        string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
115
+	PrescriptionStatus int64  `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
116
+	DoctorId           int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
117
+	DepartmentId       int64  `gorm:"column:department_id" json:"department_id" form:"department_id"`
118
+	SickType           int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
119
+}
120
+
121
+func (HisPrescriptionInfoTwo) TableName() string {
122
+	return "his_prescription_info"
123
+}

+ 10 - 9
models/supply.models.go View File

@@ -2,15 +2,16 @@ package models
2 2
 
3 3
 //供应商联系人
4 4
 type SpSupplierContacts struct {
5
-	ID        int64  `gorm:"column:id" json:"id" from:"id"`
6
-	Name      string `gorm:"column:name" json:"name" from:"name"`
7
-	Phone     string `gorm:"column:phone" json:"phone" from:"phone"`
8
-	Address   string `gorm:"column:address" json:"address" from:"address"`
9
-	IsFirst   int64  `gorm:"column:is_first" json:"is_first" from:"is_first"`
10
-	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" from:"user_org_id"`
11
-	Status    int64  `gorm:"column:status" json:"status" from:"status"`
12
-	Ctime     int64  `gorm:"column:ctime" json:"ctime" from:"ctime"`
13
-	Mtime     int64  `gorm:"column:mtime" json:"mtime" from:"mtime"`
5
+	ID           int64  `gorm:"column:id" json:"id" from:"id"`
6
+	Name         string `gorm:"column:name" json:"name" from:"name"`
7
+	Phone        string `gorm:"column:phone" json:"phone" from:"phone"`
8
+	Address      string `gorm:"column:address" json:"address" from:"address"`
9
+	IsFirst      int64  `gorm:"column:is_first" json:"is_first" from:"is_first"`
10
+	SupplierCode string `gorm:"column:supplier_code" json:"supplier_code" from:"supplier_code"`
11
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" from:"user_org_id"`
12
+	Status       int64  `gorm:"column:status" json:"status" from:"status"`
13
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" from:"ctime"`
14
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" from:"mtime"`
14 15
 }
15 16
 
16 17
 func (SpSupplierContacts) TableName() string {

+ 1 - 0
routers/router.go View File

@@ -56,6 +56,7 @@ func init() {
56 56
 	controllers.HisConfigApiRegistRouters()
57 57
 	controllers.HisChargeApiRegistRouters()
58 58
 	controllers.HisHospitalManagerApiRegistRouters()
59
+	controllers.HisPrintApiRegistRouters()
59 60
 
60 61
 	m_api.MobileAPIControllersRegisterRouters()
61 62
 	new_m_api.NewMobileAPIControllersRegisterRouters()

+ 1 - 1
service/gobal_config_service.go View File

@@ -248,7 +248,7 @@ func GetExportHisOrderList(user_org_id int64, start_time int64, end_time int64,
248 248
 		Preload("HisPrescriptionInfo", func(db *gorm.DB) *gorm.DB {
249 249
 			return db.Where("status = 1 AND user_org_id = ?", user_org_id).Preload("XtHisDepartment", "status = 1")
250 250
 		})
251
-	err = db.Order("ctime desc").Find(&order).Error
251
+	err = db.Order("setl_time asc").Find(&order).Error
252 252
 	return
253 253
 }
254 254
 

+ 10 - 0
service/his_charge_service.go View File

@@ -301,3 +301,13 @@ func FindFapiaoByIsUse(org_id int64) (models.HisFapiaoRecord, error) {
301 301
 	err := readDb.Model(&models.HisFapiaoRecord{}).Where("user_org_id = ? AND status = 1 AND is_use = 1", org_id).First(&record).Error
302 302
 	return record, err
303 303
 }
304
+
305
+func FindHisYidiClearRecord(org_id int64) (records []*models.HisYidiClearRecord, err error) {
306
+	err = readDb.Model(&models.HisYidiClearRecord{}).Where("user_org_id = ? AND status = 1", org_id).Find(&records).Error
307
+	return
308
+}
309
+
310
+func GetHisYidiClearRecordById(org_id int64, id int64) (record models.HisYidiClearRecord, err error) {
311
+	err = readDb.Model(&models.HisYidiClearRecord{}).Where("user_org_id = ? AND status = 1 AND id = ?", org_id, id).First(&record).Error
312
+	return
313
+}

+ 47 - 0
service/his_print_service.go View File

@@ -0,0 +1,47 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
7
+
8
+func GetBatchDrugHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
9
+	readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
10
+		Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
11
+			return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type = 1", user_org_id, record_time).
12
+				Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
13
+					return db.Where("status = 1 AND user_org_id = ?", user_org_id).Preload("Drug", "status=1")
14
+				})
15
+		}).
16
+		Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
17
+		Where("id in (?) AND user_org_id = ?", ids, user_org_id).Find(&patients)
18
+	return
19
+}
20
+
21
+func GetBatchProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
22
+	readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
23
+		Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
24
+			return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1", user_org_id, record_time).
25
+				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
26
+					return db.Where("status = 1 ").Preload("HisProject", "status = 1").Preload("GoodInfo", "status=1")
27
+				})
28
+		}).
29
+		Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
30
+		Where("id in (?) AND user_org_id = ?  ", ids, user_org_id).Find(&patients)
31
+	return
32
+
33
+}
34
+
35
+func GetBatchInspectionProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
36
+	readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
37
+		Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
38
+			return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1", user_org_id, record_time).
39
+				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
40
+					return db.Where("status = 1 ").Preload("HisProject", "status = 1 AND cost_classify = 3")
41
+				})
42
+		}).
43
+		Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
44
+		Where("id in (?) AND user_org_id = ?  ", ids, user_org_id).Find(&patients)
45
+	return
46
+
47
+}

+ 29 - 2
service/his_service.go View File

@@ -854,7 +854,7 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
854 854
 	return
855 855
 }
856 856
 
857
-func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int64, end_time int64, doctor_id int64, keywords string, p_type int64) (order []*models.HisOrder, err error, total int64) {
857
+func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int64, end_time int64, doctor_id int64, keywords string, p_type int64, sort_type int64) (order []*models.HisOrder, err error, total int64) {
858 858
 	offset := (page - 1) * limit
859 859
 	db := readDb.Model(&models.HisOrder{})
860 860
 
@@ -883,7 +883,24 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int6
883 883
 		Preload("HisHospitalCheckRecord", "status = 1 AND user_org_id = ?", user_org_id)
884 884
 	db = db.Preload("HisFundSettleListResult", "status = 1")
885 885
 	db = db.Count(&total)
886
-	err = db.Limit(limit).Offset(offset).Order("settle_accounts_date desc,ctime").Find(&order).Error
886
+	db = db.Limit(limit).Offset(offset)
887
+	if user_org_id == 10215 {
888
+		if sort_type == 1 {
889
+			err = db.Order("settle_accounts_date asc,ctime asc").Find(&order).Error
890
+		}
891
+		if sort_type == 2 {
892
+			err = db.Order("setl_time asc,ctime asc").Find(&order).Error
893
+		}
894
+
895
+	} else {
896
+		if sort_type == 1 {
897
+			err = db.Order("settle_accounts_date desc,ctime desc").Find(&order).Error
898
+		}
899
+		if sort_type == 2 {
900
+			err = db.Order("setl_time desc,ctime desc").Find(&order).Error
901
+		}
902
+	}
903
+
887 904
 	return
888 905
 }
889 906
 
@@ -2248,3 +2265,13 @@ func GetHisDoctorAdviceInfo(id int64) (models.HisDoctorAdviceInfo, error) {
2248 2265
 	err := readDb.Model(&info).Where("id = ? and status = 1", id).Preload("Drug", "status = 1").Find(&info).Error
2249 2266
 	return info, err
2250 2267
 }
2268
+
2269
+func UpdateBatchHisPrescriptionMedType(ids []string, med_type string, start_time int64, end_time int64, user_org_id int64, old_med_type string) (err error) {
2270
+	tx := writeDb.Begin()
2271
+	if err = tx.Model(&models.HisPrescription{}).Where("id in (?) AND status = 1 AND user_org_id=? AND med_type = ? AND record_date >= ? AND record_date <= ?", ids, user_org_id, old_med_type, start_time, end_time).Updates(map[string]interface{}{"med_type": med_type}).Error; err != nil {
2272
+		tx.Rollback()
2273
+		return
2274
+	}
2275
+	tx.Commit()
2276
+	return
2277
+}

+ 2 - 5
service/patient_service.go View File

@@ -2612,10 +2612,7 @@ func GetAllPrescriptionByListOne(orgID int64, scheduleDate int64) (prescriptions
2612 2612
 	}
2613 2613
 }
2614 2614
 
2615
-func GetAllHisProjectPrescription(orgid int64, recorddate int64) (project []*models.HisPrescriptionProject, err error) {
2616
-
2617
-	err = XTReadDB().Where("user_org_id = ? and record_date = ? and status = 1", orgid, recorddate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
2618
-		return db.Preload("GoodsType", "status = 1").Where("status = 1 ")
2619
-	}).Find(&project).Error
2615
+func GetAllHisProjectPrescription(orgid int64, recorddate int64) (project []*models.HisPrescriptionProjectTwo, err error) {
2616
+	err = XTReadDB().Where("user_org_id = ? and record_date = ? and status = 1", orgid, recorddate).Find(&project).Error
2620 2617
 	return project, err
2621 2618
 }

+ 175 - 10
service/supply_service.go View File

@@ -7,6 +7,158 @@ import (
7 7
 	"time"
8 8
 )
9 9
 
10
+//根据供应商编号获取首要联系人
11
+func FindName(code string) (fistname models.SpSupplierContacts, err error) {
12
+	err = XTReadDB().Model(&models.SpSupplierContacts{}).Where("supplier_code = ? and status = 1", code).First(&fistname).Error
13
+	return fistname, err
14
+}
15
+
16
+//供应商分页
17
+func GetSupplyList(ctype int64, page int64, limit int64, code string, sname string, cname string) (supplylist []*models.SpSupplierName, total int64, err error) {
18
+	db := XTReadDB().Model(&supplylist).Where("sgj_xt.xt_supplier_name.status = 1 ")
19
+
20
+	offset := (page - 1) * limit
21
+
22
+	if cname != "" {
23
+		cname = "%" + cname + "%" //联系人
24
+		db = db.Joins("join sgj_xt.xt_supplier_contacts on sgj_xt.xt_supplier_contacts.supplier_code = sgj_xt.xt_supplier_name.supplier_code")
25
+		db = db.Where("sgj_xt.xt_supplier_contacts.name like ? and sgj_xt.xt_supplier_contacts.status = 1 ", cname).Group("sgj_xt.xt_supplier_name.id")
26
+	}
27
+	if ctype > 0 {
28
+		db = db.Where("sgj_xt.xt_supplier_name.supplier_type = ?", ctype)
29
+	}
30
+	if code != "" {
31
+		code = "%" + code + "%" //供应商编码
32
+		db = db.Where("sgj_xt.xt_supplier_name.supplier_code = ?", code)
33
+	}
34
+	if sname != "" {
35
+		sname = "%" + sname + "%" //供应商名称
36
+		db = db.Where("sgj_xt.xt_supplier_name.supplier_name = ?", sname)
37
+	}
38
+	err = db.Count(&total).Offset(offset).Limit(limit).Find(&supplylist).Error
39
+	return supplylist, total, err
40
+}
41
+
42
+//修改供应商和联系人
43
+func UpdateSupplyAndContact(thisStockIn []interface{}, suid, orgId, supplierType, tcreater int64, supplierCode, supplierName, number, bank, bankAccount string, vatRate float64) error {
44
+	tx := XTWriteDB().Begin()
45
+	defer func() {
46
+		if err != nil {
47
+			tx.Rollback()
48
+		} else {
49
+			tx.Commit()
50
+		}
51
+	}()
52
+	for _, item := range thisStockIn {
53
+		items := item.(map[string]interface{})
54
+		//查询是否
55
+		id, _ := strconv.ParseInt(items["id"].(string), 10, 64)
56
+		name := items["name"].(string)
57
+		phone := items["phone"].(string)
58
+		address := items["address"].(string)
59
+		isfirst, _ := strconv.ParseInt(items["isfirst"].(string), 10, 64)
60
+		updatecontacts := models.SpSupplierContacts{
61
+			ID:           id,
62
+			Name:         name,
63
+			Phone:        phone,
64
+			Address:      address,
65
+			IsFirst:      isfirst,
66
+			SupplierCode: supplierCode,
67
+			UserOrgId:    orgId,
68
+			Status:       1,
69
+			Ctime:        0,
70
+			Mtime:        time.Now().Unix(),
71
+		}
72
+		if id == 0 {
73
+			spcontacts := models.SpSupplierContacts{
74
+				Name:         name,
75
+				Phone:        phone,
76
+				Address:      address,
77
+				IsFirst:      isfirst,
78
+				SupplierCode: supplierCode,
79
+				UserOrgId:    orgId,
80
+				Status:       1,
81
+				Ctime:        time.Now().Unix(),
82
+				Mtime:        0,
83
+			}
84
+			err = SaveContacts(spcontacts, tx)
85
+			if err != nil {
86
+				return err
87
+			}
88
+		} else {
89
+			err = UpdateContact(updatecontacts, tx)
90
+		}
91
+		var tmpid int64
92
+		if isfirst == 1 {
93
+			if id == 0 {
94
+				var spconid []*models.SpSupplierContacts
95
+				spconid, err = SaveContactsId(tx)
96
+
97
+				if err != nil {
98
+					return err
99
+				}
100
+				tmpid = spconid[0].ID
101
+			} else {
102
+				tmpid = id
103
+			}
104
+			//更新供应商
105
+			upsupply := models.SpSupplierName{
106
+				ID:           suid,
107
+				SupplierCode: supplierCode,
108
+				SupplierName: supplierName,
109
+				SupplierType: supplierType,
110
+				VatRate:      vatRate,
111
+				Number:       number,
112
+				Bank:         bank,
113
+				BankAccount:  bankAccount,
114
+				UserOrgId:    orgId,
115
+				Status:       1,
116
+				ContactsId:   tmpid,
117
+				Mtime:        time.Now().Unix(),
118
+				Modify:       tcreater,
119
+			}
120
+			err = UpdateSupplyName(upsupply, tx)
121
+			if err != nil {
122
+				return err
123
+			}
124
+		}
125
+
126
+	}
127
+	return err
128
+}
129
+
130
+//更新一条供应商的信息
131
+func UpdateSupplyName(upsupply models.SpSupplierName, tx *gorm.DB) error {
132
+	err := tx.Model(&models.SpSupplierName{}).Where("id = ? and status = 1", upsupply.ID).Updates(map[string]interface{}{"supplier_code": upsupply.SupplierCode, "supplier_name": upsupply.SupplierName, "supplier_type": upsupply.SupplierType, "vat_rate": upsupply.VatRate, "number": upsupply.Number, "bank": upsupply.Bank, "bank_account": upsupply.BankAccount, "user_org_id": upsupply.UserOrgId, "status": upsupply.Status, "contacts_id": upsupply.ContactsId, "mtime": upsupply.Mtime, "modify": upsupply.Modify}).Error
133
+	return err
134
+}
135
+
136
+//更新一条联系人的信息
137
+func UpdateContact(updatecontacts models.SpSupplierContacts, tx *gorm.DB) error {
138
+	err := tx.Model(&models.SpSupplierContacts{}).Where("id = ? and status = 1", updatecontacts.ID).Updates(map[string]interface{}{"name": updatecontacts.Name, "phone": updatecontacts.Phone, "address": updatecontacts.Address, "is_first": updatecontacts.IsFirst, "supplier_code": updatecontacts.SupplierCode, "user_org_id": updatecontacts.UserOrgId, "status": updatecontacts.Status, "mtime": updatecontacts.Mtime}).Error
139
+	return err
140
+}
141
+
142
+//查询供应商单条记录
143
+func GetSupplyOne(id int64) (supply models.SpSupplierName, err error) {
144
+	err = XTReadDB().Model(&models.SpSupplierName{}).Where("id = ? and status = 1", id).First(&supply).Error
145
+	return supply, err
146
+}
147
+
148
+//删除单条联系人记录
149
+func DelContactOne(id int64) error {
150
+	err := XTWriteDB().Model(&models.SpSupplierContacts{}).Where("id = ?", id).Update("status", 0).Error
151
+	return err
152
+}
153
+
154
+//获取单条供应商和涉及到的联系人记录
155
+func GetSupplyAndContactOne(id int64) (supply models.SpSupplierName, contact []*models.SpSupplierContacts, err error) {
156
+	err = XTReadDB().Model(&models.SpSupplierName{}).Where("id = ? and status = 1", id).First(&supply).Error
157
+	code := supply.SupplierCode
158
+	err = XTReadDB().Model(&models.SpSupplierContacts{}).Where("supplier_code = ? and status = 1", code).Find(&contact).Error
159
+	return supply, contact, err
160
+}
161
+
10 162
 //删除供应商及联系人
11 163
 func DelSupply(supply models.SpSupplierName) error {
12 164
 	err := XTWriteDB().Model(&supply).Update("status", 0).Error
@@ -31,14 +183,15 @@ func SaveSupplyAndContact(thisStockIn []interface{}, orgId, supplierType, tcreat
31 183
 		isfirst, _ := strconv.ParseInt(items["isfirst"].(string), 10, 64)
32 184
 
33 185
 		spcontacts := models.SpSupplierContacts{
34
-			Name:      name,
35
-			Phone:     phone,
36
-			Address:   address,
37
-			IsFirst:   isfirst,
38
-			UserOrgId: orgId,
39
-			Status:    1,
40
-			Ctime:     time.Now().Unix(),
41
-			Mtime:     0,
186
+			Name:         name,
187
+			Phone:        phone,
188
+			Address:      address,
189
+			IsFirst:      isfirst,
190
+			SupplierCode: supplierCode,
191
+			UserOrgId:    orgId,
192
+			Status:       1,
193
+			Ctime:        time.Now().Unix(),
194
+			Mtime:        0,
42 195
 		}
43 196
 		err = SaveContacts(spcontacts, tx)
44 197
 		if isfirst == 1 {
@@ -82,7 +235,7 @@ func SaveSupplyAndContact(thisStockIn []interface{}, orgId, supplierType, tcreat
82 235
 //获取供应商编码
83 236
 func GetSuppliyCode() (spcode []*models.SpSupplierName, err error) {
84 237
 
85
-	err = XTReadDB().Model(&models.SpSupplierName{}).Select("supplier_code").Where("supplier_code like 'gys%' ").Order("supplier_code desc").First(&spcode).Error
238
+	err = XTReadDB().Model(&models.SpSupplierName{}).Select("supplier_code").Where("supplier_code like 'gys%' and status = 1 ").Order("supplier_code desc").First(&spcode).Error
86 239
 	return spcode, err
87 240
 }
88 241
 
@@ -98,6 +251,18 @@ func FindSupplierName(supplierName string) (sbool bool, err error) {
98 251
 	return sbool, err
99 252
 }
100 253
 
254
+//查询供应商的编号是否有重复
255
+func FindSupplierCode(supplierCode string) (codebool bool, err error) {
256
+	var total int
257
+	err = XTReadDB().Model(&models.SpSupplierName{}).Where("supplier_name = ? and status = 1", supplierCode).Count(&total).Error
258
+	if total != 0 {
259
+		codebool = true
260
+	} else {
261
+		codebool = false
262
+	}
263
+	return codebool, err
264
+}
265
+
101 266
 //保存一条供应商数据
102 267
 func SaveSupply(supply models.SpSupplierName, tx *gorm.DB) error {
103 268
 	err := tx.Create(&supply).Error
@@ -106,7 +271,7 @@ func SaveSupply(supply models.SpSupplierName, tx *gorm.DB) error {
106 271
 
107 272
 //获取联系人的id
108 273
 func SaveContactsId(tx *gorm.DB) (spconid []*models.SpSupplierContacts, err error) {
109
-	err = tx.Model(&models.SpSupplierContacts{}).Select("id").Order("id desc").First(&spconid).Error
274
+	err = tx.Model(&models.SpSupplierContacts{}).Select("id").Where("and status = 1").Order("id desc").First(&spconid).Error
110 275
 	return
111 276
 }
112 277