Parcourir la source

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

28169 il y a 1 mois
Parent
révision
81513a6a4d
2 fichiers modifiés avec 94 ajouts et 16 suppressions
  1. 58 14
      controllers/his_api_controller.go
  2. 36 2
      service/his_service.go

+ 58 - 14
controllers/his_api_controller.go Voir le fichier

@@ -1080,8 +1080,8 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
1080 1080
 	var operationSelfTotal float64 = 0         //床位部分项目自费
1081 1081
 	var operationInscpTotal float64 = 0        //床位部分项目自费
1082 1082
 
1083
-	var otherCostTotal float64 = 0 //其他费用
1084
-	//var otherCostSelfTotal float64 = 0     //其他费用
1083
+	var otherCostTotal float64 = 0         //其他费用
1084
+	var otherCostSelfTotal float64 = 0     //其他费用
1085 1085
 	var otherCostPartSelfTotal float64 = 0 //其他费用
1086 1086
 	//var otherSelfTotal float64 = 0         //床位部分项目自费
1087 1087
 	//var otherInscpTotal float64 = 0        //床位部分项目自费
@@ -1122,6 +1122,18 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
1122 1122
 	var treatSelfTotal float64 = 0         //床位部分项目自费
1123 1123
 	var treatInscpTotal float64 = 0        //床位部分项目自费
1124 1124
 
1125
+	var huliCostTotal float64 = 0         //治疗费用
1126
+	var huliCostSelfTotal float64 = 0     //治疗费用
1127
+	var huliCostPartSelfTotal float64 = 0 //治疗费用
1128
+	var huliSelfTotal float64 = 0         //床位部分项目自费
1129
+	var huliInscpTotal float64 = 0        //床位部分项目自费
1130
+
1131
+	var zcCostTotal float64 = 0         //治疗费用
1132
+	var zcCostSelfTotal float64 = 0     //治疗费用
1133
+	var zcCostPartSelfTotal float64 = 0 //治疗费用
1134
+	var zcSelfTotal float64 = 0         //床位部分项目自费
1135
+	var zcInscpTotal float64 = 0        //床位部分项目自费
1136
+
1125 1137
 	var zhenChaCostTotal float64 = 0 //其他费用
1126 1138
 	//var zhenChaCostPartSelfTotal float64 = 0 //其他费用
1127 1139
 
@@ -1347,8 +1359,26 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
1347 1359
 
1348 1360
 		if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
1349 1361
 			otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
1350
-			//otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
1351
-			//otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
1362
+			otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
1363
+			otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
1364
+		}
1365
+
1366
+		if item.MedChrgitmType == "02" { //其他费
1367
+			zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
1368
+			zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
1369
+			zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
1370
+			zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
1371
+			zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
1372
+
1373
+		}
1374
+
1375
+		if item.MedChrgitmType == "07" { //其他费
1376
+			huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
1377
+			huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
1378
+			huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
1379
+			huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
1380
+			huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
1381
+
1352 1382
 		}
1353 1383
 	}
1354 1384
 
@@ -1391,8 +1421,8 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
1391 1421
 		"operationInscpTotal":        operationInscpTotal,
1392 1422
 		"operationSelfTotal":         operationSelfTotal,
1393 1423
 
1394
-		"otherCostTotal": otherCostTotal,
1395
-		//"otherCostSelfTotal":        otherCostSelfTotal,
1424
+		"otherCostTotal":            otherCostTotal,
1425
+		"otherCostSelfTotal":        otherCostSelfTotal,
1396 1426
 		"otherCostPartSelfTotal":    otherCostPartSelfTotal,
1397 1427
 		"materialCostTotal":         materialCostTotal,
1398 1428
 		"materialCostSelfTotal":     materialCostSelfTotal,
@@ -1446,6 +1476,18 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
1446 1476
 		"his":           his,
1447 1477
 		"funds":         rf,
1448 1478
 		"dia_config":    dia_config,
1479
+
1480
+		"huliCostTotal":         huliCostTotal,
1481
+		"huliCostSelfTotal":     huliCostSelfTotal,
1482
+		"huliCostPartSelfTotal": huliCostPartSelfTotal,
1483
+		"huliSelfTotal":         huliSelfTotal,
1484
+		"huliInscpTotal":        huliInscpTotal,
1485
+
1486
+		"zcCostTotal":         zcCostTotal,
1487
+		"zcCostSelfTotal":     zcCostSelfTotal,
1488
+		"zcCostPartSelfTotal": zcCostPartSelfTotal,
1489
+		"zcSelfTotal":         zcSelfTotal,
1490
+		"zcInscpTotal":        zcInscpTotal,
1449 1491
 	})
1450 1492
 
1451 1493
 }
