Browse Source

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

XMLWAN 4 years ago
parent
commit
488f32df31

+ 30 - 0
controllers/dialysis_api_controller.go View File

@@ -56,6 +56,8 @@ func DialysisApiRegistRouters() {
56 56
 
57 57
 	beego.Router("/api/func_per/get", &DialysisApiController{}, "Get:GetFuncPurview")
58 58
 
59
+	beego.Router("/api/doctoradvice/get", &DialysisApiController{}, "Get:GetLastOrNextDoctorAdvice")
60
+
59 61
 }
60 62
 
61 63
 func (c *DialysisApiController) PostPrescription() {
@@ -5108,3 +5110,31 @@ func (this *DialysisApiController) GetFuncPurview() {
5108 5110
 		})
5109 5111
 	}
5110 5112
 }
5113
+
5114
+func (this *DialysisApiController) GetLastOrNextDoctorAdvice() {
5115
+	change_type, _ := this.GetInt64("type", 0)
5116
+	record_date := this.GetString("record_time")
5117
+	patient_id, _ := this.GetInt64("patient_id", 0)
5118
+
5119
+	timeLayout := "2006-01-02"
5120
+	loc, _ := time.LoadLocation("Local")
5121
+	theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
5122
+	record_time := theAdviceRecordTime.Unix()
5123
+	adminUserInfo := this.GetAdminUserInfo()
5124
+	advices, sch, err := service.GetDoctorAdviceByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id)
5125
+	if err == nil {
5126
+		if len(advices) == 0 {
5127
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
5128
+			return
5129
+		} else {
5130
+			this.ServeSuccessJSON(map[string]interface{}{
5131
+				"advices":  advices,
5132
+				"schedule": sch,
5133
+			})
5134
+			return
5135
+		}
5136
+	} else {
5137
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
5138
+		return
5139
+	}
5140
+}

+ 15 - 11
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -334,6 +334,10 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
334 334
 
335 335
 	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 {
336 336
 		dewater_amount = dewater_amount * 1000
337
+
338
+		if dewater_amount < 0 {
339
+			dewater_amount = 0
340
+		}
337 341
 	}
338 342
 
339 343
 	if dialysistype == 1 {
@@ -550,17 +554,17 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
550 554
 			}
551 555
 		}
552 556
 
553
-		if dialysisPrescribe != nil {
554
-			dialysisPrescribe.UpdatedTime = time.Now().Unix()
555
-			dialysisPrescribe.RecordDate = theAssessmentDateTime
556
-			dialysisPrescribe.DewaterAmount = dewater_amount
557
-			dialysisPrescribe.TargetUltrafiltration = dewater_amount
558
-			dialysisPrescribe.Status = 1
559
-			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
560
-			if updateErr != nil {
561
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
562
-			}
563
-		}
557
+		//if dialysisPrescribe != nil {
558
+		//	dialysisPrescribe.UpdatedTime = time.Now().Unix()
559
+		//	dialysisPrescribe.RecordDate = theAssessmentDateTime
560
+		//	dialysisPrescribe.DewaterAmount = dewater_amount
561
+		//	dialysisPrescribe.TargetUltrafiltration = dewater_amount
562
+		//	dialysisPrescribe.Status = 1
563
+		//	updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
564
+		//	if updateErr != nil {
565
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
566
+		//	}
567
+		//}
564 568
 
565 569
 		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
