Browse Source

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

XMLWAN 2 years ago
parent
commit
866cd1b3ab

+ 639 - 0
controllers/coordinate_controller.go View File

@@ -0,0 +1,639 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"fmt"
10
+	"github.com/astaxie/beego"
11
+	"io/ioutil"
12
+	"math/rand"
13
+	"strconv"
14
+	"strings"
15
+	"time"
16
+)
17
+
18
+type CoordinateController struct {
19
+	BaseAPIController
20
+}
21
+
22
+type ResultReg struct {
23
+	ResultCode string `json:"resultCode"`
24
+	ResultDesc string `json:"resultDesc"`
25
+	InfoSeq    string `json:"infoSeq"`
26
+}
27
+
28
+type ResultSettle struct {
29
+	ResultCode string `json:"resultCode"`
30
+	ResultDesc string `json:"resultDesc"`
31
+	DocId      string `json:"docId"`
32
+	Amount     string `json:"amount"`
33
+}
34
+
35
+type ResultCancelSettle struct {
36
+	ResultCode string `json:"resultCode"`
37
+	ResultDesc string `json:"resultDesc"`
38
+}
39
+
40
+type Settle struct {
41
+	PatientId string `json:"resultCode"`
42
+	DocId     string `json:"docId"`
43
+	InfoSeq   string `json:"infoSeq"`
44
+}
45
+
46
+type Refund struct {
47
+	PatientId string `json:"resultCode"`
48
+	DocId     string `json:"docId"`
49
+	InfoSeq   string `json:"infoSeq"`
50
+}
51
+
52
+type RefundDetail struct {
53
+	Msg    string `json:"msg"`
54
+	Result []struct {
55
+		ResultMsg string `json:"resultMsg"`
56
+		Code      string `json:"code"`
57
+		Records   int    `json:"records"`
58
+		TotalPage int    `json:"totalPage"`
59
+		List      []struct {
60
+			Zae01 int64 `json:"ZAE01"`
61
+		} `json:"list"`
62
+		RecordsTotal  int    `json:"recordsTotal"`
63
+		Pagenumber    int    `json:"pagenumber"`
64
+		Result        string `json:"result"`
65
+		Total         int    `json:"total"`
66
+		RecordsFtered int    `json:"recordsFtered"`
67
+		Page          int    `json:"page"`
68
+	} `json:"result"`
69
+	Code string `json:"code"`
70
+}
71
+
72
+func CoordinateRegistRouters() {
73
+	beego.Router("/coordinate/check", &CoordinateController{}, "get:SavePatientMessageInfo")
74
+	//坐标挂号
75
+	beego.Router("/coordinate/register", &CoordinateController{}, "get:Register")
76
+	//beego.Router("/coordinate/getWaitPayDetail", &CoordinateController{}, "get:GetWaitPayDetail")
77
+	//坐标记账
78
+	beego.Router("/coordinate/opKeepAccounts", &CoordinateController{}, "get:OpKeepAccounts")
79
+	//坐标撤销记账
80
+	beego.Router("/coordinate/opCancelKeepAccounts", &CoordinateController{}, "get:OpCancelKeepAccounts")
81
+	//坐标结算回调
82
+	beego.Router("/coordinate/settle", &CoordinateController{}, "post:Settle")
83
+	//坐标退费回调
84
+	beego.Router("/coordinate/refund", &CoordinateController{}, "post:Refund")
85
+
86
+}
87
+
88
+func (c *CoordinateController) Settle() {
89
+	//参数1 patient_id
90
+	//参数2 就诊号
91
+	//参数3 单据id
92
+	fmt.Println(c.Ctx.Request.Body)
93
+
94
+	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
95
+	fmt.Println(string(body))
96
+
97
+	var respJSON map[string]interface{}
98
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
99
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
100
+		return
101
+	}
102
+	patien_id := respJSON["patientId"].(string)
103
+	infoSeq := respJSON["infoSeq"].(string)
104
+	docId := respJSON["docId"].(string)
105
+	fmt.Println(patien_id)
106
+	fmt.Println(infoSeq)
107
+	fmt.Println(docId)
108
+
109
+	order, _ := service.GetHisOrderFour(patien_id, infoSeq, docId)
110
+	if order.ID == 0 {
111
+		json := make(map[string]interface{})
112
+		json["msg"] = "结算记录不存在,请检查参数是否正确"
113
+		json["code"] = "-1"
114
+		c.Data["json"] = json
115
+		c.ServeJSON()
116
+		return
117
+	}
118
+	order.OrderStatus = 2
119
+	service.UpDateOrder(order)
120
+	service.UpdataOrderStatusTwo(order.Number, order.UserOrgId)
121
+	json := make(map[string]interface{})
122
+	json["msg"] = "结算成功"
123
+	json["code"] = "0"
124
+	c.Data["json"] = json
125
+	c.ServeJSON()
126
+	return
127
+}
128
+func (c *CoordinateController) Refund() {
129
+	//参数1 patient_id
130
+	//参数2 就诊号
131
+	//参数3 单据id
132
+	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
133
+	var respJSON map[string]interface{}
134
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
135
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
136
+		return
137
+	}
138
+	patien_id := respJSON["patientId"].(string)
139
+	infoSeq := respJSON["infoSeq"].(string)
140
+	docId := respJSON["docId"].(string)
141
+	order, _ := service.GetHisOrderFour(patien_id, infoSeq, docId)
142
+	if order.ID == 0 {
143
+		json := make(map[string]interface{})
144
+		json["msg"] = "结算记录不存在,请检查参数是否正确"
145
+		json["code"] = "-1"
146
+		c.Data["json"] = json
147
+		c.ServeJSON()
148
+		return
149
+	}
150
+	service.UpdataOrderStatus(order.ID, order.Number, order.UserOrgId)
151
+	json := make(map[string]interface{})
152
+	json["msg"] = "退费成功"
153
+	json["code"] = "0"
154
+	c.Data["json"] = json
155
+	c.ServeJSON()
156
+	return
157
+}
158
+
159
+func (c *CoordinateController) SavePatientMessageInfo() {
160
+	result, request_log := service.SavePatientMessageInfo()
161
+	fmt.Println(result)
162
+	fmt.Println(request_log)
163
+
164
+}
165
+
166
+func (c *CoordinateController) Register() {
167
+	patient_id, _ := c.GetInt64("patient_id")
168
+	diagnosis_time := c.GetString("diagnosis_time")
169
+	record_date := c.GetString("record_date")
170
+	admin_user_id, _ := c.GetInt64("admin_user_id")
171
+	org_id, _ := c.GetInt64("org_id")
172
+	org_id = 4
173
+	patient, _ := service.GetPatientByID(org_id, patient_id)
174
+
175
+	timeLayout := "2006-01-02"
176
+	loc, _ := time.LoadLocation("Local")
177
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
178
+	if err != nil {
179
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
180
+		return
181
+	}
182
+	recordDateTime := theTime.Unix()
183
+	patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2)
184
+	if patientPrescription.ID == 0 {
185
+		patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime)
186
+	}
187
+	//department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
188
+	doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId)
189
+
190
+	//admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
191
+
192
+	reg := models.Reg{
193
+		DeptId:      "0112",
194
+		PatientId:   patient.ZbPatientId,
195
+		PatientName: patient.Name,
196
+		DoctorId:    doctor_info.DoctorNumber,
197
+		RegDate:     strings.Split(diagnosis_time, " ")[0],
198
+		RegFee:      "8",
199
+		TreatFee:    "10",
200
+		OperatorId:  "测试",
201
+		IdCardNo:    patient.IdCardNo,
202
+	}
203
+
204
+	result, request_log := service.SaveReg(reg)
205
+	fmt.Println(result)
206
+	fmt.Println(request_log)
207
+
208
+	var res ResultReg
209
+	//if err := json.Unmarshal([]byte(result), &res); err != nil {
210
+	//	utils.ErrorLog("解析失败:%v", err)
211
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
212
+	//	return
213
+	//}
214
+	res.ResultCode = "0"
215
+	res.InfoSeq = "122333"
216
+	if res.ResultCode == "0" {
217
+		timestamp := time.Now().Unix()
218
+		tempTime := time.Unix(timestamp, 0)
219
+		timeFormat := tempTime.Format("20060102150405")
220
+		chrgBchno := rand.Intn(100000) + 10000
221
+		ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10)
222
+		his := models.VMHisPatient{
223
+			Name:                   patient.Name,
224
+			Gender:                 patient.Gender,
225
+			Birthday:               patient.Birthday,
226
+			MedicalTreatmentType:   0,
227
+			IdType:                 1,
228
+			IdCardNo:               patient.IdCardNo,
229
+			BalanceAccountsType:    1,
230
+			MedicalInsuranceNumber: "",
231
+			RegisterType:           0,
232
+			RegisterCost:           0,
233
+			TreatmentCost:          0,
234
+			Status:                 1,
235
+			Ctime:                  time.Now().Unix(),
236
+			Mtime:                  time.Now().Unix(),
237
+			PsnNo:                  patient.ZbPatientId,
238
+			PsnCertType:            "",
239
+			Certno:                 patient.IdCardNo,
240
+			PsnName:                patient.Name,
241
+			Gend:                   "",
242
+			Naty:                   "",
243
+			Brdy:                   "",
244
+			Age:                    0,
245
+			Iinfo:                  "",
246
+			Idetinfo:               "",
247
+			PatientId:              patient.ID,
248
+			RecordDate:             theTime.Unix(),
249
+			UserOrgId:              org_id,
250
+			AdminUserId:            admin_user_id,
251
+			IsReturn:               1,
252
+			Doctor:                 patientPrescription.DoctorId,
253
+			Departments:            patientPrescription.Departments,
254
+			IptOtpNo:               ipt_otp_no,
255
+			Number:                 res.InfoSeq,
256
+			PhoneNumber:            patient.Phone,
257
+		}
258
+		service.UpdateHisPatientStatus(&his)
259
+		service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id)
260
+		c.ServeSuccessJSON(map[string]interface{}{
261
+			"his_info": his,
262
+		})
263
+	} else {
264
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
265
+		return
266
+	}
267
+}
268
+
269
+//func (c *CoordinateController) GetWaitPayDetail() {
270
+//	result, request_log := service.GetWaitPayDetail()
271
+//	fmt.Println(result)
272
+//	fmt.Println(request_log)
273
+//
274
+//}
275
+
276
+func (c *CoordinateController) OpKeepAccounts() {
277
+	id, _ := c.GetInt64("id")
278
+	record_time := c.GetString("record_time")
279
+	his_patient_id, _ := c.GetInt64("his_patient_id")
280
+	timeLayout := "2006-01-02"
281
+	loc, _ := time.LoadLocation("Local")
282
+	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
283
+	fapiao_code := c.GetString("fapiao_code")
284
+	fapiao_number := c.GetString("fapiao_number")
285
+	diagnosis_id := c.GetString("diagnosis")
286
+	sick_type, _ := c.GetInt64("sick_type")
287
+	reg_type, _ := c.GetInt64("p_type")
288
+	org_id, _ := c.GetInt64("org_id")
289
+	org_id = 4
290
+	his, _ := service.GetHisPatientByIdThree(his_patient_id)
291
+
292
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
293
+	if err != nil {
294
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
295
+		return
296
+	}
297
+	recordDateTime := theTime.Unix()
298
+	//adminUser := c.GetAdminUserInfo()
299
+	var prescriptions []*models.HisPrescription
300
+	var start_time int64
301
+	var end_time int64
302
+
303
+	//ids_str := c.GetString("ids")
304
+	//ids_arr := strings.Split(ids_str, ",")
305
+
306
+	if settle_accounts_type == 1 { //日结
307
+		//fmt.Println(reg_type)
308
+		prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, id, recordDateTime, 2)
309
+
310
+	} else { //月结
311
+
312
+		start_time_str := c.GetString("start_time")
313
+		end_time_str := c.GetString("end_time")
314
+		timeLayout := "2006-01-02"
315
+		loc, _ := time.LoadLocation("Local")
316
+		theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
317
+		if err != nil {
318
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
319
+			return
320
+		}
321
+		recordStartTime := theStartTime.Unix()
322
+		start_time = recordStartTime
323
+		theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
324
+		if err != nil {
325
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
326
+			return
327
+		}
328
+		recordEndTime := theEndTime.Unix()
329
+		end_time = recordEndTime
330
+		prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, id, recordStartTime, recordEndTime)
331
+	}
332
+
333
+	timestamp := time.Now().Unix()
334
+	tempTime := time.Unix(timestamp, 0)
335
+	timeFormat := tempTime.Format("20060102150405")
336
+	chrgBchno := rand.Intn(100000) + 10000
337
+	chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
338
+	strconv.FormatInt(his.PatientId, 10)
339
+
340
+	var ids []int64
341
+
342
+	for _, item := range prescriptions {
343
+		ids = append(ids, item.ID)
344
+	}
345
+	var total float64
346
+
347
+	for _, item := range prescriptions {
348
+		fmt.Println(item)
349
+		if item.Type == 1 { //药品
350
+			for _, subItem := range item.HisDoctorAdviceInfo {
351
+				total = total + (subItem.Price * subItem.PrescribingNumber)
352
+			}
353
+		}
354
+		if item.Type == 2 { //项目
355
+			for _, subItem := range item.HisPrescriptionProject {
356
+				cnt, _ := strconv.ParseFloat(subItem.Count, 64)
357
+				total = total + (subItem.Price * cnt)
358
+			}
359
+		}
360
+
361
+		for _, subItem := range item.HisAdditionalCharge {
362
+			total = total + (subItem.Price * float64(subItem.Count))
363
+		}
364
+	}
365
+
366
+	tm := time.Unix(time.Now().Unix(), 0)
367
+
368
+	var customs []*models.NewCustomTwo
369
+	for _, item := range prescriptions {
370
+		if item.Type == 1 { //药品
371
+			for _, subItem := range item.HisDoctorAdviceInfo {
372
+				cus := &models.NewCustomTwo{
373
+					AdviceId:         subItem.ID,
374
+					ProjectId:        0,
375
+					DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
376
+					Cut:              fmt.Sprintf("%.4f", subItem.PrescribingNumber),
377
+					FeedetlSn:        subItem.FeedetlSn,
378
+					Price:            fmt.Sprintf("%.2f", subItem.Price),
379
+					MedListCodg:      subItem.Drug.MedicalInsuranceNumber,
380
+					Type:             1,
381
+				}
382
+				customs = append(customs, cus)
383
+			}
384
+		}
385
+		if item.Type == 2 { //项目
386
+			for _, subItem := range item.HisPrescriptionProject {
387
+				if subItem.Type == 2 {
388
+					cnt, _ := strconv.ParseFloat(subItem.Count, 64)
389
+					cus := &models.NewCustomTwo{
390
+						AdviceId:         0,
391
+						ProjectId:        subItem.ID,
392
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
393
+						Cut:              fmt.Sprintf("%.4f", cnt),
394
+						FeedetlSn:        subItem.FeedetlSn,
395
+						Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
396
+						MedListCodg:      subItem.HisProject.MedicalCode,
397
+						Type:             2,
398
+					}
399
+					customs = append(customs, cus)
400
+
401
+				} else {
402
+					cnt, _ := strconv.ParseFloat(subItem.Count, 64)
403
+					cus := &models.NewCustomTwo{
404
+						AdviceId:         0,
405
+						ProjectId:        subItem.ID,
406
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
407
+						Cut:              fmt.Sprintf("%.4f", cnt),
408
+						FeedetlSn:        subItem.FeedetlSn,
409
+						Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
410
+						MedListCodg:      subItem.GoodInfo.MedicalInsuranceNumber,
411
+						Type:             3,
412
+					}
413
+					customs = append(customs, cus)
414
+
415
+				}
416
+
417
+			}
418
+		}
419
+		for _, item := range item.HisAdditionalCharge {
420
+			cus := &models.NewCustomTwo{
421
+				ItemId:           item.ID,
422
+				AdviceId:         0,
423
+				ProjectId:        0,
424
+				DetItemFeeSumamt: fmt.Sprintf("%.4f", item.Price),
425
+				Cut:              fmt.Sprintf("%.4f", float64(item.Count)),
426
+				FeedetlSn:        item.FeedetlSn,
427
+				Price:            fmt.Sprintf("%.4f", float64(item.Price)),
428
+				MedListCodg:      item.XtHisAddtionConfig.Code,
429
+				Type:             3,
430
+			}
431
+			customs = append(customs, cus)
432
+		}
433
+	}
434
+	result, request_log := service.OpKeepAccounts(his.Number, customs)
435
+
436
+	fmt.Println(result)
437
+	fmt.Println(request_log)
438
+
439
+	var res ResultSettle
440
+	res.ResultCode = "0"
441
+	res.DocId = "708275799870021632"
442
+	res.Amount = "1088.00"
443
+	//if err := json.Unmarshal([]byte(result), &res); err != nil {
444
+	//	utils.ErrorLog("解析失败:%v", err)
445
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
446
+	//	return
447
+	//}
448
+	if res.ResultCode == "0" {
449
+		//allTotal := fmt.Sprintf("%.4f", total)
450
+		totals, _ := strconv.ParseFloat(res.Amount, 64)
451
+		order := &models.HisOrder{
452
+			PsnNo:              his.PsnNo,
453
+			UserOrgId:          org_id,
454
+			HisPatientId:       his.ID,
455
+			PatientId:          id,
456
+			SettleAccountsDate: recordDateTime,
457
+			Ctime:              time.Now().Unix(),
458
+			Mtime:              time.Now().Unix(),
459
+			Status:             1,
460
+			OrderStatus:        1,
461
+			MdtrtId:            his.Number,
462
+			Number:             chrg_bchno,
463
+			SetlId:             res.DocId,
464
+			MedfeeSumamt:       totals,
465
+			MedType:            strconv.Itoa(int(reg_type)),
466
+			SettleEndTime:      end_time,
467
+			SettleStartTime:    start_time,
468
+			SettleType:         settle_accounts_type,
469
+			FaPiaoCode:         fapiao_code,
470
+			FaPiaoNumber:       fapiao_number,
471
+			Diagnosis:          diagnosis_id,
472
+			PType:              2,
473
+			SetlTime:           tm.Format("2006-01-02 15:04:05"),
474
+		}
475
+		err = service.CreateOrder(order)
476
+		if err != nil {
477
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
478
+			return
479
+		}
480
+
481
+		for _, item := range customs {
482
+			var advice_id int64 = 0
483
+			var project_id int64 = 0
484
+			var item_id int64 = 0
485
+
486
+			var types int64 = 0
487
+
488
+			if item.Type == 1 {
489
+				advice_id = item.AdviceId
490
+				project_id = 0
491
+				item_id = 0
492
+			} else if item.Type == 2 {
493
+				advice_id = 0
494
+				item_id = 0
495
+
496
+				project_id = item.ProjectId
497
+			} else if item.Type == 3 {
498
+				advice_id = 0
499
+				item_id = item.ItemId
500
+				project_id = 0
501
+			}
502
+			detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
503
+			cut, _ := strconv.ParseFloat(item.Cut, 32)
504
+			pric, _ := strconv.ParseFloat(item.Price, 32)
505
+			info := &models.HisOrderInfo{
506
+				OrderNumber:      order.Number,
507
+				UploadDate:       time.Now().Unix(),
508
+				AdviceId:         advice_id,
509
+				DetItemFeeSumamt: detItemFeeSumamt,
510
+				Cnt:              cut,
511
+				Pric:             pric,
512
+				PatientId:        id,
513
+				Status:           1,
514
+				Mtime:            time.Now().Unix(),
515
+				Ctime:            time.Now().Unix(),
516
+				UserOrgId:        org_id,
517
+				HisPatientId:     his.ID,
518
+				OrderId:          order.ID,
519
+				ProjectId:        project_id,
520
+				Type:             types,
521
+				ItemId:           item_id,
522
+			}
523
+			service.CreateOrderInfo(info)
524
+		}
525
+		his.Diagnosis = diagnosis_id
526
+		his.SickType = sick_type
527
+		his.RegisterType = reg_type
528
+		his.MedicalTreatmentType = reg_type
529
+		service.UpdataHisPateint(&his)
530
+		err = service.UpDatePrescriptionNumber(org_id, ids, chrg_bchno)
531
+		err = service.UpDateHisPrescriptionInfoNumber(org_id, id, chrg_bchno, recordDateTime, his_patient_id)
532
+		err = service.UpdataOrderStatusThree(chrg_bchno, org_id)
533
+		if err == nil {
534
+			c.ServeSuccessJSON(map[string]interface{}{
535
+				"msg": "记账成功",
536
+			})
537
+		}
538
+	}
539
+
540
+}
541
+
542
+func (c *CoordinateController) OpCancelKeepAccounts() {
543
+	order_id, _ := c.GetInt64("order_id")
544
+	admin_user_id, _ := c.GetInt64("admin_user_id")
545
+	org_id, _ := c.GetInt64("org_id")
546
+	org_id = 4
547
+	order, _ := service.GetHisOrderByID(order_id)
548
+	if order.ID == 0 {
549
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
550
+		return
551
+	}
552
+
553
+	role, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
554
+	result, request_log := service.OpCancelKeepAccounts(order.SetlId, role.UserName, role.DoctorNumber)
555
+
556
+	var res RefundDetail
557
+	if err := json.Unmarshal([]byte(result), &res); err != nil {
558
+		utils.ErrorLog("解析失败:%v", err)
559
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
560
+		return
561
+	}
562
+	fmt.Println(result)
563
+	fmt.Println(request_log)
564
+	fmt.Println(res)
565
+	flag := 0
566
+	isSuccess := false
567
+	for _, item := range res.Result {
568
+		if item.Code == "200" {
569
+			flag = flag + 1
570
+		}
571
+	}
572
+	if len(res.Result) == flag {
573
+		isSuccess = true
574
+	}
575
+
576
+	if isSuccess {
577
+		err := service.UpdataOrderStatus(order_id, order.Number, org_id)
578
+		if err == nil {
579
+			c.ServeSuccessJSON(map[string]interface{}{
580
+				"msg": "撤销记账成功",
581
+			})
582
+		} else {
583
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
584
+			return
585
+		}
586
+	} else {
587
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
588
+		return
589
+	}
590
+}
591
+
592
+//func saveLog(result string, request string, infno string, desc string) {
593
+//
594
+//	org_id, _ := beego.AppConfig.Int64("org_id")
595
+//	miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
596
+//	dir := miConfig.OrgName + "日志"
597
+//	utils.Mkdir(dir)
598
+//	month := time.Unix(1557042972, 0).Format("1")
599
+//	year := time.Now().Format("2006")
600
+//	month = time.Now().Format("01")
601
+//	day := time.Now().Format("02")
602
+//	hour := time.Now().Format("15")
603
+//	min := time.Now().Format("04")
604
+//	sec := time.Now().Format("05")
605
+//
606
+//	result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
607
+//
608
+//	file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
609
+//	file_name := file + ".txt"
610
+//	file_path := miConfig.OrgName + "日志" + "/" + file_name
611
+//	exist, _ := utils.PathExists(file_path)
612
+//	if exist { //存在
613
+//		fmt.Println("存在")
614
+//		f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
615
+//		if err != nil {
616
+//			fmt.Println("read fail")
617
+//		}
618
+//		content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
619
+//		n, _ := f.Seek(0, 2)
620
+//		_, err = f.WriteAt([]byte(content), n)
621
+//
622
+//	} else { //不存在
623
+//		fmt.Println("文件不存在,创建文件")
624
+//		f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
625
+//		defer f.Close()
626
+//		if err != nil {
627
+//		} else {
628
+//			_, err = f.Write([]byte("记录日志"))
629
+//		}
630
+//	}
631
+//
632
+//}
633
+
634
+type Charset string
635
+
636
+const (
637
+	UTF8    = Charset("UTF-8")
638
+	GB18030 = Charset("GB18030")
639
+)

