Browse Source

医保对接

csx 3 years ago
parent
commit
4192972d27

+ 3 - 0
controllers/his_api_controller.go View File

@@ -567,6 +567,8 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
567 567
 	//获取所有基础药
568 568
 	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
569 569
 
570
+	manufacturers, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
571
+
570 572
 	_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
571 573
 	if config.ID > 0 && config.IsOpen == 1 {
572 574
 		for _, item := range drugs {
@@ -606,6 +608,7 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
606 608
 		"sick":             sick,
607 609
 		"additions":        additions,
608 610
 		"diagnose":         diagnose,
611
+		"manufacturers":    manufacturers,
609 612
 	})
610 613
 }
611 614
 func (c *HisApiController) CreateHisPrescription() {

+ 164 - 0
controllers/his_charge_api_controller.go View File

@@ -2,7 +2,9 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
5 6
 	"XT_New/service"
7
+	"XT_New/utils"
6 8
 	"github.com/astaxie/beego"
7 9
 	"time"
8 10
 )
@@ -18,6 +20,168 @@ func HisChargeApiRegistRouters() {
18 20
 	beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
19 21
 	beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
20 22
 
23
+	//发票
24
+	beego.Router("/api/fapiao/create", &HisChargeApiController{}, "post:CreateFaPiaoRecord")
25
+	beego.Router("/api/fapiao/modify", &HisChargeApiController{}, "post:ModifyFaPiaoRecord")
26
+	beego.Router("/api/fapiao/list", &HisChargeApiController{}, "get:GetFaPiaoRecordList")
27
+	beego.Router("/api/fapiao/delete", &HisChargeApiController{}, "post:DeleteFaPiaoRecord")
28
+	beego.Router("/api/fapiao", &HisChargeApiController{}, "get:GetFaPiaoRecord")
29
+	beego.Router("/api/fapiao/is_use", &HisChargeApiController{}, "post:UpdateFaPiaoRecordIsUse")
30
+
31
+}
32
+
33
+func (c *HisChargeApiController) UpdateFaPiaoRecordIsUse() {
34
+	id, _ := c.GetInt64("id", 0)
35
+	is_use, _ := c.GetInt64("is_use")
36
+	if id <= 0 {
37
+		utils.ErrorLog("id == 0")
38
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
39
+		return
40
+	}
41
+
42
+	record, _ := service.FindFapiaoById(id)
43
+	adminUserInfo := c.GetAdminUserInfo()
44
+	service.UpdateFapiaoIsUse(adminUserInfo.CurrentOrgId)
45
+	records := models.HisFapiaoRecord{
46
+		ID:           id,
47
+		FapiaoCode:   record.FapiaoCode,
48
+		FapiaoNumber: record.FapiaoNumber,
49
+		Ctime:        time.Now().Unix(),
50
+		Mtime:        time.Now().Unix(),
51
+		UserOrgId:    adminUserInfo.CurrentOrgId,
52
+		Status:       1,
53
+		IsUse:        is_use,
54
+	}
55
+	err := service.ModifyFapiao(&records)
56
+	if err == nil {
57
+		c.ServeSuccessJSON(map[string]interface{}{
58
+			"fapiao_record": records,
59
+		})
60
+	} else {
61
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
62
+	}
63
+}
64
+func (c *HisChargeApiController) CreateFaPiaoRecord() {
65
+	fapiao_code := c.GetString("fapiao_code")
66
+	fapiao_number := c.GetString("fapiao_number")
67
+	if len(fapiao_code) <= 0 {
68
+		utils.ErrorLog("len(fapiao_code) == 0")
69
+
70
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
71
+		return
72
+	}
73
+
74
+	if len(fapiao_number) <= 0 {
75
+		utils.ErrorLog("len(fapiao_number) == 0")
76
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
77
+		return
78
+	}
79
+
80
+	adminUserInfo := c.GetAdminUserInfo()
81
+
82
+	record := models.HisFapiaoRecord{
83
+		FapiaoCode:   fapiao_code,
84
+		FapiaoNumber: fapiao_number,
85
+		Ctime:        time.Now().Unix(),
86
+		Mtime:        time.Now().Unix(),
87
+		UserOrgId:    adminUserInfo.CurrentOrgId,
88
+		Status:       1,
89
+		IsUse:        0,
90
+	}
91
+
92
+	err, records := service.AddSigleFapiaoRecord(&record)
93
+	if err == nil {
94
+		c.ServeSuccessJSON(map[string]interface{}{
95
+			"fapiao_record": records,
96
+		})
97
+
98
+	} else {
99
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
100
+
101
+	}
102
+
103
+}
104
+func (c *HisChargeApiController) ModifyFaPiaoRecord() {
105
+	id, _ := c.GetInt64("id", 0)
106
+	fapiao_code := c.GetString("fapiao_code")
107
+	fapiao_number := c.GetString("fapiao_number")
108
+
109
+	if id <= 0 {
110
+		utils.ErrorLog("id == 0")
111
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
112
+		return
113
+	}
114
+
115
+	if len(fapiao_code) <= 0 {
116
+		utils.ErrorLog("len(fapiao_code) == 0")
117
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
118
+		return
119
+	}
120
+
121
+	if len(fapiao_number) <= 0 {
122
+		utils.ErrorLog("len(fapiao_number) == 0")
123
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
124
+		return
125
+	}
126
+
127
+	record, _ := service.FindFapiaoById(id)
128
+	adminUserInfo := c.GetAdminUserInfo()
129
+	records := models.HisFapiaoRecord{
130
+		ID:           id,
131
+		FapiaoCode:   fapiao_code,
132
+		FapiaoNumber: fapiao_number,
133
+		Ctime:        time.Now().Unix(),
134
+		Mtime:        time.Now().Unix(),
135
+		UserOrgId:    adminUserInfo.CurrentOrgId,
136
+		Status:       1,
137
+		IsUse:        record.IsUse,
138
+	}
139
+
140
+	err := service.ModifyFapiao(&records)
141
+
142
+	if err == nil {
143
+		c.ServeSuccessJSON(map[string]interface{}{
144
+			"fapiao_record": records,
145
+		})
146
+	} else {
147
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
148
+	}
149
+}
150
+func (c *HisChargeApiController) GetFaPiaoRecordList() {
151
+	page, _ := c.GetInt64("page", 1)
152
+	limit, _ := c.GetInt64("limit", 7)
153
+	adminUserInfo := c.GetAdminUserInfo()
154
+	fapiaoRecord, total, err := service.FindAllFapiaoList(adminUserInfo.CurrentOrgId, page, limit)
155
+	if err == nil {
156
+		c.ServeSuccessJSON(map[string]interface{}{
157
+			"fapiao_record": fapiaoRecord,
158
+			"total":         total,
159
+		})
160
+	} else {
161
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
162
+	}
163
+}
164
+func (c *HisChargeApiController) DeleteFaPiaoRecord() {
165
+	id, _ := c.GetInt64("id", 0)
166
+	err := service.DeleteFapiaoById(id)
167
+	if err == nil {
168
+		c.ServeSuccessJSON(map[string]interface{}{
169
+			"msg": "删除成功",
170
+		})
171
+	} else {
172
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
173
+	}
174
+}
175
+func (c *HisChargeApiController) GetFaPiaoRecord() {
176
+	id, _ := c.GetInt64("id", 0)
177
+	fapiaoRecord, err := service.FindFapiaoById(id)
178
+	if err == nil {
179
+		c.ServeSuccessJSON(map[string]interface{}{
180
+			"fapiao_record": fapiaoRecord,
181
+		})
182
+	} else {
183
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
184
+	}
21 185
 }
