XMLWAN vor 4 Jahren
Ursprung
Commit
5b38323e28
4 geänderte Dateien mit 164 neuen und 67 gelöschten Zeilen
  1. 1 1
      conf/app.conf
  2. 147 64
      controllers/patient_api_controller.go
  3. 15 1
      service/patient_service.go
  4. 1 1
      service/patientmanage_service.go

+ 1 - 1
conf/app.conf Datei anzeigen

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 

+ 147 - 64
controllers/patient_api_controller.go Datei anzeigen

@@ -183,16 +183,16 @@ func (c *PatientApiController) CreatePatient() {
183 183
 	remind_cycle, _ := c.GetInt64("remind_cycle")
184 184
 
185 185
 	adminUserInfo := c.GetAdminUserInfo()
186
-	patientTotal := service.GetLapsetoPatientCount(adminUserInfo.CurrentOrgId, 1)
186
+	//patientTotal := service.GetLapsetoPatientCount(adminUserInfo.CurrentOrgId, 1)
187 187
 
188
-	subscibes := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
189
-	if subscibes.State == 2 && patientTotal >= 20 { //免费试用版,不过期,限制患者数20
190
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientReachLimit)
191
-		return
192
-	} else if subscibes.State == 1 && patientTotal >= 60 { //标准版,不过期,限制患者数60
193
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientReachLimit)
194
-		return
195
-	}
188
+	//subscibes := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
189
+	//if subscibes.State == 2 && patientTotal >= 20 { //免费试用版,不过期,限制患者数20
190
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientReachLimit)
191
+	//	return
192
+	//} else if subscibes.State == 1 && patientTotal >= 60 { //标准版,不过期,限制患者数60
193
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientReachLimit)
194
+	//	return
195
+	//}
196 196
 
197 197
 	var patient models.Patients
198 198
 	contagions, diseases, code, formItems := patientFormData(&patient, c.Ctx.Input.RequestBody, "create")