+ 9 - 4
controllers/gobal_config_api_controller.go View File

@@ -1089,12 +1089,17 @@ func (c *GobalConfigApiController) GetOrgs() {
1089 1089
 		}
1090 1090
 	}
1091 1091
 	orgs = RemoveRepeatedOrgElement(orgs)
1092
+	fmt.Println("~~~~")
1093
+	role, _ := service.GetAdminUserInfoByID(orgId, id)
1094
+	miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
1092 1095
 
1093 1096
 	c.ServeSuccessJSON(map[string]interface{}{
1094
-		"orgs":      orgs,
1095
-		"adminUser": adminUser,
1096
-		"creator":   creator,
1097
-		"admin":     admin,
1097
+		"orgs":       orgs,
1098
+		"adminUser":  adminUser,
1099
+		"creator":    creator,
1100
+		"admin":      admin,
1101
+		"role":       role,
1102
+		"org_config": miConfig,
1098 1103
 	})
1099 1104
 
1100 1105
 }

File diff suppressed because it is too large
+ 713 - 146
controllers/his_api_controller.go


+ 90 - 0
controllers/his_charge_api_controller.go View File

@@ -17,6 +17,9 @@ func HisChargeApiRegistRouters() {
17 17
 	beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail")
18 18
 	beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
19 19
 
20
+	beego.Router("/api/his/patient", &HisChargeApiController{}, "get:GetAllPatient")
21
+	//beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
22
+
20 23
 	beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
21 24
 	beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
22 25
 
@@ -316,3 +319,90 @@ func (c *HisChargeApiController) GetHisYidiClearRecord() {
316 319
 		return
317 320
 	}
318 321
 }
