Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
c340b3bed0

+ 39 - 0
controllers/doctors_api_controller.go View File

@@ -39,6 +39,11 @@ func DoctorApiRegistRouters() {
39 39
 	beego.Router("/api/patient/updatepasswayassesment", &DoctorsApiController{}, "Get:UpdatePassWayAssesment")
40 40
 	beego.Router("/api/patient/deletepasswayassessment", &DoctorsApiController{}, "Get:DeleteWayAssessment")
41 41
 	beego.Router("/api/patient/getaccesslist", &DoctorsApiController{}, "Get:GetAccessList")
42
+
43
+	//阶段小结路由
44
+	beego.Router("/api/patient/getinspectionmajoritem", &DoctorsApiController{}, "Get:GetInspectionMajorItem")
45
+	beego.Router("/api/patient/getinspectiondetail", &DoctorsApiController{}, "Get:GetInspectionDetailByProject")
46
+
42 47
 }
43 48
 
44 49
 func (c *DoctorsApiController) ScheduleAdvices() {
@@ -661,3 +666,37 @@ func (this *DoctorsApiController) GetAccessList() {
661 666
 		return
662 667
 	}
663 668
 }
669
+
670
+func (this *DoctorsApiController) GetInspectionMajorItem() {
671
+
672
+	other_start_time := this.GetString("other_start_time")
673
+	timeLayout := "2006-01-02"
674
+	loc, _ := time.LoadLocation("Local")
675
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
676
+	fmt.Println("startTime2222345555533344334334433433344", startTime.Unix())
677
+	patient_id, _ := this.GetInt64("patient_id")
678
+	adminUserInfo := this.GetAdminUserInfo()
679
+	orgId := adminUserInfo.CurrentOrgId
680
+	list, err := service.GetInspectionMajorItem(startTime.Unix(), orgId, patient_id)
681
+	if err == nil {
682
+		this.ServeSuccessJSON(map[string]interface{}{
683
+			"list": list,
684
+		})
685
+		return
686
+	}
687
+}
688
+
689
+func (this *DoctorsApiController) GetInspectionDetailByProject() {
690
+
691
+	project_id, _ := this.GetInt64("project_id")
692
+	patient_id, _ := this.GetInt64("patient_id")
693
+	inspect_date, _ := this.GetInt64("inspect_date")
694
+	orgId := this.GetAdminUserInfo().CurrentOrgId
695
+	list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
696
+	if err == nil {
697
+		this.ServeSuccessJSON(map[string]interface{}{
698
+			"list": list,
699
+		})
700
+		return
701
+	}
702
+}

+ 6 - 1
controllers/drug_stock_api_contorller.go View File

@@ -2233,7 +2233,12 @@ func (c *StockDrugApiController) CreateDrugCancelStock() {
2233 2233
 			out_number += item.Count
2234 2234
 		}
2235 2235
 		fmt.Println("出库数量23232232323222332", out_number)
2236
-
2236
+		if out_number == 0 {
2237
+			c.ServeSuccessJSON(map[string]interface{}{
2238
+				"msg": "2",
2239
+			})
2240
+			return
2241
+		}
2237 2242
 		//判断退库数量是否大于总入库数量
2238 2243
 		if total_number > out_number {
2239 2244
 			service.UpdateDrugCancel(item.CancelStockId)

+ 41 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -3,8 +3,10 @@ package new_mobile_api_controllers
3 3
 import (
4 4
 	"XT_New/controllers/mobile_api_controllers"
5 5
 	"XT_New/enums"
6
+	"XT_New/models"
6 7
 	"XT_New/service"
7 8
 	"fmt"
9
+	"strings"
8 10
 	"time"
9 11
 )
10 12
 
@@ -320,3 +322,42 @@ func (this *StaffScheduleApiController) SearchPatient() {
320 322
 		"schedule": schedule,
321 323
 	})
322 324
 }
325
+
326
+func (this *StaffScheduleApiController) UpdatePatientScheduleById() {
327
+
328
+	ids := this.GetString("ids")
329
+	idSplit := strings.Split(ids, ",")
330
+	var err error
331
+	//查询患者信息
332
+	list, _ := service.GetStaffScheduleById(idSplit)
333
+	if len(list) > 0 {
334
+		for index, _ := range list {
335
+			fmt.Println("index2322332", index)
336
+			schedule := models.XtSchedule{
337
+				PartitionId:  list[0].PartitionId,
338
+				BedId:        list[0].BedId,
339
+				PatientId:    list[0].PatientId,
340
+				ScheduleDate: list[0].ScheduleDate,
341
+				ScheduleType: list[0].ScheduleType,
342
+				ScheduleWeek: list[0].ScheduleWeek,
343
+				ModeId:       list[0].ModeId,
344
+			}
345
+			xtSchedule := models.WeekSchedule{
346
+				PartitionId:  list[1].PartitionId,
347
+				BedId:        list[1].BedId,
348
+				PatientId:    list[1].PatientId,
349
+				ScheduleDate: list[1].ScheduleDate,
350
+				ScheduleType: list[1].ScheduleType,
351
+				ScheduleWeek: list[1].ScheduleWeek,
352
+				ModeId:       list[1].ModeId,
353
+			}
354
+			err = service.UpdateStaffSchedule(list[1].ID, schedule)
355
+			fmt.Println("errrrrrrr2323323232323", err)
356
+			service.UpdateStaffScheduleOne(list[0].ID, xtSchedule)
357
+		}
358
+	}
359
+	fmt.Println(err)
360
+	this.ServeSuccessJSON(map[string]interface{}{
361
+		"msg": "切换成功",
362
+	})
363
+}

