Browse Source

医保对接

csx 3 years ago
parent
commit
35bbec5dad

+ 4 - 4
controllers/base_api_controller.go View File

@@ -82,7 +82,7 @@ func (this *BaseAuthAPIController) Prepare() {
82 82
 		userAdmin.ModifyTime = 1530786071
83 83
 		var subscibe models.ServeSubscibe
84 84
 		subscibe.ID = 1
85
-		subscibe.OrgId = 3877
85
+		subscibe.OrgId = 9675
86 86
 		subscibe.PeriodStart = 1538035409
87 87
 		subscibe.PeriodEnd = 1569571409
88 88
 		subscibe.State = 1
@@ -92,7 +92,7 @@ func (this *BaseAuthAPIController) Prepare() {
92 92
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93 93
 		subscibes[4] = &subscibe
94 94
 		var adminUserInfo service.AdminUserInfo
95
-		adminUserInfo.CurrentOrgId = 3877
95
+		adminUserInfo.CurrentOrgId = 9675
96 96
 		adminUserInfo.CurrentAppId = 4
97 97
 		adminUserInfo.AdminUser = &userAdmin
98 98
 		adminUserInfo.Subscibes = subscibes
@@ -328,7 +328,7 @@ func (this *BaseServeAPIController) Prepare() {
328 328
 		userAdmin.ModifyTime = 1530786071
329 329
 		var subscibe models.ServeSubscibe
330 330
 		subscibe.ID = 1
331
-		subscibe.OrgId = 3877
331
+		subscibe.OrgId = 9675
332 332
 		subscibe.PeriodStart = 1538035409
333 333
 		subscibe.PeriodEnd = 1569571409
334 334
 		subscibe.State = 1
@@ -338,7 +338,7 @@ func (this *BaseServeAPIController) Prepare() {
338 338
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339 339
 		subscibes[4] = &subscibe
340 340
 		var adminUserInfo service.AdminUserInfo
341
-		adminUserInfo.CurrentOrgId = 3877
341
+		adminUserInfo.CurrentOrgId = 9675
342 342
 		adminUserInfo.CurrentAppId = 4
343 343
 		adminUserInfo.AdminUser = &userAdmin
344 344
 		adminUserInfo.Subscibes = subscibes

+ 2 - 0
controllers/his_api_controller.go View File

@@ -396,6 +396,8 @@ func (c *HisApiController) GetHisPatientInfo() {
396 396
 	//endRecordDateTime := endTime.Unix()
397 397
 	admin := c.GetAdminUserInfo()
398 398
 	his_patient_info, _ := service.GetNewHisPatientInfoTwo(admin.CurrentOrgId, his_patient_id, recordDateTime)
399
+	//his_patient_info, _ := service.GetNewHisPatientInfoTwo(admin.CurrentOrgId, his_patient_id, recordDateTime)
400
+
399 401
 	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
400 402
 
401 403
 	count, _ := service.GetHisPatientCount(admin.CurrentOrgId, patient_id, recordDateTime)

+ 11 - 6
controllers/his_hospital_api_controller.go View File

@@ -43,21 +43,25 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
43 43
 	}
44 44
 	recordDateTime := theTime.Unix()
45 45
 	adminInfo := c.GetAdminUserInfo()
46
-	var patients []*service.HospitalPatient
46
+	//var patients []*service.HospitalPatient
47 47
 	tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
48
+	tempPatients_two, _ := service.GetHisHospitalSchPatientList(adminInfo.CurrentOrgId, recordDateTime)
48 49
 
50
+	//当天有登记住院的和排班同时存在的话,删除掉排班的记录
49 51
 	for _, item := range tempPatients {
50
-		if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 && item.HisHospitalCheckRecord.OutHospitalStatus == 0 {
51
-			patients = append(patients, item)
52
+		for index, subItem := range tempPatients_two {
53
+			if item.ID == subItem.ID {
54
+				tempPatients_two = append(tempPatients_two[:index], tempPatients_two[index+1:]...)
52 55
 
56
+			}
53 57
 		}
54
-
55 58
 	}
59
+	tempPatients = append(tempPatients, tempPatients_two...)
56 60
 
57 61
 	var total_one int64
58 62
 	var total_two int64
59 63
 
60
-	for _, item := range patients {
64
+	for _, item := range tempPatients {
61 65
 
62 66
 		if item.VMHisPrescriptionInfo.ID == 0 {
63 67
 			total_one = total_one + 1
@@ -73,7 +77,7 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
73 77
 
74 78
 	if types == 0 {
75 79
 		c.ServeSuccessJSON(map[string]interface{}{
76
-			"list":       patients,
80
+			"list":       tempPatients,
77 81
 			"total_one":  total_one,
78 82
 			"total_two":  total_two,
79 83
 			"info":       adminUserInfo,
@@ -491,6 +495,7 @@ func (c *HisHospitalApiController) GetSettleInfo() {
491 495
 		SettleStartTime:    start_time,
492 496
 		SettleType:         settle_accounts_type,
493 497
 		PType:              1,
498
+		Creator:            c.GetAdminUserInfo().AdminUser.Id,
494 499
 	}
495 500
 	order.DiscountPrice = discount_price
496 501
 	order.MedicalInsurancePrice = medical_insurance_price

+ 14 - 4
service/his_hospital_service.go View File

@@ -72,7 +72,17 @@ func (HisHospitalOrder) TableName() string {
72 72
 
73 73
 func GetHisHospitalPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
74 74
 	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
75
-	db = db.Joins("join his_hospital_check_record as record ON record.patient_id = xt_patients.id AND record.status = 1 AND record.user_org_id = ? AND record.in_hospital_status = 1 ", org_id)
75
+	db = db.Joins("join his_hospital_check_record as record ON record.patient_id = xt_patients.id AND record.status = 1 AND record.user_org_id = ? AND record.in_hospital_status = 1 AND record.record_date = ? ", org_id, record_date)
76
+	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
77
+		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
78
+	})
79
+	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
80
+	return
81
+}
82
+
83
+func GetHisHospitalSchPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
84
+	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
85
+	db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_date = ? ", org_id, record_date)
76 86
 	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
77 87
 		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
78 88
 	})
@@ -219,7 +229,7 @@ func (VMHisHospitalPrescriptionInfo) TableName() string {
219 229
 
220 230
 func GetHisHospitalPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMHisHospitalPrescriptionInfo, err error, total int64) {
221 231
 	offset := (page - 1) * limit
222
-	db := readDb.Model(&VMHisHospitalPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1 ", org_id, record_date)
232
+	db := readDb.Model(&VMHisHospitalPrescriptionInfo{}).Where("his_prescription_info.user_org_id = ? AND his_prescription_info.status = 1 AND his_prescription_info.record_date = ? AND his_prescription_info.p_type = 1 ", org_id, record_date)
223 233
 	if len(keywords) > 0 {
224 234
 		keywords = "%" + keywords + "%"
225 235
 		db = db.Joins("JOIN xt_patients as p On his_prescription_info.patient_id = p.id AND p.user_org_id = ? AND p.name like ?", org_id, keywords)
@@ -269,10 +279,10 @@ func GetHospitalMonthHisPrescription(org_id int64, patient_id int64, start_time
269 279
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
270 280
 		}).
271 281
 		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
272
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
282
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
273 283
 		}).
274 284
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
275
-			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
285
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
276 286
 		}).
277 287
 		Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
278 288
 		Find(&prescription).Error

+ 5 - 0
service/his_service.go View File

@@ -314,6 +314,11 @@ func GetNewHisPatientInfoTwo(org_id int64, id int64, record_date int64) (info mo
314 314
 	return
315 315
 }
316 316
 
317
+func GetNewHisHosptialRecordTwo(org_id int64, id int64, record_date int64) (info models.HisPatient, err error) {
318
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND id = ?", org_id, record_date, id).First(&info).Error
319
+	return
320
+}
321
+
317 322
 func GetHisPatientCount(org_id int64, patient_id int64, record_date int64) (total int64, err error) {
318 323
 	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Count(&total).Error
319 324
 	return