XMLWAN 4 years ago
parent
commit
7af6d66b48

+ 8 - 2
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -530,14 +530,20 @@ func (this *CommonApiController) GetDialysislist() {
530 530
 	orgId := adminUser.CurrentOrgId
531 531
 
532 532
 	dialysislist, total, err := service.GetDialysisList(statime, entime, page, limit, orgId)
533
+
534
+	prescriptionList, _ := service.GetAllDialysisList(statime, entime, orgId)
535
+	list, totallist, _ := service.GetDialysisPatientList(statime, entime, page, limit, orgId)
533 536
 	fmt.Println("err", err)
534 537
 	if err != nil {
535 538
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
536 539
 		return
537 540
 	}
538 541
 	this.ServeSuccessJSON(map[string]interface{}{
539
-		"dialysislist": dialysislist,
540
-		"total":        total,
542
+		"dialysislist":     dialysislist,
543
+		"total":            total,
544
+		"list":             list,
545
+		"totallist":        totallist,
546
+		"prescriptionList": prescriptionList,
541 547
 	})
542 548
 }
543 549
 

+ 79 - 79
controllers/patient_api_controller.go View File

@@ -252,29 +252,29 @@ func (c *PatientApiController) CreatePatient() {
252 252
 	//获取老表的最后一条数据
253 253
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
254 254
 	patientsNew := models.XtPatientsNew{
255
-		UserOrgId:          adminUserInfo.CurrentOrgId,
256
-		UserId:             0,
257
-		Avatar:             patients.Avatar,
258
-		PatientType:        patients.PatientType,
259
-		DialysisNo:         patients.DialysisNo,
260
-		AdmissionNumber:    patients.AdmissionNumber,
261
-		Source:             patients.Source,
262
-		Lapseto:            patients.Lapseto,
263
-		PartitionId:        patients.PartitionId,
264
-		BedId:              patients.BedId,
265
-		Name:               patients.Name,
266
-		Alias:              patients.Alias,
267
-		Gender:             patients.Gender,
268
-		MaritalStatus:      patients.MaritalStatus,
269
-		IdCardNo:           patients.IdCardNo,
270
-		Birthday:           patients.Birthday,
271
-		ReimbursementWayId: patients.ReimbursementWayId,
272
-		HealthCareType:     patients.HealthCareType,
273
-		HealthCareNo:       patients.HealthCareNo,
274
-		HealthCareDueDate:  patients.HealthCareDueDate,
275
-		Height:             patients.Height,
276
-		BloodType:          patients.BloodType,
277
-		Rh:                 patients.Rh,
255
+		UserOrgId:                    adminUserInfo.CurrentOrgId,
256
+		UserId:                       0,
257
+		Avatar:                       patients.Avatar,
258
+		PatientType:                  patients.PatientType,
259
+		DialysisNo:                   patients.DialysisNo,
260
+		AdmissionNumber:              patients.AdmissionNumber,
261
+		Source:                       patients.Source,
262
+		Lapseto:                      patients.Lapseto,
263
+		PartitionId:                  patients.PartitionId,
264
+		BedId:                        patients.BedId,
265
+		Name:                         patients.Name,
266
+		Alias:                        patients.Alias,
267
+		Gender:                       patients.Gender,
268
+		MaritalStatus:                patients.MaritalStatus,
269
+		IdCardNo:                     patients.IdCardNo,
270
+		Birthday:                     patients.Birthday,
271
+		ReimbursementWayId:           patients.ReimbursementWayId,
272
+		HealthCareType:               patients.HealthCareType,
273
+		HealthCareNo:                 patients.HealthCareNo,
274
+		HealthCareDueDate:            patients.HealthCareDueDate,
275
+		Height:                       patients.Height,
276
+		BloodType:                    patients.BloodType,
277
+		Rh:                           patients.Rh,
278 278
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
279 279
 		EducationLevel:               patients.EducationLevel,
280 280
 		Profession:                   patients.Profession,
@@ -320,28 +320,28 @@ func (c *PatientApiController) CreatePatient() {
320 320
 		Nation:                       patients.Nation,
321 321
 		NativePlace:                  patients.NativePlace,
322 322
 		Age:                          patients.Age,
323
-		InfectiousNextRecordTime: patients.InfectiousNextRecordTime,
324
-		IsInfectious:             patients.IsInfectious,
325
-		RemindCycle:              patients.RemindCycle,
326
-		ResponseResult:           patients.ResponseResult,
327
-		IsOpenRemind:             patients.IsOpenRemind,
328
-		FirstTreatmentDate:       patients.FirstTreatmentDate,
329
-		DialysisAge:              patients.DialysisAge,
330
-		ExpenseKind:              patients.ExpenseKind,
331
-		TellPhone:                patients.TellPhone,
332
-		ContactName:              patients.ContactName,
333
-		BloodPatients:            1,
334
-		SlowPatients:             0,
335
-		MemberPatients:           0,
336
-		EcommerPatients:          "",
337
-		BloodId:                  patients.ID,
338
-		SlowId:                   0,
339
-		MemberId:                 0,
340
-		MemberFistdate:           0,
341
-		MemberPatienttype:        0,
342
-		MemberTreatement:         0,
343
-		EquitmentId:              "",
344
-		UserSysBeforeCount:       patient.UserSysBeforeCount,
323
+		InfectiousNextRecordTime:     patients.InfectiousNextRecordTime,
324
+		IsInfectious:                 patients.IsInfectious,
325
+		RemindCycle:                  patients.RemindCycle,
326
+		ResponseResult:               patients.ResponseResult,
327
+		IsOpenRemind:                 patients.IsOpenRemind,
328
+		FirstTreatmentDate:           patients.FirstTreatmentDate,
329
+		DialysisAge:                  patients.DialysisAge,
330
+		ExpenseKind:                  patients.ExpenseKind,
331
+		TellPhone:                    patients.TellPhone,
332
+		ContactName:                  patients.ContactName,
333
+		BloodPatients:                1,
334
+		SlowPatients:                 0,
335
+		MemberPatients:               0,
336
+		EcommerPatients:              "",
337
+		BloodId:                      patients.ID,
338
+		SlowId:                       0,
339
+		MemberId:                     0,
340
+		MemberFistdate:               0,
341
+		MemberPatienttype:            0,
342
+		MemberTreatement:             0,
343
+		EquitmentId:                  "",
344
+		UserSysBeforeCount:           patient.UserSysBeforeCount,
345 345
 	}
346 346
 
347 347
 	err = service.CreatePatientsNew(&patientsNew)
@@ -469,29 +469,29 @@ func (c *PatientApiController) EditPatient() {
469 469
 	}
470 470
 	fmt.Println("病人--------------------------------------------------------------", patient.Name, patient.Age)
471 471
 	patientsNew := models.XtPatientsNew{
472
-		UserOrgId:          patient.UserOrgId,
473
-		UserId:             patient.UserId,
474
-		Avatar:             patient.Avatar,
475
-		PatientType:        patient.PatientType,
476
-		DialysisNo:         patient.DialysisNo,
477
-		AdmissionNumber:    patient.AdmissionNumber,
478
-		Source:             patient.Source,
479
-		Lapseto:            patient.Lapseto,
480
-		PartitionId:        patient.PartitionId,
481
-		BedId:              patient.BedId,
482
-		Name:               patient.Name,
483
-		Alias:              patient.Alias,
484
-		Gender:             patient.Gender,
485
-		MaritalStatus:      patient.MaritalStatus,
486
-		IdCardNo:           patient.IdCardNo,
487
-		Birthday:           patient.Birthday,
488
-		ReimbursementWayId: patient.ReimbursementWayId,
489
-		HealthCareType:     patient.HealthCareType,
490
-		HealthCareNo:       patient.HealthCareNo,
491
-		HealthCareDueDate:  patient.HealthCareDueDate,
492
-		Height:             patient.Height,
493
-		BloodType:          patient.BloodType,
494
-		Rh:                 patient.Rh,
472
+		UserOrgId:                 patient.UserOrgId,
473
+		UserId:                    patient.UserId,
474
+		Avatar:                    patient.Avatar,
475
+		PatientType:               patient.PatientType,
476
+		DialysisNo:                patient.DialysisNo,
477
+		AdmissionNumber:           patient.AdmissionNumber,
478
+		Source:                    patient.Source,
479
+		Lapseto:                   patient.Lapseto,
480
+		PartitionId:               patient.PartitionId,
481
+		BedId:                     patient.BedId,
482
+		Name:                      patient.Name,
483
+		Alias:                     patient.Alias,
484
+		Gender:                    patient.Gender,
485
+		MaritalStatus:             patient.MaritalStatus,
486
+		IdCardNo:                  patient.IdCardNo,
487
+		Birthday:                  patient.Birthday,
488
+		ReimbursementWayId:        patient.ReimbursementWayId,
489
+		HealthCareType:            patient.HealthCareType,
490
+		HealthCareNo:              patient.HealthCareNo,
491
+		HealthCareDueDate:         patient.HealthCareDueDate,
492
+		Height:                    patient.Height,
493
+		BloodType:                 patient.BloodType,
494
+		Rh:                        patient.Rh,
495 495
 		HealthCareDueAlertDate:    patient.HealthCareDueAlertDate,
496 496
 		EducationLevel:            patient.EducationLevel,
497 497
 		Profession:                patient.Profession,
@@ -533,17 +533,17 @@ func (c *PatientApiController) EditPatient() {
533 533
 		Nation:                    patient.Nation,
534 534
 		NativePlace:               patient.NativePlace,
535 535
 		Age:                       patient.Age,
536
-		InfectiousNextRecordTime: patient.InfectiousNextRecordTime,
537
-		IsInfectious:             patient.IsInfectious,
538
-		RemindCycle:              patient.RemindCycle,
539
-		ResponseResult:           patient.ResponseResult,
540
-		IsOpenRemind:             patient.IsOpenRemind,
541
-		FirstTreatmentDate:       patient.FirstTreatmentDate,
542
-		DialysisAge:              patient.DialysisAge,
543
-		ExpenseKind:              patient.ExpenseKind,
544
-		TellPhone:                patient.TellPhone,
545
-		ContactName:              patient.ContactName,
546
-		UpdatedTime:              time.Now().Unix(),
536
+		InfectiousNextRecordTime:  patient.InfectiousNextRecordTime,
537
+		IsInfectious:              patient.IsInfectious,
538
+		RemindCycle:               patient.RemindCycle,
539
+		ResponseResult:            patient.ResponseResult,
540
+		IsOpenRemind:              patient.IsOpenRemind,
541
+		FirstTreatmentDate:        patient.FirstTreatmentDate,
542
+		DialysisAge:               patient.DialysisAge,
543
+		ExpenseKind:               patient.ExpenseKind,
544
+		TellPhone:                 patient.TellPhone,
545
+		ContactName:               patient.ContactName,
546
+		UpdatedTime:               time.Now().Unix(),
547 547
 	}
548 548
 	//	//更新病人ID获取新表病人ID
549 549
 	err = service.UpdatepatientTwo(&patientsNew, id)

+ 2 - 0
models/common_models.go View File

@@ -276,6 +276,8 @@ type BloodDialysisPrescription struct {
276 276
 	Name                       string  `gorm:"column:name" json:"name" form:"name"`
277 277
 	DialysisNo                 string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
278 278
 	IdCardNo                   string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
279
+	TotalDialysis              int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
280
+	UserSysBeforeCount         int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
279 281
 }
280 282
 
281 283
 func (BloodDialysisPrescription) TableName() string {

+ 37 - 2
service/common_service.go View File

@@ -321,7 +321,6 @@ func GetCurentOrgPatients(orgid int64) (patients []*models.XtPatients, err error
321 321
 }
322 322
 
323 323
 func GetDialysisList(startime int64, endtime int64, page int64, limit int64, orgid int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
324
-	fmt.Println(startime, endtime)
325 324
 	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
326 325
 	table := XTReadDB().Table("xt_patients as s")
327 326
 	fmt.Println("table", table)
@@ -335,7 +334,43 @@ func GetDialysisList(startime int64, endtime int64, page int64, limit int64, org
335 334
 		db = db.Where("p.record_date <=?", endtime)
336 335
 	}
337 336
 	offset := (page - 1) * limit
338
-	err = db.Group("p.patient_id,p.mode_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no").Joins("left join xt_patients as s on s.id = p.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&prescription).Error
337
+	err = db.Group("p.patient_id,p.mode_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no,s.total_dialysis,s.user_sys_before_count").Joins("left join xt_patients as s on s.id = p.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&prescription).Error
338
+	return prescription, total, err
339
+}
340
+
341
+func GetAllDialysisList(startime int64, endtime int64, orgid int64) (prescription []*models.BloodDialysisPrescription, err error) {
342
+
343
+	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
344
+	table := XTReadDB().Table("xt_patients as s")
345
+	fmt.Println(table)
346
+	if orgid > 0 {
347
+		db = db.Where("p.user_org_id = ?", orgid)
348
+	}
349
+	if startime > 0 {
350
+		db = db.Where("p.record_date >= ?", startime)
351
+	}
352
+	if endtime > 0 {
353
+		db = db.Where("p.record_date <=?", endtime)
354
+	}
355
+	err = db.Group("p.patient_id,p.mode_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no,s.total_dialysis,s.user_sys_before_count").Joins("left join xt_patients as s on s.id = p.patient_id").Scan(&prescription).Error
356
+	return prescription, err
357
+}
358
+
359
+func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int64, orgid int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
360
+	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
361
+	table := XTReadDB().Table("xt_patients as s")
362
+	fmt.Println("table", table)
363
+	if orgid > 0 {
364
+		db = db.Where("p.user_org_id = ?", orgid)
365
+	}
366
+	if startime > 0 {
367
+		db = db.Where("p.record_date >= ?", startime)
368
+	}
369
+	if endtime > 0 {
370
+		db = db.Where("p.record_date <=?", endtime)
371
+	}
372
+	offset := (page - 1) * limit
373
+	err = db.Group("p.patient_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no,s.total_dialysis,s.user_sys_before_count").Joins("left join xt_patients as s on s.id = p.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&prescription).Error
339 374
 	return prescription, total, err
340 375
 }
341 376