XMLWAN il y a 4 ans
Parent
révision
ccd1c8eb22
3 fichiers modifiés avec 61 ajouts et 31 suppressions
  1. 23 7
      controllers/his_project_api_controller.go
  2. 19 19
      models/his_models.go
  3. 19 5
      service/his_project_service.go

+ 23 - 7
controllers/his_project_api_controller.go Voir le fichier

@@ -77,6 +77,7 @@ func HisProjectRouters() {
77 77
 	beego.Router("/api/hispatient/getallhispatient", &HisProjectApiController{}, "Get:GetAllHisPatient")
78 78
 	beego.Router("/api/hispatient/getchargeprint", &HisProjectApiController{}, "Get:GetChargePrint")
79 79
 	beego.Router("/api/hispatient/gettodayschedulepatient", &HisProjectApiController{}, "Get:GetTodaySchedulePatient")
80
+	beego.Router("/api/hispatient/gethispatientdetail", &HisProjectApiController{}, "Get:GetHisPatientDetail")
80 81
 }
81 82
 
82 83
 func (this *HisProjectApiController) SaveProject() {
@@ -1035,20 +1036,22 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1035 1036
 	loc, _ := time.LoadLocation("Local")
1036 1037
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1037 1038
 	recordDateTime := theTime.Unix()
1038
-	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime)
1039
-	//
1039
+	fmt.Println("recordDateTime-----------", recordDateTime)
1040
+	prescription_id, _ := this.GetInt64("prescription_id")
1041
+	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, prescription_id)
1042
+
1040 1043
 	doctorPorject, err := service.GetDoctorProjectItem(patient_id, recordDateTime)
1041 1044
 	patient, err := service.GetBloodPatientByPatient(patient_id)
1042
-	//hisPatient, err := service.GetHisPatientById(patient_id)
1045
+	prescriptionInfo, err := service.GetPrscriptionInfo(patient_id, recordDateTime)
1043 1046
 	if err != nil {
1044 1047
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1045 1048
 		return
1046 1049
 	}
1047 1050
 	this.ServeSuccessJSON(map[string]interface{}{
1048
-		"advicePrint": advicePrint,
1049
-		//"hisPatient":hisPatient,
1050
-		"patient":       patient,
1051
-		"doctorPorject": doctorPorject,
1051
+		"advicePrint":      advicePrint,
1052
+		"patient":          patient,
1053
+		"doctorPorject":    doctorPorject,
1054
+		"prescriptionInfo": prescriptionInfo,
1052 1055
 	})
1053 1056
 }
1054 1057
 
@@ -1347,3 +1350,16 @@ func (this *HisProjectApiController) GetTodaySchedulePatient() {
1347 1350
 		"patient": patient,
1348 1351
 	})
1349 1352
 }
1353
+
1354
+func (this *HisProjectApiController) GetHisPatientDetail() {
1355
+	patient_id, _ := this.GetInt64("patient_id")
1356
+
1357
+	hisPatient, err := service.GetHisPatientById(patient_id)
1358
+	if err != nil {
1359
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1360
+		return
1361
+	}
1362
+	this.ServeSuccessJSON(map[string]interface{}{
1363
+		"hisPatient": hisPatient,
1364
+	})
1365
+}

+ 19 - 19
models/his_models.go Voir le fichier

@@ -418,25 +418,25 @@ func (HisDoctorAdviceTemplate) TableName() string {
418 418
 }
419 419
 