@@ -1657,7 +1699,7 @@ func (c *HisApiController) GetHisPatientInfo() {
1657 1699
 	sch, _ := service.GetPatientSch(patient_id, recordDateTime, admin.CurrentOrgId)
1658 1700
 	if sch.ID > 0 {
1659 1701
 		var week string
1660
-		t := time.Now()
1702
+		t := theTime
1661 1703
 		switch t.Weekday().String() {
1662 1704
 		case "Monday":
1663 1705
 			week = "周一"
@@ -1713,12 +1755,12 @@ func (c *HisApiController) GetHisPatientInfo() {
1713 1755
 					}
1714 1756
 
1715 1757
 					if subItem.FrequencyType == 2 { //按照天数频率
1716
-						p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
1758
+						p, _ := time.Parse("2006-01-02", theTime.Format("2006-01-02"))
1717 1759
 						now := p.Unix()
1718 1760
 						dayStr := strconv.FormatInt(subItem.DayCount, 10)
1719 1761
 						dayStr2 := "-" + dayStr
1720 1762
 						count, _ := strconv.ParseInt(dayStr2, 10, 64)
1721
-						oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
1763
+						oldTime := theTime.AddDate(0, 0, int(count)).Unix()
1722 1764
 						advices, _ := service.FindAllHisDoctorAdviceByTime(now, oldTime, patient_id, c.GetAdminUserInfo().CurrentOrgId, subItem.DrugId)
1723 1765
 						if len(advices) == 0 {
1724 1766
 							cus.HisPrescriptionAdviceTemplate = append(cus.HisPrescriptionAdviceTemplate, subItem)
@@ -1740,12 +1782,12 @@ func (c *HisApiController) GetHisPatientInfo() {
1740 1782
 						}
1741 1783
 
1742 1784
 						if subItem.FrequencyType == 2 {
1743
-							p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
1785
+							p, _ := time.Parse("2006-01-02", theTime.Format("2006-01-02"))
1744 1786
 							now := p.Unix()
1745 1787
 							dayStr := strconv.FormatInt(subItem.DayCount, 10)
1746 1788
 							dayStr2 := "-" + dayStr
1747 1789
 							count, _ := strconv.ParseInt(dayStr2, 10, 64)
1748
-							oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
1790
+							oldTime := theTime.AddDate(0, 0, int(count)).Unix()
1749 1791
 							projects, _ := service.FindAllHisProjectByTime(now, oldTime, patient_id, c.GetAdminUserInfo().CurrentOrgId, subItem.ProjectId)
1750 1792
 							if len(projects) == 0 {
1751 1793
 								cus.HisPrescriptionProjectTemplate = append(cus.HisPrescriptionProjectTemplate, subItem)
@@ -1765,12 +1807,12 @@ func (c *HisApiController) GetHisPatientInfo() {
1765 1807
 						}
1766 1808
 
1767 1809
 						if subItem.FrequencyType == 2 {
1768
-							p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
1810
+							p, _ := time.Parse("2006-01-02", theTime.Format("2006-01-02"))
1769 1811
 							now := p.Unix()
1770 1812
 							dayStr := strconv.FormatInt(subItem.DayCount, 10)
1771 1813
 							dayStr2 := "-" + dayStr
1772 1814
 							count, _ := strconv.ParseInt(dayStr2, 10, 64)
1773
-							oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
1815
+							oldTime := theTime.AddDate(0, 0, int(count)).Unix()
1774 1816
 							projects, _ := service.FindAllHisProjectByTime(now, oldTime, patient_id, c.GetAdminUserInfo().CurrentOrgId, subItem.ProjectId)
1775 1817
 							if len(projects) == 0 {
1776 1818
 								cus.HisPrescriptionProjectTemplate = append(cus.HisPrescriptionProjectTemplate, subItem)
@@ -3572,6 +3614,7 @@ func (c *HisApiController) CreateHisPrescription() {
3572 3614
 					ctime := time.Now().Unix()
3573 3615
 
3574 3616
 					if tempPrescription.ID == 0 {
3617
+
3575 3618
 						prescription := &models.HisPrescription{
3576 3619
 							ID:                 0,
3577 3620
 							PatientId:          patient_id,
@@ -10214,6 +10257,7 @@ func (c *HisApiController) GetHisOrderList() {
10214 10257
 	sch_type, _ := c.GetInt64("sch_type", 0)
10215 10258
 	zone_type, _ := c.GetInt64("zone_type", 0)
10216 10259
 	med_type, _ := c.GetInt64("med_type", 0)
10260
+	fee_type, _ := c.GetInt64("fee_type", 0)
10217 10261
 
10218 10262
 	timeLayout := "2006-01-02"
10219 10263
 	loc, _ := time.LoadLocation("Local")
@@ -10240,7 +10284,7 @@ func (c *HisApiController) GetHisOrderList() {
10240 10284
 
10241 10285
 	adminUser := c.GetAdminUserInfo()
10242 10286
 	org_id := adminUser.CurrentOrgId
10243
-	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type, sch_type, zone_type, med_type)
10287
+	order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type, sch_type, zone_type, med_type, fee_type)
10244 10288
 
10245 10289
 	for _, item := range order {
10246 10290
 		info, _ := service.GetHisPrescriptionByPatientID(item.PatientId, item.UserOrgId)

+ 36 - 2
service/his_service.go Voir le fichier

@@ -1166,7 +1166,7 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
1166 1166
 	return err
1167 1167
 }
1168 1168
 
1169
-func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, doctor_id int64, keywords string, p_type int64, sort_type int64, start_time string, end_time string, charge_type int64, sch_type int64, zone_type int64, med_type int64) (order []*models.HisOrder, err error, total int64) {
1169
+func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, doctor_id int64, keywords string, p_type int64, sort_type int64, start_time string, end_time string, charge_type int64, sch_type int64, zone_type int64, med_type int64, fee_type int64) (order []*models.HisOrder, err error, total int64) {
1170 1170
 	offset := (page - 1) * limit
1171 1171
 	db := readDb.Model(&models.HisOrder{})
1172 1172
 
@@ -1176,7 +1176,7 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_time
1176 1176
 
1177 1177
 	if len(keywords) > 0 {
1178 1178
 		keywords = "%" + keywords + "%"
1179
-		db = db.Joins("join xt_patients as patient on patient.id = his_order.patient_id  AND patient.name like ? AND patient.user_org_id = ?", keywords, user_org_id)
1179
+		db = db.Joins("join xt_patients as patient on patient.id = his_order.patient_id   AND patient.user_org_id = ?  AND (patient.name like ? or his_order.mdtrt_id like ?)", user_org_id, keywords, keywords)
1180 1180
 
1181 1181
 	}
1182 1182
 	if sch_type > 0 && zone_type > 0 {
@@ -1193,6 +1193,17 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time_time
1193 1193
 		db = db.Where("his_order.med_type = ?", med_type)
1194 1194
 	}
1195 1195
 
1196
+	if fee_type > 0 {
1197
+		if fee_type == 2 {
1198
+			db = db.Where("his_order.is_medicine_insurance <> 1")
1199
+
1200
+		}
1201
+		if fee_type == 1 {
1202
+			db = db.Where("his_order.is_medicine_insurance = 1")
1203
+
1204
+		}
1205
+	}
1206
+
1196 1207
 	//if zone_type > 0 {
1197 1208
 	//	db = db.Joins("join xt_schedule sch_two on sch_two.schedule_date = his_order.settle_accounts_date AND sch_two.patient_id = his_order.patient_id AND sch_two.partition_id = ?", zone_type)
1198 1209
 	//}
@@ -1883,6 +1894,7 @@ type VMHisProjectTeam struct {
1883 1894
 	ProjectId         string               `gorm:"column:project_id" json:"project_id" form:"project_id"`
1884 1895
 	VMItemProjectList []*VMItemProjectList `gorm:"-" json:"list" form:"list"`
1885 1896
 	ItemId            string               `gorm:"column:item_id" json:"item_id" form:"item_id"`
1897
+	DrugItemId        string               `gorm:"column:drug_item_id" json:"drug_item_id" form:"drug_item_id"`
1886 1898
 }
1887 1899
 
1888 1900
 func (VMHisProjectTeam) TableName() string {
@@ -3657,3 +3669,25 @@ func GetFaPiaoHisOrderByID(order_id int64) (order models.HisFaPiaoOrder, err err
3657 3669
 	err = readDb.Model(&models.HisFaPiaoOrder{}).Where("order_ids like ? and status = 1", key).First(&order).Error
3658 3670
 	return
3659 3671
 }
3672
+
3673
+func GetDrugInfomationList(orgid int64, keyword string) (drug []*models.BaseDrugLib, err error) {
3674
+	key := "%" + keyword + "%"
3675
+	if len(keyword) == 0 {
3676
+		err = XTReadDB().Where("org_id = ? and status = 1 AND  find_in_set('停用',drug_status) = 0", orgid).Find(&drug).Error
3677
+
3678
+	} else {
3679
+		err = XTReadDB().Where("org_id = ? and status = 1 AND drug_name like ? AND  find_in_set('停用',drug_status) = 0", orgid, key).Find(&drug).Error
3680
+
3681
+	}
3682
+	return drug, err
3683
+}
3684
+
3685
+func CreateDoctorAdviceTeamList(list *models.HisDoctorAdviceTeamInfo) error {
3686
+	err := XTWriteDB().Model(&list).Save(&list).Error
3687
+	return err
3688
+}
3689
+
3690
+func GetDrugHisListByIds(ids []string) (hisProjectList []*models.HisDoctorAdviceTeamInfo, error error) {
3691
+	error = XTReadDB().Model(&hisProjectList).Preload("BaseDrugLib").Where(" status = 1 and id in (?)", ids).Find(&hisProjectList).Error
3692
+	return hisProjectList, error
3693
+}