Browse Source

提交代码

陈少旭 1 year ago
parent
commit
076372f381

+ 405 - 25
controllers/his_print_api_controller.go View File

@@ -4,11 +4,24 @@ import (
4 4
 	"XT_New/enums"
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7
+	"XT_New/utils"
8
+	"bytes"
9
+	"encoding/json"
10
+	"encoding/xml"
11
+	"fmt"
7 12
 	"github.com/astaxie/beego"
13
+	"io/ioutil"
14
+	"net/http"
15
+	"os"
16
+	"strconv"
8 17
 	"strings"
9 18
 	"time"
10 19
 )
11 20
 
21
+const (
22
+	key = "4a6617a4409c48dc836152e80e18febd"
23
+)
24
+
12 25
 type HisPrintApiController struct {
13 26
 	BaseAuthAPIController
14 27
 }
@@ -19,34 +32,205 @@ func HisPrintApiRegistRouters() {
19 32
 	beego.Router("/api/his/prescription/summary", &HisPrintApiController{}, "get:GetUnChargePrescriptionSummary")
20 33
 	beego.Router("/api/his/label/create", &HisPrintApiController{}, "get:CreateLablePrint")
21 34
 	beego.Router("/api/his/label/get", &HisPrintApiController{}, "get:GetLablePrint")
35
+	beego.Router("/api/his/label/send", &HisPrintApiController{}, "get:SendApplyCode")
36
+}
22 37
 