322
+
323
+func (c *HisChargeApiController) GetAllPatient() {
324
+	patients, err := service.GetAllPatientTwo(c.GetAdminUserInfo().CurrentOrgId)
325
+	if err == nil {
326
+		c.ServeSuccessJSON(map[string]interface{}{
327
+			"list": patients,
328
+		})
329
+		return
330
+	} else {
331
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
332
+		return
333
+	}
334
+}
335
+
336
+func (c *HisChargeApiController) GetStatisticsDetail() {
337
+	start_time := c.GetString("start_time")
338
+	end_time := c.GetString("end_time")
339
+	keyword := c.GetString("keyword")
340
+	item_type, _ := c.GetInt64("type")
341
+	p_type, _ := c.GetInt64("p_type")
342
+	patinet_id, _ := c.GetInt64("patinet_id")
343
+
344
+	adminUser := c.GetAdminUserInfo()
345
+
346
+	timeLayout := "2006-01-02"
347
+	loc, _ := time.LoadLocation("Local")
348
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
349
+	if err != nil {
350
+
351
+	}
352
+	startRecordDateTime := startTime.Unix()
353
+
354
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
355
+	if err != nil {
356
+
357
+	}
358
+	endRecordDateTime := endTime.Unix()
359
+
360
+	chargePatient, err := service.GetPatientChargeDetails(patinet_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type, p_type)
361
+
362
+	if err == nil {
363
+		c.ServeSuccessJSON(map[string]interface{}{
364
+			"patients": chargePatient,
365
+		})
366
+		return
367
+	} else {
368
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
369
+		return
370
+
371
+	}
372
+
373
+}
374
+
375
+func (c *HisChargeApiController) GetStatisticsGather() {
376
+	start_time := c.GetString("start_time")
377
+	end_time := c.GetString("end_time")
378
+	keyword := c.GetString("keyword")
379
+	item_type, _ := c.GetInt64("type")
380
+	adminUser := c.GetAdminUserInfo()
381
+	timeLayout := "2006-01-02"
382
+	loc, _ := time.LoadLocation("Local")
383
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
384
+	if err != nil {
385
+
386
+	}
387
+	startRecordDateTime := startTime.Unix()
388
+
389
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
390
+	if err != nil {
391
+
392
+	}
393
+	endRecordDateTime := endTime.Unix()
394
+
395
+	chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
396
+
397
+	if err == nil {
398
+		c.ServeSuccessJSON(map[string]interface{}{
399
+			"patients": chargePatient,
400
+		})
401
+		return
402
+	} else {
403
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
404
+		return
405
+
406
+	}
407
+
408
+}

+ 80 - 8
controllers/his_hospital_api_controller.go View File

