XMLWAN hace 3 años
padre
commit
75f40472ce
Se han modificado 4 ficheros con 66 adiciones y 42 borrados
  1. 28 12
      controllers/his_api_controller.go
  2. 29 28
      controllers/role_controller.go
  3. 1 0
      models/his_models.go
  4. 8 2
      service/his_service.go

+ 28 - 12
controllers/his_api_controller.go Ver fichero

@@ -917,7 +917,7 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
917 917
 
918 918
 	blood_fat := c.GetString("blood_fat")
919 919
 	bloodfatfloat, _ := strconv.ParseFloat(blood_fat, 64)
920
-	//fmt.Println("33333333", bloodfatfloat)
920
+
921 921
 	blood_sugar := c.GetString("blood_sugar")
922 922
 	bloodsugarfloat, _ := strconv.ParseFloat(blood_sugar, 64)
923 923
 	fmt.Println(bloodsugarfloat)
@@ -927,9 +927,9 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
927 927
 	dbpfloat, _ := strconv.ParseFloat(dbp, 64)
928 928
 	delivery_way, _ := c.GetInt64("delivery_way")
929 929
 	diagnostic := c.GetString("diagnostic")
930
-	fmt.Println("diagnostic", diagnostic)
930
+
931 931
 	family_history := c.GetString("family_history")
932
-	fmt.Println(family_history)
932
+
933 933
 	height := c.GetString("height")
934 934
 	history_of_present_illness := c.GetString("history_of_present_illness")
935 935
 	is_infect, _ := c.GetInt64("is_infect")
@@ -957,12 +957,15 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
957 957
 	doctor_advice := c.GetString("doctor_advice")
958 958
 	remark := c.GetString("remark")
959 959
 	breathingfloat, _ := strconv.ParseFloat(breathing, 64)
960
-	//fmt.Println("breathingfloat", breathingfloat)
960
+
961 961
 	sick, _ := c.GetInt64("sick")
962 962
 	diagnose, _ := c.GetInt64("diagnose")
963
+	id, _ := c.GetInt64("id")
964
+
963 965
 	timeLayout := "2006-01-02"
964 966
 	loc, _ := time.LoadLocation("Local")
965 967
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
968
+	allergic_history := c.GetString("allergic_history")
966 969
 	if err != nil {
967 970
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
968 971
 		return
@@ -1008,17 +1011,30 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
1008 1011
 		Remark:                  remark,
1009 1012
 		Sick:                    sick,
1010 1013
 		Diagnose:                diagnose,
1014
+		AllergicHistory:         allergic_history,
1011 1015
 	}