23
-	//beego.Router("/api/his/checkprescription/print", &HisPrintApiController{}, "get:GetBatchCheckHisPrescriptionData")
38
+func (c *HisPrintApiController) SendApplyCode() {
39
+	list, _ := service.GetAllLisDataFor10191(c.GetAdminUserInfo().CurrentOrgId)
40
+	if len(list) > 0 {
41
+		//插入中间库中
42
+		for _, item := range list {
43
+			if len(item.ApplyCode) == 0 {
44
+				var apply models.JYApply
45
+				apply.BedCode = ""
46
+				apply.PatientName = item.Patient.Name
47
+				idCard := item.Patient.IdCardNo // 身份证号码示例
48
+				age, err := GetAge(idCard)
49
+				if err != nil {
50
+					age = int(item.Patient.Age)
51
+					fmt.Println("计算年龄时出错:", err)
52
+				}
24 53
 
25
-}
54
+				apply.Age = strconv.FormatInt(int64(age), 10)
55
+				apply.AgeUnit = "岁"
56
+				if item.Patient.Gender == 1 {
57
+					apply.Sex = "男"
58
+				} else if item.Patient.Gender == 2 {
59
+					apply.Sex = "女"
60
+				} else {
61
+					apply.Sex = "不详"
62
+				}
63
+				apply.RegisterCode = ""
64
+				apply.Diagnosis = ""
65
+				apply.Ward = ""
66
+				role, _ := service.GetAdminUserRole(2398, c.GetAdminUserInfo().CurrentOrgId)
67
+				apply.SendDoctor = role.UserName
68
+				apply.PatientType = 1
69
+				apply.PatientPhone = item.Patient.Phone
70
+				//applys = append(applys, apply)
71
+				var jYApplyDetails []models.CustomerApplyDetail
72
+
73
+				if len(item.ItemIds) > 0 {
74
+					team_ids := strings.Split(item.ItemIds, ",")
75
+					for index, subItem := range team_ids {
76
+						//判断一些需要拆分的组套 血透体检(定量):需要拆分出传染病检查(定性),丙型肝炎抗体测试,血透体检(定量)
77
+						if subItem == "267" {
78
+							//血透体检(定量)
79
+							var jYApplyDetail models.CustomerApplyDetail
80
+							id, _ := strconv.ParseInt(subItem, 10, 64)
81
+							jYApplyDetail.CustomerChargeItemCode = strconv.FormatInt(id, 10)
82
+							jYApplyDetail.RowIndex = int64(index + 1)
83
+							jYApplyDetail.Barcode = ""
84
+							jYApplyDetail.CustomerBarcode = strconv.FormatInt(item.ID, 10)
85
+							jYApplyDetail.Comment = ""
86
+							jYApplyDetail.TakeSampleTime = time.Unix(item.Ctime, 0).Format("2006-01-02 15:04:05")
87
+							jYApplyDetails = append(jYApplyDetails, jYApplyDetail)
88
+
89
+							//丙型肝炎抗体测定
90
+							var jYApplyDetail2 models.CustomerApplyDetail
91
+							id2, _ := strconv.ParseInt("26701", 10, 64)
92
+							jYApplyDetail2.CustomerChargeItemCode = strconv.FormatInt(id2, 10)
93
+							jYApplyDetail2.RowIndex = int64(index + 1)
94
+							jYApplyDetail2.Barcode = ""
95
+							jYApplyDetail2.CustomerBarcode = strconv.FormatInt(item.ID, 10)
96
+							jYApplyDetail2.Comment = ""
97
+							jYApplyDetail2.TakeSampleTime = time.Unix(item.Ctime, 0).Format("2006-01-02 15:04:05")
98
+							jYApplyDetails = append(jYApplyDetails, jYApplyDetail2)
99
+
100
+							//传染病检查(定性)
101
+							var jYApplyDetail3 models.CustomerApplyDetail
102
+							id3, _ := strconv.ParseInt("26700", 10, 64)
103
+							jYApplyDetail3.CustomerChargeItemCode = strconv.FormatInt(id3, 10)
104
+							jYApplyDetail3.RowIndex = int64(index + 1)
105
+							jYApplyDetail3.Barcode = ""
106
+							jYApplyDetail3.CustomerBarcode = strconv.FormatInt(item.ID, 10)
107
+							jYApplyDetail3.Comment = ""
108
+							jYApplyDetail3.TakeSampleTime = time.Unix(item.Ctime, 0).Format("2006-01-02 15:04:05")
109
+							jYApplyDetails = append(jYApplyDetails, jYApplyDetail3)
110
+
111
+						}
112
+
113
+						//判断一些需要拆分的组套 血透体检(定性):需要拆分出传染病检查(定性),丙型肝炎抗体测试,血透体检(定性)
114
+						if subItem == "424" {
115
+							//血透体检(定性)
116
+							var jYApplyDetail models.CustomerApplyDetail
117
+							id, _ := strconv.ParseInt(subItem, 10, 64)
118
+							jYApplyDetail.CustomerChargeItemCode = strconv.FormatInt(id, 10)
119
+							jYApplyDetail.RowIndex = int64(index + 1)
120
+							jYApplyDetail.Barcode = ""
121
+							jYApplyDetail.CustomerBarcode = strconv.FormatInt(item.ID, 10)
122
+							jYApplyDetail.Comment = ""
123
+							jYApplyDetail.TakeSampleTime = time.Unix(item.Ctime, 0).Format("2006-01-02 15:04:05")
124
+							jYApplyDetails = append(jYApplyDetails, jYApplyDetail)
125
+
126
+							//丙型肝炎抗体测定
127
+							var jYApplyDetail2 models.CustomerApplyDetail
128
+							id2, _ := strconv.ParseInt("42401", 10, 64)
129
+							jYApplyDetail2.CustomerChargeItemCode = strconv.FormatInt(id2, 10)
130
+							jYApplyDetail2.RowIndex = int64(index + 1)
131
+							jYApplyDetail2.Barcode = ""
132
+							jYApplyDetail2.CustomerBarcode = strconv.FormatInt(item.ID, 10)
133
+							jYApplyDetail2.Comment = ""
134
+							jYApplyDetail2.TakeSampleTime = time.Unix(item.Ctime, 0).Format("2006-01-02 15:04:05")
135
+							jYApplyDetails = append(jYApplyDetails, jYApplyDetail2)
136
+
137
+							//传染病检查(定性)
138
+							var jYApplyDetail3 models.CustomerApplyDetail
139
+							id3, _ := strconv.ParseInt("42400", 10, 64)
140
+							jYApplyDetail3.CustomerChargeItemCode = strconv.FormatInt(id3, 10)
141
+							jYApplyDetail3.RowIndex = int64(index + 1)
142
+							jYApplyDetail3.Barcode = ""
143
+							jYApplyDetail3.CustomerBarcode = strconv.FormatInt(item.ID, 10)
144
+							jYApplyDetail3.Comment = ""
145
+							jYApplyDetail3.TakeSampleTime = time.Unix(item.Ctime, 0).Format("2006-01-02 15:04:05")
146
+							jYApplyDetails = append(jYApplyDetails, jYApplyDetail3)
147
+
148
+						}
149
+						var jYApplyDetail models.CustomerApplyDetail
150
+						id, _ := strconv.ParseInt(subItem, 10, 64)
151
+						jYApplyDetail.CustomerChargeItemCode = strconv.FormatInt(id, 10)
152
+						jYApplyDetail.RowIndex = int64(index + 1)
153
+						jYApplyDetail.Barcode = ""
154
+						jYApplyDetail.CustomerBarcode = strconv.FormatInt(item.ID, 10)
155
+						jYApplyDetail.Comment = ""
156
+						jYApplyDetail.TakeSampleTime = time.Unix(item.Ctime, 0).Format("2006-01-02 15:04:05")
157
+						jYApplyDetails = append(jYApplyDetails, jYApplyDetail)
158
+					}
159
+				}
160
+
161
+				if len(item.ProjectIds) > 0 {
162
+					team_ids := strings.Split(item.ProjectIds, ",")
163
+					for index, subItem := range team_ids {
164
+						var jYApplyDetail models.CustomerApplyDetail
165
+						id, _ := strconv.ParseInt(subItem, 10, 64)
166
+						jYApplyDetail.CustomerChargeItemCode = strconv.FormatInt(id, 10)
167
+						jYApplyDetail.RowIndex = int64(index)
168
+						jYApplyDetail.Barcode = ""
169
+						jYApplyDetail.CustomerBarcode = strconv.FormatInt(item.ID, 10)
170
+						jYApplyDetail.Comment = ""
171
+						jYApplyDetail.TakeSampleTime = time.Unix(item.Ctime, 0).Format("2006-01-02 15:04:05")
172
+						jYApplyDetails = append(jYApplyDetails, jYApplyDetail)
173
+					}
174
+				}
175
+				result := PostInspectApply(key, apply, jYApplyDetails)
176
+				if result.Res == 0 {
177
+					item.ApplyCode = result.JYApplyResult.ApplyCode
178
+					jsonData, err := json.Marshal(apply)
179
+					if err != nil {
180
+						fmt.Println("转换为JSON时发生错误:", err)
181
+					}
182
+					jsonStr := string(jsonData)
183
+					jsonData2, err2 := json.Marshal(jYApplyDetails)
184
+					if err2 != nil {
185
+						fmt.Println("转换为JSON时发生错误:", err2)
186
+					}
187
+					jsonStr2 := string(jsonData2)
188
+
189
+					jsonData3, err3 := json.Marshal(result)
190
+					if err3 != nil {
191
+						fmt.Println("转换为JSON时发生错误:", err3)
192
+					}
193
+					jsonStr3 := string(jsonData3)
194
+					saveSuccessLog(jsonStr3, jsonStr+"\r\n"+jsonStr2, "申清单成功日志", "申清单")
195
+					err1 := service.CreateLabelPrint(&item)
196
+					if err1 == nil {
197
+						c.ServeSuccessJSON(map[string]interface{}{
198
+							"msg": "发送成功",
199
+						})
200
+					}
201
+					return
202
+				} else {
203
+					jsonData, err := json.Marshal(apply)
204
+					if err != nil {
205
+						fmt.Println("转换为JSON时发生错误:", err)
206
+
207
+					}
208
+					jsonStr := string(jsonData)
209
+
210
+					jsonData2, err2 := json.Marshal(jYApplyDetails)
211
+					if err2 != nil {
212
+						fmt.Println("转换为JSON时发生错误:", err2)
213
+
214
+					}
215
+					jsonStr2 := string(jsonData2)
216
+
217
+					jsonData3, err3 := json.Marshal(result)
218
+					if err3 != nil {
219
+						fmt.Println("转换为JSON时发生错误:", err3)
220
+
221
+					}
222
+					jsonStr3 := string(jsonData3)
26 223
 
27
-//func (c *HisPrintApiController) GetBatchCheckHisPrescriptionData() {
28
-//	record_date := c.GetString("record_date")
29
-//	patient_ids := c.GetString("patient_ids")
30
-//	timeLayout := "2006-01-02"
31
-//	loc, _ := time.LoadLocation("Local")
32
-//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
33
-//	if err != nil {
34
-//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
35
-//		return
36
-//	}
37
-//	recordDateTime := theTime.Unix()
38
-//	adminInfo := c.GetAdminUserInfo()
39
-//	ids := strings.Split(patient_ids, ",")
40
-//
41
-//	//var newPatients []*models.PrintPatient
42
-//
43
-//	patients, _ := service.GetBatchInspectionProjectHisPrescriptionTwo(ids, recordDateTime, adminInfo.CurrentOrgId)
44
-//
45
-//	c.ServeSuccessJSON(map[string]interface{}{
46
-//		"patients": patients,
47
-//	})
48
-//	break
49
-//}
224
+					SaveErrorLog(jsonStr3, jsonStr+"\r\n"+jsonStr2, "申清单错误日志", "申清单")
225
+
226
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
227
+					return
228
+				}
229
+			}
230
+		}
231
+
232
+	}
233
+}
50 234
 
