Browse Source

医保对接

csx 3 years ago
parent
commit
4033c2a899

+ 57 - 1
controllers/his_api_controller.go View File

@@ -631,6 +631,8 @@ func (c *HisApiController) CreateHisPrescription() {
631 631
 
632 632
 	}
633 633
 
634
+	patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
635
+
634 636
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
635 637
 
636 638
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
@@ -964,14 +966,63 @@ func (c *HisApiController) CreateHisPrescription() {
964 966
 								c.ServeFailJSONWithSGJErrorCode(errcode)
965 967
 								return
966 968
 							}
967
-							service.CreateHisProjectTwo(&p)
968 969
 
970
+							service.CreateHisProjectTwo(&p)
969 971
 							var randNum int
970 972
 							randNum = rand.Intn(10000) + 1000
971 973
 							timestamp := time.Now().Unix()
972 974
 							tempTime := time.Unix(timestamp, 0)
973 975
 							timeFormat := tempTime.Format("20060102150405")
974 976
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
977
+
978
+							//新增或者编辑项目,修改对应的标签数据
979
+							labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
980
+							if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
981
+								var label models.HisLabelPrintInfo
982
+								project, _ := service.GetProjectDetail(p.ProjectId)
983
+								if project.CostClassify == 3 { //类别为检验检查
984
+									if p.TeamId > 0 { //检验检查组套
985
+										tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
986
+										if tempLabel.ID == 0 {
987
+											team, _ := service.GetProjectTeamDetail(p.TeamId)
988
+											label.Number = tempPrescription.PrescriptionNumber
989
+											label.ProjectId = project.ID
990
+											label.Status = 1
991
+											label.IsPrint = 2
992
+											label.DoctorId = info.DoctorId
993
+											label.UserOrgId = p.UserOrgId
994
+											label.PatientId = patient_id
995
+											label.RecordDate = recordDateTime
996
+											label.Ctime = time.Now().Unix()
997
+											label.Mtime = time.Now().Unix()
998
+											label.ItemId = p.TeamId
999
+											label.FeedetlSn = p.FeedetlSn
1000
+											label.PProjectId = p.ID
1001
+											label.ProjectName = team.ProjectTeam
1002
+											label.PatientName = patient.Name
1003
+											service.CreateHisLabelRecord(&label)
1004
+										}
1005
+									} else { //单条检验检查项目
1006
+										label.Number = tempPrescription.PrescriptionNumber
1007
+										label.ProjectId = project.ID
1008
+										label.Status = 1
1009
+										label.DoctorId = info.DoctorId
1010
+										label.UserOrgId = p.UserOrgId
1011
+										label.PatientId = patient_id
1012
+										label.RecordDate = recordDateTime
1013
+										label.IsPrint = 2
1014
+										label.Ctime = time.Now().Unix()
1015
+										label.Mtime = time.Now().Unix()
1016
+										label.FeedetlSn = p.FeedetlSn
1017
+										label.PProjectId = p.ID
1018
+										label.ItemId = p.TeamId
1019
+										label.ProjectName = project.ProjectName
1020
+										label.PatientName = patient.Name
1021
+										service.CreateHisLabelRecord(&label)
1022
+									}
1023
+								}
1024
+							}
1025
+
975 1026
 							service.SaveHisProjectTwo(&p)
976 1027
 
977 1028
 							if p.Type == 3 { //处理透前准备耗材数量数据
@@ -981,6 +1032,7 @@ func (c *HisApiController) CreateHisPrescription() {
981 1032
 									service.UpdateConsumables(&consumables)
982 1033
 								}
983 1034
 							}
1035
+
984 1036
 						}
985 1037
 					}
986 1038
 				}
@@ -1378,6 +1430,10 @@ func (c *HisApiController) DeleteProject() {
1378 1430
 	}
1379 1431
 	err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