@@ -6,6 +6,7 @@ import (
6 6
 	"XT_New/service"
7 7
 	"fmt"
8 8
 	"github.com/astaxie/beego"
9
+	"github.com/shopspring/decimal"
9 10
 	"math/rand"
10 11
 	"strconv"
11 12
 	"strings"
@@ -29,6 +30,7 @@ func HisHospitalManagerApiRegistRouters() {
29 30
 	beego.Router("/api/hospital/outhopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHOutHospitalUnCheck")
30 31
 	beego.Router("/api/hospital/refund", &HisHospitalApiController{}, "get:ZHRefund")
31 32
 	beego.Router("/api/hospital/upload", &HisHospitalApiController{}, "get:GetUploadInfo")
33
+	beego.Router("/api/hospital/refunddetail", &HisHospitalApiController{}, "get:RefundDetail")
32 34
 
33 35
 	beego.Router("/api/hospitaldetail/list", &HisHospitalApiController{}, "get:GetHisHospitalDetailPatientList")
34 36
 	beego.Router("/api/hospitaldetail/info", &HisHospitalApiController{}, "get:GetHisHospitalDetailInfo")
@@ -36,6 +38,55 @@ func HisHospitalManagerApiRegistRouters() {
36 38
 	beego.Router("/api/monthhospitaldetail/get", &HisHospitalApiController{}, "get:GetHisHospitalMonthDetailInfo")
37 39
 
38 40
 }
41
+func (c *HisHospitalApiController) RefundDetail() {
42
+	patient_id, _ := c.GetInt64("patient_id")
43
+	his_patient_id, _ := c.GetInt64("his_patient_id")
44
+	record_time := c.GetString("record_time")
45
+	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
46
+	timeLayout := "2006-01-02"
47
+	loc, _ := time.LoadLocation("Local")
48
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
49
+	if err != nil {
50
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
51
+		return
52
+	}
53
+	recordDateTime := theTime.Unix()
54
+	adminUser := c.GetAdminUserInfo()
55
+	theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
56
+	if err != nil {
57
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
58
+		return
59
+	}
60
+	recordDateTimeTwo := theTimeTwo.Unix()
61
+	if settle_accounts_type == 1 { //日结
62
+		err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
63
+
64
+		if err != nil {
65
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
66
+			return
67
+		}
68
+		err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
69
+		if err1 != nil {
70
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
71
+			return
72
+		}
73
+		c.ServeSuccessJSON(map[string]interface{}{
74
+			"msg": "撤销明细成功",
75
+		})
76
+
77
+	} else {
78
+		record, _ := service.GetInHospitalRecord(his_patient_id)
79
+		err := service.UpdataHospitalOrderStatusTwo(record.Number, adminUser.CurrentOrgId)
80
+		if err == nil {
81
+			c.ServeSuccessJSON(map[string]interface{}{
82
+				"msg": "撤销明细成功",
83
+			})
84
+		} else {
85
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
86
+			return
87
+		}
88
+	}
89
+}
39 90
 
40 91
 func (c *HisHospitalApiController) GetUploadInfo() {
41 92
 	id, _ := c.GetInt64("id")
@@ -453,17 +504,36 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
453 504
 	}
454 505
 
455 506
 	if order_status == 1 || order_status == 0 {
456
-		settle_prescriptions, _ = service.GetSettleHisHospitalPrescription(admin.CurrentOrgId, patient_id, his_patient_id, his_patient_info.RecordDate)
507
+		settle_prescriptions, _ = service.GetSettleHisHospitalPrescription(admin.CurrentOrgId, patient_id, his_patient_info.Number)
457 508
 	} else if order_status == 2 {
458 509
 		settle_prescriptions, _ = service.GetSettleHisHospitalPrescriptionTwo(admin.CurrentOrgId, patient_id, his_patient_info.Number)
459 510
 	}
511
+
512
+	var settle_total float64
513
+	for _, item := range settle_prescriptions {
514
+		if len(item.HisPrescriptionProject) > 0 {
515
+			for _, subItem := range item.HisPrescriptionProject {
516
+				count, _ := strconv.ParseFloat(subItem.Count, 64)
517
+				total, _ := decimal.NewFromFloat(count * subItem.Price).Round(2).Float64()
518
+				settle_total = settle_total + total
519
+			}
520
+		}
521
+		if len(item.HisDoctorAdviceInfo) > 0 {
522
+			for _, subItem := range item.HisDoctorAdviceInfo {
523
+				total, _ := decimal.NewFromFloat(subItem.PrescribingNumber * subItem.Price).Round(2).Float64()
524
+				settle_total = settle_total + total
525
+			}
526
+		}
527
+
528
+	}
529
+	settle_total, _ = decimal.NewFromFloat(settle_total).Round(2).Float64()
530
+
460 531
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
461 532
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
462 533
 	order, _ := service.GetNewHisOrder(admin.CurrentOrgId, his_patient_info.Number, patient_id)
463 534
 	doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
464 535
 	//获取所有科室信息
465 536
 	department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
466
-
467 537
 	c.ServeSuccessJSON(map[string]interface{}{
468 538
 		"his_info":             his_patient_info,
469 539
 		"xt_info":              xt_patient_info,
@@ -475,6 +545,7 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
475 545
 		"doctors":              doctors,
476 546
 		"department":           department,
477 547
 		"settle_prescriptions": settle_prescriptions,
548
+		"settle_total":         settle_total,
478 549
 	})
479 550
 	return
480 551
 
@@ -622,7 +693,8 @@ func (c *HisHospitalApiController) GetZHInHospitalCheck() {
622 693
 }
623 694
 func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
624 695
 	id, _ := this.GetInt64("id")
625
-	record_date := this.GetString("record_date")
696
+	record_time := this.GetString("record_time")
697
+	out_time := this.GetString("out_time")
626 698
 
627 699
 	record, _ := service.GetInHospitalRecord(id)
628 700
 	if record.ID == 0 {
@@ -632,15 +704,15 @@ func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
632 704
 
633 705
 	timeLayout := "2006-01-02"
634 706
 	loc, _ := time.LoadLocation("Local")
635
-	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
707
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
636 708
 
637 709
 	recordDateTime := theTime.Unix()
638 710
 
639
-	timestamp := time.Now().Unix()
640
-	tempTime := time.Unix(timestamp, 0)
641
-	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
711
+	//timestamp := time.Now().Unix()
712
+	//tempTime := time.Unix(timestamp, 0)
713
+	//timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
642 714
 	record.OutHospitalStatus = 1
643
-	record.OutHosptialTime = timeFormatOne
715
+	record.OutHosptialTime = out_time
644 716
 	record.OutWay = 1
645 717
 	service.CreateHospitalRecord(&record)
646 718
 

+ 36 - 11
controllers/his_print_api_controller.go View File

@@ -2,6 +2,7 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
5 6
 	"XT_New/service"
6 7
 	"github.com/astaxie/beego"
7 8
 	"strings"
@@ -38,25 +39,49 @@ func (c *HisPrintApiController) GetBatchHisPrescriptionData() {
38 39
 		})
39 40
 		break
40 41
 	case 2:
41
-		patients, _ := service.GetBatchProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
42
-		for _, item := range patients {
43
-			for _, subItem := range item.HisPrintPrescription {
44
-				for _, subItemTwo := range subItem.HisPrescriptionProject {
45
-					if subItemTwo.HisProject.CostClassify == 3 {
46
-
47
-					}
48
-				}
49
-			}
50
-		}
42
+		//var newPatients []*models.PrintPatient
51 43
 
44
+		patients, _ := service.GetBatchProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
45
+		//for _, item := range patients {
46
+		//	for _, subItem := range item.HisPrintPrescription {
47
+		//		for _, subItemTwo := range subItem.HisPrescriptionProject {
48
+		//			if subItemTwo.HisProject.CostClassify != 3 {
49
+		//
50
+		//			}
51
+		//		}
52
+		//	}
53
+		//}
52 54
 		c.ServeSuccessJSON(map[string]interface{}{
53 55
 			"patients": patients,
54 56
 		})
55 57
 		break
56 58
 	case 3:
59
+		var newPatients []*models.PrintPatient
60
+		var newPatientsTwo []*models.PrintPatient
61
+
57 62
 		patients, _ := service.GetBatchInspectionProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
63
+		for _, item := range patients {
64
+			var newPatient *models.PrintPatient
65
+			newPatient = item
66
+			for index, subItem := range item.HisPrintPrescription {
67
+				if index > 0 {
68
+					item.HisPrintPrescription[0].HisPrescriptionProject = append(item.HisPrintPrescription[0].HisPrescriptionProject, subItem.HisPrescriptionProject...)
69
+				}
70
+			}
71
+			newPatients = append(newPatients, newPatient)
72
+		}
73
+
74
+		for _, item := range patients {
75
+			var newPatient *models.PrintPatient
76
+			newPatient = item
77
+			if len(item.HisPrintPrescription) > 0 {
78
+				newPatient.NewHisPrintPrescription = append(newPatient.NewHisPrintPrescription, item.HisPrintPrescription[0])
79
+				newPatientsTwo = append(newPatientsTwo, newPatient)
80
+			}
81
+		}
82
+
58 83
 		c.ServeSuccessJSON(map[string]interface{}{
59
-			"patients": patients,
84
+			"patients": newPatientsTwo,
60 85
 		})
61 86
 		break
62 87
 	}

+ 4 - 6
controllers/his_project_api_controller.go View File

@@ -1201,6 +1201,8 @@ func (this *HisProjectApiController) GetHisPatient() {
1201 1201
 func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1202 1202
 
1203 1203
 	patient_id, _ := this.GetInt64("patient_id")
1204
+	his_patient_id, _ := this.GetInt64("his_patient_id")
1205
+
1204 1206
 	record_date := this.GetString("record_date")
1205 1207
 	schIDStr := this.GetString("ids")
1206 1208
 	p_type, _ := this.GetInt64("p_type")
@@ -1230,7 +1232,7 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1230 1232
 	his, _ := service.GetLastHisPatient(patient_id, adminUserInfo.CurrentOrgId)
1231 1233
 	prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1232 1234
 	//advicePrint, err := service.GetPre(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId, temp_p_type)
1233
-	hisPatient, _ := service.GetHisPatientInfo(adminUserInfo.CurrentOrgId, patient_id, recordDateTime)
1235
+	hisPatient, _ := service.GetHisPatientInfoFour(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, his_patient_id)
1234 1236
 	//hisPatient, _ := service.GetHisPatientById(patient_id)
1235 1237
 	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
1236 1238
 
@@ -1553,14 +1555,10 @@ func (this *HisProjectApiController) GetTodaySchedulePatient() {
1553 1555
 func (this *HisProjectApiController) GetHisPatientDetail() {
1554 1556
 	patient_id, _ := this.GetInt64("patient_id")
1555 1557
 
1556
-	hisPatient, err := service.GetHisPatientById(patient_id)
1558
+	hisPatient, _ := service.GetHisPatientByIdFour(patient_id)
1557 1559
 	//service.GetLastHospitalRecordTwo(patient_id,this.GetAdminUserInfo().CurrentOrgId)
1558 1560
 	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, this.GetAdminUserInfo().CurrentOrgId)
1559 1561
 
1560
-	if err != nil {
1561
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1562
-		return
1563
-	}
1564 1562
 	this.ServeSuccessJSON(map[string]interface{}{
1565 1563
 		"hisPatient":        hisPatient,
1566 1564
 		"hisHospitalRecord": hisHospitalRecord,

+ 51 - 0
models/his_charge_models.go View File

@@ -241,3 +241,54 @@ type GdybPsnNcdsRecord struct {
241 241
 func (GdybPsnNcdsRecord) TableName() string {
242 242
 	return "gdyb_psn_ncds_record"
243 243
 }
244
+
245
+type ChargePatientTwo struct {
246
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
247
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
248
+	Name      string `gorm:"column:name" json:"name" form:"name"`
249
+	Lapseto   int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
250
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
251
+}
252
+
253
+func (ChargePatientTwo) TableName() string {
254
+	return "xt_patients"
255
+}
256
+
257
+type HisChargeOrderTwo struct {
258
+	ID                    int64                    `gorm:"column:id" json:"id" form:"id"`
259
+	UserOrgId             int64                    `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
260
+	HisPatientId          int64                    `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
261
+	SettleAccountsDate    int64                    `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
262
+	Status                int64                    `gorm:"column:status" json:"status" form:"status"`
263
+	Number                string                   `gorm:"column:number" json:"number" form:"number"`
264
+	OrderStatus           int64                    `gorm:"column:order_status" json:"order_status" form:"order_status"`
265
+	MdtrtId               string                   `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
266
+	PatientId             int64                    `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
267
+	HisChargeOrderInfoTwo []*HisChargeOrderInfoTwo `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"order_info"`
268
+}
269
+
270
+func (HisChargeOrderTwo) TableName() string {
271
+	return "his_order"
272
+}
273
+
274
+type HisChargeOrderInfoTwo struct {
275
+	ID                           int64                        `gorm:"column:id" json:"id" form:"id"`
276
+	OrderNumber                  string                       `gorm:"column:order_number" json:"order_number" form:"order_number"`
277
+	AdviceId                     int64                        `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
278
+	DetItemFeeSumamt             float64                      `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
279
+	Cnt                          float64                      `gorm:"column:cnt" json:"cnt" form:"cnt"`
280
+	Pric                         float64                      `gorm:"column:pric" json:"pric" form:"pric"`
281
+	MedChrgitmType               string                       `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
282
+	Status                       int64                        `gorm:"column:status" json:"status" form:"status"`
283
+	ChldMedcFlag                 string                       `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
284
+	ChrgitmLv                    string                       `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
285
+	UserOrgId                    int64                        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
286
+	ProjectId                    int64                        `gorm:"column:project_id" json:"project_id" form:"project_id"`
287
+	Type                         int64                        `gorm:"column:type" json:"type" form:"type"`
288
+	HisChargePrescriptionProject HisChargePrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
289
+	HisChargeDoctorAdviceInfo    HisChargeDoctorAdviceInfo    `gorm:"ForeignKey:AdviceId;AssociationForeignKey:ID" json:"advice"`
290
+}
291
+
292
+func (HisChargeOrderInfoTwo) TableName() string {
293
+	return "his_order_info"
294
+}

+ 48 - 0
models/his_hospital_models.go View File

@@ -83,6 +83,54 @@ func (HisHospitalCheckRecord) TableName() string {
83 83
 	return "his_hospital_check_record"
84 84
 }
85 85
 
86
+type HisHospitalCheckRecordTwo struct {
87
+	ID                   int64  `gorm:"column:id" json:"id" form:"id"`
88
+	Name                 string `gorm:"column:name" json:"name" form:"name"`
89
+	MedicalTreatmentType int64  `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
90
+	RecordDate           int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
91
+	IdCardNo             string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
92
+	AdminUserId          int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
93
+	Departments          int64  `gorm:"column:departments" json:"departments" form:"departments"`
94
+	UserOrgId            int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
95
+	Status               int64  `gorm:"column:status" json:"status" form:"status"`
96
+	Ctime                int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
97
+	Mtime                int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
98
+	PatientId            int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
99
+	Number               string `gorm:"column:number" json:"number" form:"number"`
100
+	Doctor               int64  `gorm:"column:doctor" json:"doctor" form:"doctor"`
101
+	PsnNo                string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
102
+	PsnCertType          string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
103
+	Certno               string `gorm:"column:certno" json:"certno" form:"certno"`
104
+	PsnName              string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
105
+	Gend                 string `gorm:"column:gend" json:"gend" form:"gend"`
106
+	Naty                 string `gorm:"column:naty" json:"naty" form:"naty"`
107
+	MedType              int64  `gorm:"column:med_type" json:"med_type" form:"med_type"`
108
+	Brdy                 string `gorm:"column:brdy" json:"brdy" form:"brdy"`
109
+	Iinfo                string `gorm:"column:iinfo" json:"iinfo" form:"iinfo"`
110
+	Idetinfo             string `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
111
+	IptOtpNo             string `gorm:"column:ipt_otp_no" json:"ipt_otp_no" form:"ipt_otp_no"`
112
+	AdmBed               int64  `gorm:"column:adm_bed" json:"adm_bed" form:"adm_bed"`
113
+	IdCardType           int64  `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
114
+	Diagnosis            string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
115
+	InsutypeType         string `gorm:"column:insutype_type" json:"insutype_type" form:"insutype_type"`
116
+	SickType             int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
117
+	MdtrtCertType        string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
118
+	InHosptialTime       string `gorm:"column:in_hosptial_time" json:"in_hosptial_time" form:"in_hosptial_time"`
119
+	OutHosptialTime      string `gorm:"column:out_hosptial_time" json:"out_hosptial_time" form:"out_hosptial_time"`
120
+	InHospitalStatus     int64  `gorm:"column:in_hospital_status" json:"in_hospital_status" form:"in_hospital_status"`
121
+	Certificates         int64  `gorm:"column:certificates" json:"certificates" form:"certificates"`
122
+	OutHospitalStatus    int64  `gorm:"column:out_hospital_status" json:"out_hospital_status" form:"out_hospital_status"`
123
+	OutWay               int64  `gorm:"column:out_way" json:"out_way" form:"out_way"`
124
+	Phone                string `gorm:"column:phone" json:"phone" form:"phone"`
125
+	BalanceAccountsType  int64  `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
126
+	PsnType              int64  `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
127
+	InsuplcAdmdvs        string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
128
+}
129
+
130
+func (HisHospitalCheckRecordTwo) TableName() string {
131
+	return "his_hospital_check_record"
132
+}
133
+
86 134
 type NewCustom struct {
87 135
 	DetItemFeeSumamt float64
88 136
 	Cut              float64

+ 25 - 2
models/his_models.go View File

@@ -519,7 +519,6 @@ type HisPrescription struct {
519 519
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
520 520
 	HisAdditionalCharge    []*HisAdditionalCharge    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
521 521
 	HisPrescriptionInfo    HisPrescriptionInfo       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,RecordDate" json:"info"`
522
-	HisOrder               HisOrder                  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
523 522
 	Total                  string                    `gorm:"-" json:"total" form:"total"`
524 523
 	PType                  int64                     `gorm:"column:p_type" json:"p_type" form:"p_type"`
525 524
 	MedType                string                    `gorm:"column:med_type" json:"med_type" form:"med_type"`
@@ -735,7 +734,7 @@ type HisDoctorAdviceTemplate struct {
735 734
 	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
736 735
 	TemplateId            int64   `gorm:"column:template_id" json:"template_id" form:"template_id"`
737 736
 	DrugSpec              string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
738
-	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
737
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spechis_unit" form:"drug_spec_unit"`
739 738
 	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
740 739
 	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
741 740
 	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
@@ -1970,3 +1969,27 @@ type HisPrescriptionProjectTwo struct {
1970 1969
 func (HisPrescriptionProjectTwo) TableName() string {
1971 1970
 	return "his_prescription_project"
1972 1971
 }
1972
+
1973
+type Reg struct {
1974
+	DeptId      string
1975
+	PatientId   string
1976
+	PatientName string
1977
+	DoctorId    string
1978
+	RegDate     string
1979
+	RegFee      string
1980
+	TreatFee    string
1981
+	OperatorId  string
1982
+	IdCardNo    string
1983
+}
1984
+
1985
+type NewCustomTwo struct {
1986
+	DetItemFeeSumamt string
1987
+	Cut              string
1988
+	FeedetlSn        string
1989
+	Price            string
1990
+	MedListCodg      string
1991
+	Type             int64
1992
+	AdviceId         int64
1993
+	ProjectId        int64
1994
+	ItemId           int64
1995
+}

+ 14 - 13
models/his_print_models.go View File

@@ -1,19 +1,20 @@
1 1
 package models
2 2
 
3 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"`
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
+	NewHisPrintPrescription []*HisPrintPrescription `json:"new_prescriptions"`
17 18
 }
18 19
 
19 20
 func (PrintPatient) TableName() string {

+ 2 - 0
models/patient_models.go View File

@@ -189,6 +189,7 @@ type Patients struct {
189 189
 	TrobleShoot              int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
190 190
 	ContagionIds             []int64 `gorm:"-"`
191 191
 	DryWeight                float64 `gorm:"-"`
192
+	ZbPatientId              string  `gorm:"column:zb_patient_id" json:"zb_patient_id" form:"zb_patient_id"`
192 193
 }
193 194
 
194 195
 func (Patients) TableName() string {
@@ -540,6 +541,7 @@ type UserAdminRole struct {
540 541
 	Status          int64           `gorm:"column:status" json:"status"`
541 542
 	Ctime           int64           `gorm:"column:ctime" json:"ctime"`
542 543
 	Mtime           int64           `gorm:"column:mtime" json:"mtime"`
544
+	DoctorNumber    string          `gorm:"column:doctor_number" json:"doctor_number"`
543 545
 	Department      string          `gorm:"column:department" json:"department"`
544 546
 	DepartmentId    int64           `gorm:"column:department_id" json:"department_id"`
545 547
 	XtHisDepartment XtHisDepartment `json:"department" gorm:"foreignkey:DepartmentId;AssociationForeignKey:ID;"`

+ 1 - 0
routers/router.go View File

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

+ 327 - 0
service/coordinate_service.go View File

@@ -0,0 +1,327 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"bytes"
6
+	"encoding/json"
7
+	"fmt"
8
+	"github.com/jinzhu/gorm"
9
+	"io/ioutil"
10
+	"net/http"
11
+)
12
+
13
+func SavePatientMessageInfo() (string, string) {
14
+
15
+	//input := make(map[string]interface{})
16
+	inputData := make(map[string]interface{})
17
+	inputData["patType"] = "1"                  // 就诊凭证编号
18
+	inputData["patIdNo"] = "440510199211080033" // 开始时间
19
+	inputData["patName"] = "测试患者"               // 人员姓名
20
+
21
+	inputData["patMobile"] = "13535547902" // 人员姓名
22
+	inputData["patSex"] = "M"              // 人员姓名
23
+	inputData["patMarriage"] = "1"         // 人员姓名
24
+	inputData["birthday"] = "1992-10-23"   // 人员姓名
25
+	inputData["patAddress"] = "11111"      // 人员姓名
26
+	inputData["thirdPartyID"] = "6933"     // 人员姓名
27
+	inputData["patAge"] = "30"             // 人员姓名
28
+	//input["req"] = inputData
29
+
30
+	var inputLog string
31
+	bytesData, err := json.Marshal(inputData)
32
+	inputLog = string(bytesData)
33
+	fmt.Println(string(bytesData))
34
+	if err != nil {
35
+		fmt.Println(err.Error())
36
+		return err.Error(), ""
37
+	}
38
+	reader := bytes.NewReader(bytesData)
39
+	var url string
40
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/savePatientMessageInfo"
41
+	url = gdyb_url
42
+
43
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
44
+	request, err := http.NewRequest("GET", url, reader)
45
+	if err != nil {
46
+		fmt.Println(err.Error())
47
+		return err.Error(), ""
48
+	}
49
+
50
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
51
+	request.Header.Set("code", "Xmrjyy")
52
+
53
+	client := http.Client{}
54
+	resp, err := client.Do(request)
55
+	if err != nil {
56
+		fmt.Println(err.Error())
57
+		return err.Error(), ""
58
+	}
59
+	respBytes, err := ioutil.ReadAll(resp.Body)
60
+	if err != nil {
61
+		fmt.Println(err.Error())
62
+		return err.Error(), ""
63
+	}
64
+	fmt.Println(string(respBytes))
65
+	str := string(respBytes)
66
+	return str, inputLog
67
+
68
+}
69
+
70
+func SaveReg(reg models.Reg) (string, string) {
71
+
72
+	//input := make(map[string]interface{})
73
+	inputData := make(map[string]interface{})
74
+
75
+	inputData["deptId"] = reg.DeptId
76
+	inputData["clinicUnitId"] = ""
77
+	inputData["healthCardNo"] = ""
78
+	fmt.Println(reg.PatientId)
79
+	inputData["patientId"] = reg.PatientId
80
+	inputData["patientName"] = reg.PatientName
81
+	inputData["idCardNo"] = reg.IdCardNo
82
+	inputData["phone"] = "13535547901"
83
+	inputData["doctorId"] = "1111"
84
+	inputData["doctorLevelCode"] = ""
85
+	inputData["regDate"] = reg.RegDate
86
+
87
+	inputData["shiftCode"] = ""
88
+	inputData["startTime"] = ""
89
+	inputData["endTime"] = ""
90
+
91
+	inputData["scheduleId"] = ""
92
+	inputData["periodId"] = ""
93
+
94
+	inputData["svObjectId"] = ""
95
+	inputData["diseaseId"] = ""
96
+	inputData["regFee"] = reg.RegFee
97
+
98
+	inputData["treatFee"] = reg.TreatFee
99
+	inputData["operatorId"] = reg.OperatorId
100
+	inputData["remark"] = "111111"
101
+
102
+	inputData["orderType"] = "0"
103
+	inputData["clinicCode"] = ""
104
+	inputData["infoSeq"] = ""
105
+
106
+	//input["Request"] = inputData
107
+
108
+	var inputLog string
109
+	bytesData, err := json.Marshal(inputData)
110
+	inputLog = string(bytesData)
111
+	fmt.Println(string(bytesData))
112
+	if err != nil {
113
+		fmt.Println(err.Error())
114
+		return err.Error(), ""
115
+	}
116
+	reader := bytes.NewReader(bytesData)
117
+	var url string
118
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/saveReg"
119
+	url = gdyb_url
120
+
121
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
122
+	request, err := http.NewRequest("POST", url, reader)
123
+	if err != nil {
124
+		fmt.Println(err.Error())
125
+		return err.Error(), ""
126
+	}
127
+
128
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
129
+	request.Header.Set("code", "Xmrjyy")
130
+
131
+	client := http.Client{}
132
+	resp, err := client.Do(request)
133
+	if err != nil {
134
+		fmt.Println(err.Error())
135
+		return err.Error(), ""
136
+	}
137
+	respBytes, err := ioutil.ReadAll(resp.Body)
138
+	if err != nil {
139
+		fmt.Println(err.Error())
140
+		return err.Error(), ""
141
+	}
142
+	fmt.Println(string(respBytes))
143
+	str := string(respBytes)
144
+	return str, inputLog
145
+
146
+}
147
+func GetWaitPayDetail() (string, string) {
148
+
149
+	//input := make(map[string]interface{})
150
+	inputData := make(map[string]interface{})
151
+
152
+	inputData["clinicSeq"] = "30445"              // 就诊凭证编号
153
+	inputData["prescriptionId"] = ""              // 开始时间
154
+	inputData["patientId"] = "701822660170096645" // 人员姓名
155
+
156
+	var inputLog string
157
+	bytesData, err := json.Marshal(inputData)
158
+	inputLog = string(bytesData)
159
+	fmt.Println(string(bytesData))
160
+	if err != nil {
161
+		fmt.Println(err.Error())
162
+		return err.Error(), ""
163
+	}
164
+	reader := bytes.NewReader(bytesData)
165
+	var url string
166
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/getWaitPayDetail"
167
+	url = gdyb_url
168
+
169
+	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
170
+	request, err := http.NewRequest("POST", url, reader)
171
+	if err != nil {
172
+		fmt.Println(err.Error())
173
+		return err.Error(), ""
174
+	}
175
+
176
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
177
+	request.Header.Set("code", "Xmrjyy")
178
+
179
+	client := http.Client{}
180
+	resp, err := client.Do(request)
181
+	if err != nil {
182
+		fmt.Println(err.Error())
183
+		return err.Error(), ""
184
+	}
185
+	respBytes, err := ioutil.ReadAll(resp.Body)
186
+	if err != nil {
187
+		fmt.Println(err.Error())
188
+		return err.Error(), ""
189
+	}
190
+	fmt.Println(string(respBytes))
191
+	str := string(respBytes)
192
+	return str, inputLog
193
+
194
+}
195
+func OpKeepAccounts(number string, cus []*models.NewCustomTwo) (string, string) {
196
+
197
+	inputData := make(map[string]interface{})
198
+	feedetail := make([]map[string]interface{}, 0)
199
+	for _, item := range cus {
200
+		feedetailInfo := make(map[string]interface{})
201
+		feedetailInfo["itemCode"] = item.MedListCodg
202
+		feedetailInfo["num"] = item.Cut
203
+		feedetail = append(feedetail, feedetailInfo)
204
+	}
205
+	inputData["item"] = feedetail
206
+	inputData["clinicSeq"] = number // 就诊凭证编号
207
+	var inputLog string
208
+	bytesData, err := json.Marshal(inputData)
209
+	inputLog = string(bytesData)
210
+	fmt.Println(string(bytesData))
211
+	if err != nil {
212
+		fmt.Println(err.Error())
213
+		return err.Error(), ""
214
+	}
215
+	reader := bytes.NewReader(bytesData)
216
+	var url string
217
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/opKeepAccounts"
218
+	url = gdyb_url
219
+
220
+	request, err := http.NewRequest("POST", url, reader)
221
+	if err != nil {
222
+		fmt.Println(err.Error())
223
+		return err.Error(), ""
224
+	}
225
+
226
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
227
+	request.Header.Set("code", "Xmrjyy")
228
+
229
+	client := http.Client{}
230
+	resp, err := client.Do(request)
231
+	if err != nil {
232
+		fmt.Println(err.Error())
233
+		return err.Error(), ""
234
+	}
235
+	respBytes, err := ioutil.ReadAll(resp.Body)
236
+	if err != nil {
237
+		fmt.Println(err.Error())
238
+		return err.Error(), ""
239
+	}
240
+	fmt.Println(string(respBytes))
241
+	str := string(respBytes)
242
+	return str, inputLog
243
+
244
+}
245
+func OpCancelKeepAccounts(setl_id string, op_name string, op_code string) (string, string) {
246
+	inputData := make(map[string]interface{})
247
+	inputData["docId"] = setl_id
248
+	inputData["operCode"] = "111"
249
+	inputData["operName"] = "2222"
250
+	var inputLog string
251
+	bytesData, err := json.Marshal(inputData)
252
+	inputLog = string(bytesData)
253
+	fmt.Println(string(bytesData))
254
+	if err != nil {
255
+		fmt.Println(err.Error())
256
+		return err.Error(), ""
257
+	}
258
+	reader := bytes.NewReader(bytesData)
259
+	var url string
260
+	gdyb_url := "http://218.104.146.179:9091/esb/listener/opCancelKeepAccounts"
261
+	url = gdyb_url
262
+	request, err := http.NewRequest("POST", url, reader)
263
+	if err != nil {
264
+		fmt.Println(err.Error())
265
+		return err.Error(), ""
266
+	}
267
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
268
+	request.Header.Set("code", "Xmrjyy")
269
+	client := http.Client{}
270
+	resp, err := client.Do(request)
271
+	if err != nil {
272
+		fmt.Println(err.Error())
273
+		return err.Error(), ""
274
+	}
275
+	respBytes, err := ioutil.ReadAll(resp.Body)
276
+	if err != nil {
277
+		fmt.Println(err.Error())
278
+		return err.Error(), ""
279
+	}
280
+	fmt.Println(string(respBytes))
281
+	str := string(respBytes)
282
+	return str, inputLog
283
+
284
+}
285
+
286
+func UpdateHisPatientStatus(his *models.VMHisPatient) {
287
+	writeDb.Save(&his)
288
+}
289
+
290
+func GetUnSettleHisPrescriptionFive(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
291
+	err = readDb.Model(&models.HisPrescription{}).
292
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
293
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
294
+		}).
295
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
296
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
297
+		}).
298
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
299
+			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")
300
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
301
+		return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3  AND order_status <> 2  ", org_id)
302
+	}).
303
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 and order_status <> 5  AND p_type = ?", org_id, record_date, patient_id, p_type).
304
+		Find(&prescription).Error
305
+	return
306
+}
307
+
308
+func GetUnSettleMonthHisPrescription(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
309
+	err = readDb.Model(&models.HisPrescription{}).
310
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
311
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
312
+		}).
313
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
314
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
315
+		}).
316
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
317
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
318
+		}).
319
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 5 AND p_type <> 1", org_id, start_date, end_date, patient_id).
320
+		Find(&prescription).Error
321
+	return
322
+}
323
+
324
+func GetHisOrderFour(patient_id string, infoSeq string, docId string) (order models.HisOrder, err error) {
325
+	err = readDb.Model(&models.HisOrder{}).Where("mdtrt_id = ? AND psn_no = ? AND setl_id = ?", infoSeq, patient_id, docId).First(&order).Error
326
+	return
327
+}