566 570
 		if getPEErr != nil {

+ 0 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -2857,7 +2857,6 @@ func (this *DialysisAPIController) StartDialysis() {
2857 2857
 				} else {
2858 2858
 
2859 2859
 					if prescription.Niprocart > 0 {
2860
-
2861 2860
 						warehouseOutInfo := &models.WarehouseOutInfo{
2862 2861
 							WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
2863 2862
 							WarehouseOutId:          warehouseOut.ID,

+ 4 - 0
enums/error_code.go View File

@@ -200,6 +200,8 @@ const ( // ErrorCode
200 200
 	ErrorCodeExportError = 20050
201 201
 
202 202
 	ErrorCodeOrgNoPatient = 20051
203
+
204
+	ErrorCodeDoctorAdviceEmpty = 20052
203 205
 )
204 206
 
205 207
 var ErrCodeMsgs = map[int]string{
@@ -397,6 +399,8 @@ var ErrCodeMsgs = map[int]string{
397 399
 	ErrorCodeExportError: "导入出错,请下载并查看相关日志",
398 400
 
399 401
 	ErrorCodeOrgNoPatient: "暂无病人",
402
+
403
+	ErrorCodeDoctorAdviceEmpty: "没有更多了",
400 404
 }
401 405
 
402 406
 type SGJError struct {

+ 1 - 0
models/dialysis.go View File

@@ -289,6 +289,7 @@ type PredialysisEvaluationList struct {
289 289
 	CreatedTime            int64   `gorm:"column:created_time" json:"created_time"`
290 290
 	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
291 291
 	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
292
+	DryWeight              float64 `gorm:"column:dry_weight" json:"dry_weight"`
292 293
 }
293 294
 
294 295
 func (PredialysisEvaluationList) TableName() string {

+ 73 - 0
service/doctor_advice_service.go View File

@@ -270,3 +270,76 @@ func UpdateDataTwo(id int64, model models.ConfigViewModel) error {
270 270
 	err := writeDb.Model(&model).Where("id=?", id).Update(map[string]interface{}{"name": model.Name, "orders": model.Order, "remark": model.Remark, "update_time": time.Now().Unix()}).Error
271 271
 	return err
272 272
 }
273
+
274
+type AdviceDate struct {
275
+	RecordDate int64
276
+}
277
+
278
+type DoctorAdvice struct {
279
+	ID                    int64           `gorm:"column:id" json:"id" form:"id"`
280
+	GroupNo               int64           `gorm:"column:groupno" json:"groupno" form:"groupno"`
281
+	UserOrgId             int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
282
+	PatientId             int64           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
283
+	AdviceType            int64           `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
284
+	AdviceDate            int64           `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
285
+	StartTime             int64           `gorm:"column:start_time" json:"start_time" form:"start_time"`
286
+	AdviceName            string          `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
287
+	AdviceDesc            string          `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
288
+	ReminderDate          int64           `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
289
+	SingleDose            float64         `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
290
+	SingleDoseUnit        string          `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
291
+	DrugSpec              float64         `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
292
+	DrugSpecUnit          string          `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
293
+	PrescribingNumber     float64         `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
294
+	PrescribingNumberUnit string          `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
295
+	DeliveryWay           string          `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
296
+	ExecutionFrequency    string          `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
297
+	AdviceDoctor          int64           `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
298
+	Status                int64           `gorm:"column:status" json:"status" form:"status"`
299
+	CreatedTime           int64           `gorm:"column:created_time" json:"created_time" form:"created_time"`
300
+	UpdatedTime           int64           `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
301
+	AdviceAffirm          string          `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
302
+	Remark                string          `gorm:"column:remark" json:"remark" form:"remark"`
303
+	StopTime              int64           `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
304
+	StopReason            string          `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
305
+	StopDoctor            int64           `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
306
+	StopState             int64           `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
307
+	ParentId              int64           `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
308
+	ExecutionTime         int64           `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
309
+	ExecutionStaff        int64           `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
310
+	ExecutionState        int64           `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
311
+	Checker               int64           `gorm:"column:checker" json:"checker" form:"checker"`
312
+	RecordDate            int64           `gorm:"column:record_date" json:"record_date"`
313
+	DialysisOrderId       int64           `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
314
+	CheckTime             int64           `gorm:"column:check_time" json:"check_time" form:"check_time"`
315
+	CheckState            int64           `gorm:"column:check_state" json:"check_state" form:"check_state"`
316
+	AdviceId              int64           `gorm:"-"`
317
+	RemindType            int64           `gorm:"column:remind_type" json:"remind_type"`
318
+	FrequencyType         int64           `gorm:"column:frequency_type" json:"frequency_type"`
319
+	DayCount              int64           `gorm:"column:day_count" json:"day_count"`
320
+	WeekDay               string          `gorm:"column:week_day" json:"week_day"`
321
+	DoctorAdvice          []*DoctorAdvice `gorm:"ForeignKey:ParentId;AssociationForeignKey:ID" json:"children"`
322
+	TemplateId            string          `gorm:"column:template_id" json:"template_id"`
323
+	Modifier              int64           `gorm:"column:modifier" json:"modifier" form:"modifier"`
324
+	IsCheck               int64           `gorm:"-" json:"is_check" form:"is_check"`
325
+}
326
+
327
+func (DoctorAdvice) TableName() string {
328
+	return "xt_doctor_advice"
329
+}
330
+
331
+func GetDoctorAdviceByType(change_type int64, record_time int64, org_id int64, patient_id int64) (advice []*DoctorAdvice, sch models.Schedule, err error) {
332
+	if change_type == 1 { //根据日期取出上一方数据
333
+		var Id AdviceDate
334
+		err = readDb.Model(&DoctorAdvice{}).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
335
+		err = readDb.Model(&models.Schedule{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND schedule_date  = ?", patient_id, org_id, Id.RecordDate).Find(&sch).Error
336
+		err = readDb.Model(&DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ? AND parent_id= 0", patient_id, org_id, Id.RecordDate).Preload("DoctorAdvice", "status = 1 AND user_org_id = ? AND patient_id = ?", org_id, patient_id).Find(&advice).Error
337
+
338
+	} else if change_type == 2 {
339
+		var Id AdviceDate
340
+		err = readDb.Model(&DoctorAdvice{}).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
341
+		err = readDb.Model(&models.Schedule{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND schedule_date  = ?", patient_id, org_id, Id.RecordDate).Find(&sch).Error
342
+		err = readDb.Model(&DoctorAdvice{}).Where("patient_id = ? AND user_org_id = ? AND  status=1 AND record_date  = ? AND parent_id= 0", patient_id, org_id, Id.RecordDate).Preload("DoctorAdvice", "status = 1 AND user_org_id = ? AND patient_id = ?", org_id, patient_id).Find(&advice).Error
343
+	}
344
+	return
345
+}

+ 19 - 2
service/mobile_dialysis_service.go View File

@@ -36,6 +36,8 @@ func MobileGetDialysisScheduals(orgID int64, scheduleDate int64, scheduleType in
36 36
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
37 37
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
38 38
 		Preload("TreatmentSummary", "status = 1  AND user_org_id = ?", orgID).
39
+		Preload("AssessmentAfterDislysis", "status = 1  AND user_org_id = ?", orgID).
40
+
39 41
 		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
40 42
 		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
41 43
 		// }).
@@ -86,6 +88,19 @@ func (VMTreatmentSummary) TableName() string {
86 88
 	return "xt_treatment_summary"
87 89
 }
88 90
 
91
+type AssessmentAfterDislysis struct {
92
+	ID             int64   `gorm:"column:id" json:"id"`
93
+	UserOrgId      int64   `gorm:"column:user_org_id" json:"user_org_id"`
94
+	PatientId      int64   `gorm:"column:patient_id" json:"patient_id"`
95
+	AssessmentDate int64   `gorm:"column:assessment_date" json:"assessment_date"`
96
+	WeightAfter    float64 `gorm:"column:weight_after" json:"weight_after"`
97
+	Status         int64   `gorm:"column:status" json:"status"`
98
+}
99
+
100
+func (AssessmentAfterDislysis) TableName() string {
101
+	return "xt_assessment_after_dislysis"
102
+}
103
+
89 104
 type MDialysisScheduleVM struct {
90 105
 	ID           int64 `gorm:"column:id" json:"id"`
91 106
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
@@ -103,8 +118,10 @@ type MDialysisScheduleVM struct {
103 118
 	DialysisOrder            *MDialysisOrderVMList             `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
104 119
 	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
105 120
 	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
106
-	Advices                  []*VMDoctorAdvice                 `gorm:"ForeignKey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"doctor_advice"`
107
-	TreatmentSummary         *VMTreatmentSummary               `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"treatment_summary"`
121
+	AssessmentAfterDislysis  *AssessmentAfterDislysis          `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
122
+
123
+	Advices          []*VMDoctorAdvice   `gorm:"ForeignKey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"doctor_advice"`
124
+	TreatmentSummary *VMTreatmentSummary `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"treatment_summary"`
108 125
 }
109 126
 
110 127
 func (MDialysisScheduleVM) TableName() string {