51 235
 func (c *HisPrintApiController) GetLablePrint() {
52 236
 	patient_id, _ := c.GetInt64("patient_id")
@@ -213,3 +397,199 @@ func (c *HisPrintApiController) GetBatchHisPrescriptionData() {
213 397
 		break
214 398
 	}
215 399
 }
400
+
401
+func GetAge(idCard string) (int, error) {
402
+	birthDate, err := getBirthDateFromIDCard(idCard)
403
+	if err != nil {
404
+		return 0, err
405
+	}
406
+
407
+	age := calculateAge(birthDate)
408
+	return age, nil
409
+}
410
+
411
+func getBirthDateFromIDCard(idCard string) (time.Time, error) {
412
+	birthDateStr := idCard[6:14] // 身份证号码中生日部分的字符
413
+	birthDate, err := time.Parse("20060102", birthDateStr)
414
+	if err != nil {
415
+		return time.Time{}, err
416
+	}
417
+
418
+	return birthDate, nil
419
+}
420
+
421
+func calculateAge(birthDate time.Time) int {
422
+	now := time.Now()
423
+	age := now.Year() - birthDate.Year()
424
+
425
+	// 如果当前月份小于出生月份,或者当前月份等于出生月份但当前日期小于出生日期,则年龄减一
426
+	if now.Month() < birthDate.Month() || (now.Month() == birthDate.Month() && now.Day() < birthDate.Day()) {
427
+		age--
428
+	}
429
+
430
+	return age
431
+}
432
+
433
+// 送检单
434
+func PostInspectApply(key string, apply models.JYApply, list []models.CustomerApplyDetail) models.InspectApplyData {
435
+	// 构建SOAP请求数据
436
+	requestData := &models.JYApplyEnvelope{
437
+		Soap: "http://schemas.xmlsoap.org/soap/envelope/",
438
+		Xsi:  "http://www.w3.org/2001/XMLSchema-instance",
439
+		Xsd:  "http://www.w3.org/2001/XMLSchema",
440
+		Body: models.JYApplyBody{
441
+			InspectApplyReq: models.InspectApplyReq{
442
+				XMLName: xml.Name{Local: "InspectApplyByInstituteItemCode", Space: "http://tempuri.org/"},
443
+				ApiKey:  key,
444
+				Apply:   apply,
445
+				ApplyDetailList: struct {
446
+					CustomerApplyDetail []models.CustomerApplyDetail `xml:"CustomerApplyDetail"`
447
+				}{
448
+					CustomerApplyDetail: list,
449
+				},
450
+				ApplyAdditional: nil,
451
+			},
452
+		},
453
+	}
454
+
455
+	// 将SOAP请求数据转换为XML格式
456
+	requestBody, err := xml.Marshal(requestData)
457
+	if err != nil {
458
+		fmt.Println("XML Marshal error:", err)
459
+	}
460
+	fmt.Println(string(requestBody))
461
+
462
+	// 创建POST请求
463
+	url := "http://gpis.cnhiqc.com:9799/InstituteLISService.asmx"
464
+	req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
465
+	if err != nil {
466
+		fmt.Println("Request creation error:", err)
467
+	}
468
+
469
+	// 设置请求头
470
+	req.Header.Set("Content-Type", "text/xml; charset=utf-8")
471
+	req.Header.Set("Content-Length", "length")
472
+	req.Header.Set("SOAPAction", "http://tempuri.org/InspectApplyByInstituteItemCode")
473
+
474
+	// 发送请求
475
+	client := &http.Client{}
476
+	resp, err := client.Do(req)
477
+	if err != nil {
478
+		fmt.Println("Request error:", err)
479
+	}
480
+	defer resp.Body.Close()
481
+
482
+	// 读取响应数据
483
+	responseBody, err := ioutil.ReadAll(resp.Body)
484
+	if err != nil {
485
+		fmt.Println("Response read error:", err)
486
+
487
+	}
488
+	fmt.Println(string(responseBody))
489
+
490
+	// 解析XML数据
491
+	var envelope_four models.EnvelopeFour
492
+	err2 := xml.Unmarshal(responseBody, &envelope_four)
493
+	if err2 != nil {
494
+		fmt.Println("XML Unmarshal error:", err2)
495
+
496
+	}
497
+
498
+	// 获取GetReportListResult的JSON字符串
499
+	jsonStr := envelope_four.Body.InspectApplyByInstituteItemCodeResponse.InspectApply
500
+
501
+	// 解析JSON字符串到结构体
502
+	var reportData models.InspectApplyData
503
+	err = json.Unmarshal([]byte(jsonStr), &reportData)
504
+
505
+	if err != nil {
506
+		fmt.Println("JSON Unmarshal error:", err)
507
+	}
508
+	if reportData.Res != 0 {
509
+		fmt.Println("Data:", reportData)
510
+		//return reportData.JYApplyResult
511
+	}
512
+	return reportData
513
+}
514
+
515
+func SaveErrorLog(result string, request string, infno string, desc string) {
516
+	//org_id, _ := beego.AppConfig.Int64("org_id")
517
+	//miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
518
+	dir := "faild"
519
+	utils.Mkdir(dir)
520
+	month := time.Unix(1557042972, 0).Format("1")
521
+	year := time.Now().Format("2006")
522
+	month = time.Now().Format("01")
523
+	day := time.Now().Format("02")
524
+	hour := time.Now().Format("15")
525
+	min := time.Now().Format("04")
526
+	sec := time.Now().Format("05")
527
+
528
+	result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
529
+
530
+	file := "failed" + "_" + year + month + day + "_log"
531
+	file_name := file + ".txt"
532
+	file_path := "faild" + "/" + file_name
533
+	exist, _ := utils.PathExists(file_path)
534
+	if exist { //存在
535
+		fmt.Println("存在")
536
+		f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
537
+		if err != nil {
538
+			fmt.Println("read fail")
539
+		}
540
+		content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
541
+		n, _ := f.Seek(0, 2)
542
+		_, err = f.WriteAt([]byte(content), n)
543
+
544
+	} else { //不存在
545
+		fmt.Println("文件不存在,创建文件")
546
+		f, err := os.Create("faild" + "/" + file_name)
547
+		defer f.Close()
548
+		if err != nil {
549
+		} else {
550
+			_, err = f.Write([]byte("记录日志"))
551
+		}
552
+	}
553
+
554
+}
555
+func saveSuccessLog(result string, request string, infno string, desc string) {
556
+
557
+	//org_id, _ := beego.AppConfig.Int64("org_id")
558
+	//miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
559
+	//dir := "同步成功日志"
560
+	//utils.Mkdir(dir)
561
+	month := time.Unix(1557042972, 0).Format("1")
562
+	year := time.Now().Format("2006")
563
+	month = time.Now().Format("01")
564
+	day := time.Now().Format("02")
565
+	hour := time.Now().Format("15")
566
+	min := time.Now().Format("04")
567
+	sec := time.Now().Format("05")
568
+
569
+	result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
570
+
571
+	file := "success" + "_" + year + month + day + "_log"
572
+	file_name := file + ".txt"
573
+	file_path := file_name
574
+	exist, _ := utils.PathExists(file_path)
575
+	if exist { //存在
576
+		fmt.Println("存在")
577
+		f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
578
+		if err != nil {
579
+			fmt.Println("read fail")
580
+		}
581
+		content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
582
+		n, _ := f.Seek(0, 2)
583
+		_, err = f.WriteAt([]byte(content), n)
584
+
585
+	} else { //不存在
586
+		fmt.Println("文件不存在,创建文件")
587
+		f, err := os.Create(file_name)
588
+		defer f.Close()
589
+		if err != nil {
590
+		} else {
591
+			_, err = f.Write([]byte("记录日志"))
592
+		}
593
+	}
594
+
595
+}

