Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
e72234e348

+ 24 - 12
controllers/his_api_controller.go View File

@@ -6,6 +6,7 @@ import (
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8 8
 	"encoding/json"
9
+	"fmt"
9 10
 	"github.com/astaxie/beego"
10 11
 	"reflect"
11 12
 	"strconv"
@@ -129,12 +130,13 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
129 130
 }
130 131
 func (c *HisApiController) CreateHisPrescription() {
131 132
 	record_date := c.GetString("record_date")
133
+	fmt.Println("record_date", record_date)
132 134
 	patient_id, _ := c.GetInt64("patient_id")
133 135
 	//diagnose := c.GetString("diagnose")
134 136
 	//sick_history := c.GetString("sick_history")
135 137
 	doctor, _ := c.GetInt64("doctor")
136 138
 	//departm/**/ent, _ := c.GetInt64("department")
137
-
139
+	his_patient_id, _ := c.GetInt64("his_patient_id")
138 140
 	dataBody := make(map[string]interface{}, 0)
139 141
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
140 142
 	if err != nil {
@@ -169,16 +171,17 @@ func (c *HisApiController) CreateHisPrescription() {
169 171
 
170 172
 				ctime := time.Now().Unix()
171 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 186
 				service.SaveHisPrescription(prescription)
184 187
 
@@ -205,7 +208,7 @@ func (c *HisApiController) CreateHisPrescription() {
205 208
 							s.CreatedTime = ctime
206 209
 							s.UpdatedTime = mtime
207 210
 							s.PatientId = patient_id
208
-
211
+							s.HisPatientId = his_patient_id
209 212
 							errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
210 213
 							if errcode > 0 {
211 214
 								c.ServeFailJSONWithSGJErrorCode(errcode)
@@ -226,6 +229,7 @@ func (c *HisApiController) CreateHisPrescription() {
226 229
 							p.PatientId = patient_id
227 230
 							p.RecordDate = recordDateTime
228 231
 							p.UserOrgId = adminInfo.CurrentOrgId
232
+							p.HisPatientId = his_patient_id
229 233
 							errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
230 234
 							if errcode > 0 {
231 235
 								c.ServeFailJSONWithSGJErrorCode(errcode)
@@ -237,6 +241,14 @@ func (c *HisApiController) CreateHisPrescription() {
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 254
 	if err == nil {

+ 36 - 1
controllers/his_project_api_controller.go View File

@@ -54,6 +54,7 @@ func HisProjectRouters() {
54 54
 	beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
55 55
 	beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
56 56
 	beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
57
+	beego.Router("/api/patient/changepatient", &HisProjectApiController{}, "Get:ChangePatient")
57 58
 }
58 59
 
59 60
 func (this *HisProjectApiController) SaveProject() {
@@ -769,7 +770,8 @@ func (this *HisProjectApiController) SaveHisPatient() {
769 770
 			IdType:                 certificates,
770 771
 			CostOfProduction:       cost_float,
771 772
 			Departments:            department,
772
-			AdminUserId:            doctor,
773
+			Doctor:                 doctor,
774
+			AdminUserId:            adminUserInfo.AdminUser.Id,
773 775
 			MedicalTreatmentType:   medicalcare,
774 776
 			IdCardNo:               idcard,
775 777
 			IsNeedCostOfProduction: cost_checked,
@@ -784,6 +786,7 @@ func (this *HisProjectApiController) SaveHisPatient() {
784 786
 			UserOrgId:              orgId,
785 787
 			Status:                 1,
786 788
 			RecordDate:             nowtime,
789
+			IsReturn:               1,
787 790
 		}
788 791
 		err := service.CreateHisPatient(&patient)
789 792
 		if err != nil {
@@ -872,7 +875,10 @@ func (this *HisProjectApiController) GetHisPatientHistory() {
872 875
 	adminUserInfo := this.GetAdminUserInfo()
873 876
 	orgId := adminUserInfo.CurrentOrgId
874 877
 	history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
878
+
875 879
 	department, err := service.GetAllDepartMent(orgId)
880
+	appId := adminUserInfo.CurrentAppId
881
+	doctor, err := service.GetAllDoctor(orgId, appId)
876 882
 	if err != nil {
877 883
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
878 884
 		return
@@ -881,5 +887,34 @@ func (this *HisProjectApiController) GetHisPatientHistory() {
881 887
 		"history":    history,
882 888
 		"total":      total,
883 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 View File

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

+ 2 - 0
models/his_models.go View File

@@ -489,6 +489,8 @@ type XtHisPatient struct {
489 489
 	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
490 490
 	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
491 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 496
 func (XtHisPatient) TableName() string {

+ 27 - 1
service/his_project_service.go View File

@@ -304,6 +304,32 @@ func GetHisPatientHistory(keyword string, startime int64, endtime int64, registt
304 304
 	if orgid > 0 {
305 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 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
+}