ソースを参照

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

XMLWAN 3 年 前
コミット
faf8cf7235

+ 11 - 4
controllers/doctors_api_controller.go ファイルの表示

@@ -68,7 +68,12 @@ func (c *DoctorsApiController) ScheduleAdvices() {
68 68
 
69 69
 	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
70 70
 	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
71
+
72
+	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type)
73
+
71 74
 	config, _ := service.GetHisDoctorConfig(orgID)
75
+	project_config, _ := service.GetHisProjectConfig(orgID)
76
+
72 77
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
73 78
 	if err != nil {
74 79
 		c.ErrorLog("获取排班信息失败:%v", err)
@@ -81,10 +86,12 @@ func (c *DoctorsApiController) ScheduleAdvices() {
81 86
 			}
82 87
 		}
83 88
 		c.ServeSuccessJSON(map[string]interface{}{
84
-			"scheduals":  filtedScheduals,
85
-			"adminUser":  adminUser,
86
-			"hisAdvices": hisAdvices,
87
-			"config":     config,
89
+			"scheduals":      filtedScheduals,
90
+			"adminUser":      adminUser,
91
+			"hisAdvices":     hisAdvices,
92
+			"config":         config,
93
+			"project_config": project_config,
94
+			"project":        project,
88 95
 		})
89 96
 	}
90 97
 }

+ 5 - 0
controllers/manager_center_api_controller.go ファイルの表示

@@ -295,6 +295,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
295 295
 	drug_day := c.GetString("drug_day")
296 296
 	dose, _ := c.GetFloat("dose")
297 297
 	dose_unit := c.GetString("dose_unit")
298
+	total, _ := c.GetFloat("total")
298 299
 
299 300
 	min_price, _ := c.GetFloat("min_price")
300 301
 	hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
@@ -367,6 +368,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
367 368
 		MinPrice:                    min_price,
368 369
 		DoseUnit:                    dose_unit,
369 370
 		PrescribingNumberUnit:       prescribing_number_unit,
371
+		Total:                       total,
370 372
 	}
371 373
 
372 374
 	err := service.UpdateBaseDrugLib(drugLib)
@@ -1594,6 +1596,8 @@ func (c *ManagerCenterApiController) ModifyGoodInfo() {
1594 1596
 	packing_price, _ := c.GetFloat("packing_price")
1595 1597
 	default_count_unit := c.GetString("default_count_unit")
1596 1598
 	min_unit := c.GetString("min_unit")
1599
+	total, _ := c.GetFloat("total")
1600
+
1597 1601
 	adminUserInfo := c.GetAdminUserInfo()
1598 1602
 
1599 1603
 	goodInfo := models.GoodInfo{
@@ -1643,6 +1647,7 @@ func (c *ManagerCenterApiController) ModifyGoodInfo() {
1643 1647
 		PackingPrice:                packing_price,
1644 1648
 		DefaultCountUnit:            default_count_unit,
1645 1649
 		MinUnit:                     min_unit,
1650
+		Total:                       total,
1646 1651
 	}
1647 1652
 
1648 1653
 	totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id, good_name)

+ 10 - 4
controllers/mobile_api_controllers/doctor_advice_api_controller.go ファイルの表示

@@ -42,7 +42,11 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
42 42
 	//获取his医嘱数据
43 43
 	fmt.Println("date.un222222", date.Unix())
44 44
 	hisAdvices, _ := service.GetHisDoctorAdvices(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
45
+
46
+	project, _ := service.GetMobileHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
45 47
 	config, _ := service.GetHisDoctorConfig(orgID)
48
+	project_config, _ := service.GetHisProjectConfig(orgID)
49
+
46 50
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
47 51
 	if err != nil {
48 52
 		this.ErrorLog("获取排班信息失败:%v", err)
@@ -55,10 +59,12 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
55 59
 			}
56 60
 		}
57 61
 		this.ServeSuccessJSON(map[string]interface{}{
58
-			"scheduals":  filtedScheduals,
59
-			"adminUser":  adminUser,
60
-			"hisAdvices": hisAdvices,
61
-			"config":     config,
62
+			"scheduals":      filtedScheduals,
63
+			"adminUser":      adminUser,
64
+			"hisAdvices":     hisAdvices,
65
+			"config":         config,
66
+			"project":        project,
67
+			"project_config": project_config,
62 68
 		})
63 69
 	}