+ 225 - 0
service/his_charge_service.go View File

@@ -311,3 +311,228 @@ func GetHisYidiClearRecordById(org_id int64, id int64) (record models.HisYidiCle
311 311
 	err = readDb.Model(&models.HisYidiClearRecord{}).Where("user_org_id = ? AND status = 1 AND id = ?", org_id, id).First(&record).Error
312 312
 	return
313 313
 }
314
+
315
+func GetAllPatientTwo(org_id int64) (patients []*models.ChargePatientTwo, err error) {
316
+	err = readDb.Model(&models.ChargePatientTwo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&patients).Error
317
+	return
318
+}
319
+
320
+func GetPatientChargeDetails(patient_id int64, org_id int64, start_time int64, end_time int64, keyword string, item_type int64, settle_type int64) (patients []*models.HisChargeOrderTwo, err error) {
321
+	if len(keyword) == 0 {
322
+		switch item_type {
323
+		case 0:
324
+			readDb2.Model(&models.HisChargeOrderTwo{}).Joins("join his_patient his on his.number = his_order.mdtrt_id AND his.patient_id = ").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
325
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
326
+					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
327
+						return db.Preload("Drug", "status = 1").Where("status = 1")
328
+					}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
329
+					return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
330
+						return db.Select("id,project_name,unit").Where("status = 1 ")
331
+					}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
332
+						return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
333
+					}).Where("status = 1 ")
334
+				})
335
+			}).Where("status = 1  AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
336
+			break
337
+		case 1:
338
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
339
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
340
+					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
341
+						return db.Preload("Drug", "status = 1").Where("status = 1")
342
+					}).Where("status = 1 AND advice_id > 0 AND project_id = 0")
343
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2  AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
344
+
345
+			break
346
+		case 2:
347
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
348
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
349
+					Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
350
+						return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
351
+							return db.Select("id,project_name,unit").Where("status = 1 ")
352
+						}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
353
+							return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
354
+						}).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
355
+					})
356
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
357
+
358
+			break
359
+		case 3:
360
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
361
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
362
+					Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
363
+						return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
364
+							return db.Select("id,project_name,unit").Where("status = 1 ")
365
+						}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
366
+							return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
367
+						}).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
368
+					})
369
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
370
+			break
371
+		}
372
+
373
+	} else {
374
+		//keyword := "%" + keyword + "%"
375
+		switch item_type {
376
+		case 0:
377
+			readDb2.Model(&models.HisChargeOrderTwo{}).Joins("join his_patient his on his.number = his_order.mdtrt_id AND his.patient_id = ").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
378
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
379
+					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
380
+						return db.Preload("Drug", "status = 1").Where("status = 1")
381
+					}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
382
+					return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
383
+						return db.Select("id,project_name,unit").Where("status = 1 ")
384
+					}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
385
+						return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
386
+					}).Where("status = 1 ")
387
+				})
388
+			}).Where("status = 1  AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
389
+			break
390
+		case 1:
391
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
392
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
393
+					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
394
+						return db.Preload("Drug", "status = 1").Where("status = 1")
395
+					}).Where("status = 1 AND advice_id > 0 AND project_id = 0")
396
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2  AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
397
+
398
+			break
399
+		case 2:
400
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
401
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
402
+					Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
403
+						return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
404
+							return db.Select("id,project_name,unit").Where("status = 1 ")
405
+						}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
406
+							return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
407
+						}).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
408
+					})
409
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
410
+
411
+			break
412
+		case 3:
413
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
414
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
415
+					Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
416
+						return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
417
+							return db.Select("id,project_name,unit").Where("status = 1 ")
418
+						}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
419
+							return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
420
+						}).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
421
+					})
422
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
423
+			break
424
+		}
425
+
426
+	}
427
+	return
428
+}
429
+
430
+func GetPatientGather(patient_id int64, org_id int64, start_time int64, end_time int64, keyword string, item_type int64, settle_type int64) (patients []*models.HisChargeOrderTwo, err error) {
431
+	if len(keyword) == 0 {
432
+		switch item_type {
433
+		case 0:
434
+			readDb2.Model(&models.HisChargeOrderTwo{}).Joins("join his_patient his on his.number = his_order.mdtrt_id AND his.patient_id = ").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
435
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
436
+					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
437
+						return db.Preload("Drug", "status = 1").Where("status = 1")
438
+					}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
439
+					return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
440
+						return db.Select("id,project_name,unit").Where("status = 1 ")
441
+					}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
442
+						return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
443
+					}).Where("status = 1 ")
444
+				})
445
+			}).Where("status = 1  AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
446
+			break
447
+		case 1:
448
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
449
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
450
+					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
451
+						return db.Preload("Drug", "status = 1").Where("status = 1")
452
+					}).Where("status = 1 AND advice_id > 0 AND project_id = 0")
453
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2  AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
454
+
455
+			break
456
+		case 2:
457
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
458
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
459
+					Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
460
+						return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
461
+							return db.Select("id,project_name,unit").Where("status = 1 ")
462
+						}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
463
+							return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
464
+						}).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
465
+					})
466
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
467
+
468
+			break
469
+		case 3:
470
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
471
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
472
+					Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
473
+						return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
474
+							return db.Select("id,project_name,unit").Where("status = 1 ")
475
+						}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
476
+							return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
477
+						}).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
478
+					})
479
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
480
+			break
481
+		}
482
+
483
+	} else {
484
+		//keyword := "%" + keyword + "%"
485
+		switch item_type {
486
+		case 0:
487
+			readDb2.Model(&models.HisChargeOrderTwo{}).Joins("join his_patient his on his.number = his_order.mdtrt_id AND his.patient_id = ").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
488
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
489
+					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
490
+						return db.Preload("Drug", "status = 1").Where("status = 1")
491
+					}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
492
+					return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
493
+						return db.Select("id,project_name,unit").Where("status = 1 ")
494
+					}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
495
+						return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
496
+					}).Where("status = 1 ")
497
+				})
498
+			}).Where("status = 1  AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
499
+			break
500
+		case 1:
501
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
502
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
503
+					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
504
+						return db.Preload("Drug", "status = 1").Where("status = 1")
505
+					}).Where("status = 1 AND advice_id > 0 AND project_id = 0")
506
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2  AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
507
+
508
+			break
509
+		case 2:
510
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
511
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
512
+					Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
513
+						return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
514
+							return db.Select("id,project_name,unit").Where("status = 1 ")
515
+						}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
516
+							return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
517
+						}).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
518
+					})
519
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
520
+
521
+			break
522
+		case 3:
523
+			readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
524
+				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
525
+					Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
526
+						return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
527
+							return db.Select("id,project_name,unit").Where("status = 1 ")
528
+						}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
529
+							return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
530
+						}).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
531
+					})
532
+			}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
533
+			break
534
+		}
535
+
536
+	}
537
+	return
538
+}