+ 1 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go View File

@@ -19,4 +19,5 @@ func StaffScheduleApiControllersRegisterRouters() {
19 19
 	beego.Router("/m/api/getpatientschedulelist", &StaffScheduleApiController{}, "Get:GetPatientScheduleList")
20 20
 	beego.Router("/m/api/deleteSchedule", &StaffScheduleApiController{}, "Get:DeleteSchedule")
21 21
 	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")
22
+	beego.Router("/m/api/updatepatientschedule", &StaffScheduleApiController{}, "Get:UpdatePatientScheduleById")
22 23
 }

+ 1 - 0
controllers/stock_in_api_controller.go View File

@@ -1940,6 +1940,7 @@ func (c *StockManagerApiController) CreateCancelStock() {
1940 1940
 
1941 1941
 		//统计该耗材的出库数量
1942 1942
 		info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId)
1943
+		fmt.Println("2333223323322332233223322323", item.Count, info.Count)
1943 1944
 		if item.Count > info.Count {
1944 1945
 			service.UpdateCancelInfo(item.CancelStockId)
1945 1946
 			c.ServeSuccessJSON(map[string]interface{}{

+ 20 - 0
models/patient_models.go View File

@@ -800,6 +800,26 @@ func (XtInspection) TableName() string {
800 800
 	return "xt_inspection"
801 801
 }
802 802
 
803
+type VmInspection struct {
804
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
805
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
806
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
807
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
808
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
809
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
810
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
811
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
812
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
813
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
814
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
815
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
816
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
817
+	RangeMin     string `gorm:"column:range_min" json:"range_min" form:"range_min"`
818
+	RangeMax     string `gorm:"column:range_max" json:"range_max" form:"range_max"`
819
+	RangeValue   string `gorm:"column:range_value" json:"range_value" form:"range_value"`
820
+	Unit         string `gorm:"column:unit" json:"unit" form:"unit"`
821
+}
822
+
803 823
 type BloodXtPatients struct {
804 824
 	ID         int64  `gorm:"column:id" json:"id" form:"id"`
805 825
 	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`

+ 1 - 1
service/device_service.go View File

@@ -387,7 +387,7 @@ type DeviceNumberViewModel struct {
387 387
 
388 388
 func GetAllValidDeviceNumbers(orgID int64) ([]*DeviceNumberViewModel, error) {
389 389
 	var vms []*DeviceNumberViewModel = make([]*DeviceNumberViewModel, 0)
390
-	rows, err := readDb.Raw("SELECT n.*, z.name as zone_name, g.name as group_name FROM xt_device_number as n join xt_device_zone as z on z.id = n.zone_id AND z.status = 1 join xt_device_group as g on g.id = n.group_id WHERE (n.org_id = ? AND n.status = 1)", orgID).Rows()
390
+	rows, err := readDb.Raw("SELECT n.*, z.name as zone_name, g.name as group_name FROM xt_device_number  as n join xt_device_zone as z on z.id = n.zone_id AND z.status = 1 join xt_device_group as g on g.id = n.group_id WHERE (n.org_id = ? AND n.status = 1) order by sort ", orgID).Rows()
391 391
 	defer rows.Close()
392 392
 	if err != nil {
393 393
 		return nil, err

+ 19 - 0
service/doctor_schedule_service.go View File

@@ -615,3 +615,22 @@ func GetSearchPatient(keywords string, orgid int64, startime int64) (schedule []
615 615
 		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,p.name as patient").Find(&schedule).Error
616 616
 	return schedule, err
617 617
 }
618
+
619
+func GetStaffScheduleById(ids []string) (schedule []*models.XtSchedule, err error) {
620
+
621
+	err = XTReadDB().Where("id in(?)", ids).Find(&schedule).Error
622
+	return schedule, err
623
+
624
+}
625
+
626
+func UpdateStaffSchedule(nextid int64, schedule models.XtSchedule) error {
627
+
628
+	err := XTWriteDB().Model(&schedule).Where("id = ?", nextid).Updates(map[string]interface{}{"partition_id": schedule.PartitionId, "bed_id": schedule.BedId, "patient_id": schedule.PatientId, "schedule_type": schedule.ScheduleType, "schedule_week": schedule.ScheduleWeek, "mode_id": schedule.ModeId}).Error
629
+	return err
630
+}
631
+
632
+func UpdateStaffScheduleOne(nextid int64, schedule models.WeekSchedule) error {
633
+
634
+	err := XTWriteDB().Model(&schedule).Where("id = ?", nextid).Updates(map[string]interface{}{"partition_id": schedule.PartitionId, "bed_id": schedule.BedId, "patient_id": schedule.PatientId, "schedule_type": schedule.ScheduleType, "schedule_week": schedule.ScheduleWeek, "mode_id": schedule.ModeId}).Error
635
+	return err
636
+}

+ 37 - 0
service/patientmanage_service.go View File

@@ -1621,3 +1621,40 @@ func GetTotalBedNumber(orgid int64, ids []string) (list []*models.XtDeviceNumber
1621 1621
 	err = db.Count(&total).Find(&list).Error
1622 1622
 	return list, total, err
1623 1623
 }
1624
+
1625
+func GetInspectionMajorItem(startime int64, orgid int64, patientid int64) (inspection []*models.XtInspection, err error) {
1626
+
1627
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
1628
+	if startime > 0 {
1629
+		db = db.Where("x.inspect_date<=?", startime)
1630
+	}
1631
+	if orgid > 0 {
1632
+		db = db.Where("x.org_id = ?", orgid)
1633
+	}
1634
+	if patientid > 0 {
1635
+		db = db.Where("x.patient_id = ?", patientid)
1636
+	}
1637
+	err = db.Group("x.project_id").Find(&inspection).Error
1638
+	return inspection, err
1639
+}
1640
+
1641
+func GetInspectionDetailByProject(project_id int64, patientid int64, inspect_date int64, orgid int64) (inspection []*models.VmInspection, err error) {
1642
+
1643
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
1644
+	table := XTReadDB().Table("xt_inspection_reference as t").Where("t.status = 1")
1645
+	fmt.Println(table)
1646
+	if inspect_date > 0 {
1647
+		db = db.Where("x.inspect_date=?", inspect_date)
1648
+	}
1649
+	if orgid > 0 {
1650
+		db = db.Where("x.org_id = ?", orgid)
1651
+	}
1652
+	if patientid > 0 {
1653
+		db = db.Where("x.patient_id = ?", patientid)
1654
+	}
1655
+	if project_id > 0 {
1656
+		db = db.Where("x.project_id = ?", project_id)
1657
+	}
1658
+	err = db.Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,t.range_max,t.range_min,t.range_value,t.unit").Joins("left join xt_inspection_reference as t on t.id = x.item_id").Scan(&inspection).Error
1659
+	return inspection, err
1660
+}

+ 3 - 3
service/stock_service.go View File

@@ -3908,16 +3908,16 @@ func UpdatedStockFlow(flow models.VmStockFlow) error {
3908 3908
 
3909 3909
 func GetStockFlowIsExsit(warehousing_id int64, patient_id int64, record_time int64, good_id int64) (*models.VmStockFlow, error) {
3910 3910
 
3911
-	flow := models.VmStockFlow{}
3911
+	stock := models.VmStockFlow{}
3912 3912
 	var err error
3913
-	err = XTReadDB().Model(&flow).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Find(&flow).Error
3913
+	err = XTReadDB().Model(&stock).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Find(&stock).Error
3914 3914
 	if err == gorm.ErrRecordNotFound {
3915 3915
 		return nil, err
3916 3916
 	}
3917 3917
 	if err != nil {
3918 3918
 		return nil, err
3919 3919
 	}
3920
-	return &flow, nil
3920
+	return &stock, nil
3921 3921
 }
3922 3922
 
3923 3923
 func GetWarehouseOutInfoIsExist(id int64) (*models.WarehouseOutInfo, error) {

+ 26 - 17
service/warhouse_service.go View File

@@ -203,24 +203,27 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
203 203
 		// 判断处方里药品单位是拆零单位还是包装单位,	如果是拆零单位,则根据规格,将拆零数量转为包装数量
204 204
 		var maxNumber int64 = 0
205 205
 		var minNumber int64 = 0
206
-		if advice.PrescribingNumberUnit == drup.MinUnit {
206
+		fmt.Println("单位1111111111", advice.PrescribingNumberUnit)
207
+		fmt.Println("单位222222222222222", drup.MaxUnit)
208
+		if advice.PrescribingNumberUnit == drup.MaxUnit {
207 209
 			maxNumber = count / drup.MinNumber
208 210
 			minNumber = count % drup.MinNumber
209 211
 		} else {
210
-			maxNumber = count
212
+			minNumber = count
211 213
 		}
212
-
214
+		fmt.Println("maxNumber0000000000000", maxNumber)
215
+		fmt.Println("minNumber999999999999999", minNumber)
213 216
 		if warehouse.StockMaxNumber < maxNumber {
214
-			fmt.Println("尽量323223232")
217
+
215 218
 			return errors.New("库存数量不足")
216 219
 		}
217 220
 
218 221
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
219 222
 		warehouse.Mtime = time.Now().Unix()
220
-
221 223
 		if warehouse.StockMinNumber < minNumber {
222 224
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
223 225
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
226
+
224 227
 		} else {
225 228
 			warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
226 229
 		}
@@ -228,6 +231,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
228 231
 		if warehouse.StockMaxNumber < 0 {
229 232
 			return errors.New("库存数量不足")
230 233
 		}
234
+
231 235
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
232 236
 		if errThree != nil {
233 237
 			return errThree
@@ -933,7 +937,6 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
933 937
 	info, _ := GetGoodInformationByGoodId(goods.GoodId)
934 938
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
935 939
 	if stock_number >= deliver_number {
936
-		fmt.Println("进来22323232323232323232233223323223322323")
937 940
 		warehouseOutInfo := &models.WarehouseOutInfo{
938 941
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
939 942
 			WarehouseOutId:          warehouseOut.ID,
@@ -986,6 +989,9 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
986 989
 
987 990
 		if errcode == gorm.ErrRecordNotFound {
988 991
 			errTwo := CreateAutoReduceRecord(&details)
992
+			if errTwo != nil {
993
+				return errTwo
994
+			}
989 995
 			//插入库存流水表
990 996
 			flow := models.VmStockFlow{
991 997
 				WarehouseOutId:          warehouseOut.ID,
@@ -1013,10 +1019,13 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1013 1019
 			}
1014 1020
 			//查询流水是否存在
1015 1021
 			exsit, errflow := GetStockFlowIsExsit(warehouseOut.ID, patient_id, record_time, goods.GoodId)
1016
-			fmt.Println("8888232322332323222332323223322332233232323232322323233223232332", exsit.Count+goods.Count)
1017 1022
 
1023
+			fmt.Println("什么数据233232323", errflow)
1018 1024
 			if errflow == gorm.ErrRecordNotFound {
1019
-				CreateStockFlowOne(flow)
1025
+				errThre := CreateStockFlowOne(flow)
1026
+				if errThre != nil {
1027
+					return errThre
1028
+				}
1020 1029
 			} else if errflow == nil {
1021 1030
 				flow := models.VmStockFlow{
1022 1031
 					ID:                      exsit.ID,
@@ -1044,14 +1053,13 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1044 1053
 					PatientId:               patient_id,
1045 1054
 					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1046 1055
 				}
1047
-				UpdatedStockFlow(flow)
1048
-			}
1049
-			if errTwo != nil {
1050
-				return errTwo
1056
+				errFour := UpdatedStockFlow(flow)
1057
+				if errFour != nil {
1058
+					return errFour
1059
+				}
1051 1060
 			}
1052
-		} else if errcode == nil {
1053 1061
 
1054
-			fmt.Println("wodeeeeeeeeeeewewewewewewewewweewewewewewweewewew")
1062
+		} else if errcode == nil {
1055 1063
 			flow := models.VmStockFlow{
1056 1064
 				WarehouseOutId:          warehouseOut.ID,
1057 1065
 				WarehousingId:           warehouse.ID,
@@ -1078,10 +1086,11 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1078 1086
 			}
1079 1087
 			//查询流水是否存在
1080 1088
 			exsit, errflow := GetStockFlowIsExsit(warehouseOut.ID, patient_id, record_time, goods.GoodId)
1081
-			fmt.Println("8888232322332323222332323223322332233232323232322323233223232332", exsit.Count+goods.Count)
1082 1089
 
1083 1090
 			if errflow == gorm.ErrRecordNotFound {
1084 1091
 				CreateStockFlowOne(flow)
1092
+				DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
1093
+				CreateAutoReduceRecord(&details)
1085 1094
 			} else if errflow == nil {
1086 1095
 				flow := models.VmStockFlow{
1087 1096
 					ID:                      exsit.ID,
@@ -1110,9 +1119,9 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1110 1119
 					ReturnCount:             exsit.Count + (exsit.Count + deliver_number),
1111 1120
 				}
1112 1121
 				UpdatedStockFlow(flow)
1122
+				DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
1123
+				CreateAutoReduceRecord(&details)
1113 1124
 			}
1114
-			DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
1115
-			CreateAutoReduceRecord(&details)
1116 1125
 
1117 1126
 		}
1118 1127