Parcourir la source

时间选择更新

XMLWAN il y a 4 ans
Parent
révision
68b097a862

+ 7 - 0
controllers/manage_api_controller.go Voir le fichier

@@ -191,6 +191,13 @@ func (this *MachineApiController) SaveManageInfo() {
191 191
 		ids = append(ids, id)
192 192
 	}
193 193
 
194
+	//查询机位号是否绑定设备
195
+	thisAddmacher, err := service.GetEquitmentByBedID(bed_number, orgid)
196
+	if thisAddmacher.ID > 0 {
197
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisNoExist)
198
+		return
199
+	}
200
+
194 201
 	addmacher := &models.DeviceAddmacher{
195 202
 		SerialNumber: serial_numbe,
196 203
 		DeviceType:   device_type,

+ 123 - 69
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Voir le fichier

@@ -243,72 +243,91 @@ func (this *NewDialysisApiController) SavePatient() {
243 243
 
244 244
 	//如果是血透病人
245 245
 	if bloodPatient == 1 {
246
-		_, errcode := service.GetPatientData(phone, orgid)
247
-		if errcode == gorm.ErrRecordNotFound {
248
-			patients := models.Patients{
249
-				Name:              name,
250
-				Gender:            sex,
251
-				Birthday:          birth,
252
-				Age:               ages,
253
-				Phone:             phone,
254
-				Lapseto:           lapseto,
255
-				AdmissionNumber:   adminssionNumber,
256
-				FirstDialysisDate: fisttime,
257
-				Diagnose:          diagonse,
258
-				Source:            patientsoure,
259
-				DialysisNo:        dialysis,
260
-				UserOrgId:         orgid,
261
-				Status:            1,
262
-				CreatedTime:       time.Now().Unix(),
263
-				Avatar:            avatar,
264
-				IdCardNo:          idCard,
265
-				IsInfectious:      is_infectious,
266
-			}
267
-			err := service.CreateOldPatient(&patients)
268
-			fmt.Print("报错", err)
269
-			patient, err := service.GetLastOldPatient(orgid)
270
-			fmt.Print("病人ID", patient.ID)
271
-			err = service.AddContagions(patient.ID, patient.CreatedTime, patient.UpdatedTime, ids)
272
-			fmt.Println("添加传染病失败", err)
273
-
274
-			patientsNew := models.XtPatientsNew{
275
-				Name:              name,
276
-				Gender:            sex,
277
-				Birthday:          birth,
278
-				Age:               ages,
279
-				Phone:             phone,
280
-				Lapseto:           lapseto,
281
-				AdmissionNumber:   adminssionNumber,
282
-				FirstDialysisDate: fisttime,
283
-				Diagnose:          diagonse,
284
-				Source:            patientsoure,
285
-				DialysisNo:        dialysis,
286
-				UserOrgId:         orgid,
287
-				Status:            1,
288
-				CreatedTime:       time.Now().Unix(),
289
-				Avatar:            avatar,
290
-				MemberPatients:    memberpatient,
291
-				BloodPatients:     bloodPatient,
292
-				SlowPatients:      slowpatient,
293
-				BloodId:           patient.ID,
294
-				IsInfectious:      is_infectious,
295
-				IdCardNo:          idCard,
296
-			}
297
-			err = service.CreateNewPatient(&patientsNew)
298
-			fmt.Print("报错", err)
299
-			if err != nil {
300
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
301
-				return
302
-			}
303
-			this.ServeSuccessJSON(map[string]interface{}{
304
-				"patient": patientsNew,
305
-			})
306
-		} else if errcode == nil {
307
-			fmt.Print("病人已存在")
246
+		//查询身份证号码是否存在
247
+		thisPatientOne, _ := service.FindPatientByIdCardNoOne(orgid, idCard)
248
+		if thisPatientOne.ID > 0 {
249
+			returnData := make(map[string]interface{}, 0)
250
+			returnData["msg"] = "身份证号码已存在"
251
+			this.ServeSuccessJSON(returnData)
308 252
 			return
309
-		} else {
253
+		}
254
+
255
+		//查询手机号码是否存在
256
+		thisPatient, err := service.FindPatientByMobileOne(phone, orgid)
257
+		if thisPatient.ID > 0 {
258
+			returnData := make(map[string]interface{}, 0)
259
+			returnData["msg"] = "手机号码已存在"
260
+			this.ServeSuccessJSON(returnData)
261
+			return
262
+		}
310 263
 
264
+		//查询透析号是否存在
265
+		thisPatientTwo, _ := service.FindPatientByDialysisNoOne(orgid, dialysis)
266
+		if thisPatientTwo.ID > 0 {
267
+			returnData := make(map[string]interface{}, 0)
268
+			returnData["msg"] = "透析号已存在"
269
+			this.ServeSuccessJSON(returnData)
270
+			return
271
+		}
272
+
273
+		patients := models.Patients{
274
+			Name:              name,
275
+			Gender:            sex,
276
+			Birthday:          birth,
277
+			Age:               ages,
278
+			Phone:             phone,
279
+			Lapseto:           lapseto,
280
+			AdmissionNumber:   adminssionNumber,
281
+			FirstDialysisDate: fisttime,
282
+			Diagnose:          diagonse,
283
+			Source:            patientsoure,
284
+			DialysisNo:        dialysis,
285
+			UserOrgId:         orgid,
286
+			Status:            1,
287
+			CreatedTime:       time.Now().Unix(),
288
+			Avatar:            avatar,
289
+			IdCardNo:          idCard,
290
+			IsInfectious:      is_infectious,
311 291
 		}
292
+		err = service.CreateOldPatient(&patients)
293
+		fmt.Print("报错", err)
294
+		patient, err := service.GetLastOldPatient(orgid)
295
+		fmt.Print("病人ID", patient.ID)
296
+		err = service.AddContagions(patient.ID, patient.CreatedTime, patient.UpdatedTime, ids)
297
+		fmt.Println("添加传染病失败", err)
298
+
299
+		patientsNew := models.XtPatientsNew{
300
+			Name:              name,
301
+			Gender:            sex,
302
+			Birthday:          birth,
303
+			Age:               ages,
304
+			Phone:             phone,
305
+			Lapseto:           lapseto,
306
+			AdmissionNumber:   adminssionNumber,
307
+			FirstDialysisDate: fisttime,
308
+			Diagnose:          diagonse,
309
+			Source:            patientsoure,
310
+			DialysisNo:        dialysis,
311
+			UserOrgId:         orgid,
312
+			Status:            1,
313
+			CreatedTime:       time.Now().Unix(),
314
+			Avatar:            avatar,
315
+			MemberPatients:    memberpatient,
316
+			BloodPatients:     bloodPatient,
317
+			SlowPatients:      slowpatient,
318
+			BloodId:           patient.ID,
319
+			IsInfectious:      is_infectious,
320
+			IdCardNo:          idCard,
321
+		}
322
+		err = service.CreateNewPatient(&patientsNew)
323
+		fmt.Print("报错", err)
324
+		if err != nil {
325
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
326
+			return
327
+		}
328
+		this.ServeSuccessJSON(map[string]interface{}{
329
+			"patient": patientsNew,
330
+		})
312 331
 	}
313 332
 
314 333
 	fmt.Print("slowpatient", slowpatient)
@@ -511,7 +530,7 @@ func (this *NewDialysisApiController) SavePatient() {
511 530
 					MemberTreatement:  treatmentmethod,
512 531
 				}
513 532
 				err = service.CreateNewPatient(&patientsNew)
514
-				fmt.Print("报错-----------------------", err)
533
+				fmt.Print("报错", err)
515 534
 				if err != nil {
516 535
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
517 536
 					return
@@ -578,7 +597,7 @@ func (this *NewDialysisApiController) GetDoctorAdvices() {
578 597
 	fmt.Print("开始时间", startime)
579 598
 	end := this.GetString("endtime")
580 599
 	fmt.Print("end", end)
581
-	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
600
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
582 601
 	endtime := endTimes.Unix()
583 602
 	fmt.Print("结束时间", endtime)
584 603
 	limit, _ := this.GetInt64("limit")
@@ -607,7 +626,8 @@ func (this *NewDialysisApiController) GetDryWeight() {
607 626
 	startime := startTimes.Unix()
608 627
 	fmt.Print("startime", startime)
609 628
 	end := this.GetString("endtime")
610
-	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
629
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
630
+
611 631
 	endtime := endTimes.Unix()
612 632
 	fmt.Print("endtime", endtime)
613 633
 	limit, _ := this.GetInt64("limit")
@@ -652,7 +672,7 @@ func (this *NewDialysisApiController) GetCourseManagement() {
652 672
 	startime := startTimes.Unix()
653 673
 	fmt.Print("startime", startime)
654 674
 	end := this.GetString("endtime")
655
-	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
675
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
656 676
 	endtime := endTimes.Unix()
657 677
 	fmt.Print("endtime", endtime)
658 678
 	limit, _ := this.GetInt64("limit")
@@ -814,7 +834,7 @@ func (this *NewDialysisApiController) GetRescuerecord() {
814 834
 	startime := startTimes.Unix()
815 835
 	fmt.Print("startime", startime)
816 836
 	end := this.GetString("endtime")
817
-	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
837
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
818 838
 	endtime := endTimes.Unix()
819 839
 	fmt.Print("endtime", endtime)
820 840
 	limit, _ := this.GetInt64("limit")
@@ -1241,6 +1261,34 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1241 1261
 	if bloodPatient == 1 {
1242 1262
 		//根据新表ID获取老表病人ID
1243 1263
 		patient, _ := service.GetNewPatient(id)
1264
+
1265
+		//判断身份证号是否相同
1266
+		thisPatient, _ := service.FindPatientByIdCardNoOne(orgid, idCard)
1267
+		if thisPatient.ID > 0 && thisPatient.ID != patient.BloodId {
1268
+			returnData := make(map[string]interface{}, 0)
1269
+			returnData["msg"] = "身份证号码已存在"
1270
+			this.ServeSuccessJSON(returnData)
1271
+			return
1272
+		}
1273
+
1274
+		//查询手机号码是否存在
1275
+		thisPatientOne, err := service.FindPatientByMobileOne(phone, orgid)
1276
+		if thisPatientOne.ID > 0 && thisPatientOne.ID != patient.BloodId {
1277
+			returnData := make(map[string]interface{}, 0)
1278
+			returnData["msg"] = "手机号码已存在"
1279
+			this.ServeSuccessJSON(returnData)
1280
+			return
1281
+		}
1282
+
1283
+		//查询号透析号是否相同
1284
+		thisPatientother, _ := service.FindPatientByDialysisNoOne(orgid, dialysis)
1285
+		if thisPatientother.ID > 0 && thisPatientother.ID != patient.BloodId {
1286
+			returnData := make(map[string]interface{}, 0)
1287
+			returnData["msg"] = "透析号码已存在"
1288
+			this.ServeSuccessJSON(returnData)
1289
+			return
1290
+		}
1291
+
1244 1292
 		patients := models.Patients{
1245 1293
 			Name:              name,
1246 1294
 			Gender:            sex,
@@ -1260,7 +1308,7 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1260 1308
 			IdCardNo:          idCard,
1261 1309
 			IsInfectious:      is_infectious,
1262 1310
 		}
1263
-		err := service.UpdatedPatient(patients, patient.BloodId)
1311
+		err = service.UpdatedPatient(patients, patient.BloodId)
1264 1312
 		patientsNew := models.XtPatientsNew{
1265 1313
 			ID:                id,
1266 1314
 			Name:              name,
@@ -1289,6 +1337,12 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1289 1337
 		this.ServeSuccessJSON(map[string]interface{}{
1290 1338
 			"patients": patientsNew,
1291 1339
 		})
1340
+		//更改传染病
1341
+		updateContagions, err := service.UpdateContagions(patient.BloodId)
1342
+		fmt.Print("更新传染病失败", err)
1343
+		fmt.Print("up", updateContagions)
1344
+		err = service.AddContagions(patient.BloodId, patient.CreatedTime, patient.UpdatedTime, ids)
1345
+		fmt.Println("添加传染病失败", err)
1292 1346
 	}
1293 1347
 	if slowpatient == 1 {
1294 1348
 		patient, _ := service.GetNewPatient(id)

+ 6 - 0
service/manage_service.go Voir le fichier

@@ -29,6 +29,12 @@ func CreateEquimentName(equimentname models.DeviceEquimentname) error {
29 29
 	return err
30 30
 }
31 31
 
32
+func GetEquitmentByBedID(bedid int64, orgid int64) (models.DeviceAddmacher, error) {
33
+	addmacher := models.DeviceAddmacher{}
34
+	err := UserReadDB().Model(&addmacher).Where("bed_id = ? and user_org_id = ? and status = 1", bedid, orgid).First(&addmacher).Error
35
+	return addmacher, err
36
+}
37
+
32 38
 func CreateMacher(machers *models.DeviceAddmacher) error {
33 39
 
34 40
 	//err := writeDb.Create(&machers).Error

+ 1 - 1
service/patient_service.go Voir le fichier

@@ -316,7 +316,7 @@ func UpdatePatient(patient *models.Patients, contagions []int64, diseases []int6
316 316
 		return
317 317
 	}
318 318
 	err = utx.Model(&models.InfectiousDiseases{}).Where("patient_id=?", patient.ID).Update(map[string]interface{}{"Status": 2, "UpdatedTime": patient.UpdatedTime}).Error
319
-	fmt.Println("错误是什么。。。。。。。。。。。。。。。。。。。。。。。。。。。", err)
319
+	fmt.Println("err", err)
320 320
 	if err != nil {
321 321
 		utx.Rollback()
322 322
 		return

+ 26 - 5
service/patientmanage_service.go Voir le fichier

@@ -400,6 +400,21 @@ func CreatePatientTwo(patient *models.Patients, contagions []int64, diseases []i
400 400
 	return
401 401
 }
402 402
 
403
+func FindPatientByIdCardNoOne(orgID int64, idCardNo string) (patient models.Patients, err error) {
404
+	err = readDb.Model(&models.Patients{}).Where("status=1 and user_org_id=? and id_card_no=?", orgID, idCardNo).First(&patient).Error
405
+	return
406
+}
407
+
408
+func FindPatientByDialysisNoOne(orgID int64, dialysisNo string) (patient models.Patients, err error) {
409
+	err = readDb.Model(&models.Patients{}).Where("status=1 and user_org_id=? and dialysis_no=?", orgID, dialysisNo).First(&patient).Error
410
+	return
411
+}
412
+
413
+func FindPatientByMobileOne(mobile string, orgID int64) (patient models.Patients, err error) {
414
+	err = readDb.Model(&models.Patients{}).Where("phone=? and user_org_id=? and status=1", mobile, orgID).First(&patient).Error
415
+	return
416
+}
417
+
403 418
 func GetPatientData(phone string, orgid int64) (*models.XtPatientsNew, error) {
404 419
 	var patientnew models.XtPatientsNew
405 420
 	var err error
@@ -470,10 +485,10 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
470 485
 	} else if advice_type == 0 {
471 486
 		db = db.Where("x.advice_type in (?)", []int{1, 3})
472 487
 	}
473
-	if start != 0 {
488
+	if start > 0 {
474 489
 		db = db.Where("x.start_time>=?", start)
475 490
 	}
476
-	if end != 0 {
491
+	if end > 0 {
477 492
 		db = db.Where("start_time<=?", end)
478 493
 	}
479 494
 	offset := (page - 1) * limit
@@ -634,7 +649,7 @@ func GetEducation(patientid int64, startime int64, endtime int64, limit int64, p
634 649
 		db = db.Where("x.assessment_date <= ?", endtime)
635 650
 	}
636 651
 	offset := (page - 1) * limit
637
-	err = db.Count(&total).Order("x.assessment_date").Offset(offset).Limit(limit).Group("x.id").
652
+	err = db.Count(&total).Order("x.assessment_date desc").Offset(offset).Limit(limit).Group("x.id").
638 653
 		Select("x.id,x.user_org_id,x.patient_id,x.assessment_date,x.dialysis_order_id,x.mission,x.dialysis_summary,x.change,x.sj_nurse,x.zl_nurse,x.hd_nurse,x.xj_nurse,x.zl_doctor,x.channel_image,x.puncture,x.puncture_needle,x.puncture_direction,x.status,x.created_time,x.updated_time,x.creater,x.modifier").Scan(&treatment).Error
639 654
 	return
640 655
 }
@@ -783,10 +798,10 @@ func GetDialysisrecord(patientID int64, start int64, end int64, limit int64, pag
783 798
 		Joins("JOIN xt_device_zone as dz ON dz.org_id = ? and dz.id=s.partition_id", orgID).
784 799
 		Where("do.patient_id=? and do.user_org_id=? and do.stage = 2 and do.status=1", patientID, orgID).Group("s.schedule_date")
785 800
 
786
-	if start != 0 {
801
+	if start > 0 {
787 802
 		db = db.Where("do.dialysis_date>=?", start)
788 803
 	}
789
-	if end != 0 {
804
+	if end > 0 {
790 805
 		db = db.Where("do.dialysis_date<=?", end)
791 806
 	}
792 807
 	if mode_id > 0 {
@@ -864,6 +879,12 @@ func UpdateXtPatientNew(patients models.XtPatientsNew, id int64) error {
864 879
 	return err
865 880
 }
866 881
 
882
+func UpdateContagions(patientid int64) (models.XtPatientsInfectiousDiseases, error) {
883
+	diseases := models.XtPatientsInfectiousDiseases{}
884
+	err := XTWriteDB().Model(&diseases).Where("patient_id = ?", patientid).Update(map[string]interface{}{"status": 2, "updated_time": time.Now().Unix()}).Error
885
+	return diseases, err
886
+}
887
+
867 888
 func UpdateCustomer(cdmpatient models.CdmPatients, id int64) error {
868 889
 
869 890
 	err := PatientWriteDB().Model(&cdmpatient).Where("id=?", id).Update(map[string]interface{}{"name": cdmpatient.Name, "phone": cdmpatient.Phone, "gender": cdmpatient.Gender, "birthday": cdmpatient.Birthday, "diagnose": cdmpatient.Diagnose, "source": cdmpatient.Source, "avatar": cdmpatient.Avatar, "id_card_no": cdmpatient.IdCardNo, "updated_time": cdmpatient.UpdatedTime}).Error