Bladeren bron

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

csx 4 jaren geleden
bovenliggende
commit
ef1ce58678

+ 7 - 1
controllers/dialysis_record_api_controller.go Bestand weergeven

265
 
265
 
266
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.CurrentOrgId)
266
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.CurrentOrgId)
267
 
267
 
268
-	his_advices, _ := service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
268
+	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.CurrentOrgId)
269
+
270
+	var his_advices []*models.HisDoctorAdviceInfo
271
+	if is_open_config.IsOpen == 1 {
272
+		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
273
+	}
269
 
274
 
270
 	returnData := map[string]interface{}{
275
 	returnData := map[string]interface{}{
271
 		"patient":                     patient,
276
 		"patient":                     patient,
292
 		"headNurses":                  headNurses,
297
 		"headNurses":                  headNurses,
293
 		"system_prescribe":            systemDialysisPrescribe,
298
 		"system_prescribe":            systemDialysisPrescribe,
294
 		"his_advices":                 his_advices,
299
 		"his_advices":                 his_advices,
300
+		"is_open_config":              is_open_config,
295
 	}
301
 	}
296
 	this.ServeSuccessJSON(returnData)
302
 	this.ServeSuccessJSON(returnData)
297
 
303
 

+ 52 - 0
controllers/his_api_controller.go Bestand weergeven

64
 
64
 
65
 	//beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
65
 	//beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
66
 
66
 
67
+	beego.Router("/api/hisprescription/get", &DialysisApiController{}, "Get:GetLastOrNextHisPrescription")
68
+
69
+	beego.Router("/api/callhisprescription/get", &DialysisApiController{}, "Get:GetCallHisPrescription")
70
+
67
 }
71
 }
68
 
72
 
69
 func (c *HisApiController) GetHisPatientList() {
73
 func (c *HisApiController) GetHisPatientList() {
2115
 		"doctors": doctors,
2119
 		"doctors": doctors,
2116
 	})
2120
 	})
2117
 }
2121
 }
2122
+
2123
+func (this *DialysisApiController) GetLastOrNextHisPrescription() {
2124
+	change_type, _ := this.GetInt64("type", 0)
2125
+	record_date := this.GetString("record_time")
2126
+	patient_id, _ := this.GetInt64("patient_id", 0)
2127
+
2128
+	timeLayout := "2006-01-02"
2129
+	loc, _ := time.LoadLocation("Local")
2130
+	theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
2131
+	record_time := theAdviceRecordTime.Unix()
2132
+	adminUserInfo := this.GetAdminUserInfo()
2133
+	prescriptions, err := service.GetHisPrescriptionByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id)
2134
+	if err == nil {
2135
+		if len(prescriptions) == 0 {
2136
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
2137
+			return
2138
+		} else {
2139
+			this.ServeSuccessJSON(map[string]interface{}{
2140
+				"prescriptions": prescriptions,
2141
+			})
2142
+			return
2143
+		}
2144
+	} else {
2145
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2146
+		return
2147
+	}
2148
+}
2149
+
2150
+func (this *DialysisApiController) GetCallHisPrescription() {
2151
+	patient_id, _ := this.GetInt64("patient_id", 0)
2152
+	timeLayout := "2006-01-02"
2153
+	loc, _ := time.LoadLocation("Local")
2154
+	start_time := this.GetString("start_time")
2155
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2156
+	end_time := this.GetString("end_time")
2157
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2158
+	adminUserInfo := this.GetAdminUserInfo()
2159
+	prescriptions, err := service.GetCallHisPrescriptions(startime.Unix(), endtime.Unix(), adminUserInfo.CurrentOrgId, patient_id)
2160
+	if err == nil {
2161
+		this.ServeSuccessJSON(map[string]interface{}{
2162
+			"prescriptions": prescriptions,
2163
+		})
2164
+		return
2165
+	} else {
2166
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2167
+		return
2168
+	}
2169
+}

+ 1 - 1
controllers/new_mobile_api_controllers/good_types.json Bestand weergeven

13
       "status": 1,
13
       "status": 1,
14
       "type": 1,
14
       "type": 1,
15
       "number": 1,
15
       "number": 1,
16
-      "out_stock": 1,
16
+      "out_stock": 1
17
     },
17
     },
18
     {
18
     {
19
       "id": 10001,
19
       "id": 10001,

+ 1 - 0
controllers/new_mobile_api_controllers/mobile_regist_controller.go Bestand weergeven

1266
 			OrgId:    org.Id,
1266
 			OrgId:    org.Id,
1267
 			Status:   1,
1267
 			Status:   1,
1268
 			Type:     1,
1268
 			Type:     1,
1269
+			OutStock: item.OutStock,
1269
 		}
1270
 		}
