Browse Source

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

csx 4 years ago
parent
commit
33a8bb9a70

+ 43 - 2
controllers/his_project_api_controller.go View File

76
 	beego.Router("/api/hispatient/getchargeprint", &HisProjectApiController{}, "Get:GetChargePrint")
76
 	beego.Router("/api/hispatient/getchargeprint", &HisProjectApiController{}, "Get:GetChargePrint")
77
 	beego.Router("/api/hispatient/gettodayschedulepatient", &HisProjectApiController{}, "Get:GetTodaySchedulePatient")
77
 	beego.Router("/api/hispatient/gettodayschedulepatient", &HisProjectApiController{}, "Get:GetTodaySchedulePatient")
78
 	beego.Router("/api/hispatient/gethispatientdetail", &HisProjectApiController{}, "Get:GetHisPatientDetail")
78
 	beego.Router("/api/hispatient/gethispatientdetail", &HisProjectApiController{}, "Get:GetHisPatientDetail")
79
+
80
+	beego.Router("/api/hispatient/getalldepartmentlist", &HisProjectApiController{}, "Get:GetAllDepartmentList")
81
+	beego.Router("/api/hispatient/getprescription", &HisProjectApiController{}, "Get:GetPrescription")
79
 }
82
 }
80
 
83
 
81
 func (this *HisProjectApiController) SaveProject() {
84
 func (this *HisProjectApiController) SaveProject() {
729
 	recordDateStr := time.Now().Format("2006-01-02")
732
 	recordDateStr := time.Now().Format("2006-01-02")
730
 	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
733
 	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
731
 	nowtime := recordDate.Unix()
734
 	nowtime := recordDate.Unix()
732
-
735
+	phone := this.GetString("phone")
736
+	social_type, _ := this.GetInt64("social_type")
733
 	bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
737
 	bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
734
 	if errcode == gorm.ErrRecordNotFound {
738
 	if errcode == gorm.ErrRecordNotFound {
735
 		patient := models.XtHisPatient{
739
 		patient := models.XtHisPatient{
756
 			RecordDate:          nowtime,
760
 			RecordDate:          nowtime,
757
 			IsReturn:            1,
761
 			IsReturn:            1,
758
 			Ctime:               time.Now().Unix(),
762
 			Ctime:               time.Now().Unix(),
763
+			Phone:               phone,
764
+			SocialType:          social_type,
759
 		}
765
 		}
760
 		err := service.CreateHisPatient(&patient)
766
 		err := service.CreateHisPatient(&patient)
761
 		lastPatient, err := service.GetLastPatient(orgId)
767
 		lastPatient, err := service.GetLastPatient(orgId)
762
 		timeStr := time.Now().Format("2006-01-02")
768
 		timeStr := time.Now().Format("2006-01-02")
763
 		timeArr := strings.Split(timeStr, "-")
769
 		timeArr := strings.Split(timeStr, "-")
764
 		var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
770
 		var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
765
-		fmt.Println("str--------", str)
771
+
766
 		hisPatient := models.HisPatient{
772
 		hisPatient := models.HisPatient{
767
 			Number: str,
773
 			Number: str,
768
 		}
774
 		}
797
 			UserOrgId:           orgId,
803
 			UserOrgId:           orgId,
798
 			PatientId:           bloodPatient.ID,
804
 			PatientId:           bloodPatient.ID,
799
 			Ctime:               time.Now().Unix(),
805
 			Ctime:               time.Now().Unix(),
806
+			Phone:               phone,
807
+			SocialType:          social_type,
800
 		}
808
 		}
801
 		err := service.CreateHisPatient(&patient)
809
 		err := service.CreateHisPatient(&patient)
802
 		if err != nil {
810
 		if err != nil {
1316
 		"hisPatient": hisPatient,
1324
 		"hisPatient": hisPatient,
1317
 	})
1325
 	})
1318
 }
1326
 }
1327
+
1328
+func (this *HisProjectApiController) GetAllDepartmentList() {
1329
+
1330
+	adminUserInfo := this.GetAdminUserInfo()
1331
+	orgId := adminUserInfo.CurrentOrgId
1332
+	departMent, err := service.GetAllDepartMent(orgId)
1333
+	if err != nil {
1334
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1335
+		return
1336
+	}
1337
+	this.ServeSuccessJSON(map[string]interface{}{
1338
+		"departMent": departMent,
1339
+	})
1340
+}
1341
+
1342
+func (this *HisProjectApiController) GetPrescription() {
1343
+
1344
+	patient_id, _ := this.GetInt64("patient_id")
1345
+	fmt.Println("patient_id", patient_id)
1346
+	timeStr := time.Now().Format("2006-01-02")
1347
+	timeLayout := "2006-01-02 15:04:05"
1348
+	fmt.Println("timeStr:", timeStr)
1349
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
1350
+	timenow := timeStringToTime.Unix()
1351
+	list, err := service.GetPrescriptionByPatientId(patient_id, timenow)
1352
+	if err != nil {
1353
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1354
+		return
1355
+	}
1356
+	this.ServeSuccessJSON(map[string]interface{}{
1357
+		"list": list,
1358
+	})
1359
+}

