csx пре 3 година
родитељ
комит
c65186dac4
3 измењених фајлова са 154 додато и 8 уклоњено
  1. 74 8
      controllers/his_api_controller.go
  2. 43 0
      models/his_models.go
  3. 37 0
      service/his_service.go

+ 74 - 8
controllers/his_api_controller.go Прегледај датотеку

@@ -5225,6 +5225,15 @@ func (c *HisApiController) PreSettle() {
5225 5225
 	}
5226 5226
 }
5227 5227
 
5228
+type CustomOrderInfo struct {
5229
+	Name  string
5230
+	Spec  string
5231
+	Unit  string
5232
+	Count float64
5233
+	Price float64
5234
+	Total float64
5235
+}
5236
+
5228 5237
 func (c *HisApiController) GetPrivateExpensesInfo() {
5229 5238
 	order_id, _ := c.GetInt64("id", 0)
5230 5239
 	his_patient_id, _ := c.GetInt64("his_patient_id", 0)
@@ -5238,16 +5247,56 @@ func (c *HisApiController) GetPrivateExpensesInfo() {
5238 5247
 	his, _ := service.GetHisPatientByIdThree(his_patient_id)
5239 5248
 	org_id := c.GetAdminUserInfo().CurrentOrgId
5240 5249
 	adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
5241
-	order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5250
+	//order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5251
+
5252
+	orderInfos, _ := service.GetHisOrderInfoByNumberOne(order.Number)
5253
+	orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
5254
+	orderInfos_three, _ := service.GetHisOrderInfoByNumberThree(order.Number)
5255
+
5256
+	var orderInfos_four []*models.HisOrderInfoTwo
5257
+	for _, item := range orderInfos_three {
5258
+		if item.HisPrescriptionProject.HisProject.CostClassify == 3 {
5259
+			item.HisPrescriptionProject.IsCheckTeam = 1
5260
+			orderInfos_four = append(orderInfos_four, item)
5261
+
5262
+		}
5263
+		if item.HisPrescriptionProject.HisProject.CostClassify != 3 {
5264
+			item.HisPrescriptionProject.IsCheckTeam = 2
5265
+			orderInfos_two = append(orderInfos_two, item)
5266
+		}
5267
+	}
5268
+
5269
+	new_order_info := RemoveRepeatedTeam(orderInfos_four)
5270
+	var cus_slice []CustomOrderInfo
5271
+	for _, item := range new_order_info {
5272
+		var cus CustomOrderInfo
5273
+		cus.Name = item.HisPrescriptionProject.XtHisProjectTeam.ProjectTeam
5274
+		cus.Unit = ""
5275
+		cus.Spec = ""
5276
+		var total float64
5277
+		for _, subItem := range orderInfos_four {
5278
+			if item.HisPrescriptionProject.TeamId == subItem.HisPrescriptionProject.TeamId {
5279
+				total = total + subItem.DetItemFeeSumamt
5280
+				fmt.Println(subItem.DetItemFeeSumamt)
5281
+			}
5282
+		}
5283
+		cus.Count = 1
5284
+		cus.Total = total
5285
+		cus_slice = append(cus_slice, cus)
5286
+	}
5287
+
5288
+	orderInfos = append(orderInfos, orderInfos_two...)
5289
+
5242 5290
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
5243 5291
 	c.ServeSuccessJSON(map[string]interface{}{
5244
-		"order":         order,
5245
-		"order_info":    order_info,
5246
-		"patient":       patient,
5247
-		"admin_info":    adminInfo,
5248
-		"his":           his,
5249
-		"current_admin": role,
5250
-		"org_config":    miConfig,
5292
+		"order":          order,
5293
+		"order_info":     orderInfos,
5294
+		"patient":        patient,
5295
+		"admin_info":     adminInfo,
5296
+		"his":            his,
5297
+		"current_admin":  role,
5298
+		"org_config":     miConfig,
5299
+		"new_order_info": cus_slice,
5251 5300
 	})
5252 5301
 
5253 5302
 }
@@ -5411,3 +5460,20 @@ func (c *HisApiController) GetAllOrder() {
5411 5460
 	return
5412 5461
 
5413 5462
 }
5463
+
5464
+func RemoveRepeatedTeam(arr []*models.HisOrderInfoTwo) (newArr []*models.HisOrderInfoTwo) {
5465
+	newArr = make([]*models.HisOrderInfoTwo, 0)
5466
+	for i := 0; i < len(arr); i++ {
5467
+		repeat := false
5468
+		for j := i + 1; j < len(arr); j++ {
5469
+			if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
5470
+				repeat = true
5471
+				break
5472
+			}
5473
+		}
5474
+		if !repeat {
5475
+			newArr = append(newArr, arr[i])
5476
+		}
5477
+	}
5478
+	return
5479
+}