@@ -234,6 +234,7 @@ func (c *PatientApiController) CreatePatient() {
234 234
 	// patient.Lapseto = 1
235 235
 
236 236
 	err := service.CreatePatient(&patient, contagions, diseases)
237
+	fmt.Println("创建病人失败---------------------------------------------err")
237 238
 	if err != nil {
238 239
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePatient)
239 240
 		return
@@ -242,29 +243,29 @@ func (c *PatientApiController) CreatePatient() {
242 243
 	//获取老表的最后一条数据
243 244
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
244 245
 	patientsNew := models.XtPatientsNew{
245
-		UserOrgId:          adminUserInfo.CurrentOrgId,
246
-		UserId:             0,
247
-		Avatar:             patients.Avatar,
248
-		PatientType:        patients.PatientType,
249
-		DialysisNo:         patients.DialysisNo,
250
-		AdmissionNumber:    patients.AdmissionNumber,
251
-		Source:             patients.Source,
252
-		Lapseto:            patients.Lapseto,
253
-		PartitionId:        patients.PartitionId,
254
-		BedId:              patients.BedId,
255
-		Name:               patients.Name,
256
-		Alias:              patients.Alias,
257
-		Gender:             patients.Gender,
258
-		MaritalStatus:      patients.MaritalStatus,
259
-		IdCardNo:           patients.IdCardNo,
260
-		Birthday:           patients.Birthday,
261
-		ReimbursementWayId: patients.ReimbursementWayId,
262
-		HealthCareType:     patients.HealthCareType,
263
-		HealthCareNo:       patients.HealthCareNo,
264
-		HealthCareDueDate:  patients.HealthCareDueDate,
265
-		Height:             patients.Height,
266
-		BloodType:          patients.BloodType,
267
-		Rh:                 patients.Rh,
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,
268 269
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
269 270
 		EducationLevel:               patients.EducationLevel,
270 271
 		Profession:                   patients.Profession,
@@ -310,27 +311,27 @@ func (c *PatientApiController) CreatePatient() {
310 311
 		Nation:                       patients.Nation,
311 312
 		NativePlace:                  patients.NativePlace,
312 313
 		Age:                          patients.Age,
313
-		InfectiousNextRecordTime: patients.InfectiousNextRecordTime,
314
-		IsInfectious:             patients.IsInfectious,
315
-		RemindCycle:              patients.RemindCycle,
316
-		ResponseResult:           patients.ResponseResult,
317
-		IsOpenRemind:             patients.IsOpenRemind,
318
-		FirstTreatmentDate:       patients.FirstTreatmentDate,
319
-		DialysisAge:              patients.DialysisAge,
320
-		ExpenseKind:              patients.ExpenseKind,
321
-		TellPhone:                patients.TellPhone,
322
-		ContactName:              patients.ContactName,
323
-		BloodPatients:            1,
324
-		SlowPatients:             0,
325
-		MemberPatients:           0,
326
-		EcommerPatients:          "",
327
-		BloodId:                  patients.ID,
328
-		SlowId:                   0,
329
-		MemberId:                 0,
330
-		MemberFistdate:           0,
331
-		MemberPatienttype:        0,
332
-		MemberTreatement:         0,
333
-		EquitmentId:              "",
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:                  "",
334 335
 	}
335 336
 
336 337
 	err = service.CreatePatientsNew(&patientsNew)
@@ -411,6 +412,7 @@ func (c *PatientApiController) CreatePatient() {
411 412
 //EditPatient 修改
412 413
 func (c *PatientApiController) EditPatient() {
413 414
 	id, _ := c.GetInt64("id", 0)
415
+
414 416
 	record_date := c.GetString("record_date")
415 417
 	is_infectious, _ := c.GetInt64("is_infectious")
416 418
 	remind_cycle, _ := c.GetInt64("remind_cycle")
@@ -455,6 +457,87 @@ func (c *PatientApiController) EditPatient() {
455 457
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdatePatient)
456 458
 		return
457 459
 	}
460
+	fmt.Println("病人--------------------------------------------------------------", patient.Name, patient.Age)
461
+	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,
485
+		HealthCareDueAlertDate:    patient.HealthCareDueAlertDate,
486
+		EducationLevel:            patient.EducationLevel,
487
+		Profession:                patient.Profession,
488
+		Phone:                     patient.Phone,
489
+		HomeTelephone:             patient.HomeTelephone,
490
+		RelativePhone:             patient.RelativePhone,
491
+		RelativeRelations:         patient.RelativeRelations,
492
+		HomeAddress:               patient.HomeAddress,
493
+		WorkUnit:                  patient.WorkUnit,
494
+		UnitAddress:               patient.UnitAddress,
495
+		Children:                  patient.Children,
496
+		ReceivingDate:             patient.ReceivingDate,
497
+		IsHospitalFirstDialysis:   patient.IsHospitalFirstDialysis,
498
+		FirstDialysisDate:         patient.FirstDialysisDate,
499
+		FirstDialysisHospital:     patient.FirstDialysisHospital,
500
+		PredialysisCondition:      patient.PredialysisCondition,
501
+		PreHospitalDialysisTimes:  patient.PreHospitalDialysisTimes,
502
+		HospitalFirstDialysisDate: patient.HospitalFirstDialysisDate,
503
+		InductionPeriod:           patient.InductionPeriod,
504
+		InitialDialysis:           patient.InitialDialysis,
505
+		TotalDialysis:             patient.TotalDialysis,
506
+		AttendingDoctorId:         patient.AttendingDoctorId,
507
+		HeadNurseId:               patient.HeadNurseId,
508
+		Evaluate:                  patient.Evaluate,
509
+		Diagnose:                  patient.Diagnose,
510
+		Remark:                    patient.Remark,
511
+		RegistrarsId:              patient.RegistrarsId,
512
+		Registrars:                patient.Registrars,
513
+		QrCode:                    patient.QrCode,
514
+		BindingState:              patient.BindingState,
515
+		PatientComplains:          patient.PatientComplains,
516
+		PresentHistory:            patient.PresentHistory,
517
+		PastHistory:               patient.PastHistory,
518
+		Temperature:               patient.Temperature,
519
+		Pulse:                     patient.Pulse,
520
+		Respiratory:               patient.Respiratory,
521
+		Sbp:                       patient.SBP,
522
+		Dbp:                       patient.DBP,
523
+		Nation:                    patient.Nation,
524
+		NativePlace:               patient.NativePlace,
525
+		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(),
537
+	}
538
+	//	//更新病人ID获取新表病人ID
539
+	err = service.UpdatepatientTwo(&patientsNew, id)
540
+	fmt.Println("更新病人失败---------------------------------------", err)
458 541
 
459 542
 	if len(record_date) > 0 {
460 543
 		var recordTime int64
@@ -587,17 +670,17 @@ func (c *PatientApiController) EditLapseto() {
587 670
 	lapseto.Status = 1
588 671
 	patient.Lapseto = lapseto.LapsetoType
589 672
 
590
-	if patient.Lapseto == 1 {
591
-		patientTotal := service.GetLapsetoPatientCount(adminUserInfo.CurrentOrgId, 1)
592
-		subscibes := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
593
-		if subscibes.State == 2 && patientTotal >= 100 { //免费试用版,不过期,限制患者数20
594
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientReachLimit)
595
-			return
596
-		} else if subscibes.State == 1 && patientTotal >= 200 { //标准版,不过期,限制患者数60
597
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientReachLimit)
598
-			return
599
-		}
600
-	}
673
+	//if patient.Lapseto == 1 {
674
+	//	patientTotal := service.GetLapsetoPatientCount(adminUserInfo.CurrentOrgId, 1)
675
+	//	subscibes := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
676
+	//	if subscibes.State == 2 && patientTotal >= 100 { //免费试用版,不过期,限制患者数20
677
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientReachLimit)
678
+	//		return
679
+	//	} else if subscibes.State == 1 && patientTotal >= 200 { //标准版,不过期,限制患者数60
680
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientReachLimit)
681
+	//		return
682
+	//	}
683
+	//}
601 684
 
602 685
 	err = service.EditPatientLapseto(&patient, &lapseto)
603 686
 	if err != nil {

+ 15 - 1
service/patient_service.go Datei anzeigen

@@ -67,7 +67,7 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
67 67
 
68 68
 	offset := (page - 1) * limit
69 69
 
70
-	err = db.Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
70
+	err = db.Order("p.id desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
71 71
 	return
72 72
 }
73 73
 
@@ -122,6 +122,13 @@ func FindPatientById(orgID int64, id int64) (patient models.Patients, err error)
122 122
 	err = readDb.Model(&models.Patients{}).Where("id = ? and user_org_id=? and status=1", id, orgID).First(&patient).Error
123 123
 	return
124 124
 }
125
+
126
+func FindPatientByIdTwo(orgID int64, id int64) (patient models.XtPatientsNew, err error) {
127
+
128
+	err = readDb.Model(&models.XtPatientsNew{}).Where("blood_id = ? and user_org_id = ? and status =1", id, orgID).First(&patient).Error
129
+	return
130
+}
131
+
125 132
 func FindPatientByIdWithDiseases(orgID int64, id int64) (patient models.Patients, err error) {
126 133
 	err = readDb.Model(&models.Patients{}).Preload("Contagions", "status = 1").Preload("Diseases", "status = 1").Where("id = ? and user_org_id=? and status=1", id, orgID).First(&patient).Error
127 134
 	return
@@ -373,6 +380,13 @@ func UpdatePatient(patient *models.Patients, contagions []int64, diseases []int6
373 380
 	return
374 381
 }
375 382
 
383
+func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
384
+
385
+	err := XTWriteDB().Model(&patientsNew).Where("blood_id = ?", id).Update(map[string]interface{}{"user_org_id": patientsNew.UserOrgId, "user_id": patientsNew.UserId, "avatar": patientsNew.Avatar, "patient_type": patientsNew.Avatar, "dialysis_no": patientsNew.DialysisNo, "admission_number": patientsNew.AdmissionNumber, "source": patientsNew.Source, "lapseto": patientsNew.Lapseto, "partition_id": patientsNew.PartitionId, "bed_id": patientsNew.BedId, "name": patientsNew.Name, "alias": patientsNew.Alias, "gender": patientsNew.Gender, "marital_status": patientsNew.MaritalStatus, "id_card_no": patientsNew.IdCardNo, "birthday": patientsNew.Birthday, "reimbursement_way_id": patientsNew.ReimbursementWayId, "health_care_type": patientsNew.HealthCareType, "health_care_no": patientsNew.HealthCareType, "health_care_due_date": patientsNew.HealthCareType, "height": patientsNew.Height, "blood_type": patientsNew.BloodType, "rh": patientsNew.Rh, "health_care_due_alert_date": patientsNew.HealthCareDueAlertDate, "education_level": patientsNew.EducationLevel, "profession": patientsNew.Profession, "phone": patientsNew.Phone, "home_telephone": patientsNew.HomeTelephone, "relative_phone": patientsNew.RelativePhone, "relative_relations": patientsNew.RelativeRelations, "home_address": patientsNew.HomeAddress, "work_unit": patientsNew.WorkUnit, "unit_address": patientsNew.UnitAddress, "children": patientsNew.Children, "receiving_date": patientsNew.ReceivingDate, "is_hospital_first_dialysis": patientsNew.IsHospitalFirstDialysis, "first_dialysis_date": patientsNew.FirstDialysisDate, "first_dialysis_hospital": patientsNew.FirstDialysisHospital, "predialysis_condition": patientsNew.PredialysisCondition, "pre_hospital_dialysis_frequency": patientsNew.PreHospitalDialysisFrequency, "pre_hospital_dialysis_times": patientsNew.PreHospitalDialysisFrequency, "hospital_first_dialysis_date": patientsNew.HospitalFirstDialysisDate, "induction_period": patientsNew.InductionPeriod, "initial_dialysis": patientsNew.InitialDialysis, "total_dialysis": patientsNew.TotalDialysis, "attending_doctor_id": patientsNew.AttendingDoctorId, "head_nurse_id": patientsNew.HeadNurseId, "evaluate": patientsNew.Evaluate, "diagnose": patientsNew.Diagnose, "remark": patientsNew.Remark, "registrars_id": patientsNew.RegistrarsId, "registrars": patientsNew.Registrars, "qr_code": patientsNew.QrCode, "binding_state": patientsNew.BindingState, "patient_complains": patientsNew.PatientComplains, "present_history": patientsNew.PresentHistory, "past_history": patientsNew.PastHistory, "temperature": patientsNew.Temperature,
386
+		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients}).Error
387
+	return err
388
+}
389
+
376 390
 func GetLastInfectionRecord(id int64, org_id int64, project_id int64, date int64) (inspection models.Inspection, err error) {
377 391
 	err = readDb.Model(&models.Inspection{}).Where("patient_id=? and status=1 and org_id = ? and project_id = ? AND inspect_date = ? ", id, org_id, project_id, date).Last(&inspection).Error
378 392
 	return

+ 1 - 1
service/patientmanage_service.go Datei anzeigen

@@ -1254,7 +1254,7 @@ func GetAdminName(id int64) (models.AdminUsers, error) {
1254 1254
 	db := UserReadDB().Table("sgj_user_admin as x").Where("x.status = 1")
1255 1255
 	table := UserReadDB().Table("sgj_user_admin_role as r")
1256 1256
 	fmt.Println("table", table)
1257
-	err := db.Select("x.id,x.mobile,x.password,x.is_super_admin,x.source,x.name,r.admin_user_id,r.org_id,r.app_id,r.role_id,r.user_name,r.avatar,r.message,r.sex,r.birthday").Where("x.id = ?", id).Joins("left join sgj_user_admin_role as r on r.admin_user_id = x.id").Scan(&user).Error
1257
+	err := db.Group("x.id").Select("x.id,x.mobile,x.password,x.is_super_admin,x.source,x.name,r.admin_user_id,r.org_id,r.app_id,r.role_id,r.user_name,r.avatar,r.message,r.sex,r.birthday").Where("x.id = ?", id).Joins("left join sgj_user_admin_role as r on r.admin_user_id = x.id").Scan(&user).Error
1258 1258
 	return user, err
1259 1259
 }
1260 1260