Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
f091b3e395
2 changed files with 81 additions and 16 deletions
  1. 56 16
      controllers/his_project_api_controller.go
  2. 25 0
      service/his_project_service.go

+ 56 - 16
controllers/his_project_api_controller.go View File

@@ -5,7 +5,6 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
-	"encoding/json"
9 8
 	"fmt"
10 9
 	"github.com/astaxie/beego"
11 10
 	"github.com/jinzhu/gorm"
@@ -52,6 +51,8 @@ func HisProjectRouters() {
52 51
 	beego.Router("/api/his/gettreatlist", &HisProjectApiController{}, "Get:GetTreatmentList")
53 52
 	beego.Router("/api/his/getpatientinformation", &HisProjectApiController{}, "Get:GetPatientInformation")
54 53
 	beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
54
+	beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
55
+	beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
55 56
 }
56 57
 
57 58
 func (this *HisProjectApiController) SaveProject() {
@@ -768,13 +769,13 @@ func (this *HisProjectApiController) SaveHisPatient() {
768 769
 			IsNeedCostOfProduction: cost_checked,
769 770
 			TreatmentCost:          medicalExpense_float,
770 771
 			MedicalInsuranceNumber: medicalinsurancecard,
771
-			Name:                name,
772
-			RegisterType:        register,
773
-			RegisterCost:        registrationfees_float,
774
-			BalanceAccountsType: settlementValue,
775
-			Gender:              sex,
776
-			Total:               totals_float,
777
-			UserOrgId:           orgId,
772
+			Name:                   name,
773
+			RegisterType:           register,
774
+			RegisterCost:           registrationfees_float,
775
+			BalanceAccountsType:    settlementValue,
776
+			Gender:                 sex,
777
+			Total:                  totals_float,
778
+			UserOrgId:              orgId,
778 779
 		}
779 780
 		err := service.CreateHisPatient(&patient)
780 781
 		if err != nil {
@@ -797,14 +798,14 @@ func (this *HisProjectApiController) SaveHisPatient() {
797 798
 			IsNeedCostOfProduction: cost_checked,
798 799
 			TreatmentCost:          medicalExpense_float,
799 800
 			MedicalInsuranceNumber: medicalinsurancecard,
800
-			Name:                name,
801
-			RegisterType:        register,
802
-			RegisterCost:        registrationfees_float,
803
-			BalanceAccountsType: settlementValue,
804
-			Gender:              sex,
805
-			Total:               totals_float,
806
-			UserOrgId:           orgId,
807
-			PatientId:           bloodPatient.ID,
801
+			Name:                   name,
802
+			RegisterType:           register,
803
+			RegisterCost:           registrationfees_float,
804
+			BalanceAccountsType:    settlementValue,
805
+			Gender:                 sex,
806
+			Total:                  totals_float,
807
+			UserOrgId:              orgId,
808
+			PatientId:              bloodPatient.ID,
808 809
 		}
809 810
 		err := service.CreateHisPatient(&patient)
810 811
 		if err != nil {
@@ -831,3 +832,42 @@ func (this *HisProjectApiController) GetAllProjectTeam() {
831 832
 		"team": team,
832 833
 	})
833 834
 }
835
+
836
+func (this *HisProjectApiController) GetProjectListById() {
837
+
838
+	adminUserInfo := this.GetAdminUserInfo()
839
+	orgId := adminUserInfo.CurrentOrgId
840
+	project_id := this.GetString("project_id")
841
+	idStrs := strings.Split(project_id, ",")
842
+	project, err := service.GetProjectListById(orgId, idStrs)
843
+	if err != nil {
844
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
845
+		return
846
+	}
847
+	this.ServeSuccessJSON(map[string]interface{}{
848
+		"project": project,
849
+	})
850
+}
851
+
852
+func (this *HisProjectApiController) GetHisPatientHistory() {
853
+	timeLayout := "2006-01-02"
854
+	loc, _ := time.LoadLocation("Local")
855
+	keyword := this.GetString("keyword")
856
+	start_time := this.GetString("start_time")
857
+	end_time := this.GetString("end_time")
858
+	register_type, _ := this.GetInt64("register_type")
859
+	limit, _ := this.GetInt64("limit")
860
+	page, _ := this.GetInt64("page")
861
+	fmt.Println(keyword, start_time, end_time, register_type, limit, page)
862
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
863
+	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
864
+	history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page)
865
+	if err != nil {
866
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
867
+		return
868
+	}
869
+	this.ServeSuccessJSON(map[string]interface{}{
870
+		"history": history,
871
+		"total":   total,
872
+	})
873
+}

+ 25 - 0
service/his_project_service.go View File

@@ -278,3 +278,28 @@ func GetAllProjectTeam(orgid int64) (project []*models.XtHisProjectTeam, err err
278 278
 	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
279 279
 	return project, err
280 280
 }
281
+
282
+func GetProjectListById(orgid int64, ids []string) (project []*models.XtHisProject, err error) {
283
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and id in (?)", orgid, ids).Find(&project).Error
284
+	return project, err
285
+}
286
+
287
+func GetHisPatientHistory(keyword string, startime int64, endtime int64, registtype int64, limit int64, page int64) (hisPatient []*models.XtHisPatient, total int64, err error) {
288
+	offset := (page - 1) * limit
289
+	likeKey := "%" + keyword + "%"
290
+	db := XTReadDB().Table("his_patient as x").Where("x.status = 1")
291
+	if len(keyword) > 0 {
292
+		db = db.Where("x.name like ?", likeKey)
293
+	}
294
+	if startime > 0 {
295
+		db = db.Where("x.record_date >= ?", startime)
296
+	}
297
+	if endtime > 0 {
298
+		db = db.Where("x.record_date<=?", endtime)
299
+	}
300
+	if registtype > 0 {
301
+		db = db.Where("x.register_type = ?", registtype)
302
+	}
303
+	err = db.Select("x.id,x.balance_accounts_type,x.medical_insurance_number,x.name,x.gender,x.id_type,x.medical_treatment_type,x.birthday,x.record_date,x.age,x.phone_number,x.id_card_no,x.register_type,x.admin_user_id,x.departments,x.is_need_cost_of_production,x.register_cost,x.treatment_cost,x.cost_of_production,x.total,x.user_org_id,x.patient_id,x.number").Count(&total).Offset(offset).Limit(limit).Find(&hisPatient).Error
304
+	return hisPatient, total, err
305
+}