+ 27 - 2
service/his_hospital_service.go View File

@@ -315,7 +315,7 @@ func GetHospitalMonthHisPrescription(org_id int64, patient_id int64, start_time
315 315
 	return
316 316
 }
317 317
 
318
-func GetSettleHisHospitalPrescription(org_id int64, patient_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisHospitalPrescription, err error) {
318
+func GetSettleHisHospitalPrescription(org_id int64, patient_id int64, batch_number string) (prescription []*models.HisHospitalPrescription, err error) {
319 319
 	err = readDb.Model(&models.HisHospitalPrescription{}).
320 320
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
321 321
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
@@ -326,7 +326,7 @@ func GetSettleHisHospitalPrescription(org_id int64, patient_id int64, his_patien
326 326
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
327 327
 			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")
328 328
 		}).
329
-		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND patient_id = ? AND order_status = 4 ", org_id, record_date, patient_id).
329
+		Where("user_org_id = ? AND status = 1  AND patient_id = ? AND order_status = 4 AND batch_number = ? ", org_id, patient_id, batch_number).
330 330
 		Find(&prescription).Error
331 331
 	return
332 332
 }
@@ -523,3 +523,28 @@ func GetNewUnChargeHisHospitalPrescriptionFive(org_id int64, patient_id int64, h
523 523
 		Find(&prescription).Error
524 524
 	return
525 525
 }