+ 6 - 0
controllers/his_project_api_controller.go View File

@@ -87,6 +87,7 @@ func HisProjectRouters() {
87 87
 	beego.Router("/api/hispatient/getmaintemplatebyid", &HisProjectApiController{}, "Get:GetMainTemplateById")
88 88
 	beego.Router("/api/hispatient/updatemaintemplate", &HisProjectApiController{}, "Get:UpdateMainTemplate")
89 89
 	beego.Router("/api/hispatient/deletemaintemplate", &HisProjectApiController{}, "Get:DeleteMainTemplate")
90
+
90 91
 }
91 92
 
92 93
 func (this *HisProjectApiController) SaveProject() {
@@ -1268,6 +1269,11 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1268 1269
 	prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1269 1270
 	//advicePrint, err := service.GetPre(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId, temp_p_type)
1270 1271
 	hisPatient, _ := service.GetHisPatientInfoFour(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, his_patient_id)
1272
+	hisPatient_two, _ := service.GetHisPatientInfoTen(adminUserInfo.CurrentOrgId, patient_id, recordDateTime)
1273
+	if hisPatient.ID == 0 {
1274
+		hisPatient = hisPatient_two
1275
+	}
1276
+
1271 1277
 	//hisPatient, _ := service.GetHisPatientById(patient_id)
1272 1278
 	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
1273 1279
 

+ 16 - 14
models/his_print_models.go View File

@@ -147,20 +147,22 @@ func (HisPrescriptionInfoTwo) TableName() string {
147 147
 }
148 148
 
149 149
 type HisLabelPrintStatusInfo struct {
150
-	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
151
-	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
152
-	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
153
-	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
154
-	Status             int64  `gorm:"column:status" json:"status" form:"status"`
155
-	IsCombinationPrint int64  `gorm:"column:is_combination_print" json:"is_combination_print" form:"is_combination_print"`
156
-	RecordDate         string `gorm:"column:record_date" json:"record_date" form:"record_date"`
157
-	ItemIds            string `gorm:"column:item_ids" json:"item_ids" form:"item_ids"`
158
-	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
159
-	ProjectIds         string `gorm:"column:project_ids" json:"project_ids" form:"project_ids"`
160
-	Ids                string `gorm:"column:ids" json:"ids" form:"ids"`
161
-	DoctorId           int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
162
-	IsTeam             int64  `gorm:"column:is_team" json:"is_team" form:"is_team"`
163
-	IsPrint            int64  `gorm:"column:is_print" json:"is_print" form:"is_print"`
150
+	ID                 int64    `gorm:"column:id" json:"id" form:"id"`
151
+	PatientId          int64    `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
152
+	Ctime              int64    `gorm:"column:ctime" json:"ctime" form:"ctime"`
153
+	Mtime              int64    `gorm:"column:mtime" json:"mtime" form:"mtime"`
154
+	Status             int64    `gorm:"column:status" json:"status" form:"status"`
155
+	IsCombinationPrint int64    `gorm:"column:is_combination_print" json:"is_combination_print" form:"is_combination_print"`
156
+	RecordDate         string   `gorm:"column:record_date" json:"record_date" form:"record_date"`
157
+	ItemIds            string   `gorm:"column:item_ids" json:"item_ids" form:"item_ids"`
158
+	UserOrgId          int64    `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
159
+	ProjectIds         string   `gorm:"column:project_ids" json:"project_ids" form:"project_ids"`
160
+	Ids                string   `gorm:"column:ids" json:"ids" form:"ids"`
161
+	DoctorId           int64    `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
162
+	IsTeam             int64    `gorm:"column:is_team" json:"is_team" form:"is_team"`
163
+	IsPrint            int64    `gorm:"column:is_print" json:"is_print" form:"is_print"`
164
+	ApplyCode          string   `gorm:"column:apply_code" json:"apply_code" form:"apply_code"`
165
+	Patient            Patients `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patient"`
164 166
 }
165 167
 
166 168
 func (HisLabelPrintStatusInfo) TableName() string {

+ 17 - 12
service/his_charge_service.go View File

@@ -157,43 +157,43 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
157 157
 		switch item_type {
158 158
 		case 0:
159 159
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
160
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
160
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
161 161
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
162 162
 
163 163
 			break
164 164
 		case 1:
165 165
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
166
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id)
166
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id).Order("ctime")
167 167
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
168 168
 
169 169
 			break
170 170
 		case 2:
171 171
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
172
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id)
172
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id).Order("ctime")
173 173
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
174 174
 
