Bläddra i källkod

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

XMLWAN 2 år sedan
förälder
incheckning
0e7418e70f

+ 2 - 1
controllers/his_api_controller.go Visa fil

@@ -5231,6 +5231,7 @@ func (c *HisApiController) GetHisPrescriptionList() {
5231 5231
 	keywords := c.GetString("keywords")
5232 5232
 	page, _ := c.GetInt64("page")
5233 5233
 	limit, _ := c.GetInt64("limit")
5234
+	sch_type, _ := c.GetInt64("sch_type")
5234 5235
 
5235 5236
 	timeLayout := "2006-01-02"
5236 5237
 	loc, _ := time.LoadLocation("Local")
@@ -5241,7 +5242,7 @@ func (c *HisApiController) GetHisPrescriptionList() {
5241 5242
 	}
5242 5243
 	recordDateTime := theTime.Unix()
5243 5244
 	adminInfo := c.GetAdminUserInfo()
5244
-	prescriptionOrder, err, total := service.GetNewHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
5245
+	prescriptionOrder, err, total := service.GetNewHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit, sch_type)
5245 5246
 
5246 5247
 	//adminInfo := c.GetAdminUserInfo()
5247 5248
 	//prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)

+ 0 - 4
controllers/his_project_api_controller.go Visa fil

@@ -1239,10 +1239,6 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1239 1239
 	schIDStr := this.GetString("ids")
1240 1240
 	p_type, _ := this.GetInt64("p_type")
1241 1241
 
1242
-	if len(schIDStr) == 0 {
1243
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1244
-		return
1245
-	}
1246 1242
 	idStrs := strings.Split(schIDStr, ",")
1247 1243
 
1248 1244
 	timeLayout := "2006-01-02"

+ 12 - 9
models/his_print_models.go Visa fil

@@ -1,15 +1,18 @@
1 1
 package models
2 2
 