1270
 		service.AddSigleGoodType(good_type)
1271
 		service.AddSigleGoodType(good_type)
1271
 	}
1272
 	}

Diff onderdrukt omdat het te groot bestand
+ 624 - 288
controllers/patient_api_controller.go


+ 4 - 1
controllers/verify_login_controller.go Bestand weergeven

252
 							if len(ids) == 0 {
252
 							if len(ids) == 0 {
253
 								ids = purview_ids
253
 								ids = purview_ids
254
 							} else {
254
 							} else {
255
-								ids = ids + "," + purview_ids
255
+								if len(purview_ids) > 0 {
256
+									ids = ids + "," + purview_ids
257
+								}
256
 							}
258
 							}
257
 
259
 
258
 							if len(system_ids) > 0 {
260
 							if len(system_ids) > 0 {
259
 								ids = ids + "," + system_ids
261
 								ids = ids + "," + system_ids
260
 							}
262
 							}
261
 						}
263
 						}
264
+
262
 						if len(ids) != 0 {
265
 						if len(ids) != 0 {
263
 							pruviews, _ = service.GetPurviewById(CompressStr(ids))
266
 							pruviews, _ = service.GetPurviewById(CompressStr(ids))
264
 							for _, item := range pruviews {
267
 							for _, item := range pruviews {

+ 1 - 0
models/vm_models.go Bestand weergeven

348
 	Status   int64  `gorm:"column:status" json:"status"`
348
 	Status   int64  `gorm:"column:status" json:"status"`
349
 	Type     int64  `gorm:"column:type" json:"type"`
349
 	Type     int64  `gorm:"column:type" json:"type"`
350
 	Number   int64  `gorm:"column:number" json:"number"`
350
 	Number   int64  `gorm:"column:number" json:"number"`
351
+	OutStock int64  `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
351
 }
352
 }
352
 
353
 
353
 func (VMGoodsType) TableName() string {
354
 func (VMGoodsType) TableName() string {

+ 17 - 0
service/dialysis_service.go Bestand weergeven

320
 	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
320
 	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
321
 	return err
321
 	return err
322
 }
322
 }
323
+
324
+func ExceHidDoctorAdviceById(m *models.HisDoctorAdviceInfo, id int64, patientId int64) error {
325
+	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
326
+	return err
327
+}
328
+
323
 func CheckDoctorAdviceById(m *models.DoctorAdvice, id int64, patientId int64) error {
329
 func CheckDoctorAdviceById(m *models.DoctorAdvice, id int64, patientId int64) error {
324
 	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND (id = ? Or parent_id=?) AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
330
 	err := writeDb.Model(&models.DoctorAdvice{}).Where("patient_id = ? AND (id = ? Or parent_id=?) AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
325
 	return err
331
 	return err
326
 }
332
 }
327
 
333
 
334
+func CheckHisDoctorAdviceById(m *models.HisDoctorAdviceInfo, id int64, patientId int64) error {
335
+	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?) AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
336
+	return err
337
+}
338
+
328
 func CreateMonitor(m *models.MonitoringRecord) (err error) {
339
 func CreateMonitor(m *models.MonitoringRecord) (err error) {
329
 	return writeDb.Create(m).Error
340
 	return writeDb.Create(m).Error
330
 }
341
 }
1122
 	return doctorAdvice, err
1133
 	return doctorAdvice, err
1123
 }
1134
 }
1124
 
1135
 
1136
+func GetHisExecutionDoctors(orgid int64, patientid int64, id int64) (doctorAdvice []*models.HisDoctorAdviceInfo, err error) {
1137
+
1138
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? and patient_id = ? AND (id = ? Or parent_id=?) and status = 1", orgid, patientid, id, id).Find(&doctorAdvice).Error
1139
+	return doctorAdvice, err
1140
+}
1141
+
1125
 func FindHisDoctorAdviceById(orgID int64, id int64) (advice models.HisDoctorAdviceInfo, err error) {
1142
 func FindHisDoctorAdviceById(orgID int64, id int64) (advice models.HisDoctorAdviceInfo, err error) {
1126
 	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1143
 	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1127
 	return
1144
 	return

+ 73 - 0
service/his_service.go Bestand weergeven

720
 	err := XTWriteDB().Model(&patient).Where("patient_id = ? and record_date = ? and user_org_id = ? and status = 1", patientid, recorddate, orgid).Updates(map[string]interface{}{"is_return": 3}).Error
720
 	err := XTWriteDB().Model(&patient).Where("patient_id = ? and record_date = ? and user_org_id = ? and status = 1", patientid, recorddate, orgid).Updates(map[string]interface{}{"is_return": 3}).Error
721
 	return patient, err
721
 	return patient, err
722
 }
722
 }
723
+
724
+type VMOtherHisPrescriptionInfo struct {
725
+	ID                int64                `gorm:"column:id" json:"id" form:"id"`
726
+	UserOrgId         int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
727
+	RecordDate        int64                `gorm:"column:record_date" json:"record_date" form:"record_date"`
728
+	PatientId         int64                `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
729
+	Status            int64                `gorm:"column:status" json:"status" form:"status"`
730
+	CheckGroup        []int64              `gorm:"-" json:"check_group" form:"check_group"`
731
+	VMHisPrescription []*VMHisPrescription `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId" json:"prescriptions"`
732
+}
733
+
734
+func (VMOtherHisPrescriptionInfo) TableName() string {
735
+	return "his_prescription_info"
736
+}
737
+
738
+type VMHisPrescription struct {
739
+	ID                     int64                            `gorm:"column:id" json:"id" form:"id"`
740
+	UserOrgId              int64                            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
741
+	RecordDate             int64                            `gorm:"column:record_date" json:"record_date" form:"record_date"`
742
+	PatientId              int64                            `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
743
+	Status                 int64                            `gorm:"column:status" json:"status" form:"status"`
744
+	OrderStatus            int64                            `gorm:"column:order_status" json:"order_status" form:"order_status"`
745
+	BatchNumber            string                           `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
746
+	PrescriptionNumber     string                           `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
747
+	Type                   int64                            `gorm:"column:type" json:"type" form:"type"`
748
+	HisDoctorAdviceInfo    []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"doctor_advice"`
749
+	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
750
+}
751
+
752
+func (VMHisPrescription) TableName() string {
753
+	return "his_prescription"
754
+}
755
+
756
+func GetHisPrescriptionByType(change_type int64, record_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
757
+	if change_type == 1 { //根据日期取出上一方数据
758
+		var Id AdviceDate
759
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
760
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ?", patient_id, org_id, Id.RecordDate).
761
+			Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
762
+				return db.Where("status = 1 AND user_org_id = ?", org_id).
763
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
764
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
765
+						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
766
+					})
767
+			}).Find(&advice).Error
768
+
769
+	} else if change_type == 2 {
770
+		var Id AdviceDate
771
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date > ?", patient_id, org_id, record_time).Select("record_date").Group("record_date").Order("record_date desc").Scan(&Id).Error
772
+		err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ?", patient_id, org_id, Id.RecordDate).
773
+			Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
774
+				return db.Where("status = 1 AND user_org_id = ?", org_id).
775
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
776
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
777
+						return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
778
+					})
779
+			}).Find(&advice).Error
780
+	}
781
+	return
782
+}
783
+
784
+func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
785
+	err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date >= ? AND record_date <= ?", patient_id, org_id, start_time, end_time).
786
+		Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
787
+			return db.Where("status = 1 AND user_org_id = ?", org_id).
788
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
789
+				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
790
+					return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
791
+				})
792
+		}).Find(&advice).Error
793
+
794
+	return
795
+}