175 175
 			break
176 176
 		case 3:
177 177
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
178
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id)
178
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id).Order("ctime")
179 179
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
180 180
 
181 181
 			break
182 182
 		case 4:
183 183
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
184
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id)
184
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id).Order("ctime")
185 185
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
186 186
 
187 187
 			break
188 188
 		case 5:
189 189
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 AND orders.insutype = 390", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
190
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 ", start_time, end_time, org_id)
190
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 ", start_time, end_time, org_id).Order("ctime")
191 191
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
192 192
 
193 193
 			break
194 194
 		case 6:
195 195
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 AND orders.insutype = 310 ", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
196
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
196
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
197 197
 			}).Where("p.status = 1  AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
198 198
 
199 199
 			break
@@ -205,31 +205,31 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
205 205
 		switch item_type {
206 206
 		case 0:
207 207
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
208
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
208
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id).Order("ctime")
209 209
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
210 210
 
211 211
 			break
212 212
 		case 1:
213 213
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
214
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id)
214
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id).Order("ctime")
215 215
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
216 216
 
217 217
 			break
218 218
 		case 2:
219 219
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
220
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id)
220
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id).Order("ctime")
221 221
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
222 222
 
223 223
 			break
224 224
 		case 3:
225 225
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
226
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id)
226
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id).Order("ctime")
227 227
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
228 228
 