3 3
 type PrintPatient struct {
4
-	ID                      int64                   `gorm:"column:id" json:"id" form:"id"`
5
-	UserOrgId               int64                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
-	Name                    string                  `gorm:"column:name" json:"name" form:"name"`
7
-	Age                     string                  `gorm:"column:age" json:"age" form:"age"`
8
-	Gender                  int64                   `gorm:"column:gender" json:"gender" form:"gender"`
9
-	HomeAddress             string                  `gorm:"column:home_address" json:"home_address" form:"home_address"`
10
-	Phone                   string                  `gorm:"column:phone" json:"phone" form:"phone"`
11
-	Lapseto                 int64                   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
12
-	Status                  int64                   `gorm:"column:status" json:"status" form:"status"`
4
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	Name               string `gorm:"column:name" json:"name" form:"name"`
7
+	Age                string `gorm:"column:age" json:"age" form:"age"`
8
+	Gender             int64  `gorm:"column:gender" json:"gender" form:"gender"`
9
+	HomeAddress        string `gorm:"column:home_address" json:"home_address" form:"home_address"`
10
+	Phone              string `gorm:"column:phone" json:"phone" form:"phone"`
11
+	Lapseto            int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
12
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
13
+	ReimbursementWayId int64  `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
14
+	Birthday           int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
15
+
13 16
 	HisPrintPatient         HisPrintPatient         `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
14 17
 	HisHospitalCheckRecord  HisHospitalCheckRecord  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_record_patient"`
15 18
 	HisPrescriptionInfoTwo  HisPrescriptionInfoTwo  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"info"`

+ 14 - 0
models/schedule_models.go Visa fil

@@ -671,3 +671,17 @@ type MyVmBloodSchedule struct {
671 671
 func (MyVmBloodSchedule) TableName() string {
672 672
 	return "xt_schedule"
673 673
 }
674
+
675
+type ScheduleConfig struct {
676
+	ID            int64 `gorm:"column:id" json:"id" form:"id"`
677
+	UserOrgId     int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
678
+	IsShowMode    int64 `gorm:"column:is_show_mode" json:"is_show_mode" form:"is_show_mode"`
679
+	Status        int64 `gorm:"column:status" json:"status" form:"status"`
680
+	Ctime         int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
681
+	Mtime         int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
682
+	IsShowMachine int64 `gorm:"column:is_show_machine" json:"is_show_machine" form:"is_show_machine"`
683
+}
684
+
685
+func (ScheduleConfig) TableName() string {
686
+	return "xt_schedule_config"
687
+}

+ 25 - 0
service/gobal_config_service.go Visa fil

@@ -1010,6 +1010,31 @@ func GetAllBaseDrugListTwenty(orgid int64) (drug []*models.BaseDrugLibTwenty, er
1010 1010
 	return drug, err
1011 1011
 }
1012 1012
 
1013
+func GetScheduleConfigByOrgId(org_id int64) (config models.ScheduleConfig, err error) {
1014
+	err = XTReadDB().Model(&models.ScheduleConfig{}).Where("user_org_id = ?", org_id).First(&config).Error
1015
+	return config, err
1016
+}
1017
+
1018
+func SaveScheduleConfig(config models.ScheduleConfig) (err error) {
1019
+	err = XTWriteDB().Save(&config).Error
1020
+	return err
1021
+}
1022
+
1023
+func CreateScheduleConfig(config models.ScheduleConfig) (err error) {
1024
+	err = XTWriteDB().Create(&config).Error
1025
+	return err
1026
+}
1027
+
1028
+func GetScheduleConfigById(id int64) (config models.ScheduleConfig, err error) {
1029
+	err = XTReadDB().Model(&models.ScheduleConfig{}).Where("id = ?", id).First(&config).Error
1030
+	return config, err
1031
+}
1032
+
1033
+//func Get(id int64)(config models.ScheduleConfig, err error){
1034
+//	err = XTReadDB().Model(&models.ScheduleConfig{}).Where("id = ?", id).First(&config).Error
1035
+//	return config, err
1036
+//}
1037
+
1013 1038
 func GetMobileScheduleList(orgid int64) (schedule []*models.MyVmBloodSchedule, err error) {
1014 1039
 
1015 1040
 	err = XTReadDB().Where("user_org_id = ? and status= 1 and schedule_date=1676563200", orgid).Preload("SchedualPatient", "user_org_id = ? and status = 1", orgid).Find(&schedule).Error

+ 6 - 2
service/his_service.go Visa fil

@@ -1396,17 +1396,21 @@ func DelelteAddition(id int64, user_org_id int64) (err error) {
1396 1396
 	return
1397 1397
 }
1398 1398
 
1399
-func GetNewHisPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*VMHisHospitalPrescriptionInfo, err error, total int64) {
1399
+func GetNewHisPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64, sch_type int64) (patients []*VMHisHospitalPrescriptionInfo, err error, total int64) {
1400 1400
 	offset := (page - 1) * limit
1401 1401
 	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)
1402
+
1402 1403
 	if len(keywords) > 0 {
1403 1404
 		keywords = "%" + keywords + "%"
1404 1405
 		db = db.Joins("JOIN xt_patients  On his_prescription_info.patient_id = xt_patients.id  AND xt_patients.name like ?", keywords)
1405 1406
 	}
1407
+	if sch_type > 0 {
1408
+		db = db.Joins("JOIN xt_schedule  On xt_schedule.status = 1 AND his_prescription_info.patient_id = xt_schedule.patient_id AND xt_schedule.schedule_date = ?  AND xt_schedule.schedule_type = ?", record_date, sch_type)
1409
+	}
1406 1410
 	db = db.Preload("Patients", "xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
1407 1411
 	db = db.Preload("HisPrescription", "his_prescription.user_org_id = ? AND his_prescription.status = 1 AND his_prescription.p_type <> 1", org_id)
1408 1412
 	db = db.Count(&total)
1409
-	err = db.Limit(limit).Offset(offset).Find(&patients).Error
1413
+	err = db.Limit(limit).Offset(offset).Group("his_prescription_info.id").Find(&patients).Error
1410 1414
 	return
1411 1415
 }
1412 1416
 

+ 68 - 0
service/schedule_service.go Visa fil

@@ -1487,3 +1487,71 @@ func GetDialysisOrderByPatientAndBed(org_id int64, record_date int64, bed_id int
1487 1487
 	err = readDb.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND status = 1 AND dialysis_date = ? AND bed_id = ? AND patient_id = ?", org_id, record_date, bed_id, patient_id).First(&order).Error
1488 1488
 	return
1489 1489
 }
1490
+
1491
+func GetScheduleTemplateTen(orgID, id int64) (models.PatientScheduleTemplateItem, error) {
1492
+	var schedule models.PatientScheduleTemplateItem
1493
+	var err error
1494
+	err = readDb.Model(&models.PatientScheduleTemplateItem{}).Where("id = ? and user_org_id=? and status=1", id, orgID).First(&schedule).Error
1495
+	return schedule, err
1496
+}
1497
+
1498
+func GetScheduleTemplateCountByDate(org_id int64, week_day int8, patient_id int64, template_id int64) (total int64, err error) {
1499
+	err = readDb.Model(&models.PatientScheduleTemplateItem{}).Where(" org_id = ? AND weekday = ? AND status = 1 AND patient_id = ? AND template_id = ?", org_id, week_day, patient_id, template_id).Count(&total).Error
1500
+	return
1501
+}
1502
+
1503
+func SaveSchTemplateTwo(sch models.PatientScheduleTemplateItem, sch_two models.PatientScheduleTemplateItem) (err error) {
1504
+	//err = writeDb.Save(&sch).Error
1505
+	err = writeDb.Model(&models.PatientScheduleTemplateItem{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"status": 0}).Error
1506
+	err = writeDb.Model(&models.PatientScheduleTemplateItem{}).Where("status=1 AND id = ?", sch_two.ID).Updates(map[string]interface{}{"status": 0}).Error
1507
+
1508
+	return
1509
+}
1510
+
1511
+func SaveSchTemplate(sch models.PatientScheduleTemplateItem) (err error) {
1512
+	err = writeDb.Save(&sch).Error
1513
+	return
1514
+}
1515
+
1516
+func UpdateScheduleTemplateThree(schone models.PatientScheduleTemplateItem, schtwo models.PatientScheduleTemplateItem) {
1517
+	utx := XTWriteDB()
1518
+	//床位
1519
+	var tempBedID int64
1520
+	var tempBedIDTwo int64
1521
+
1522
+	//上下午
1523
+	var tempTypeID int8
1524
+	var tempTypeTwo int8
1525
+
1526
+	//周数
1527
+	var sch_week_one int8
1528
+	var sch_week_two int8
1529
+
1530
+	tempBedID = schone.DeviceNumberID
1531
+	tempBedIDTwo = schtwo.DeviceNumberID
1532
+
1533
+	tempTypeID = schone.TimeType
1534
+	tempTypeTwo = schtwo.TimeType
1535
+
1536
+	sch_week_one = schone.Weekday
1537
+	sch_week_two = schtwo.Weekday
1538
+
1539
+	schone.DeviceNumberID = tempBedIDTwo
1540
+	schtwo.DeviceNumberID = tempBedID
1541
+
1542
+	schone.TimeType = tempTypeTwo
1543
+	schtwo.TimeType = tempTypeID
1544
+
1545
+	schone.Weekday = sch_week_two
1546
+	schtwo.Weekday = sch_week_one
1547
+
1548
+	utx.Model(&models.PatientScheduleTemplateItem{}).Where("id = ?", schone.ID).Updates(map[string]interface{}{"device_number_id": schone.DeviceNumberID, "time_type": schone.TimeType, "weekday": schone.Weekday, "is_export": 9000})
1549
+	utx.Model(&models.PatientScheduleTemplateItem{}).Where("id = ?", schtwo.ID).Updates(map[string]interface{}{"device_number_id": schtwo.DeviceNumberID, "time_type": schtwo.TimeType, "weekday": schtwo.Weekday, "is_export": 9000})
1550
+
1551
+}
1552
+
1553
+func GetScheduleTemplateForDeviceNumberTwo(orgID int64, deviceNumberID int64, template_id int64, week_type int64, time_type int64, patient_id int64) (models.PatientScheduleTemplateItem, error) {
1554
+	var item models.PatientScheduleTemplateItem
1555
+	err := readDb.Model(&models.PatientScheduleTemplateItem{}).Where("device_number_id = ? AND org_id = ? AND status = 1 AND template_id = ? AND weekday = ? AND time_type = ? AND patient_id = ?", deviceNumberID, orgID, template_id, week_type, time_type, patient_id).First(&item).Error
1556
+	return item, err
1557
+}