+ 43 - 0
models/his_models.go Прегледај датотеку

@@ -1016,6 +1016,49 @@ func (HisOrderInfo) TableName() string {
1016 1016
 	return "his_order_info"
1017 1017
 }
1018 1018
 
1019
+type HisOrderInfoTwo struct {
1020
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
1021
+	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
1022
+	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
1023
+	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
1024
+	DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
1025
+	Cnt              float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
1026
+	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
1027
+	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1028
+	PricUplmtAmt     float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
1029
+	SelfpayProp      float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
1030
+	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1031
+	OverlmtAmt       float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
1032
+	PreselfpayAmt    float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1033
+	BasMednFlag      string  `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
1034
+	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
1035
+	HiNegoDrugFlag   string  `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
1036
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
1037
+	Memo             string  `gorm:"column:memo" json:"memo" form:"memo"`
1038
+	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1039
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1040
+	InscpScpAmt      float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1041
+	DrtReimFlag      string  `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
1042
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1043
+	ListSpItemFlag   string  `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
1044
+	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
1045
+	LmtUsedFlag      string  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
1046
+	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
1047
+	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1048
+	HisPatientId     int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1049
+	OrderId          int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
1050
+	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1051
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
1052
+	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
1053
+
1054
+	HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1055
+	HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
1056
+}
1057
+
1058
+func (HisOrderInfoTwo) TableName() string {
1059
+	return "his_order_info"
1060
+}
1061
+
1019 1062
 type VMHisPatient struct {
1020 1063
 	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1021 1064
 	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`

+ 37 - 0
service/his_service.go Прегледај датотеку

@@ -1585,6 +1585,43 @@ func GetHisOrderDetailByNumber(order_number string, org_id int64) (order []*HisO
1585 1585
 	return
1586 1586
 }
1587 1587
 
1588
+//func GetHisOrderInfoByNumber(order_number string) (order []*models.HisOrderInfo, err error) {
1589
+//	db := readDb.Model(&models.HisOrderInfo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1590
+//		return db.Preload("BaseDrugLib", "status = 1").Where("status = 1")
1591
+//	})
1592
+//	err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
1593
+//	return
1594
+//}
1595
+
1596
+func GetHisOrderInfoByNumberOne(order_number string) (order []*models.HisOrderInfoTwo, err error) {
1597
+	db := readDb.Model(&models.HisOrderInfoTwo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1598
+		return db.Preload("Drug", "status = 1").Where("status = 1")
1599
+	})
1600
+	err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
1601
+	return
1602
+}
1603
+
1604
+func GetHisOrderInfoByNumberTwo(order_number string) (order []*models.HisOrderInfoTwo, err error) {
1605
+	db := readDb.Model(&models.HisOrderInfoTwo{})
1606
+	db = db.Joins("Join his_prescription_project as p  On p.id = his_order_info.project_id AND p.team_id = 0")
1607
+	db = db.Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1608
+		return db.Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("status = 1")
1609
+	})
1610
+	err = db.Where("his_order_info.order_number = ? AND his_order_info.status = 1 AND his_order_info.project_id > 0 ", order_number).Find(&order).Error
1611
+	return
1612
+}
1613
+
1614
+func GetHisOrderInfoByNumberThree(order_number string) (order []*models.HisOrderInfoTwo, err error) {
1615
+	db := readDb.Model(&models.HisOrderInfoTwo{})
1616
+	db = db.Joins("Join his_prescription_project as p  On p.id = his_order_info.project_id AND p.team_id > 0")
1617
+
1618
+	db = db.Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1619
+		return db.Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("status = 1")
1620
+	})
1621
+	err = db.Where("his_order_info.order_number = ? AND his_order_info.status = 1 AND his_order_info.project_id > 0", order_number).Find(&order).Error
1622
+	return
1623
+}
1624
+
1588 1625
 type MedicalInsuranceCostCompare struct {
1589 1626
 	ID        int64   `gorm:"column:id" json:"id" form:"id"`
1590 1627
 	StartTime int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`