229 229
 			break
230 230
 		case 4:
231 231
 			err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
232
-				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id)
232
+				return db.Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id).Order("ctime")
233 233
 			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
234 234
 
235 235
 			break
@@ -624,3 +624,8 @@ func GetAllChargeDetailsTwo(org_id int64, start_time int64, end_time int64) (pat
624 624
 
625 625
 	return
626 626
 }
627
+
628
+func GetAllLisDataFor10191(org_id int64) (list []models.HisLabelPrintStatusInfo, err error) {
629
+	err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Preload("Patient", "status = 1").Where("user_org_id = ? AND status = 1  and apply_code = ''", org_id).Find(&list).Error
630
+	return
631
+}

+ 5 - 0
service/his_print_service.go View File

@@ -177,3 +177,8 @@ func GetLabelPrint(ids string, org_id int64, record_date string, patient_id int6
177 177
 	err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Where("ids = ? and user_org_id = ? and record_date = ? and patient_id = ?", ids, org_id, record_date, patient_id).First(&label).Error
178 178
 	return
179 179
 }
180
+
181
+func GetLabelPrintByID(id int64) (label models.HisLabelPrintStatusInfo, err error) {
182
+	err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Preload("Patient", "status = 1").Where("id = ?", id).First(&label).Error
183
+	return
184
+}

