瀏覽代碼

耗材参数

XMLWAN 4 年之前
父節點
當前提交
762bfb84d5

+ 4 - 3
controllers/doctors_api_controller.go 查看文件

@@ -46,7 +46,8 @@ func (c *DoctorsApiController) ScheduleAdvices() {
46 46
 	adviceType, _ := c.GetInt("advice_type")
47 47
 	patientType, _ := c.GetInt("patient_type")
48 48
 	delivery_way := c.GetString("delivery_way")
49
-
49
+	schedule_type, _ := c.GetInt64("schedule_type")
50
+	partition_type, _ := c.GetInt64("partition_type")
50 51
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
51 52
 		adviceType = 0
52 53
 	}
@@ -65,8 +66,8 @@ func (c *DoctorsApiController) ScheduleAdvices() {
65 66
 	adminUserInfo := c.GetAdminUserInfo()
66 67
 	orgID := adminUserInfo.CurrentOrgId
67 68
 
68
-	scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way)
69
-	hisAdvices, _ := service.GetHisDoctorAdvices(orgID, date.Unix(), delivery_way)
69
+	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
70
+	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
70 71
 	config, _ := service.GetHisDoctorConfig(orgID)
71 72
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
72 73
 	if err != nil {

+ 15 - 19
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

@@ -3589,7 +3589,7 @@ func (c *DialysisAPIController) EditConsumables() {
3589 3589
 					}
3590 3590
 
3591 3591
 					count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
3592
-					fmt.Println("count222222222222", count)
3592
+
3593 3593
 					if items["ctime"] == nil || reflect.TypeOf(items["ctime"]).String() != "float64" {
3594 3594
 						utils.ErrorLog("ctime")
3595 3595
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -3622,7 +3622,6 @@ func (c *DialysisAPIController) EditConsumables() {
3622 3622
 
3623 3623
 		//查询今日患者出库列表
3624 3624
 		consumables_source, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
3625
-		fmt.Println("6666666666666", consumables_source)
3626 3625
 
3627 3626
 		if dataBody["new_goods"] != nil && reflect.TypeOf(dataBody["new_goods"]).String() == "[]interface {}" {
3628 3627
 			goods, _ := dataBody["new_goods"].([]interface{})
@@ -3652,21 +3651,21 @@ func (c *DialysisAPIController) EditConsumables() {
3652 3651
 
3653 3652
 					count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
3654 3653
 
3655
-					//commdity_code := items["commdity_code"].(string)
3656
-					//fmt.Println("commdityecode22222222222222222222",commdity_code)
3654
+					commdity_code := items["commdity_code"].(string)
3655
+					fmt.Println("commdityecode", commdity_code)
3657 3656
 					adminUser := c.GetMobileAdminUserInfo()
3658 3657
 					prepare := &models.DialysisBeforePrepare{
3659
-						UserOrgId:  adminUser.Org.Id,
3660
-						PatientId:  patient_id,
3661
-						RecordDate: record_time,
3662
-						GoodId:     good_id,
3663
-						GoodTypeId: good_type_id,
3664
-						Count:      count,
3665
-						Ctime:      time.Now().Unix(),
3666
-						Mtime:      time.Now().Unix(),
3667
-						Creater:    adminUser.AdminUser.Id,
3668
-						Modifier:   0,
3669
-						//CommdityCode:commdity_code,
3658
+						UserOrgId:    adminUser.Org.Id,
3659
+						PatientId:    patient_id,
3660
+						RecordDate:   record_time,
3661
+						GoodId:       good_id,
3662
+						GoodTypeId:   good_type_id,
3663
+						Count:        count,
3664
+						Ctime:        time.Now().Unix(),
3665
+						Mtime:        time.Now().Unix(),
3666
+						Creater:      adminUser.AdminUser.Id,
3667
+						Modifier:     0,
3668
+						CommdityCode: commdity_code,
3670 3669
 					}
3671 3670
 					newBeforePrepares = append(newBeforePrepares, prepare)
3672 3671
 
@@ -3706,7 +3705,7 @@ func (c *DialysisAPIController) EditConsumables() {
3706 3705
 			}
3707 3706
 			//创建出库单
3708 3707
 			err := service.AddSigleWarehouseOut(&warehouseOut)
3709
-			fmt.Println("err22222222222222", err)
3708
+			fmt.Println("err", err)
3710 3709
 			if err != nil {
3711 3710
 				utils.TraceLog("创建出库单失败 err = %v", err)
3712 3711
 			} else {
@@ -3946,15 +3945,12 @@ func (c *DialysisAPIController) EditConsumables() {
3946 3945
 									}
3947 3946
 								}
3948 3947
 
3949
-								fmt.Println("444444444")
3950
-
3951 3948
 							}
3952 3949
 						}
3953 3950
 					}
3954 3951
 				}
3955 3952
 			}
3956 3953
 		}
3957
-		fmt.Println("655555555")
3958 3954
 
3959 3955
 		var errs error