420 420
 type HisPrescriptionProject struct {
421
-	ID                 int64      `gorm:"column:id" json:"id" form:"id"`
422
-	ProjectId          int64      `gorm:"column:project_id" json:"project_id" form:"project_id"`
423
-	Price              float64    `gorm:"column:price" json:"price" form:"price"`
424
-	UserOrgId          int64      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
425
-	Status             int64      `gorm:"column:status" json:"status" form:"status"`
426
-	Ctime              int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
427
-	Mtime              int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
428
-	PatientId          int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
429
-	HisPatientId       int64      `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
430
-	RecordDate         int64      `gorm:"column:record_date" json:"record_date" form:"record_date"`
431
-	PrescriptionId     int64      `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
432
-	Count              int64      `gorm:"column:count" json:"count" form:"count"`
433
-	FeedetlSn          string     `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
434
-	MedListCodg        string     `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
435
-	SingleDose         string     `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
436
-	DeliveryWay        string     `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
437
-	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
438
-	Day                string     `gorm:"column:day" json:"day" form:"day"`
439
-	HisProject         HisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
421
+	ID                 int64         `gorm:"column:id" json:"id" form:"id"`
422
+	ProjectId          int64         `gorm:"column:project_id" json:"project_id" form:"project_id"`
423
+	Price              float64       `gorm:"column:price" json:"price" form:"price"`
424
+	UserOrgId          int64         `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
425
+	Status             int64         `gorm:"column:status" json:"status" form:"status"`
426
+	Ctime              int64         `gorm:"column:ctime" json:"ctime" form:"ctime"`
427
+	Mtime              int64         `gorm:"column:mtime" json:"mtime" form:"mtime"`
428
+	PatientId          int64         `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
429
+	HisPatientId       int64         `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
430
+	RecordDate         int64         `gorm:"column:record_date" json:"record_date" form:"record_date"`
431
+	PrescriptionId     int64         `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
432
+	Count              int64         `gorm:"column:count" json:"count" form:"count"`
433
+	FeedetlSn          string        `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
434
+	MedListCodg        string        `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
435
+	SingleDose         string        `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
436
+	DeliveryWay        string        `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
437
+	ExecutionFrequency string        `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
438
+	Day                string        `gorm:"column:day" json:"day" form:"day"`
439
+	HisProject         []*HisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
440 440
 }
441 441
 
442 442
 func (HisPrescriptionProject) TableName() string {

+ 19 - 5
service/his_project_service.go Voir le fichier

@@ -355,8 +355,15 @@ func GetBloodPatientByPatient(id int64) (models.XtPatients, error) {
355 355
 	return patients, err
356 356
 }
357 357
 
358
-func GetHisPatientById(patientid int64) (models.HisPatient, error) {
359
-	patient := models.HisPatient{}
358
+func GetHisPatientByIdTwo(patientid int64) (models.XtHisPatient, error) {
359
+
360
+	patient := models.XtHisPatient{}
361
+	err := XTReadDB().Model(&patient).Where("patient_id = ? and status=1", patientid).Find(&patient).Error
362
+	return patient, err
363
+}
364
+
365
+func GetHisPatientById(patientid int64) (models.VMHisPatient, error) {
366
+	patient := models.VMHisPatient{}
360 367
 	err := XTReadDB().Model(&patient).Where("patient_id = ? and status = 1", patientid).Find(&patient).Error
361 368
 	return patient, err
362 369
 }
@@ -380,9 +387,9 @@ func GetHistPatient(orgid int64, keyword string) (hisPatient []*models.HisPatien
380 387
 	return hisPatient, err
381 388
 }
382 389
 
383
-func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64) (prescription []*models.HisDoctorAdviceInfo, err error) {
390
+func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, prescription_id int64) (prescription []*models.HisDoctorAdviceInfo, err error) {
384 391
 
385
-	err = XTReadDB().Model(&prescription).Where("patient_id = ? and status = 1 and advice_date = ?", his_patient_id, recorddate).Find(&prescription).Error
392
+	err = XTReadDB().Model(&prescription).Where("patient_id = ? and status = 1 and advice_date = ? and prescription_id = ?", his_patient_id, recorddate, prescription_id).Find(&prescription).Error
386 393
 	return prescription, err
387 394
 }
388 395
 
@@ -525,7 +532,7 @@ func GetChargePrintTemplate(orgid int64) (models.XtHisChargeTemplate, error) {
525 532
 func GetDoctorProjectItem(patientid int64, record_date int64) (models.HisPrescriptionProject, error) {
526 533
 
527 534
 	project := models.HisPrescriptionProject{}
528
-	err := XTReadDB().Model(&project).Where("patient_id = ? and record_date = ? and status = 1", patientid, record_date).Error
535
+	err := XTReadDB().Model(&project).Where("patient_id = ? and record_date = ? and status = 1", patientid, record_date).Preload("HisProject", "status = 1").Find(&project).Error
529 536
 	return project, err
530 537
 }
531 538
 
@@ -567,3 +574,10 @@ func GetTodaySchedulePatient(orgid int64, scheduledata int64) (schedule []*model
567 574
 	err = db.Select("x.id,x.patient_id,x.schedule_date,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Scan(&schedule).Error
568 575
 	return schedule, err
569 576
 }
577
+
578
+func GetPrscriptionInfo(patientid int64, recorddata int64) (info []*models.HisPrescriptionInfo, err error) {
579
+
580
+	err = XTReadDB().Model(&info).Where("patient_id = ? and status = 1 and record_date = ?", patientid, recorddata).Find(&info).Error
581
+	return info, err
582
+
583
+}