+ 1 - 1
service/his_project_service.go View File

@@ -300,7 +300,7 @@ func GetAllProjectTeam(orgid int64) (project []*models.XtHisProjectTeam, err err
300 300
 }
301 301
 
302 302
 func GetProjectListById(orgid int64, ids []string) (project []*models.XtHisProjectList, err error) {
303
-	err = XTReadDB().Model(&project).Preload("XtHisProject", "status = 1").Preload("GoodInfo", "status=1").Where("user_org_id = ? and id in (?)", orgid, ids).Find(&project).Error
303
+	err = XTReadDB().Model(&project).Preload("XtHisProject", "status = 1").Preload("GoodInfo", "status=1").Where("user_org_id = ? and id in (?) and status = 1", orgid, ids).Find(&project).Error
304 304
 	return project, err
305 305
 }
306 306
 

+ 5 - 0
service/his_service.go View File

@@ -297,6 +297,11 @@ func GetHisPatientInfoThree(org_id int64, number string) (info models.HisPatient
297 297
 	return
298 298
 }
299 299
 
300
+func GetHisPatientInfoTen(org_id int64, patient_id int64, record_date int64) (info models.HisPatient, err error) {
301
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Last(&info).Error
302
+	return
303
+}
304
+
300 305
 func GetHisPatientInfoFour(org_id int64, patient_id int64, record_date int64, his_patient_id int64) (info models.HisPatient, err error) {
301 306
 	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
302 307
 	return