+ 8 - 4
controllers/role_controller.go View File

874
 	userTitle, _ := this.GetInt("title")
874
 	userTitle, _ := this.GetInt("title")
875
 	roleIds := this.GetString("role")
875
 	roleIds := this.GetString("role")
876
 	user_title_name := this.GetString("user_title_name")
876
 	user_title_name := this.GetString("user_title_name")
877
-	department_name := this.GetString("department_name")
877
+	department := this.GetString("department")
878
 	department_id, _ := this.GetInt64("department_id")
878
 	department_id, _ := this.GetInt64("department_id")
879
-
880
 	if len(mobile) == 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || len(roleIds) <= 0 {
879
 	if len(mobile) == 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || len(roleIds) <= 0 {
881
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
880
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
882
 		return
881
 		return
889
 		return
888
 		return
890
 	} else {
889
 	} else {
891
 		if adminUser == nil { //新增账号和用户
890
 		if adminUser == nil { //新增账号和用户
892
-			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile, name, user_title_name, roleIds, userType, userTitle, department_id, department_name)
891
+			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile, name, user_title_name, roleIds, userType, userTitle, department_id, department)
893
 			if createErr != nil {
892
 			if createErr != nil {
894
 				//beego.Error("创建管理员失败:", createErr)
893
 				//beego.Error("创建管理员失败:", createErr)
895
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
894
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
922
 					CreateTime:    time.Now().Unix(),
921
 					CreateTime:    time.Now().Unix(),
923
 					ModifyTime:    time.Now().Unix(),
922
 					ModifyTime:    time.Now().Unix(),
924
 					RoleIds:       roleIds,
923
 					RoleIds:       roleIds,
924
+					Department:    department,
925
+					DepartmentId:  department_id,
925
 				}
926
 				}
926
 				err := service.CreateUserRole(app_role)
927
 				err := service.CreateUserRole(app_role)
927
 				if err != nil {
928
 				if err != nil {
1022
 	roleIds := this.GetString("role")
1023
 	roleIds := this.GetString("role")
1023
 	intro := this.GetString("intro")
1024
 	intro := this.GetString("intro")
1024
 	user_title_name := this.GetString("user_title_name")
1025
 	user_title_name := this.GetString("user_title_name")
1026
+	department := this.GetString("department")
1027
+	department_id, _ := this.GetInt64("department_id")
1025
 	sort, _ := this.GetInt64("sort")
1028
 	sort, _ := this.GetInt64("sort")
1026
 	_, titleExist := models.UserTitle[userTitle]
1029
 	_, titleExist := models.UserTitle[userTitle]
1027
 	if adminUserId <= 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || !titleExist || len(roleIds) <= 0 {
1030
 	if adminUserId <= 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || !titleExist || len(roleIds) <= 0 {
1039
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
1042
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
1040
 		return
1043
 		return
1041
 	}
1044
 	}
1042
-
1045
+	appRole.Department = department
1046
+	appRole.DepartmentId = department_id
1043
 	appRole.UserName = name
1047
 	appRole.UserName = name
1044
 	appRole.UserType = int8(userType)
1048
 	appRole.UserType = int8(userType)
1045
 	appRole.UserTitle = int8(userTitle)
1049
 	appRole.UserTitle = int8(userTitle)

+ 2 - 0
models/his_models.go View File

526
 	Number                 string  `gorm:"column:number" json:"number" form:"number"`
526
 	Number                 string  `gorm:"column:number" json:"number" form:"number"`
527
 	Doctor                 int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
527
 	Doctor                 int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
528
 	IsReturn               int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
528
 	IsReturn               int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
529
+	Phone                  string  `gorm:"column:phone" json:"phone" form:"phone"`
530
+	SocialType             int64   `gorm:"column:social_type" json:"social_type" form:"social_type"`
529
 }
531
 }
530
 
532
 
531
 func (XtHisPatient) TableName() string {
533
 func (XtHisPatient) TableName() string {

+ 6 - 0
service/his_project_service.go View File

581
 	return info, err
581
 	return info, err
582
 
582
 
583
 }
583
 }
584
+
585
+func GetPrescriptionByPatientId(patient_id int64, startime int64) (prescritpion []*models.HisPrescription, err error) {
586
+
587
+	err = XTReadDB().Model(&prescritpion).Where("patient_id = ? and record_date =?", patient_id, startime).Find(&prescritpion).Error
588
+	return prescritpion, err
589
+}