Browse Source

医嘱需求

XMLWAN 4 years ago
parent
commit
c437e851c7

+ 2 - 0
.idea/.gitignore View File

@@ -0,0 +1,2 @@
1
+# Default ignored files
2
+/workspace.xml

+ 8 - 0
.idea/XT_New.iml View File

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module type="WEB_MODULE" version="4">
3
+  <component name="NewModuleRootManager">
4
+    <content url="file://$MODULE_DIR$" />
5
+    <orderEntry type="inheritedJdk" />
6
+    <orderEntry type="sourceFolder" forTests="false" />
7
+  </component>
8
+</module>

+ 6 - 0
.idea/misc.xml View File

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="JavaScriptSettings">
4
+    <option name="languageLevel" value="ES6" />
5
+  </component>
6
+</project>

+ 8 - 0
.idea/modules.xml View File

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/.idea/XT_New.iml" filepath="$PROJECT_DIR$/.idea/XT_New.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 6 - 0
.idea/vcs.xml View File

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+  </component>
6
+</project>

+ 5 - 0
controllers/device_api_controller.go View File

@@ -572,6 +572,11 @@ func (this *DeviceAPIController) ModifyZone() {
572 572
 	zone.Type = type_
573 573
 	zone.ModifyTime = time.Now().Unix()
574 574
 
575
+	byName, _ := service.GetZoneByNameOne(name, adminInfo.CurrentOrgId)
576
+	if byName.ID > 0 && byName.ID != id {
577
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
578
+		return
579
+	}
575 580
 	updateErr := service.UpdateDeviceZone(zone)
576 581
 	if updateErr != nil {
577 582
 		this.ErrorLog("修改设备分区失败:%v", updateErr)

+ 103 - 78
controllers/patient_api_controller.go View File

@@ -62,6 +62,7 @@ func PatientApiRegistRouters() {
62 62
 	beego.Router("/api/infectious/remind", &PatientApiController{}, "Get:GetRemindPatientList")
63 63
 
64 64
 	beego.Router("/api/remind/is_open", &PatientApiController{}, "Post:PostIsOpenRemind")
65
+	beego.Router("/api/patients/advices/getpatientschedules", &PatientApiController{}, "Get:GetPatientScheduleOne")
65 66
 
66 67
 }
67 68
 
@@ -243,29 +244,29 @@ func (c *PatientApiController) CreatePatient() {
243 244
 	//获取老表的最后一条数据
244 245
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
245 246
 	patientsNew := models.XtPatientsNew{
246
-		UserOrgId:          adminUserInfo.CurrentOrgId,
247
-		UserId:             0,
248
-		Avatar:             patients.Avatar,
249
-		PatientType:        patients.PatientType,
250
-		DialysisNo:         patients.DialysisNo,
251
-		AdmissionNumber:    patients.AdmissionNumber,
252
-		Source:             patients.Source,
253
-		Lapseto:            patients.Lapseto,
254
-		PartitionId:        patients.PartitionId,
255
-		BedId:              patients.BedId,
256
-		Name:               patients.Name,
257
-		Alias:              patients.Alias,
258
-		Gender:             patients.Gender,
259
-		MaritalStatus:      patients.MaritalStatus,
260
-		IdCardNo:           patients.IdCardNo,
261
-		Birthday:           patients.Birthday,
262
-		ReimbursementWayId: patients.ReimbursementWayId,
263
-		HealthCareType:     patients.HealthCareType,
264
-		HealthCareNo:       patients.HealthCareNo,
265
-		HealthCareDueDate:  patients.HealthCareDueDate,
266
-		Height:             patients.Height,
267
-		BloodType:          patients.BloodType,
268
-		Rh:                 patients.Rh,
247
+		UserOrgId:                    adminUserInfo.CurrentOrgId,
248
+		UserId:                       0,
249
+		Avatar:                       patients.Avatar,
250
+		PatientType:                  patients.PatientType,
251
+		DialysisNo:                   patients.DialysisNo,
252
+		AdmissionNumber:              patients.AdmissionNumber,
253
+		Source:                       patients.Source,
254
+		Lapseto:                      patients.Lapseto,
255
+		PartitionId:                  patients.PartitionId,
256
+		BedId:                        patients.BedId,
257
+		Name:                         patients.Name,
258
+		Alias:                        patients.Alias,
259
+		Gender:                       patients.Gender,
260
+		MaritalStatus:                patients.MaritalStatus,
261
+		IdCardNo:                     patients.IdCardNo,
262
+		Birthday:                     patients.Birthday,
263
+		ReimbursementWayId:           patients.ReimbursementWayId,
264
+		HealthCareType:               patients.HealthCareType,
265
+		HealthCareNo:                 patients.HealthCareNo,
266
+		HealthCareDueDate:            patients.HealthCareDueDate,
267
+		Height:                       patients.Height,
268
+		BloodType:                    patients.BloodType,
269
+		Rh:                           patients.Rh,
269 270
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
270 271
 		EducationLevel:               patients.EducationLevel,
271 272
 		Profession:                   patients.Profession,
@@ -311,27 +312,27 @@ func (c *PatientApiController) CreatePatient() {
311 312
 		Nation:                       patients.Nation,
312 313
 		NativePlace:                  patients.NativePlace,
313 314
 		Age:                          patients.Age,
314
-		InfectiousNextRecordTime: patients.InfectiousNextRecordTime,
315
-		IsInfectious:             patients.IsInfectious,
316
-		RemindCycle:              patients.RemindCycle,
317
-		ResponseResult:           patients.ResponseResult,
318
-		IsOpenRemind:             patients.IsOpenRemind,
319
-		FirstTreatmentDate:       patients.FirstTreatmentDate,
320
-		DialysisAge:              patients.DialysisAge,
321
-		ExpenseKind:              patients.ExpenseKind,
322
-		TellPhone:                patients.TellPhone,
323
-		ContactName:              patients.ContactName,
324
-		BloodPatients:            1,
325
-		SlowPatients:             0,
326
-		MemberPatients:           0,
327
-		EcommerPatients:          "",
328
-		BloodId:                  patients.ID,
329
-		SlowId:                   0,
330
-		MemberId:                 0,
331
-		MemberFistdate:           0,
332
-		MemberPatienttype:        0,
333
-		MemberTreatement:         0,
334
-		EquitmentId:              "",
315
+		InfectiousNextRecordTime:     patients.InfectiousNextRecordTime,
316
+		IsInfectious:                 patients.IsInfectious,
317
+		RemindCycle:                  patients.RemindCycle,
318
+		ResponseResult:               patients.ResponseResult,
319
+		IsOpenRemind:                 patients.IsOpenRemind,
320
+		FirstTreatmentDate:           patients.FirstTreatmentDate,
321
+		DialysisAge:                  patients.DialysisAge,
322
+		ExpenseKind:                  patients.ExpenseKind,
323
+		TellPhone:                    patients.TellPhone,
324
+		ContactName:                  patients.ContactName,
325
+		BloodPatients:                1,
326
+		SlowPatients:                 0,
327
+		MemberPatients:               0,
328
+		EcommerPatients:              "",
329
+		BloodId:                      patients.ID,
330
+		SlowId:                       0,
331
+		MemberId:                     0,
332
+		MemberFistdate:               0,
333
+		MemberPatienttype:            0,
334
+		MemberTreatement:             0,
335
+		EquitmentId:                  "",
335 336
 	}
336 337
 
337 338
 	err = service.CreatePatientsNew(&patientsNew)
@@ -459,29 +460,29 @@ func (c *PatientApiController) EditPatient() {
459 460
 	}
460 461
 	fmt.Println("病人--------------------------------------------------------------", patient.Name, patient.Age)
461 462
 	patientsNew := models.XtPatientsNew{
462
-		UserOrgId:          patient.UserOrgId,
463
-		UserId:             patient.UserId,
464
-		Avatar:             patient.Avatar,
465
-		PatientType:        patient.PatientType,
466
-		DialysisNo:         patient.DialysisNo,
467
-		AdmissionNumber:    patient.AdmissionNumber,
468
-		Source:             patient.Source,
469
-		Lapseto:            patient.Lapseto,
470
-		PartitionId:        patient.PartitionId,
471
-		BedId:              patient.BedId,
472
-		Name:               patient.Name,
473
-		Alias:              patient.Alias,
474
-		Gender:             patient.Gender,
475
-		MaritalStatus:      patient.MaritalStatus,
476
-		IdCardNo:           patient.IdCardNo,
477
-		Birthday:           patient.Birthday,
478
-		ReimbursementWayId: patient.ReimbursementWayId,
479
-		HealthCareType:     patient.HealthCareType,
480
-		HealthCareNo:       patient.HealthCareNo,
481
-		HealthCareDueDate:  patient.HealthCareDueDate,
482
-		Height:             patient.Height,
483
-		BloodType:          patient.BloodType,
484
-		Rh:                 patient.Rh,
463
+		UserOrgId:                 patient.UserOrgId,
464
+		UserId:                    patient.UserId,
465
+		Avatar:                    patient.Avatar,
466
+		PatientType:               patient.PatientType,
467
+		DialysisNo:                patient.DialysisNo,
468
+		AdmissionNumber:           patient.AdmissionNumber,
469
+		Source:                    patient.Source,
470
+		Lapseto:                   patient.Lapseto,
471
+		PartitionId:               patient.PartitionId,
472
+		BedId:                     patient.BedId,
473
+		Name:                      patient.Name,
474
+		Alias:                     patient.Alias,
475
+		Gender:                    patient.Gender,
476
+		MaritalStatus:             patient.MaritalStatus,
477
+		IdCardNo:                  patient.IdCardNo,
478
+		Birthday:                  patient.Birthday,
479
+		ReimbursementWayId:        patient.ReimbursementWayId,
480
+		HealthCareType:            patient.HealthCareType,
481
+		HealthCareNo:              patient.HealthCareNo,
482
+		HealthCareDueDate:         patient.HealthCareDueDate,
483
+		Height:                    patient.Height,
484
+		BloodType:                 patient.BloodType,
485
+		Rh:                        patient.Rh,
485 486
 		HealthCareDueAlertDate:    patient.HealthCareDueAlertDate,
486 487
 		EducationLevel:            patient.EducationLevel,
487 488
 		Profession:                patient.Profession,
@@ -523,17 +524,17 @@ func (c *PatientApiController) EditPatient() {
523 524
 		Nation:                    patient.Nation,
524 525
 		NativePlace:               patient.NativePlace,
525 526
 		Age:                       patient.Age,
526
-		InfectiousNextRecordTime: patient.InfectiousNextRecordTime,
527
-		IsInfectious:             patient.IsInfectious,
528
-		RemindCycle:              patient.RemindCycle,
529
-		ResponseResult:           patient.ResponseResult,
530
-		IsOpenRemind:             patient.IsOpenRemind,
531
-		FirstTreatmentDate:       patient.FirstTreatmentDate,
532
-		DialysisAge:              patient.DialysisAge,
533
-		ExpenseKind:              patient.ExpenseKind,
534
-		TellPhone:                patient.TellPhone,
535
-		ContactName:              patient.ContactName,
536
-		UpdatedTime:              time.Now().Unix(),
527
+		InfectiousNextRecordTime:  patient.InfectiousNextRecordTime,
528
+		IsInfectious:              patient.IsInfectious,
529
+		RemindCycle:               patient.RemindCycle,
530
+		ResponseResult:            patient.ResponseResult,
531
+		IsOpenRemind:              patient.IsOpenRemind,
532
+		FirstTreatmentDate:        patient.FirstTreatmentDate,
533
+		DialysisAge:               patient.DialysisAge,
534
+		ExpenseKind:               patient.ExpenseKind,
535
+		TellPhone:                 patient.TellPhone,
536
+		ContactName:               patient.ContactName,
537
+		UpdatedTime:               time.Now().Unix(),
537 538
 	}
538 539
 	//	//更新病人ID获取新表病人ID
539 540
 	err = service.UpdatepatientTwo(&patientsNew, id)
@@ -3337,3 +3338,27 @@ func (c *PatientApiController) PostIsOpenRemind() {
3337 3338
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3338 3339
 	}
3339 3340
 }
3341
+
3342
+func (c *PatientApiController) GetPatientScheduleOne() {
3343
+	id, _ := c.GetInt64("id")
3344
+	//查询该病人是否当天是排班
3345
+	nowDateTime := time.Now()
3346
+	nowDate := nowDateTime.Format("2006-01-02")
3347
+	nowDate += " 00:00:00"
3348
+	timeLayout := "2006-01-02"
3349
+	loc, _ := time.LoadLocation("Local")
3350
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
3351
+	nowdate := theTime.Unix()
3352
+	fmt.Println("nowdate", nowdate)
3353
+	adminUser := c.GetAdminUserInfo()
3354
+	orgId := adminUser.CurrentOrgId
3355
+	fmt.Println("orgid", orgId)
3356
+	scheduls, err := service.GetPatientScheduleOne(id, nowdate, orgId)
3357
+	if err != nil {
3358
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3359
+		return
3360
+	}
3361
+	c.ServeSuccessJSON(map[string]interface{}{
3362
+		"scheduls": scheduls,
3363
+	})
3364
+}

+ 11 - 5
service/device_service.go View File

@@ -275,16 +275,22 @@ func GetDeviceZoneByID(orgID int64, zoneID int64) (*models.DeviceZone, error) {
275 275
 func GetZoneByName(name string, orgid int64) (*models.DeviceZone, error) {
276 276
 	zones := models.DeviceZone{}
277 277
 	err := XTReadDB().Model(&zones).Where("name = ? and org_id = ? and status = 1", name, orgid).Find(&zones).Error
278
+	if err == gorm.ErrRecordNotFound {
279
+		return nil, err
280
+	}
278 281
 	if err != nil {
279
-		if err == gorm.ErrRecordNotFound {
280
-			return nil, nil
281
-		} else {
282
-			return nil, err
283
-		}
282
+		return nil, err
284 283
 	}
284
+
285 285
 	return &zones, nil
286 286
 }
287 287
 
288
+func GetZoneByNameOne(name string, orgid int64) (zone models.DeviceZone, err error) {
289
+
290
+	err = XTReadDB().Model(&zone).Where("name = ? and org_id=? and status = 1", name, orgid).First(&zone).Error
291
+	return zone, err
292
+}
293
+
288 294
 func CreateDeviceZone(orgID int64, name string, type_ int) (*models.DeviceZone, error) {
289 295
 	now := time.Now().Unix()
290 296
 	zone := models.DeviceZone{

+ 11 - 2
service/dialysis_service.go View File

@@ -695,9 +695,18 @@ func GetAdminUserES(orgID int64, appID int64, ids []int64) (es []*models.AdminUs
695 695
 	return
696 696
 }
697 697
 
698
-func GetAdminUserEsOne(orgid int64) (admin []*models.UserAdminRoles, err error) {
698
+//
699
+//func GetAdminUserEsOne(orgid int64) (admin []*models.UserAdminRoles, err error) {
700
+//
701
+//	db := readUserDb.Table("sgj_user_admin_role as x").Where("x.status = 1")
702
+//	table := readUserDb.Table("sgj_user_admin_electronic_signature as s")
703
+//	fmt.Println("table", table)
704
+//	err = db.Select("x.id,x.admin_user_id,x.user_name,x.org_id,s.creator,s.url,s.hash").Joins("left join sgj_user_admin_electronic_signature as s on s.creator = x.admin_user_id").Where("x.org_id = ?", orgid).Scan(&admin).Error
705
+//	return admin, err
706
+//}
699 707
 
700
-	db := readUserDb.Table("sgj_user_admin_role as x").Where("x.status = 1")
708
+func GetAdminUserEsOne(orgid int64) (admin []*models.UserAdminRoles, err error) {
709
+	db := readUserDb.Table("sgj_user_admin_role as x").Where("x.status =1")
701 710
 	table := readUserDb.Table("sgj_user_admin_electronic_signature as s")
702 711
 	fmt.Println("table", table)
703 712
 	err = db.Select("x.id,x.admin_user_id,x.user_name,x.org_id,s.creator,s.url,s.hash").Joins("left join sgj_user_admin_electronic_signature as s on s.creator = x.admin_user_id").Where("x.org_id = ?", orgid).Scan(&admin).Error

+ 17 - 4
service/patient_service.go View File

@@ -682,7 +682,8 @@ func FindDoctorAdviceByGroupNo(orgID, groupNo int64) (advice models.DoctorAdvice
682 682
 	return
683 683
 }
684 684
 func GetDoctorAdviceList(orgID, patientID, advice_type, stop, start, end int64, keywords string) (advices []*models.DoctorAdvices, total int64, err error) {
685
-	//db := readDb.Model(&models.DoctorAdvice{}).Where("status=1")
685
+
686
+	fmt.Println("advicetype-----", advice_type)
686 687
 	db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
687 688
 	table := UserReadDB().Table("sgj_user_admin_role as r")
688 689
 	fmt.Print("table", table)
@@ -692,10 +693,16 @@ func GetDoctorAdviceList(orgID, patientID, advice_type, stop, start, end int64,
692 693
 	if patientID > 0 {
693 694
 		db = db.Where("x.patient_id = ?", patientID)
694 695
 	}
695
-	if advice_type > 0 {
696
+	//if advice_type > 0 {
697
+	//	db = db.Where("x.advice_type = ?", advice_type)
698
+	//} else if advice_type == 0 {
699
+	//	db = db.Where("x.advice_type in (?)", []int{1, 3})
700
+	//}
701
+	if advice_type == 1 && advice_type > 0 {
696 702
 		db = db.Where("x.advice_type = ?", advice_type)
697
-	} else if advice_type == 0 {
698
-		db = db.Where("x.advice_type in (?)", []int{1, 3})
703
+	}
704
+	if advice_type == 3 && advice_type > 0 {
705
+		db = db.Where("x.advice_type = 2 or x.advice_type = 3")
699 706
 	}
700 707
 	if stop == 1 {
701 708
 		db = db.Where("(x.stop_state=? or x.execution_state=?)", stop, stop)
@@ -1073,3 +1080,9 @@ func GetSchedualPatientByKeyWord(orgID int64, keywords string, date int64) (pati
1073 1080
 	}
1074 1081
 	return
1075 1082
 }
1083
+
1084
+func GetPatientScheduleOne(patientid int64, nowdate int64, orgid int64) (models.XtSchedule, error) {
1085
+	schedule := models.XtSchedule{}
1086
+	err := XTReadDB().Model(&schedule).Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status =1", patientid, nowdate, orgid).Find(&schedule).Error
1087
+	return schedule, err
1088
+}