Browse Source

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

XMLWAN 3 years ago
parent
commit
a0a96c7ffe

+ 40 - 0
controllers/his_hospital_api_controller.go View File

@@ -32,6 +32,8 @@ func HisHospitalManagerApiRegistRouters() {
32 32
 	beego.Router("/api/hospitaldetail/list", &HisHospitalApiController{}, "get:GetHisHospitalDetailPatientList")
33 33
 	beego.Router("/api/hospitaldetail/info", &HisHospitalApiController{}, "get:GetHisHospitalDetailInfo")
34 34
 
35
+	beego.Router("/api/monthhospitaldetail/get", &HisHospitalApiController{}, "get:GetHisHospitalMonthDetailInfo")
36
+
35 37
 }
36 38
 
37 39
 func (c *HisHospitalApiController) GetHisHospitalPatientList() {
@@ -752,3 +754,41 @@ func (c *HisHospitalApiController) GetHisHospitalDetailInfo() {
752 754
 		"his_info":            record,
753 755
 	})
754 756
 }
757
+func (c *HisHospitalApiController) GetHisHospitalMonthDetailInfo() {
758
+	id, _ := c.GetInt64("id")
759
+	is_upload, _ := c.GetInt64("is_upload")
760
+	patient_id, _ := c.GetInt64("patient_id")
761
+	start_time_str := c.GetString("start_time")
762
+	end_time_str := c.GetString("end_time")
763
+
764
+	record, _ := service.GetInHospitalRecord(id)
765
+	timeLayout := "2006-01-02"
766
+	loc, _ := time.LoadLocation("Local")
767
+	adminInfo := c.GetAdminUserInfo()
768
+	theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
769
+	if err != nil {
770
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
771
+		return
772
+	}
773
+	recordStartTime := theStartTime.Unix()
774
+	theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
775
+	if err != nil {
776
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
777
+		return
778
+	}
779
+	recordEndTime := theEndTime.Unix()
780
+	//var prescriptions []*models.HisPrescription
781
+
782
+	var monthPrescriptions []*models.HisPrescription
783
+	if is_upload == 1 {
784
+		monthPrescriptions, _ = service.GetMonthUnUploadHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
785
+	} else if is_upload == 2 {
786
+		monthPrescriptions, _ = service.GetMonthUploadHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
787
+	} else {
788
+		monthPrescriptions, _ = service.GetAllMonthHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
789
+	}
790
+	c.ServeSuccessJSON(map[string]interface{}{
791
+		"month_prescriptions": monthPrescriptions,
792
+		"his_info":            record,
793
+	})
794
+}

+ 22 - 5
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -546,7 +546,7 @@ func (this *DialysisAPIController) DialysisRecord() {
546 546
 	temp_team_projects, _ := service.GetHisPrescriptionTeamProjects(adminInfo.Org.Id, patientID, date.Unix())
547 547
 
548 548
 	var team_projects []*models.HisPrescriptionProject
549
-	var index int64 = 0
549
+	//var index int64 = 0
550 550
 	for _, item := range temp_team_projects {
551 551
 		//组套里面非检验项目的
552 552
 		if item.HisProject.CostClassify != 3 {
@@ -554,13 +554,12 @@ func (this *DialysisAPIController) DialysisRecord() {
554 554
 		}
555 555
 		//组套里面检验项目的
556 556
 		if item.HisProject.CostClassify == 3 {
557
-			index = index + 1
558
-			if index == 1 {
559
-				team_projects = append(team_projects, item)
560
-			}
557
+			team_projects = append(team_projects, item)
561 558
 		}
562 559
 	}
563 560
 
561
+	team_projects = RemoveRepeatedCheckRecod(team_projects)
562
+
564 563
 	stockType, _ = service.GetStockType(adminInfo.Org.Id)
565 564
 
566 565
 	prepare, _ = service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
@@ -5501,6 +5500,7 @@ func ConsumablesDeliveryDeleteThree(orgID int64, record_time int64, good_yc *mod
5501 5500
 
5502 5501
 		// 删除出库完成后,要改变流水库存
5503 5502
 		errOne = service.UpDateWarehouStockFlowByStockDelete(ware.WarehouseInfotId, record_time, good_yc.GoodId, delete_count, good_yc.PatientId)
5503
+
5504 5504
 		fmt.Println("erron2332323232323232232323", errOne)
5505 5505
 		errThree := service.UpDateWarehouseInfoByStockDelete(ware.WarehouseInfotId, delete_count)
5506 5506
 
@@ -5527,3 +5527,20 @@ func (this *DialysisAPIController) GetMobileScheduleList() {
5527 5527
 	zone_options_visible, _ := this.GetInt64("zone_options_visible")
5528 5528
 	fmt.Println(limit, page, type_options_visible, sch_type_options_visible, zone_options_visible)
5529 5529
 }
5530
+
5531
+func RemoveRepeatedCheckRecod(arr []*models.HisPrescriptionProject) (newArr []*models.HisPrescriptionProject) {
5532
+	newArr = make([]*models.HisPrescriptionProject, 0)
5533
+	for i := 0; i < len(arr); i++ {
5534
+		repeat := false
5535
+		for j := i + 1; j < len(arr); j++ {
5536
+			if arr[i].TeamId == arr[j].TeamId {
5537
+				repeat = true
5538
+				break
5539
+			}
5540
+		}
5541
+		if !repeat {
5542
+			newArr = append(newArr, arr[i])
5543
+		}
5544
+	}
5545
+	return
5546
+}

+ 16 - 0
service/his_hospital_service.go View File

@@ -397,3 +397,19 @@ func GetMonthUploadHisHospitalPrescription(org_id int64, patient_id int64, start
397 397
 		Find(&prescription).Error
398 398
 	return
399 399
 }
400
+
401
+func GetAllMonthHisHospitalPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
402
+	err = readDb.Model(&models.HisPrescription{}).
403
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
404
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
405
+		}).
406
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
407
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
408
+		}).
409
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
410
+			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")
411
+		}).
412
+		Where("user_org_id = ? AND status = 1 AND patient_id = ? AND record_date <= ? AND  record_date >= ? AND p_type = 1", org_id, patient_id, end_time, start_time).
413
+		Find(&prescription).Error
414
+	return
415
+}