Przeglądaj źródła

库存调拨修改

28169 2 lat temu
rodzic
commit
15af3831a8

+ 42 - 0
controllers/dialysis_api_controller.go Wyświetl plik

@@ -109,6 +109,8 @@ func DialysisApiRegistRouters() {
109 109
 	beego.Router("/api/schedule/excutiondoctoradvicebyid", &DialysisApiController{}, "Get:ExcutionDoctorAdviceById")
110 110
 
111 111
 	beego.Router("/api/patient/getdialysisadvicetoday", &DialysisApiController{}, "Get:GetDialysisAdviceToday")
112
+
113
+	beego.Router("/api/schedule/getmobileschedulelist", &DialysisApiController{}, "Get:GetMobileScheduleList")
112 114
 }
113 115
 
114 116
 func (c *DialysisApiController) GetQueueCall() {
@@ -654,6 +656,23 @@ func (c *DialysisApiController) PostPrescription() {
654 656
 
655 657
 		updateErr := service.UpDateDialysisPrescription(&prescription)
656 658
 
659
+		//修改处方
660
+		if adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 10340 {
661
+			// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
662
+			advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
663
+			if advicePrescription.ID > 0 {
664
+
665
+				service.UpdateDoctorAdvieById(advicePrescription.ID, prescribing_number)
666
+
667
+				key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":doctor_advices"
668
+				redis := service.RedisClient()
669
+				defer redis.Close()
670
+				//清空key 值
671
+				redis.Set(key, "", time.Second)
672
+				keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":advice_list_all"
673
+				redis.Set(keyOne, "", time.Second)
674
+			}
675
+		}
657 676
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
658 677
 		redis := service.RedisClient()
659 678
 		defer redis.Close()
@@ -5761,3 +5780,26 @@ func (this *DialysisApiController) GetDialysisAdviceToday() {
5761 5780
 		return
5762 5781
 	}
5763 5782
 }
5783
+
5784
+func (this *DialysisApiController) GetMobileScheduleList() {
5785
+
5786
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5787
+	schedule, _ := service.GetMobileScheduleList(orgId)
5788
+
5789
+	if len(schedule) > 0 {
5790
+		for _, its := range schedule {
5791
+			prescription, _ := service.GetPrescriptionList(its.PatientId, its.ScheduleDate, its.UserOrgId)
5792
+			its.DialysisPrescription = prescription
5793
+			monitor, _ := service.GetLastMonitorRecordList(its.PatientId, its.ScheduleDate, its.UserOrgId)
5794
+			its.MonitoringRecord = monitor
5795
+			after, _ := service.GetLastAfter(its.PatientId, its.ScheduleDate, its.UserOrgId)
5796
+			its.XtAssessmentAfterDislysis = after
5797
+		}
5798
+	}
5799
+
5800
+	this.ServeSuccessJSON(map[string]interface{}{
5801
+		"schedule": schedule,
5802
+	})
5803
+	return
5804
+
5805
+}

+ 25 - 4
controllers/mobile_api_controllers/dialysis_api_controller.go Wyświetl plik

@@ -1658,6 +1658,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1658 1658
 
1659 1659
 		//长沙南雅医院,自动生成抗凝剂的临时处方
1660 1660
 		if adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 10340 {
1661
+
1661 1662
 			advice := models.DoctorAdvice{
1662 1663
 				UserOrgId:             adminUserInfo.Org.Id,
1663 1664
 				PatientId:             id,
@@ -1734,19 +1735,20 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1734 1735
 				break
1735 1736
 			}
1736 1737
 			//advice.AdviceDesc = "首剂" + strconv.FormatFloat(anticoagulant_shouji, 'f', -1, 64) + "维持" + strconv.FormatFloat(anticoagulant_weichi, 'f', -1, 64) + "总量" + strconv.FormatFloat(anticoagulant_zongliang, 'f', -1, 64)
1737
-			if appRole.UserType == 2 || appRole.UserType == 1 {
1738
+
1739
+			if appRole.UserType == 2 || appRole.UserType == 1 || appRole.UserType == 4 {
1738 1740
 				advice.AdviceDoctor = appRole.AdminUserId
1739 1741
 			}
1740 1742
 
1741 1743
 			// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
1742 1744
 			advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.Org.Id, id, recordDate.Unix())
1743
-			if advicePrescription.ID > 0 && (anticoagulant == 3 || anticoagulant == 5 || anticoagulant == 7) {
1745
+			if advicePrescription.ID > 0 && (anticoagulant == 3 || anticoagulant == 6 || anticoagulant == 7) {
1744 1746
 				advice.AdviceName = "低分子肝素钠注射液"
1745 1747
 				// 修改患者临时医嘱里的抗凝剂医嘱
1746 1748
 				advice.ID = advicePrescription.ID
1747 1749
 				service.UpdateDoctorAdvice(&advice)
1748 1750
 			} else {
1749
-				if anticoagulant == 3 || anticoagulant == 5 || anticoagulant == 7 {
1751
+				if anticoagulant == 3 || anticoagulant == 6 || anticoagulant == 7 {
1750 1752
 					advice.AdviceName = "低分子肝素钠注射液"
1751 1753
 					// 新增患者临时医嘱里的抗凝剂医嘱
1752 1754
 					service.CreateDoctorAdvice(&advice)
@@ -1854,6 +1856,25 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1854 1856
 		prescription.ID = dialysisPrescription.ID
1855 1857
 
1856 1858
 		err := service.UpDateDialysisPrescription(&prescription)
1859
+
1860
+		//修改处方
1861
+		if adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 10340 {
1862
+			// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
1863
+			advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.Org.Id, id, recordDate.Unix())
1864
+			if advicePrescription.ID > 0 {
1865
+
1866
+				service.UpdateDoctorAdvieById(advicePrescription.ID, prescribing_number)
1867
+
1868
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":doctor_advices"
1869
+				redis := service.RedisClient()
1870
+				defer redis.Close()
1871
+				//清空key 值
1872
+				redis.Set(key, "", time.Second)
1873
+				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":advice_list_all"
1874
+				redis.Set(keyOne, "", time.Second)
1875
+			}
1876
+		}
1877
+
1857 1878
 		//获取key,清空redis
1858 1879
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1859 1880
 		redis := service.RedisClient()
@@ -3289,7 +3310,7 @@ func (c *DialysisAPIController) PostSolution() {
3289 3310
 			break
3290 3311
 		}
3291 3312
 		//advice.AdviceDesc = "首剂" + strconv.FormatFloat(anticoagulant_shouji, 'f', -1, 64) + "维持" + strconv.FormatFloat(anticoagulant_weichi, 'f', -1, 64) + "总量" + strconv.FormatFloat(anticoagulant_zongliang, 'f', -1, 64)
3292
-		if appRole.UserType == 2 || appRole.UserType == 1 {
3313
+		if appRole.UserType == 2 || appRole.UserType == 1 || appRole.UserType == 4 {
3293 3314
 			advice.AdviceDoctor = appRole.AdminUserId
3294 3315
 		}
3295 3316
 

+ 24 - 0
models/schedule_models.go Wyświetl plik

@@ -647,3 +647,27 @@ type MySchedule struct {
647 647
 func (MySchedule) TableName() string {
648 648
 	return "xt_schedule"
649 649
 }
650
+
651
+type MyVmBloodSchedule struct {
652
+	ID                        int64                      `gorm:"column:id" json:"id" form:"id"`
653
+	UserOrgId                 int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
654
+	PartitionId               int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
655
+	BedId                     int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
656
+	PatientId                 int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
657
+	ScheduleDate              int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
658
+	ScheduleType              int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
659
+	ScheduleWeek              int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
660
+	ModeId                    int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
661
+	Status                    int64                      `gorm:"column:status" json:"status" form:"status"`
662
+	CreatedTime               int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
663
+	UpdatedTime               int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
664
+	IsExport                  int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
665
+	SchedualPatient           *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
666
+	DialysisPrescription      DialysisPrescription       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"dialysis_prescription"`
667
+	XtAssessmentAfterDislysis XtAssessmentAfterDislysis  `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_assesment_after_dislysis"`
668
+	MonitoringRecord          MonitoringRecord           `gorm:"ForeignKey:PatientId,MonitoringDate;AssociationForeignKey:PatientId,ScheduleDate" json:"monitor_record"`
669
+}
670
+
671
+func (MyVmBloodSchedule) TableName() string {
672
+	return "xt_schedule"
673
+}

+ 1 - 1
service/dialysis_solution_service.go Wyświetl plik

@@ -234,7 +234,7 @@ func GetDialysisAdviceSchedulist(orgID int64, schedule_type int64, partition_id
234 234
 	}
235 235
 	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
236 236
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
237
-		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
237
+		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ? and advice_type = 2", orgID, scheduleDate).
238 238
 		Preload("HisDoctorAdvice", func(db *gorm.DB) *gorm.DB {
239 239
 			return db.Where("user_org_id = ? and status = 1 and advice_date = ?", orgID, scheduleDate).Preload("Drug", "org_id =? and status = 1", orgID)
240 240
 		}).Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error

+ 28 - 1
service/gobal_config_service.go Wyświetl plik

@@ -237,7 +237,7 @@ func UpdateHisStockPriceRecord(config *models.HisStockPriceConfig) (err error) {
237 237
 	return
238 238
 }
239 239
 
240
-//TODO:项目开关
240
+// TODO:项目开关
241 241
 func FindXTHisProjectByOrgId(org_id int64) (err error, config models.XtHisProjectConfig) {
242 242
 	err = readDb.Model(&models.XtHisProjectConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
243 243
 	return
@@ -1009,3 +1009,30 @@ func GetAllBaseDrugListTwenty(orgid int64) (drug []*models.BaseDrugLibTwenty, er
1009 1009
 	err = XTReadDB().Model(&drug).Where("org_id = ? and status = 1 AND  find_in_set('停用',drug_status) = 0", orgid).Find(&drug).Error
1010 1010
 	return drug, err
1011 1011
 }
1012
+
1013
+func GetMobileScheduleList(orgid int64) (schedule []*models.MyVmBloodSchedule, err error) {
1014
+
1015
+	err = XTReadDB().Where("user_org_id = ? and status= 1 and schedule_date>=1667232000 and schedule_date<=1669737600", orgid).Preload("SchedualPatient", "user_org_id = ? and status = 1", orgid).Find(&schedule).Error
1016
+	return schedule, err
1017
+}
1018
+
1019
+func GetPrescriptionList(patient_id int64, schedule_date int64, user_org_id int64) (models.DialysisPrescription, error) {
1020
+
1021
+	prescription := models.DialysisPrescription{}
1022
+	err := XTReadDB().Where("patient_id = ? and record_date =? and user_org_id = ? and status =1", patient_id, schedule_date, user_org_id).Find(&prescription).Error
1023
+	return prescription, err
1024
+}
1025
+
1026
+func GetLastMonitorRecordList(patient_id int64, schedule_date int64, user_org_id int64) (models.MonitoringRecord, error) {
1027
+
1028
+	record := models.MonitoringRecord{}
1029
+	err := XTReadDB().Where("patient_id =? and monitoring_date = ? and user_org_id = ? and status = 1", patient_id, schedule_date, user_org_id).Last(&record).Error
1030
+	return record, err
1031
+}
1032
+
1033
+func GetLastAfter(patient_id int64, schedule_date int64, user_org_id int64) (models.XtAssessmentAfterDislysis, error) {
1034
+
1035
+	dislysis := models.XtAssessmentAfterDislysis{}
1036
+	err := XTReadDB().Where("patient_id = ? and assessment_date = ? and user_org_id =? and status= 1", patient_id, schedule_date, user_org_id).Find(&dislysis).Error
1037
+	return dislysis, err
1038
+}