526
+
527
+func GetZHHisUploadOrderInfo(org_id int64, patient_id int64, record_date int64, record_end_date int64, number string) (infos []*models.HisOrderInfo, err error) {
528
+	err = readDb.Model(&models.HisOrderInfo{}).
529
+		Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ? AND order_number = ? ", org_id, record_end_date, record_date, patient_id, number).
530
+		Find(&infos).Error
531
+	return
532
+}
533
+
534
+func UpDateOrderInfoStatus(patient_id int64, record_date int64, org_id int64, record_two_date int64) (err error) {
535
+	err = writeDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ?", org_id, record_two_date, record_date, patient_id).Updates(map[string]interface{}{"status": 0}).Error
536
+	return
537
+}
538
+
539
+func UpDatePrescriptionOrderStatusTwo(patient_id int64, record_date int64, org_id int64) (err error) {
540
+	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = 1", org_id, record_date, patient_id).Updates(map[string]interface{}{"order_status": 1}).Error
541
+	return
542
+}
543
+
544
+func UpdataHospitalOrderStatusTwo(number string, user_org_id int64) (err error) {
545
+	err = writeDb.Model(&models.HisOrderInfo{}).Where("status = 1 AND order_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
546
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
547
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
548
+	return
549
+
550
+}

+ 2 - 2
service/his_print_service.go View File

@@ -23,7 +23,7 @@ func GetBatchProjectHisPrescription(ids []string, record_time int64, user_org_id
23 23
 		Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
24 24
 			return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1 AND p_type = 2", user_org_id, record_time).
25 25
 				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
26
-					return db.Where("status = 1 ").Preload("HisProject", "status = 1").Preload("GoodInfo", "status=1")
26
+					return db.Where("his_prescription_project.status = 1 AND his_prescription_project.user_org_id = ?", user_org_id).Where("his_prescription_project.status = 1 ").Preload("HisProject", "status = 1").Preload("GoodInfo", "status=1")
27 27
 				})