22 186
 
23 187
 func (c *HisChargeApiController) GetChargeStatisticsDetail() {

+ 15 - 0
models/his_charge_models.go View File

@@ -203,3 +203,18 @@ type HisLabelPrintInfo struct {
203 203
 func (HisLabelPrintInfo) TableName() string {
204 204
 	return "his_label_print_info"
205 205
 }
206
+
207
+type HisFapiaoRecord struct {
208
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
209
+	FapiaoCode   string `gorm:"column:fapiao_code" json:"fapiao_code" form:"fapiao_code"`
210
+	FapiaoNumber string `gorm:"column:fapiao_number" json:"fapiao_number" form:"fapiao_number"`
211
+	IsUse        int64  `gorm:"column:is_use" json:"is_use" form:"is_use"`
212
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
213
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
214
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
215
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
216
+}
217
+
218
+func (HisFapiaoRecord) TableName() string {
219
+	return "his_fapiao_record"
220
+}

+ 7 - 4
models/his_models.go View File

@@ -236,6 +236,7 @@ type HisDoctorAdviceInfo struct {
236 236
 	Way                   int64                  `gorm:"column:way" json:"way" form:"way"`
237 237
 	HospApprFlag          int64                  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
238 238
 	LmtUsedFlag           int64                  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
239
+	HisOrderInfo          HisOrderInfo           `gorm:"ForeignKey:AdviceId;AssociationForeignKey:ID" json:"order_info"`
239 240
 }
240 241
 
241 242
 func (HisDoctorAdviceInfo) TableName() string {
@@ -775,10 +776,11 @@ type HisPrescriptionProject struct {
775 776
 
776 777
 	XtHisProjectTeam XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
777 778
 
778
-	FrequencyType int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
779
-	DayCount      int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
780
-	WeekDay       string `gorm:"column:week_day" json:"week_day" form:"week_day"`
781
-	IsCheckTeam   int64  `gorm:"-" json:"is_check_team" form:"is_check_team"`
779
+	FrequencyType int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
780
+	DayCount      int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
781
+	WeekDay       string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
782
+	IsCheckTeam   int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
783
+	HisOrderInfo  HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
782 784
 }
783 785
 
784 786
 func (HisPrescriptionProject) TableName() string {
@@ -967,6 +969,7 @@ type HisOrder struct {
967 969
 	HisFundSettleListResult HisFundSettleListResult `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"result"`
968 970
 	IsPre                   int64                   `gorm:"column:is_pre" json:"is_pre" form:"is_pre"`
969 971
 	Diagnosis               string                  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
972
+	FaPiaoBatchnumberId     int64                   `gorm:"column:fa_piao_batchnumber_id" json:"fa_piao_batchnumber_id" form:"fa_piao_batchnumber_id"`
970 973
 }
971 974
 
972 975
 func (HisOrder) TableName() string {

+ 13 - 4
service/app_version.go View File

@@ -257,13 +257,18 @@ func UpDateHis2(his *models.HisPrescriptionProject) {
257 257
 	writeDb.Save(&his)
258 258
 }
259 259
 
260
-func GetAllHisOrder() (his []*models.HisOrder, err error) {
261
-	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106 AND status = 1 AND order_status = 2 AND settle_accounts_date < 1623168000").Find(&his).Error
260
+func GetAllHisOrder(org_id int64) (his []*models.HisOrder, err error) {
261
+	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND order_status = 2 AND fa_piao_code == '' AND fa_piao_number == '' ", org_id).Find(&his).Error
262
+	return
263
+}
264
+
265
+func GetAllHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
266
+	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND order_status = 2 AND fa_piao_code <> '' AND fa_piao_number <> '' ", org_id).Last(&his).Error
262 267
 	return
263 268
 }
264 269
 
265 270
 func GetLastHisOrder() (his models.HisOrder, err error) {
266
-	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 4 AND status = 1 AND order_status = 2").Last(&his).Error
271
+	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106 AND status = 1 AND order_status = 2").Last(&his).Error
267 272
 	return
268 273
 }
269 274
 
@@ -378,7 +383,7 @@ type HisPrescriptionProjectTemplate struct {
378 383
 	PatientId          int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
379 384
 	HisPatientId       int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
380 385
 	RecordDate         int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
381
-	Count              int64   `gorm:"column:count" json:"count" form:"count"`
386
+	Count              string  `gorm:"column:count" json:"count" form:"count"`
382 387
 	FeedetlSn          string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
383 388
 	MedListCodg        string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
384 389
 	SingleDose         string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
@@ -437,3 +442,7 @@ func UpdateStatus(project_id int64, p_id int64) {
437 442
 	writeDb.Model(&HisPrescriptionProjectTemplate{}).Where("id = ?", project_id).Updates(map[string]interface{}{"status": 0})
438 443
 	writeDb.Model(&HisPrescriptionInfoTemplateTwo{}).Where("id = ?", p_id).Updates(map[string]interface{}{"status": 0})
439 444
 }
445
+
446
+func SaveOrder(order *models.HisOrder) {
447
+	writeDb.Save(&order)
448
+}

+ 42 - 0
service/his_charge_service.go View File

@@ -3,6 +3,7 @@ package service
3 3
 import (
4 4
 	"XT_New/models"
5 5
 	"github.com/jinzhu/gorm"
6
+	"time"
6 7
 )
7 8
 
8 9
 func GetAllPatientChargeDetails(org_id int64, start_time int64, end_time int64, keyword string, item_type int64) (patients []*models.ChargePatient, err error) {
@@ -247,3 +248,44 @@ func GetLabelPrintInfo(id int64) (labels models.HisLabelPrintInfo, err error) {
247 248
 	err = db.Where("id = ?", id).First(&labels).Error
248 249
 	return
249 250
 }
251
+
252
+func AddSigleFapiaoRecord(dealer *models.HisFapiaoRecord) (err error, record *models.HisFapiaoRecord) {
253
+	err = writeDb.Create(&dealer).Error
254
+	return err, dealer
255
+}
256
+
257
+func ModifyFapiao(mesick *models.HisFapiaoRecord) error {
258
+	err := writeDb.Save(&mesick).Error
259
+
260
+	return err
261
+}
262
+
263
+func UpdateFapiaoIsUse(org_id int64) {
264
+	writeDb.Model(&models.HisFapiaoRecord{}).Where("user_org_id = ?", org_id).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "is_use": 0})
265
+
266
+}
267
+
268
+func FindAllFapiaoList(orgId int64, page int64, limit int64) (list []*models.HisFapiaoRecord, total int64, err error) {
269
+	offset := (page - 1) * limit
270
+	db := readDb.Model(&models.HisFapiaoRecord{})
271
+	db = db.Where("user_org_id = ? AND status = 1", orgId)
272
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error
273
+	return
274
+}
275
+
276
+func DeleteFapiaoById(id int64) error {
277
+	err := writeDb.Model(&models.HisFapiaoRecord{}).Where("id = ? AND status = 1", id).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "status": 0}).Error
278
+	return err
279
+}
280
+
281
+func FindFapiaoById(id int64) (*models.HisFapiaoRecord, error) {
282
+	dealer := &models.HisFapiaoRecord{}
283
+	err := readDb.Model(&models.HisFapiaoRecord{}).Where("id = ? AND status = 1", id).First(&dealer).Error
284
+	return dealer, err
285
+}
286
+
287
+func FindFapiaoByIsUse(org_id int64) (models.HisFapiaoRecord, error) {
288
+	record := models.HisFapiaoRecord{}
289
+	err := readDb.Model(&models.HisFapiaoRecord{}).Where("user_org_id = ? AND status = 1 AND is_use = 1", org_id).First(&record).Error
290
+	return record, err
291
+}

+ 4 - 4
service/his_hospital_service.go View File

@@ -131,10 +131,10 @@ func GetUnChargeHisHospitalPrescriptionFive(org_id int64, patient_id int64, his_
131 131
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
132 132
 		}).
133 133
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
134
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
134
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
135 135
 		}).
