XMLWAN hace 4 años
padre
commit
e72234e348

+ 24 - 12
controllers/his_api_controller.go Ver fichero

6
 	"XT_New/service"
6
 	"XT_New/service"
7
 	"XT_New/utils"
7
 	"XT_New/utils"
8
 	"encoding/json"
8
 	"encoding/json"
9
+	"fmt"
9
 	"github.com/astaxie/beego"
10
 	"github.com/astaxie/beego"
10
 	"reflect"
11
 	"reflect"
11
 	"strconv"
12
 	"strconv"
129
 }
130
 }
130
 func (c *HisApiController) CreateHisPrescription() {
131
 func (c *HisApiController) CreateHisPrescription() {
131
 	record_date := c.GetString("record_date")
132
 	record_date := c.GetString("record_date")
133
+	fmt.Println("record_date", record_date)
132
 	patient_id, _ := c.GetInt64("patient_id")
134
 	patient_id, _ := c.GetInt64("patient_id")
133
 	//diagnose := c.GetString("diagnose")
135
 	//diagnose := c.GetString("diagnose")
134
 	//sick_history := c.GetString("sick_history")
136
 	//sick_history := c.GetString("sick_history")
135
 	doctor, _ := c.GetInt64("doctor")
137
 	doctor, _ := c.GetInt64("doctor")
136
 	//departm/**/ent, _ := c.GetInt64("department")
138
 	//departm/**/ent, _ := c.GetInt64("department")
137
-
139
+	his_patient_id, _ := c.GetInt64("his_patient_id")
138
 	dataBody := make(map[string]interface{}, 0)
140
 	dataBody := make(map[string]interface{}, 0)
139
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
141
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
140
 	if err != nil {
142
 	if err != nil {
169
 
171
 
170
 				ctime := time.Now().Unix()
172
 				ctime := time.Now().Unix()
171
 				prescription := &models.HisPrescription{
173
 				prescription := &models.HisPrescription{
172
-					PatientId:  patient_id,
173
-					UserOrgId:  adminInfo.CurrentOrgId,
174
-					RecordDate: recordDateTime,
175
-					Ctime:      ctime,
176
-					Mtime:      ctime,
177
-					Type:       types,
178
-					Modifier:   adminInfo.AdminUser.Id,
179
-					Creator:    adminInfo.AdminUser.Id,
180
-					Status:     1,
181
-					Doctor:     doctor,
174
+					PatientId:    patient_id,
175
+					UserOrgId:    adminInfo.CurrentOrgId,
176
+					RecordDate:   recordDateTime,
177
+					Ctime:        ctime,
178
+					Mtime:        ctime,
179
+					Type:         types,
180
+					Modifier:     adminInfo.AdminUser.Id,
181
+					Creator:      adminInfo.AdminUser.Id,
182
+					Status:       1,
183
+					Doctor:       doctor,
184
+					HisPatientId: his_patient_id,
182
 				}
185
 				}
183
 				service.SaveHisPrescription(prescription)
186
 				service.SaveHisPrescription(prescription)
184
 
187
 
205
 							s.CreatedTime = ctime
208
 							s.CreatedTime = ctime
206
 							s.UpdatedTime = mtime
209
 							s.UpdatedTime = mtime
207
 							s.PatientId = patient_id
210
 							s.PatientId = patient_id
208
-
211
+							s.HisPatientId = his_patient_id
209
 							errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
212
 							errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
210
 							if errcode > 0 {
213
 							if errcode > 0 {
211
 								c.ServeFailJSONWithSGJErrorCode(errcode)
214
 								c.ServeFailJSONWithSGJErrorCode(errcode)
226
 							p.PatientId = patient_id
229
 							p.PatientId = patient_id
227
 							p.RecordDate = recordDateTime
230
 							p.RecordDate = recordDateTime
228
 							p.UserOrgId = adminInfo.CurrentOrgId
231
 							p.UserOrgId = adminInfo.CurrentOrgId
232
+							p.HisPatientId = his_patient_id
229
 							errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
233
 							errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
230
 							if errcode > 0 {
234
 							if errcode > 0 {
231
 								c.ServeFailJSONWithSGJErrorCode(errcode)
235
 								c.ServeFailJSONWithSGJErrorCode(errcode)
237
 				}
241
 				}
238
 			}
242
 			}
239
 		}
243
 		}
244
+
245
+		//查询患者今日处方信息
246
+		//_, errcode := service.GetHisPrescriptionTwo(his_patient_id, adminInfo.CurrentOrgId, recordDateTime)
247
+		//if errcode == nil{
248
+		//    //改变患者信息状态
249
+		//   service.UpdatedHisPatient(his_patient_id, adminInfo.CurrentOrgId, recordDateTime)
250
+		//
251
+		//}
240
 	}
252
 	}
241
 
253
 
242
 	if err == nil {
254
 	if err == nil {

+ 36 - 1
controllers/his_project_api_controller.go Ver fichero

54
 	beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
54
 	beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
55
 	beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
55
 	beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
56
 	beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
56
 	beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
57
+	beego.Router("/api/patient/changepatient", &HisProjectApiController{}, "Get:ChangePatient")
57
 }
58
 }
58
 
59
 