28 28
 		}).
29 29
 		Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
@@ -37,7 +37,7 @@ func GetBatchInspectionProjectHisPrescription(ids []string, record_time int64, u
37 37
 		Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
38 38
 			return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1 AND p_type = 2", user_org_id, record_time).
39 39
 				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
40
-					return db.Where("status = 1 ").Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1 AND cost_classify = 3")
40
+					return db.Joins("Join xt_his_project p On p.id = his_prescription_project.project_id  AND p.cost_classify = 3").Where("his_prescription_project.status = 1 ").Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1")
41 41
 				})
42 42
 		}).
43 43
 		Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).

+ 7 - 1
service/his_project_service.go View File

@@ -370,7 +370,7 @@ func GetBloodPatientByPatient(id int64) (models.XtPatients, error) {
370 370
 	return patients, err
371 371
 }
372 372
 
373
-func GetHisPatientByIdTwo(patientid int64) (models.XtHisPatient, error) {
373
+func GetHisPatientByIdFour(patientid int64) (models.XtHisPatient, error) {
374 374
 
375 375
 	patient := models.XtHisPatient{}
376 376
 	err := XTReadDB().Model(&patient).Where("patient_id = ? and status=1", patientid).Find(&patient).Error
@@ -383,6 +383,12 @@ func GetHisPatientById(patientid int64) (models.VMHisPatient, error) {
383 383
 	return patient, err
384 384
 }
385 385
 
386
+func GetHisPatientByIdTwo(patientid int64) (models.VMHisPatient, error) {
387
+	patient := models.VMHisPatient{}
388
+	err := XTReadDB().Model(&patient).Where("patient_id = ? and status = 1", patientid).Limit(&patient).Error
389
+	return patient, err
390
+}
391
+
386 392
 func GetTemplateDetail(id int64) (models.HisCaseHistoryTemplate, error) {
387 393
 
388 394
 	template := models.HisCaseHistoryTemplate{}

+ 62 - 5
service/his_service.go View File

@@ -304,6 +304,11 @@ func GetHisPatientInfoThree(org_id int64, number string) (info models.HisPatient
304 304
 	return
305 305
 }
306 306
 
307
+func GetHisPatientInfoFour(org_id int64, patient_id int64, record_date int64, his_patient_id int64) (info models.HisPatient, err error) {
308
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND id = ?", org_id, record_date, patient_id, his_patient_id).First(&info).Error
309
+	return
310
+}
311
+
307 312
 func GetHisPatientInfoList(org_id int64, patient_id int64, record_date int64) (info []*models.HisPatient, err error) {
308 313
 	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Find(&info).Error
309 314
 	return
@@ -587,6 +592,24 @@ func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_dat
587 592
 	return
588 593
 }
589 594
 
595
+func GetUnChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
596
+	err = readDb.Model(&models.HisPrescription{}).
597
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
598
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
599
+		}).
600
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
601
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
602
+		}).
603
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
604
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
605
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
606
+		return db.Where("status = 1 AND user_org_id = ?", org_id)
607
+	}).
608
+		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", org_id, start_date, end_date, patient_id).
609
+		Find(&prescription).Error
610
+	return
611
+}
612
+
590 613
 type OtherDrugWarehouseInfo struct {
591 614
 	ID               int64   `gorm:"column:id" json:"id" form:"id"`
592 615
 	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
@@ -888,7 +911,13 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_time
888 911
 			db = db.Where("his_order.setl_time<=?", end_time+" 23:59:59")
889 912
 		}
890 913
 	}
891
-	db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.p_type = ? AND his_order.order_status = 2", user_org_id, p_type)
914
+	if p_type > 0 {
915
+		db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.p_type = ? AND his_order.order_status = 2", user_org_id, p_type)
916
+
917
+	} else {
918
+		db = db.Where("his_order.status = 1 AND his_order.user_org_id = ? AND his_order.order_status = 2", user_org_id)
919
+
920
+	}
892 921
 	db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
893 922
 		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
894 923
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
@@ -1839,11 +1868,9 @@ type CustomAccountFormData struct {
1839 1868
 
1840 1869
 func GetCheckAccountFormData(start_time int64, end_time int64, org_id int64, insutype string, clr_type string) (cus []*CustomAccountFormData, err error) {
1841 1870
 	if clr_type == "9903" {
1842
-
1843 1871
 		err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt,o.hifp_pay as hifp_pay  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND o.insutype = ? AND o.clr_type = ? Group by o.id", org_id, start_time, end_time, insutype, clr_type).Scan(&cus).Error
1844 1872
 	} else {
1845 1873
 		err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt,o.hifp_pay as hifp_pay  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND o.insutype = ? AND o.clr_type <> 9903 Group by o.id", org_id, start_time, end_time, insutype).Scan(&cus).Error
1846
-
1847 1874
 	}
1848 1875
 
1849 1876
 	for _, item := range cus {
@@ -2134,7 +2161,9 @@ func GetUnChargeMonthHisPrescriptionSix(org_id int64, patient_id int64, start_da
2134 2161
 		}).
2135 2162
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2136 2163
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
2137
-		}).
2164
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
2165
+		return db.Where("status = 1 AND user_org_id = ?", org_id)
2166
+	}).
2138 2167
 		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  AND p_type = ? AND order_status <> 2 ", org_id, start_date, end_date, patient_id, p_type).
2139 2168
 		Find(&prescription).Error
2140 2169
 	return
@@ -2150,7 +2179,9 @@ func GetChargeMonthHisPrescriptionSix(org_id int64, patient_id int64, start_date
2150 2179
 		}).
2151 2180
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2152 2181
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
2153
-		}).
2182
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
2183
+		return db.Where("status = 1 AND user_org_id = ?", org_id)
2184
+	}).
2154 2185
 		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ?  AND p_type = ? AND order_status = 2 ", org_id, start_date, end_date, patient_id, p_type).
2155 2186
 		Find(&prescription).Error
2156 2187
 	return
@@ -2333,3 +2364,29 @@ func GetGoodWarehoseInfoByGoodId(good_id int64, org_id int64) (info models.GoodS
2333 2364
 	err = readDb.Model(&models.GoodSotckInfo{}).Where("stock_count > 0 and status = 1 and good_id = ? and org_id = ?", good_id, org_id).First(&info).Error
2334 2365
 	return
2335 2366
 }
2367
+
2368
+type MonthChargePatients struct {
2369
+	ID              int64              `gorm:"column:id" json:"id" form:"id"`
2370
+	UserOrgId       int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2371
+	Name            string             `gorm:"column:name" json:"name" form:"name"`
2372
+	Status          int64              `gorm:"column:status" json:"status" form:"status"`
2373
+	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2374
+	Number          string             `gorm:"column:number" json:"number" form:"number"`
2375
+	HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"prescription"`
2376
+}
2377
+
2378
+func (MonthChargePatients) TableName() string {
2379
+	return "his_patient"
2380
+}
2381
+
2382
+func GetMonthUnChargeHisPatientList(org_id int64, record_date int64, start_time int64, end_time int64) (patients []*MonthChargePatients, err error) {
2383
+	db := readDb.Model(&MonthChargePatients{}).Where("his_patient.user_org_id = ? AND his_patient.status = 1 AND his_patient.record_date = ?", org_id, record_date)
2384
+	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND p_type <> 1 AND order_status <> 2 AND order_status <> 3", org_id, start_time, end_time)
2385
+	return
2386
+}
2387
+
2388
+func UpdataOrderStatusThree(number string, user_org_id int64) (err error) {
2389
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 5, "mtime": time.Now().Unix()}).Error
2390
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 5, "mtime": time.Now().Unix()}).Error
2391
+	return
2392
+}