1012
-
1013
-	err = service.SaveHisPatientCaseHistory(&caseHistory)
1014
-	if err != nil {
1015
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1016
+	//查询该患者是否有病历
1017
+	_, errcodes := service.GetHisPatientCaseHistoryById(id)
1018
+	if errcodes == gorm.ErrRecordNotFound {
1019
+		err = service.SaveHisPatientCaseHistory(&caseHistory)
1020
+		if err != nil {
1021
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1022
+			return
1023
+		}
1024
+		c.ServeSuccessJSON(map[string]interface{}{
1025
+			"caseHistory": caseHistory,
1026
+		})
1016 1027
 		return
1028
+	} else if errcodes == nil {
1029
+		err := service.UpdatePatientCaseHistory(id, &caseHistory)
1030
+		if err != nil {
1031
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1032
+			return
1033
+		}
1034
+		c.ServeSuccessJSON(map[string]interface{}{
1035
+			"caseHistory": caseHistory,
1036
+		})
1017 1037
 	}
1018
-	c.ServeSuccessJSON(map[string]interface{}{
1019
-		"caseHistory": caseHistory,
1020
-	})
1021
-	return
1022 1038
 
1023 1039
 	//查询该患者是否有病历
1024 1040
 	//_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)

+ 29 - 28
controllers/role_controller.go Ver fichero

@@ -982,33 +982,33 @@ func (this *RoleAPIController) AddAdmin() {
982 982
 			if total <= 0 {
983 983
 				//新增用户
984 984
 				app_role := &models.App_Role{
985
-					AdminUserId:    adminUser.Id,
986
-					OrgId:          adminUserInfo.CurrentOrgId,
987
-					AppId:          adminUserInfo.CurrentAppId,
988
-					Avatar:         "",
989
-					UserName:       name,
990
-					UserTitleName:  user_title_name,
991
-					Status:         1,
992
-					UserType:       int8(userType),
993
-					UserTitle:      int8(userTitle),
994
-					CreateTime:     time.Now().Unix(),
995
-					ModifyTime:     time.Now().Unix(),
996
-					RoleIds:        roleIds,
997
-					Department:     department,
998
-					DepartmentId:   department_id,
999
-					Sex:            sex,
1000
-					Age:            age,
1001
-					Nation:         nation,
1002
-					CardType:       card_type,
1003
-					IdCard:         id_card,
1004
-					Education:      education,
1005
-					StudyMajorName: study_major_name,
1006
-					WorkMajorName:  work_major_name,
1007
-					RoleType:       role_type,
1008
-					MedicalCode:    medical_code,
1009
-					DoctorCode:     doctor_code,
1010
-					Licensing:      licensing,
1011
-					JobNumber:      job_number,
985
+					AdminUserId:                             adminUser.Id,
986
+					OrgId:                                   adminUserInfo.CurrentOrgId,
987
+					AppId:                                   adminUserInfo.CurrentAppId,
988
+					Avatar:                                  "",
989
+					UserName:                                name,
990
+					UserTitleName:                           user_title_name,
991
+					Status:                                  1,
992
+					UserType:                                int8(userType),
993
+					UserTitle:                               int8(userTitle),
994
+					CreateTime:                              time.Now().Unix(),
995
+					ModifyTime:                              time.Now().Unix(),
996
+					RoleIds:                                 roleIds,
997
+					Department:                              department,
998
+					DepartmentId:                            department_id,
999
+					Sex:                                     sex,
1000
+					Age:                                     age,
1001
+					Nation:                                  nation,
1002
+					CardType:                                card_type,
1003
+					IdCard:                                  id_card,
1004
+					Education:                               education,
1005
+					StudyMajorName:                          study_major_name,
1006
+					WorkMajorName:                           work_major_name,
1007
+					RoleType:                                role_type,
1008
+					MedicalCode:                             medical_code,
1009
+					DoctorCode:                              doctor_code,
1010
+					Licensing:                               licensing,
1011
+					JobNumber:                               job_number,
1012 1012
 					PrescriptionQualificationIdentification: prescription_qualification_identification,
1013 1013
 					IdentificationOutpatients:               identification_outpatients,
1014 1014
 					StartTime:                               theStartTime.Unix(),
@@ -1126,7 +1126,7 @@ func (this *RoleAPIController) EditAdmin() {
1126 1126
 	department := this.GetString("department")
1127 1127
 	department_id, _ := this.GetInt64("department_id")
1128 1128
 	sort, _ := this.GetInt64("sort")
1129
-
1129
+	sex, _ := this.GetInt64("sex")
1130 1130
 	age, _ := this.GetInt64("age")
1131 1131
 	nation := this.GetString("nation")
1132 1132
 	card_type, _ := this.GetInt64("card_type")
@@ -1215,6 +1215,7 @@ func (this *RoleAPIController) EditAdmin() {
1215 1215
 	appRole.OutpatientIllnesscategory = outpatient_illnessCategory
1216 1216
 	appRole.IsActive = is_active
1217 1217
 	appRole.ActiveStatus = active_status
1218
+	appRole.Sex = sex
1218 1219
 	saveErr := service.SaveAppRole(appRole)
1219 1220
 	if saveErr != nil {
1220 1221
 		//beego.Error("修改App_Role失败:", saveErr)

+ 1 - 0
models/his_models.go Ver fichero

@@ -297,6 +297,7 @@ type HisPatientCaseHistory struct {
297 297
 	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
298 298
 	Sick                    int64   `gorm:"column:sick" json:"sick" form:"sick"`
299 299
 	Diagnose                int64   `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
300
+	AllergicHistory         string  `gorm:"column:allergic_history" json:"allergic_history" form:"allergic_history"`
300 301
 }
301 302
 
302 303
 func (HisPatientCaseHistory) TableName() string {

+ 8 - 2
service/his_service.go Ver fichero

@@ -243,9 +243,9 @@ func SaveHisPatientCaseHistoryTemplate(template models.HisCaseHistoryTemplate) (
243 243
 	return
244 244
 }
245 245
 
246
-func GetHisPatientCaseHistoryById(hispatientid int64) (*models.HisPatientCaseHistory, error) {
246
+func GetHisPatientCaseHistoryById(id int64) (*models.HisPatientCaseHistory, error) {
247 247
 	history := models.HisPatientCaseHistory{}
248
-	err := XTReadDB().Model(&history).Where("his_patient_id = ? and status = 1", hispatientid).Find(&history).Error
248
+	err := XTReadDB().Model(&history).Where("id = ? and status = 1", id).Find(&history).Error
249 249
 	if err != nil {
250 250
 		if err == gorm.ErrRecordNotFound {
251 251
 			return nil, err
@@ -261,6 +261,12 @@ func SaveHisPatientCaseHistory(caseHistory *models.HisPatientCaseHistory) error
261 261
 	return err
262 262
 }
263 263
 
264
+func UpdatePatientCaseHistory(id int64, his *models.HisPatientCaseHistory) error {
265
+
266
+	err := XTWriteDB().Model(&his).Where("id = ? and status  =1", id).Updates(map[string]interface{}{"temperature": his.Temperature, "blood_sugar": his.BloodSugar, "pulse": his.BloodSugar, "allergic_history": his.AllergicHistory, "diagnose": his.AllergicHistory, "sick": his.Sick, "remark": his.Remark, "doctor_advice": his.DoctorAdvice, "breathing": his.Breathing, "delivery_way": his.DeliveryWay, "diagnostic": his.Diagnostic, "family_history": his.FamilyHistory, "personal_history": his.PersonalHistory, "chief_conplaint": his.ChiefConplaint, "doctor": his.Doctor, "past_history": his.PastHistory, "history_of_present_illness": his.HistoryOfPresentIllness, "is_infect": his.IsInfect, "sick_date": his.SickDate, "symptom": his.Symptom, "sick_type": his.SickType, "blood_fat": his.BloodFat}).Error
267
+	return err
268
+}
269
+
264 270
 func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
265 271
 	err = writeDb.Save(&prescription).Error
266 272
 	return