64 70
 }

+ 131 - 14
service/mobile_dialysis_service.go ファイルの表示

@@ -902,6 +902,7 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
902 902
 				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
903 903
 				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
904 904
 				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
905
+				Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
905 906
 				Where("status = 1 AND user_org_id = ?", orgID)
906 907
 			if scheduleDate != 0 {
907 908
 				db = db.Where("schedule_date = ?", scheduleDate)
@@ -919,6 +920,7 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
919 920
 				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
920 921
 				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
921 922
 				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, deliverWay, adminUserId, adminUserId).
923
+				Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
922 924
 				Where("status = 1 AND user_org_id = ?", orgID)
923 925
 			if scheduleDate != 0 {
924 926
 				db = db.Where("schedule_date = ?", scheduleDate)
@@ -938,6 +940,7 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
938 940
 				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
939 941
 				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
940 942
 				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
943
+				Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
941 944
 				Where("status = 1 AND user_org_id = ?", orgID)
942 945
 			if scheduleDate != 0 {
943 946
 				db = db.Where("schedule_date = ?", scheduleDate)
@@ -956,6 +959,7 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
956 959
 				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
957 960
 				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
958 961
 				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
962
+				Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
959 963
 				Where("status = 1 AND user_org_id = ?", orgID)
960 964
 			if scheduleDate != 0 {
961 965
 				db = db.Where("schedule_date = ?", scheduleDate)
@@ -968,6 +972,52 @@ func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, pat
968 972
 	return vms, err
969 973
 }
970 974
 
975
+func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
976
+	var vms []*HisMScheduleProjectVM
977
+	if patientType == 0 {
978
+		db := readDb.
979
+			Table("xt_schedule").
980
+			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
981
+			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
982
+				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
983
+			}).
984
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
985
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
986
+			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
987
+			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
988
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
989
+			}).
990
+			Where("status = 1 AND user_org_id = ?", orgID)
991
+		if scheduleDate != 0 {
992
+			db = db.Where("schedule_date = ?", scheduleDate)
993
+		}
994
+		err = db.Find(&vms).Error
995
+	}
996
+
997
+	if patientType > 0 {
998
+		db := readDb.
999
+			Table("xt_schedule").
1000
+			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1001
+			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1002
+				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1003
+			}).
1004
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1005
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1006
+			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1007
+			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1008
+			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1009
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1010
+			}).
1011
+			Where("status = 1 AND user_org_id = ?", orgID)
1012
+		if scheduleDate != 0 {
1013
+			db = db.Where("schedule_date = ?", scheduleDate)
1014
+		}
1015
+		err = db.Find(&vms).Error
1016
+	}
1017
+
1018
+	return vms, err
1019
+}
1020
+
971 1021
 func MobileCreateDialysisOrder(orgID int64, patientID int64, order *models.DialysisOrder) error {
972 1022
 	now := time.Now()
973 1023
 	tx := writeDb.Begin()
@@ -1775,26 +1825,48 @@ func GetLastDialysisPrescriptionByPatientId(orgid int64, patientid int64, record
1775 1825
 }
1776 1826
 
1777 1827
 type HisMScheduleDoctorAdviceVM struct {
1778
-	ID                  int64                            `gorm:"column:id" json:"id"`
1779
-	UserOrgId           int64                            `gorm:"column:user_org_id" json:"user_org_id"`
1780
-	PartitionId         int64                            `gorm:"column:partition_id" json:"partition_id"`
1781
-	BedId               int64                            `gorm:"column:bed_id" json:"bed_id"`
1782
-	PatientId           int64                            `gorm:"column:patient_id" json:"patient_id"`
1783
-	ScheduleDate        int64                            `gorm:"column:schedule_date" json:"schedule_date"`
1784
-	ScheduleType        int64                            `gorm:"column:schedule_type" json:"schedule_type"`
1785
-	ModeId              int64                            `gorm:"column:mode_id" json:"mode_id"`
1786
-	Status              int64                            `gorm:"column:status" json:"status"`
1787
-	DialysisOrder       *MDialysisOrderVM                `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
1788
-	SchedualPatient     *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1789
-	DeviceNumber        *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
1790
-	Prescription        *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
1791
-	HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
1828
+	ID                     int64                            `gorm:"column:id" json:"id"`
1829
+	UserOrgId              int64                            `gorm:"column:user_org_id" json:"user_org_id"`
1830
+	PartitionId            int64                            `gorm:"column:partition_id" json:"partition_id"`
1831
+	BedId                  int64                            `gorm:"column:bed_id" json:"bed_id"`
1832
+	PatientId              int64                            `gorm:"column:patient_id" json:"patient_id"`
1833
+	ScheduleDate           int64                            `gorm:"column:schedule_date" json:"schedule_date"`
1834
+	ScheduleType           int64                            `gorm:"column:schedule_type" json:"schedule_type"`
1835
+	ModeId                 int64                            `gorm:"column:mode_id" json:"mode_id"`
1836
+	Status                 int64                            `gorm:"column:status" json:"status"`
1837
+	DialysisOrder          *MDialysisOrderVM                `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
1838
+	SchedualPatient        *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1839
+	DeviceNumber           *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
1840
+	Prescription           *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
1841
+	HisDoctorAdviceInfo    []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
1842
+	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
1792 1843
 }
1793 1844
 
1794 1845
 func (HisMScheduleDoctorAdviceVM) TableName() string {
1795 1846
 	return "xt_schedule"
1796 1847
 }
1797 1848
 
1849
+type HisMScheduleProjectVM struct {
1850
+	ID                     int64                            `gorm:"column:id" json:"id"`
1851
+	UserOrgId              int64                            `gorm:"column:user_org_id" json:"user_org_id"`
1852
+	PartitionId            int64                            `gorm:"column:partition_id" json:"partition_id"`
1853
+	BedId                  int64                            `gorm:"column:bed_id" json:"bed_id"`
1854
+	PatientId              int64                            `gorm:"column:patient_id" json:"patient_id"`
1855
+	ScheduleDate           int64                            `gorm:"column:schedule_date" json:"schedule_date"`
1856
+	ScheduleType           int64                            `gorm:"column:schedule_type" json:"schedule_type"`
1857
+	ModeId                 int64                            `gorm:"column:mode_id" json:"mode_id"`
1858
+	Status                 int64                            `gorm:"column:status" json:"status"`
1859
+	DialysisOrder          *MDialysisOrderVM                `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
1860
+	SchedualPatient        *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1861
+	DeviceNumber           *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
1862
+	Prescription           *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
1863
+	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
1864
+}
1865
+
1866
+func (HisMScheduleProjectVM) TableName() string {
1867
+	return "xt_schedule"
1868
+}
1869
+
1798 1870
 func GetHisDoctorConfig(orgid int64) (models.XtHisConfig, error) {
1799 1871
 	config := models.XtHisConfig{}
1800 1872
 	err := XTReadDB().Model(&config).Where("user_org_id = ? and status =1", orgid).Find(&config).Error
@@ -2121,3 +2193,48 @@ func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64
2121 2193
 
2122 2194
 	return
2123 2195
 }
2196
+
2197
+func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
2198
+	var vms []*HisMScheduleProjectVM
2199
+	if patientType == 0 {
2200
+		db := readDb.
2201
+			Table("xt_schedule").
2202
+			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2203
+			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2204
+				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2205
+			}).
2206
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2207
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2208
+			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2209
+			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2210
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2211
+			}).Where("status = 1 AND user_org_id = ?", orgID)
2212
+		if scheduleDate != 0 {
2213
+			db = db.Where("schedule_date = ?", scheduleDate)
2214
+		}
2215
+		err = db.Find(&vms).Error
2216
+	}
2217
+
2218
+	if patientType > 0 {
2219
+		db := readDb.
2220
+			Table("xt_schedule").
2221
+			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2222
+			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2223
+				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2224
+			}).
2225
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2226
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2227
+			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2228
+			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
2229
+			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2230
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2231
+			}).
2232
+			Where("status = 1 AND user_org_id = ?", orgID)
2233
+		if scheduleDate != 0 {
2234
+			db = db.Where("schedule_date = ?", scheduleDate)
2235
+		}
2236
+		err = db.Find(&vms).Error
2237
+	}
2238
+
2239
+	return vms, err
2240
+}