136 136
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
137
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
137
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
138 138
 		}).
139 139
 		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3", org_id, record_date, patient_id).
140 140
 		Find(&prescription).Error
@@ -147,10 +147,10 @@ func GetChargeHisHospitalPrescriptionFive(org_id int64, patient_id int64, his_pa
147 147
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
148 148
 		}).
149 149
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
150
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
150
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
151 151
 		}).
152 152
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
153
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
153
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
154 154
 		}).
155 155
 		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 2 ", org_id, record_date, patient_id).
156 156
 		Find(&prescription).Error

+ 4 - 4
service/his_service.go View File

@@ -475,10 +475,10 @@ func GetUnChargeHisPrescriptionFive(org_id int64, patient_id int64, his_patient_
475 475
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
476 476
 		}).
477 477
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
478
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
478
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
479 479
 		}).
480 480
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
481
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
481
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
482 482
 		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
483 483
 		return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3  AND order_status <> 2  ", org_id)
484 484
 	}).
@@ -2086,10 +2086,10 @@ func GetChargeHisPrescriptionSeven(org_id int64, patient_id int64, order_number
2086 2086
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
2087 2087
 		}).
2088 2088
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
2089
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
2089
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
2090 2090
 		}).
2091 2091
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2092
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
2092
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
2093 2093
 		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
2094 2094
 		return db.Where("status = 1 AND user_org_id = ?", org_id)
2095 2095
 	}).