59
 func (this *HisProjectApiController) SaveProject() {
60
 func (this *HisProjectApiController) SaveProject() {
769
 			IdType:                 certificates,
770
 			IdType:                 certificates,
770
 			CostOfProduction:       cost_float,
771
 			CostOfProduction:       cost_float,
771
 			Departments:            department,
772
 			Departments:            department,
772
-			AdminUserId:            doctor,
773
+			Doctor:                 doctor,
774
+			AdminUserId:            adminUserInfo.AdminUser.Id,
773
 			MedicalTreatmentType:   medicalcare,
775
 			MedicalTreatmentType:   medicalcare,
774
 			IdCardNo:               idcard,
776
 			IdCardNo:               idcard,
775
 			IsNeedCostOfProduction: cost_checked,
777
 			IsNeedCostOfProduction: cost_checked,
784
 			UserOrgId:              orgId,
786
 			UserOrgId:              orgId,
785
 			Status:                 1,
787
 			Status:                 1,
786
 			RecordDate:             nowtime,
788
 			RecordDate:             nowtime,
789
+			IsReturn:               1,
787
 		}
790
 		}
788
 		err := service.CreateHisPatient(&patient)
791
 		err := service.CreateHisPatient(&patient)
789
 		if err != nil {
792
 		if err != nil {
872
 	adminUserInfo := this.GetAdminUserInfo()
875
 	adminUserInfo := this.GetAdminUserInfo()
873
 	orgId := adminUserInfo.CurrentOrgId
876
 	orgId := adminUserInfo.CurrentOrgId
874
 	history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
877
 	history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
878
+
875
 	department, err := service.GetAllDepartMent(orgId)
879
 	department, err := service.GetAllDepartMent(orgId)
880
+	appId := adminUserInfo.CurrentAppId
881
+	doctor, err := service.GetAllDoctor(orgId, appId)
876
 	if err != nil {
882
 	if err != nil {
877
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
883
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
878
 		return
884
 		return
881
 		"history":    history,
887
 		"history":    history,
882
 		"total":      total,
888
 		"total":      total,
883
 		"department": department,
889
 		"department": department,
890
+		"doctor":     doctor,
884
 	})
891
 	})
885
 }
892
 }
893
+
894
+func (this *HisProjectApiController) ChangePatient() {
895
+
896
+	id, _ := this.GetInt64("id")
897
+	//查询该患者今日是否已经就诊
898
+	recordDateStr := time.Now().Format("2006-01-02")
899
+	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
900
+	fmt.Println("parseDateErr", parseDateErr)
901
+	nowtime := recordDate.Unix()
902
+	adminUserInfo := this.GetAdminUserInfo()
903
+	orgId := adminUserInfo.CurrentOrgId
904
+	_, errcode := service.GetHisPrescriptionTwo(id, orgId, nowtime)
905
+	if errcode == gorm.ErrRecordNotFound {
906
+		err := service.ChangePatient(id)
907
+		if err != nil {
908
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
909
+			return
910
+		}
911
+		returnData := make(map[string]interface{}, 0)
912
+		returnData["msg"] = "ok"
913
+		this.ServeSuccessJSON(returnData)
914
+		return
915
+	} else if errcode == nil {
916
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
917
+		return
918
+	}
919
+
920
+}

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Ver fichero

643
 		evaluation.WeightBefore = weighing_before
643
 		evaluation.WeightBefore = weighing_before
644
 		evaluation.AssessmentTime = time.Now().Unix()
644
 		evaluation.AssessmentTime = time.Now().Unix()
645
 
645
 
646
-		err := service.UpadatePredialysisEvaluation(&evaluation)
646
+		err = service.UpadatePredialysisEvaluation(&evaluation)
647
 		if err != nil {
647
 		if err != nil {
648
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
648
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
649
 			return
649
 			return

+ 2 - 0
models/his_models.go Ver fichero

489
 	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
489
 	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
490
 	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
490
 	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
491
 	Number                 string  `gorm:"column:number" json:"number" form:"number"`
491
 	Number                 string  `gorm:"column:number" json:"number" form:"number"`
492
+	Doctor                 int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
493
+	IsReturn               int64   `gorm:"column:is_return" json:"is_return" form:"is_return"`
492
 }
494
 }
493
 
495
 
494
 func (XtHisPatient) TableName() string {
496
 func (XtHisPatient) TableName() string {

+ 27 - 1
service/his_project_service.go Ver fichero

304
 	if orgid > 0 {
304
 	if orgid > 0 {
305
 		db = db.Where("x.user_org_id = ?", orgid)
305
 		db = db.Where("x.user_org_id = ?", orgid)
306
 	}
306
 	}
307
-	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
307
+	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,x.doctor,x.is_return").Count(&total).Offset(offset).Limit(limit).Find(&hisPatient).Error
308
 	return hisPatient, total, err
308
 	return hisPatient, total, err
309
 }
309
 }
310
+
311
+func ChangePatient(id int64) error {
312
+	patient := models.XtHisPatient{}
313
+
314
+	err := XTWriteDB().Model(&patient).Where("id = ?", id).Updates(map[string]interface{}{"is_return": 2}).Error
315
+	return err
316
+}
317
+
318
+func GetHisPrescriptionTwo(patientid int64, orgid int64, recorddate int64) (*models.HisPrescription, error) {
319
+	prescription := models.HisPrescription{}
320
+	err := XTReadDB().Model(&prescription).Where("his_patient_id = ? and user_org_id = ? and record_date = ? and status = 1", patientid, orgid, recorddate).Find(&prescription).Error
321
+	if err != nil {
322
+		if err == gorm.ErrRecordNotFound {
323
+			return nil, err
324
+		} else {
325
+			return nil, err
326
+		}
327
+	}
328
+	return &prescription, nil
329
+}
330
+
331
+func UpdatedHisPatient(hispatientid int64, orgid int64, recorddate int64) error {
332
+	hisPatient := models.HisPatient{}
333
+	err := XTWriteDB().Model(&hisPatient).Where("id = ? and user_org_id = ? and record_date = ?", hispatientid, orgid, recorddate).Updates(map[string]interface{}{"is_return": 3}).Error
334
+	return err
335
+}