1380 1432
 	if err == nil {
1433
+		label, _ := service.GetProjectById(adminInfo.CurrentOrgId, id, project.RecordDate, project.PatientId)
1434
+		label.Status = 0
1435
+		service.CreateHisLabelRecord(&label)
1436
+
1381 1437
 		if stockConfig.IsOpen == 1 {
1382 1438
 			if project.Type == 3 {
1383 1439
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)

+ 50 - 0
controllers/his_charge_api_controller.go View File

@@ -15,6 +15,9 @@ func HisChargeApiRegistRouters() {
15 15
 	beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail")
16 16
 	beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
17 17
 
18
+	beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
19
+	beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
20
+
18 21
 }
19 22
 
20 23
 func (c *HisChargeApiController) GetChargeStatisticsDetail() {
@@ -87,3 +90,50 @@ func (c *HisChargeApiController) GetChargeStatisticsSettle() {
87 90
 	}
88 91
 
89 92
 }
93
+
94
+func (c *HisChargeApiController) GetHisInspectionList() {
95
+	record_date := c.GetString("record_date")
96
+	keyword := c.GetString("keyword")
97
+	is_print, _ := c.GetInt64("is_print")
98
+	page, _ := c.GetInt64("page")
99
+	limit, _ := c.GetInt64("limit")
100
+
101
+	adminUser := c.GetAdminUserInfo()
102
+
103
+	timeLayout := "2006-01-02"
104
+	loc, _ := time.LoadLocation("Local")
105
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
106
+	if err != nil {
107
+
108
+	}
109
+	record_time := startTime.Unix()
110
+	labels, total, err := service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword)
111
+	if err == nil {
112
+
113
+		c.ServeSuccessJSON(map[string]interface{}{
114
+			"labels": labels,
115
+			"total":  total,
116
+		})
117
+		return
118
+
119
+	} else {
120
+
121
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
122
+		return
123
+
124
+	}
125
+
126
+}
127
+func (c *HisChargeApiController) GetHisInspectionInfo() {
128
+	id, _ := c.GetInt64("id")
129
+	label, err := service.GetLabelPrintInfo(id)
130
+	if err == nil {
131
+		c.ServeSuccessJSON(map[string]interface{}{
132
+			"label": label,
133
+		})
134
+		return
135
+	} else {
136
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
137
+		return
138
+	}
139
+}

+ 25 - 0
models/his_charge_models.go View File

@@ -177,3 +177,28 @@ type HisChargeGoodInfo struct {
177 177
 func (HisChargeGoodInfo) TableName() string {
178 178
 	return "xt_good_information"
179 179
 }
180
+
181
+type HisLabelPrintInfo struct {
182
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
183
+	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
184
+	Number      string `gorm:"column:number" json:"number" form:"number"`
185
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
186
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
187
+	DoctorId    int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
188
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
189
+	ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
190
+	ProjectId   int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
191
+	IsPrint     int64  `gorm:"column:is_print" json:"is_print" form:"is_print"`
192
+	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
193
+	ItemId      int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
194
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
195
+	PProjectId  int64  `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
196
+
197
+	FeedetlSn   string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
198
+	DoctorName  string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
199
+	PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
200
+}
201
+
202
+func (HisLabelPrintInfo) TableName() string {
203
+	return "his_label_print_info"
204
+}

+ 21 - 0
service/his_charge_service.go View File

@@ -226,3 +226,24 @@ func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, k
226 226
 
227 227
 	return
228 228
 }
229
+
230
+func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string) (labels []*models.HisLabelPrintInfo, total int64, err error) {
231
+	offset := (page - 1) * limit
232
+	db := readDb.Model(&models.HisLabelPrintInfo{})
233
+	if is_print > 0 {
234
+		db = db.Where("is_print = ?", is_print)
235
+	}
236
+	if len(keywors) > 0 {
237
+		keywors = "%" + keywors + "%"
238
+		db = db.Where("patient_name Like ?", keywors)
239
+
240
+	}
241
+	err = db.Where("user_org_id = ? AND record_date = ? AND status = 1 ", user_org_id, record_time).Count(&total).Offset(offset).Limit(limit).Find(&labels).Error
242
+	return
243
+}
244
+
245
+func GetLabelPrintInfo(id int64) (labels models.HisLabelPrintInfo, err error) {
246
+	db := readDb.Model(&models.HisLabelPrintInfo{})
247
+	err = db.Where("id = ?", id).First(&labels).Error
248
+	return
249
+}

+ 15 - 0
service/his_service.go View File

@@ -2154,3 +2154,18 @@ func FindAllHisProjectByTime(now int64, end int64, patient_id int64, orgId int64
2154 2154
 	err = readDb.Model(&models.HisPrescriptionProject{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND record_date > ? AND record_date <= ? AND project_id = ? ", orgId, patient_id, end, now, project_id).Find(&project).Error
2155 2155
 	return
2156 2156
 }
2157
+
2158
+func GetProjectByTeamId(user_org_id int64, team_id int64, patient_id int64, record_time int64) (label models.HisLabelPrintInfo, err error) {
2159
+	err = readDb.Model(&models.HisLabelPrintInfo{}).Where("user_org_id = ? AND item_id = ? AND patient_id = ? AND record_date = ? AND status = 1", user_org_id, team_id, patient_id, record_time).First(&label).Error
2160
+	return
2161
+}
2162
+
2163
+func GetProjectById(user_org_id int64, p_project_id int64, record_time int64, patient_id int64) (label models.HisLabelPrintInfo, err error) {
2164
+	err = readDb.Model(&models.HisLabelPrintInfo{}).Where("user_org_id = ? AND p_project_id = ? AND patient_id = ? AND record_date = ? AND status = 1", user_org_id, p_project_id, patient_id, record_time).First(&label).Error
2165
+	return
2166
+}
2167
+
2168
+func CreateHisLabelRecord(label *models.HisLabelPrintInfo) error {
2169
+	err := writeDb.Save(&label).Error
2170
+	return err
2171
+}