3960 3956
 		if len(beforePrepares) > 0 {

+ 2 - 0
controllers/schedule_api_controller.go 查看文件

@@ -1930,7 +1930,9 @@ func (this *ScheduleApiController) GetNextWeekDaySchedule() {
1930 1930
 	week_time, _ := this.GetInt64("week_time")
1931 1931
 	start_time, _ := this.GetInt64("start_time")
1932 1932
 	end_time, _ := this.GetInt64("end_time")
1933
+
1933 1934
 	adminUserInfo := this.GetAdminUserInfo()
1935
+
1934 1936
 	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId)
1935 1937
 	if err != nil {
1936 1938
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 149 - 3
service/mobile_dialysis_service.go 查看文件

@@ -794,9 +794,6 @@ func (MDoctorAdviceVM) TableName() string {
794 794
 func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string) ([]*MScheduleDoctorAdviceVM, error) {
795 795
 	var vms []*MScheduleDoctorAdviceVM
796 796
 	adviceWhere := ""
797
-	fmt.Println("advicetype", adviceType)
798
-	fmt.Println("patientType", patientType)
799
-	fmt.Println("adminUserId", adminUserId)
800 797
 	adviceCondition := []interface{}{}
801 798
 	if adviceType == 0 {
802 799
 		if patientType == 0 {
@@ -1792,3 +1789,152 @@ func GetHisDoctorAdviceCount(startime int64, endtime int64, deliveway string, or
1792 1789
 	err = db.Select("x.advice_name,x.advice_desc,x.delivery_way,count(x.id) as total").Group("x.advice_name,x.advice_desc").Scan(&advice).Error
1793 1790
 	return advice, err
1794 1791
 }
1792
+
1793
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64) ([]*MScheduleDoctorAdviceVM, error) {
1794
+	var vms []*MScheduleDoctorAdviceVM
1795
+	adviceWhere := ""
1796
+	adviceCondition := []interface{}{}
1797
+	if adviceType == 0 {
1798
+		if patientType == 0 {
1799
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
1800
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1801
+
1802
+		} else if patientType == 1 {
1803
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
1804
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
1805
+
1806
+		} else if patientType == 2 {
1807
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
1808
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1809
+		}
1810
+
1811
+	} else if adviceType == 1 {
1812
+		if patientType == 0 {
1813
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  "
1814
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1815
+
1816
+		} else if patientType == 1 {
1817
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
1818
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
1819
+
1820
+		} else if patientType == 2 {
1821
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
1822
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1823
+
1824
+		}
1825
+
1826
+	} else if adviceType == 3 {
1827
+		if patientType == 0 {
1828
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ?  "
1829
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1830
+
1831
+		} else if patientType == 1 {
1832
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
1833
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
1834
+		} else if patientType == 2 {
1835
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
1836
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1837
+		}
1838
+
1839
+	} else if adviceType == 2 && len(deliverWay) > 0 {
1840
+		if patientType == 0 {
1841
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
1842
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
1843
+
1844
+		} else if patientType == 1 {
1845
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
1846
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
1847
+		} else if patientType == 2 {
1848
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
1849
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
1850
+		}
1851
+
1852
+	} else if adviceType == 2 && len(deliverWay) <= 0 {
1853
+		if patientType == 0 {
1854
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
1855
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1856
+
1857
+		} else if patientType == 1 {
1858
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
1859
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
1860
+		} else if patientType == 2 {
1861
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
1862
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1863
+		}
1864
+
1865
+	}
1866
+
1867
+	db := readDb.Table("xt_schedule")
1868
+	if scheduleType > 0 {
1869
+		db = db.Where("schedule_type = ?", scheduleType)
1870
+	}
1871
+	if partitonType > 0 {
1872
+		db = db.Where("partition_id = ?", partitonType)
1873
+	}
1874
+	db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1875
+		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1876
+			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1877
+		}).
1878
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1879
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1880
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1881
+		Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
1882
+		Preload("DoctorAdvices", adviceCondition...).
1883
+		Where("status = 1 AND user_org_id = ?", orgID)
1884
+	if scheduleDate != 0 {
1885
+		db = db.Where("schedule_date = ?", scheduleDate)
1886
+	}
1887
+
1888
+	err := db.Find(&vms).Error
1889
+	return vms, err
1890
+}
1891
+
1892
+func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64) ([]*HisMScheduleDoctorAdviceVM, error) {
1893
+
1894
+	var vms []*HisMScheduleDoctorAdviceVM
1895
+	if len(deliverWay) > 0 {
1896
+		db := readDb.Table("xt_schedule")
1897
+		if scheduleType > 0 {
1898
+			db = db.Where("schedule_type = ?", scheduleType)
1899
+		}
1900
+		if partitionType > 0 {
1901
+			db = db.Where("partition_id = ?", partitionType)
1902
+		}
1903
+		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1904
+			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1905
+				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1906
+			}).
1907
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1908
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1909
+			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1910
+			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
1911
+			Where("status = 1 AND user_org_id = ?", orgID)
1912
+		if scheduleDate != 0 {
1913
+			db = db.Where("schedule_date = ?", scheduleDate)
1914
+		}
1915
+		err = db.Find(&vms).Error
1916
+	} else {
1917
+		db := readDb.Table("xt_schedule")
1918
+		if scheduleType > 0 {
1919
+			db = db.Where("schedule_type = ?", scheduleType)
1920
+		}
1921
+		if partitionType > 0 {
1922
+			db = db.Where("partition_id = ?", partitionType)
1923
+		}
1924
+		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1925
+			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1926
+				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1927
+			}).
1928
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1929
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1930
+			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1931
+			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
1932
+			Where("status = 1 AND user_org_id = ?", orgID)
1933
+		if scheduleDate != 0 {
1934
+			db = db.Where("schedule_date = ?", scheduleDate)
1935
+		}
1936
+		err = db.Find(&vms).Error
1937
+	}
1938
+
1939
+	return vms, err
1940
+}