+ 6 - 0
service/patient_service.go Bestand weergeven

710
 	err = readDb.Model(&models.DoctorAdvice{}).Where("id = ? and user_org_id=? and status = 1", id, orgID).First(&advice).Error
710
 	err = readDb.Model(&models.DoctorAdvice{}).Where("id = ? and user_org_id=? and status = 1", id, orgID).First(&advice).Error
711
 	return
711
 	return
712
 }
712
 }
713
+
714
+func FindHisDoctorAdvice(orgID, id int64) (advice models.HisDoctorAdviceInfo, err error) {
715
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("id = ? and user_org_id=? and status = 1", id, orgID).First(&advice).Error
716
+	return
717
+}
718
+
713
 func FindDoctorAdviceByGroupNo(orgID, groupNo int64) (advice models.DoctorAdvice, err error) {
719
 func FindDoctorAdviceByGroupNo(orgID, groupNo int64) (advice models.DoctorAdvice, err error) {
714
 	err = readDb.Model(&models.DoctorAdvice{}).Where("groupno = ? and user_org_id=? and status = 1", groupNo, orgID).First(&advice).Error
720
 	err = readDb.Model(&models.DoctorAdvice{}).Where("groupno = ? and user_org_id=? and status = 1", groupNo, orgID).First(&advice).Error
715
 	return
721
 	return