Browse Source

2024/6/17

28169 3 weeks ago
parent
commit
62b4216b2f

+ 1 - 1
controllers/his_api_controller.go View File

@@ -3390,7 +3390,7 @@ func (c *HisApiController) CreateHisPrescription() {
3390 3390
 	var adviceList []models.HisDoctorAdviceInfo
3391 3391
 	var projectList []models.HisPrescriptionProject
3392 3392
 
3393
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 {
3393
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 {
3394 3394
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3395 3395
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3396 3396
 

+ 13 - 5
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -641,6 +641,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
641 641
 
642 642
 	record_date, _ := c.GetInt64("record_date")
643 643
 
644
+	patient_id, _ := c.GetInt64("patient_id")
645
+
644 646
 	if origin != 2 {
645 647
 		adminUserInfo := c.GetMobileAdminUserInfo()
646 648
 		execution_staff := adminUserInfo.AdminUser.Id
@@ -672,8 +674,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
672 674
 		var advice models.DoctorAdvice
673 675
 
674 676
 		if groupno > 0 {
675
-			advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
677
+			advices, _ := service.FindAllDoctorAdviceByGoroupNoThree(adminUserInfo.Org.Id, groupno, patient_id, record_date)
676 678
 
679
+			fmt.Println("advices---------------------------------------------", advices)
677 680
 			for _, item := range advices {
678 681
 
679 682
 				//自备药
@@ -1184,6 +1187,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1184 1187
 
1185 1188
 		//针对普宁
1186 1189
 		if adminUserInfo.Org.Id != 10599 {
1190
+			fmt.Println("开始时间--------------------", advice.StartTime)
1191
+			fmt.Println("theTime---------------------", theTime.Unix())
1187 1192
 			if advice.StartTime > theTime.Unix() {
1188 1193
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
1189 1194
 				return
@@ -1223,7 +1228,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1223 1228
 
1224 1229
 				}
1225 1230
 			}
1226
-			err = service.ExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1231
+			err = service.ExceDoctorAdviceByGroupNoOne(&advices, groupno, adminUserInfo.Org.Id, patient_id, record_date)
1227 1232
 
1228 1233
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1229 1234
 			redis := service.RedisClient()
@@ -2345,6 +2350,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2345 2350
 							}
2346 2351
 
2347 2352
 							if prescribing_number_total > total_count {
2353
+								tx.Rollback()
2348 2354
 								c.ServeSuccessJSON(map[string]interface{}{
2349 2355
 									"msg":    "3",
2350 2356
 									"advice": advice,
@@ -2445,6 +2451,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2445 2451
 							}
2446 2452
 
2447 2453
 						} else {
2454
+							tx.Rollback()
2448 2455
 							c.ServeSuccessJSON(map[string]interface{}{
2449 2456
 								"msg":    "3",
2450 2457
 								"advice": advice,
@@ -2584,8 +2591,9 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
2584 2591
 	execution_time := c.GetString("execution_time")
2585 2592
 	fmt.Println("execution_time", execution_time)
2586 2593
 	groupno, _ := c.GetInt64("groupno", -1)
2587
-	//patient_id, _ := c.GetInt64("patient_id")
2594
+	patient_id, _ := c.GetInt64("patient_id")
2588 2595
 	advice_date, _ := c.GetInt64("advice_date")
2596
+	record_date, _ := c.GetInt64("record_date")
2589 2597
 	var ids []string
2590 2598
 	if groupno == 0 {
2591 2599
 		advice_ids := c.GetString("advice_id")
@@ -2617,7 +2625,7 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
2617 2625
 	var advice models.DoctorAdvice
2618 2626
 
2619 2627
 	if groupno > 0 {
2620
-		advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
2628
+		advices, _ := service.FindAllDoctorAdviceByGoroupNoThree(adminUserInfo.Org.Id, groupno, patient_id, record_date)
2621 2629
 		for _, item := range advices {
2622 2630
 			if item.ExecutionState == 1 {
2623 2631
 				advice = item
@@ -2680,7 +2688,7 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
2680 2688
 
2681 2689
 			}
2682 2690
 		}
2683
-		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
2691
+		err = service.ModifyExceDoctorAdviceByGroupNoTwo(&advices, groupno, adminUserInfo.Org.Id, patient_id, record_date)
2684 2692
 		//记录日志
2685 2693
 		byterequest, _ := json.Marshal(advices)
2686 2694
 		adviceLog := models.XtDoctorAdviceLog{

+ 207 - 4
controllers/patient_api_controller.go View File

@@ -168,9 +168,27 @@ func PatientApiRegistRouters() {
168 168
 
169 169
 	beego.Router("/api/patient/deletepatientdeathsummary", &DialysisApiController{}, "Get:DeletePatientDeathSummary")
170 170
 
171
-	beego.Router("/api/patient/createnewsickhistoryrecord", &DialysisApiController{}, "Post:CreateNewSickHistoryRecord")
171
+	beego.Router("/api/patient/createnewsickhistoryrecord", &PatientApiController{}, "Post:CreateNewSickHistoryRecord")
172 172
 
173
-	beego.Router("/api/patient/getnewsickhistory", &DialysisApiController{}, "Get:GetNewSickHistory")
173
+	beego.Router("/api/patient/getnewsickhistory", &PatientApiController{}, "Get:GetNewSickHistory")
174
+
175
+	beego.Router("/api/patient/deletenewsickhistory", &PatientApiController{}, "Get:DeleteNewSickHistory")
176
+
177
+	beego.Router("/api/patient/savesickhistorytemplate", &PatientApiController{}, "Post:SaveSickHistoryTemplate")
178
+
179
+	beego.Router("/api/patient/getsickhistorytemplate", &PatientApiController{}, "Get:GetSickHistoryTemplate")
180
+
181
+	beego.Router("/api/patient/modifysickhistorytemplate", &PatientApiController{}, "Post:ModifySickHistoryTemplate")
182
+
183
+	beego.Router("/api/patient/deletesickhistorytemplate", &PatientApiController{}, "Get:DeleteSickHistoryTemplate")
184
+
185
+	beego.Router("/api/patient/createnewcourseofdiseaserecord", &PatientApiController{}, "Post:CreateNewCourseOfDiaseaseRecord")
186
+
187
+	beego.Router("/api/patient/getpatientcourseofdiseaseslist", &PatientApiController{}, "Get:GetPatientCoureseOfDiseasesList")
188
+
189
+	beego.Router("/api/patient/deletenewcourseofdisease", &PatientApiController{}, "Get:DeleteNewCourseOfDisease")
190
+
191
+	beego.Router("/api/patient/createnewcouresetemplate", &PatientApiController{}, "Post:CreateNewCourseTemplate")
174 192
 
175 193
 }
176 194
 func (c *PatientApiController) GetExportList() {
@@ -8164,7 +8182,7 @@ func (c *DialysisApiController) DeletePatientDeathSummary() {
8164 8182
 	})
8165 8183
 }
8166 8184
 
8167
-func (this *DialysisApiController) CreateNewSickHistoryRecord() {
8185
+func (this *PatientApiController) CreateNewSickHistoryRecord() {
8168 8186
 
8169 8187
 	dataBody := make(map[string]interface{}, 0)
8170 8188
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
@@ -8187,6 +8205,8 @@ func (this *DialysisApiController) CreateNewSickHistoryRecord() {
8187 8205
 		recordDate = theTime.Unix()
8188 8206
 	}
8189 8207
 
8208
+	id := int64(dataBody["id"].(float64))
8209
+
8190 8210
 	patient_id := int64(dataBody["patient_id"].(float64))
8191 8211
 
8192 8212
 	doctor_id := int64(dataBody["doctor_id"].(float64))
@@ -8204,6 +8224,7 @@ func (this *DialysisApiController) CreateNewSickHistoryRecord() {
8204 8224
 	orgId := this.GetAdminUserInfo().CurrentOrgId
8205 8225
 
8206 8226
 	patientSickHistory := models.XtPatientSickHistory{
8227
+		ID:                      id,
8207 8228
 		OrgId:                   orgId,
8208 8229
 		PatientId:               patient_id,
8209 8230
 		Recorder:                0,
@@ -8228,7 +8249,7 @@ func (this *DialysisApiController) CreateNewSickHistoryRecord() {
8228 8249
 	})
8229 8250
 }
8230 8251
 
8231
-func (this *DialysisApiController) GetNewSickHistory() {
8252
+func (this *PatientApiController) GetNewSickHistory() {
8232 8253
 
8233 8254
 	patient_id, _ := this.GetInt64("patient_id")
8234 8255
 
@@ -8240,3 +8261,185 @@ func (this *DialysisApiController) GetNewSickHistory() {
8240 8261
 		"list": list,
8241 8262
 	})
8242 8263
 }
8264
+
8265
+func (this *PatientApiController) DeleteNewSickHistory() {
8266
+
8267
+	id, _ := this.GetInt64("id")
8268
+
8269
+	service.DeleteNewSickHistory(id)
8270
+
8271
+	this.ServeSuccessJSON(map[string]interface{}{
8272
+		"msg": "ok",
8273
+	})
8274
+}
8275
+
8276
+func (this *PatientApiController) SaveSickHistoryTemplate() {
8277
+
8278
+	dataBody := make(map[string]interface{}, 0)
8279
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
8280
+	if err != nil {
8281
+		utils.ErrorLog(err.Error())
8282
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8283
+		return
8284
+	}
8285
+
8286
+	title := dataBody["title"].(string)
8287
+
8288
+	content := dataBody["content"].(string)
8289
+
8290
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8291
+
8292
+	sickHistoryTemplate := models.XtSickHistoryTemplate{
8293
+		Content:   content,
8294
+		UserOrgId: orgId,
8295
+		Title:     title,
8296
+		Ctime:     time.Now().Unix(),
8297
+		Mtime:     time.Now().Unix(),
8298
+		Status:    1,
8299
+	}
8300
+
8301
+	service.CreateSickHistoryTemplate(sickHistoryTemplate)
8302
+
8303
+	this.ServeSuccessJSON(map[string]interface{}{
8304
+		"sickHistoryTemplate": "sickHistoryTemplate",
8305
+	})
8306
+}
8307
+
8308
+func (this *PatientApiController) GetSickHistoryTemplate() {
8309
+
8310
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8311
+
8312
+	templateList, _ := service.GetSickHistoryTemplate(orgId)
8313
+
8314
+	this.ServeSuccessJSON(map[string]interface{}{
8315
+		"templateList": templateList,
8316
+	})
8317
+}
8318
+
8319
+func (this *PatientApiController) ModifySickHistoryTemplate() {
8320
+
8321
+	dataBody := make(map[string]interface{}, 0)
8322
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
8323
+	if err != nil {
8324
+		utils.ErrorLog(err.Error())
8325
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8326
+		return
8327
+	}
8328
+
8329
+	template_id := int64(dataBody["template_id"].(float64))
8330
+	content := dataBody["content"].(string)
8331
+
8332
+	service.ModifySickHistoryTemplate(template_id, content)
8333
+
8334
+	this.ServeSuccessJSON(map[string]interface{}{
8335
+		"msg": "ok",
8336
+	})
8337
+}
8338
+
8339
+func (this *PatientApiController) DeleteSickHistoryTemplate() {
8340
+
8341
+	template_id, _ := this.GetInt64("template_id")
8342
+
8343
+	service.DeleteSickHistoryTemplate(template_id)
8344
+
8345
+	this.ServeSuccessJSON(map[string]interface{}{
8346
+		"msg": "ok",
8347
+	})
8348
+}
8349
+
8350
+func (this *PatientApiController) CreateNewCourseOfDiaseaseRecord() {
8351
+
8352
+	dataBody := make(map[string]interface{}, 0)
8353
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
8354
+	if err != nil {
8355
+		utils.ErrorLog(err.Error())
8356
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8357
+		return
8358
+	}
8359
+
8360
+	patient_id := int64(dataBody["patient_id"].(float64))
8361
+
8362
+	record_date := dataBody["record_date"].(string)
8363
+
8364
+	id := int64(dataBody["id"].(float64))
8365
+
8366
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_date)
8367
+
8368
+	content := dataBody["content"].(string)
8369
+	admin_user_id := int64(dataBody["admin_user_id"].(float64))
8370
+
8371
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8372
+
8373
+	patientCourse := models.PatientDiseaseCourse{
8374
+		ID:         id,
8375
+		OrgID:      orgId,
8376
+		PatientID:  patient_id,
8377
+		Recorder:   admin_user_id,
8378
+		RecordTime: recordDate.Unix(),
8379
+		Content:    content,
8380
+		Status:     1,
8381
+		CreateTime: time.Now().Unix(),
8382
+		ModifyTime: time.Now().Unix(),
8383
+		Title:      "",
8384
+	}
8385
+
8386
+	service.CreateNewCourseOfDiaseaseRecord(patientCourse)
8387
+
8388
+	this.ServeSuccessJSON(map[string]interface{}{
8389
+		"msg": "ok",
8390
+	})
8391
+
8392
+}
8393
+
8394
+func (this *PatientApiController) GetPatientCoureseOfDiseasesList() {
8395
+
8396
+	patient_id, _ := this.GetInt64("patient_id")
8397
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8398
+	list, _ := service.GetPatientCoureseOfDiseasesList(patient_id, orgId)
8399
+	this.ServeSuccessJSON(map[string]interface{}{
8400
+		"list": list,
8401
+	})
8402
+}
8403
+
8404
+func (this *PatientApiController) DeleteNewCourseOfDisease() {
8405
+
8406
+	id, _ := this.GetInt64("id")
8407
+
8408
+	service.DeleteNewCourseOfDisease(id)
8409
+
8410
+	this.ServeSuccessJSON(map[string]interface{}{
8411
+		"msg": "ok",
8412
+	})
8413
+}
8414
+
8415
+func (this *PatientApiController) CreateNewCourseTemplate() {
8416
+
8417
+	dataBody := make(map[string]interface{}, 0)
8418
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
8419
+	if err != nil {
8420
+		utils.ErrorLog(err.Error())
8421
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8422
+		return
8423
+	}
8424
+
8425
+	title := dataBody["title"].(string)
8426
+
8427
+	content := dataBody["content"].(string)
8428
+
8429
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8430
+
8431
+	courseTemplate := models.XtPatientCourseTemplate{
8432
+		Content:   content,
8433
+		UserOrgId: orgId,
8434
+		Title:     title,
8435
+		Status:    1,
8436
+		Ctime:     time.Now().Unix(),
8437
+		Mtime:     time.Now().Unix(),
8438
+	}
8439
+
8440
+	service.CreateCourseTemplate(courseTemplate)
8441
+
8442
+	this.ServeSuccessJSON(map[string]interface{}{
8443
+		"msg": "ok",
8444
+	})
8445
+}

+ 19 - 16
models/data_models.go View File

@@ -19,6 +19,7 @@ type Dataconfig struct {
19 19
 	Order          int64  `gorm:"column:orders" json:"orders" form:"orders"`
20 20
 	Code           string `gorm:"column:code" json:"code" form:"code"`
21 21
 	FieldType      int64  `gorm:"column:field_type" json:"field_type" form:"field_type"`
22
+	Sort           int64  `gorm:"column:sort" json:"sort" form:"sort"`
22 23
 }
23 24
 
24 25
 func (Dataconfig) TableName() string {
@@ -97,22 +98,24 @@ func (DictionaryConfigViewModel) TableName() string {
97 98
 }
98 99
 
99 100
 type ConfigViewModel struct {
100
-	ID           int64         `gorm:"column:id" json:"id" form:"id"`
101
-	ParentId     int64         `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
102
-	Module       string        `gorm:"column:module" json:"module" form:"module"`
103
-	OrgId        int64         `gorm:"column:org_id" json:"org_id" form:"org_id"`
104
-	Name         string        `gorm:"column:name" json:"name" form:"name"`
105
-	FieldName    string        `gorm:"column:field_name" json:"field_name" form:"field_name"`
106
-	Value        int           `gorm:"column:value" json:"value" form:"value"`
107
-	CreatedTime  string        `gorm:"column:create_time" json:"create_time" form:"create_time"`
108
-	UpdatedTime  string        `gorm:"column:update_time" json:"update_time" form:"update_time"`
109
-	CreateUserId int64         `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
110
-	Status       int64         `gorm:"column:status" json:"status" form:"status"`
111
-	Remark       string        `gorm:"column:remark" json:"remark" form:"remark"`
112
-	Title        string        `gorm:"column:title" json:"title" form:"title"`
113
-	Content      string        `gorm:"column:content" json:"content" form:"content"`
114
-	Order        int64         `gorm:"column:orders" json:"orders" form:"orders"`
115
-	Childs       []*Dataconfig `json:"childs" `
101
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
102
+	ParentId     int64  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
103
+	Module       string `gorm:"column:module" json:"module" form:"module"`
104
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
105
+	Name         string `gorm:"column:name" json:"name" form:"name"`
106
+	FieldName    string `gorm:"column:field_name" json:"field_name" form:"field_name"`
107
+	Value        int    `gorm:"column:value" json:"value" form:"value"`
108
+	CreatedTime  string `gorm:"column:create_time" json:"create_time" form:"create_time"`
109
+	UpdatedTime  string `gorm:"column:update_time" json:"update_time" form:"update_time"`
110
+	CreateUserId int64  `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
111
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
112
+	Remark       string `gorm:"column:remark" json:"remark" form:"remark"`
113
+	Title        string `gorm:"column:title" json:"title" form:"title"`
114
+	Content      string `gorm:"column:content" json:"content" form:"content"`
115
+	Order        int64  `gorm:"column:orders" json:"orders" form:"orders"`
116
+	Sort         int64  `gorm:"column:sort" json:"sort" form:"sort"`
117
+
118
+	Childs []*Dataconfig `json:"childs" `
116 119
 }
117 120
 
118 121
 func (ConfigViewModel) TableName() string {

+ 1 - 0
models/inspection_models.go View File

@@ -70,6 +70,7 @@ type InspectionReference struct {
70 70
 	UpdatedTime      int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
71 71
 	SystemProjectId  int64  `gorm:"column:system_project_id" json:"system_project_id" form:"system_project_id"`
72 72
 	SystemItemId     int64  `gorm:"column:system_item_id" json:"system_item_id" form:"system_item_id"`
73
+	Sort             int64  `gorm:"column:sort" json:"sort" form:"sort"`
73 74
 	//remind 	 XtCheckRemind   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ProjectId" json:"good_info"`
74 75
 }
75 76
 

+ 30 - 0
models/patient_models.go View File

@@ -2830,3 +2830,33 @@ func (XtDeathSummary) TableName() string {
2830 2830
 
2831 2831
 	return "xt_death_summary"
2832 2832
 }
2833
+
2834
+type XtSickHistoryTemplate struct {
2835
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
2836
+	Content   string `gorm:"column:content" json:"content" form:"content"`
2837
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2838
+	Title     string `gorm:"column:title" json:"title" form:"title"`
2839
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2840
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2841
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
2842
+}
2843
+
2844
+func (XtSickHistoryTemplate) TableName() string {
2845
+
2846
+	return "xt_sick_history_template"
2847
+}
2848
+
2849
+type XtPatientCourseTemplate struct {
2850
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
2851
+	Content   string `gorm:"column:content" json:"content" form:"content"`
2852
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2853
+	Title     string `gorm:"column:title" json:"title" form:"title"`
2854
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
2855
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2856
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2857
+}
2858
+
2859
+func (XtPatientCourseTemplate) TableName() string {
2860
+
2861
+	return "xt_patient_course_template"
2862
+}

+ 4 - 2
service/data.go View File

@@ -1,11 +1,12 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"XT_New/models"
5
-	_ "github.com/astaxie/beego"
6 4
 	_ "strconv"
7 5
 	_ "strings"
8 6
 	"time"
7
+
8
+	"XT_New/models"
9
+	_ "github.com/astaxie/beego"
9 10
 )
10 11
 
11 12
 // GetPatientList 返回患者的列表
@@ -48,6 +49,7 @@ func GetConfigList(orgID int64) (dataconfig interface{}, err error) {
48 49
 				Remark:       config.Remark,
49 50
 				Title:        config.Title,
50 51
 				Content:      config.Content,
52
+				Sort:         config.Sort,
51 53
 			}
52 54
 			// configResult = append(configResult,newConfig)
53 55
 			result := resultConfig[config.Module]

+ 18 - 0
service/dialysis_service.go View File

@@ -980,6 +980,12 @@ func ExceDoctorAdviceByGroupNo(m *models.DoctorAdvice, groupNo int64, org_id int
980 980
 	return err
981 981
 }
982 982
 
983
+func ExceDoctorAdviceByGroupNoOne(m *models.DoctorAdvice, groupNo int64, org_id int64, patient_id int64, record_date int64) (err error) {
984
+
985
+	err = writeDb.Model(&models.DoctorAdvice{}).Where("groupno = ?  AND user_org_id = ? AND status = 1 AND execution_state = 2 and patient_id = ? and advice_date = ?", groupNo, org_id, patient_id, record_date).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
986
+	return err
987
+}
988
+
983 989
 func GetExceDoctorAdviceGroupNo(groupNo int64, org_id int64) (advice []*models.DoctorAdvice, err error) {
984 990
 
985 991
 	err = XTReadDB().Where("groupno = ?  AND user_org_id = ? AND status = 1", groupNo, org_id).Find(&advice).Error
@@ -1195,6 +1201,18 @@ func ModifyExceDoctorAdviceByGroupNo(m *models.DoctorAdvice, groupNo int64, org_
1195 1201
 	return err
1196 1202
 }
1197 1203
 
1204
+func ModifyExceDoctorAdviceByGroupNoTwo(m *models.DoctorAdvice, groupNo int64, org_id int64, patient_id int64, advice_date int64) (err error) {
1205
+	ut := writeDb.Begin()
1206
+	err = ut.Model(&models.DoctorAdvice{}).Where("groupno = ?  AND user_org_id = ? AND status = 1 AND execution_state = 1 and patient_id = ? and advice_date = ?", groupNo, org_id, patient_id, advice_date).Updates(map[string]interface{}{"execution_time": m.ExecutionTime}).Error
1207
+	if err != nil {
1208
+		ut.Rollback()
1209
+		return
1210
+	}
1211
+	ut.Commit()
1212
+
1213
+	return err
1214
+}
1215
+
1198 1216
 func ModifyExceDoctorAdviceByGroupNoOne(m *models.DoctorAdvice, ids []string) (err error) {
1199 1217
 	ut := writeDb.Begin()
1200 1218
 	err = ut.Model(&models.DoctorAdvice{}).Where("id in(?) and status =1", ids).Updates(map[string]interface{}{"execution_time": m.ExecutionTime}).Error

+ 1 - 1
service/inspection_service.go View File

@@ -398,7 +398,7 @@ func GetInspectionByProjectId(patient_id int64, org_id int64, project_id int64)
398 398
 
399 399
 func GetInSpctionRerefce(project_id int64, user_org_id int64) (inspct []*models.InspectionReference, err error) {
400 400
 
401
-	err = XTReadDB().Where("project_id = ? and (org_id = ? or org_id=0) and status =1", project_id, user_org_id).Find(&inspct).Error
401
+	err = XTReadDB().Where("project_id = ? and (org_id = ? or org_id=0) and status =1", project_id, user_org_id).Order("sort desc").Find(&inspct).Error
402 402
 	return inspct, err
403 403
 }
404 404
 

+ 69 - 1
service/patient_service.go View File

@@ -1786,6 +1786,11 @@ func FindAllDoctorAdviceByGoroupNoOne(orgID int64, groupno int64) (advice []mode
1786 1786
 	return
1787 1787
 }
1788 1788
 
1789
+func FindAllDoctorAdviceByGoroupNoThree(orgID int64, groupno int64, patient_id int64, advice_date int64) (advice []models.DoctorAdvice, err error) {
1790
+	err = readDb.Model(&models.DoctorAdvice{}).Where("user_org_id=?  AND groupno = ? AND status = 1 and patient_id =? and advice_date =?", orgID, groupno, patient_id, advice_date).Find(&advice).Error
1791
+	return
1792
+}
1793
+
1789 1794
 func UpdateDoctorAdviceByGoroupNo(id int64, drug_id int64) error {
1790 1795
 
1791 1796
 	err := XTWriteDB().Model(&models.DoctorAdvice{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"drug_id": drug_id, "drug_name_id": drug_id, "way": 1}).Error
@@ -4395,7 +4400,7 @@ func DeletePatientDeathSummary(id int64) error {
4395 4400
 
4396 4401
 func CreateNewSickHistoryRecord(history models.XtPatientSickHistory) error {
4397 4402
 
4398
-	err := XTWriteDB().Create(&history).Error
4403
+	err := XTWriteDB().Save(&history).Error
4399 4404
 
4400 4405
 	return err
4401 4406
 }
@@ -4406,3 +4411,66 @@ func GetNewSickHistory(patient_id int64, org_id int64) (sick []*models.XtPatient
4406 4411
 
4407 4412
 	return sick, err
4408 4413
 }
4414
+
4415
+func DeleteNewSickHistory(id int64) error {
4416
+
4417
+	err := XTWriteDB().Model(&models.XtPatientSickHistory{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
4418
+
4419
+	return err
4420
+}
4421
+
4422
+func CreateSickHistoryTemplate(template models.XtSickHistoryTemplate) error {
4423
+
4424
+	err := XTWriteDB().Create(&template).Error
4425
+
4426
+	return err
4427
+}
4428
+
4429
+func GetSickHistoryTemplate(user_org_id int64) (template []*models.XtSickHistoryTemplate, err error) {
4430
+
4431
+	err = XTReadDB().Where("user_org_id = ? and status=1", user_org_id).Find(&template).Error
4432
+
4433
+	return template, err
4434
+}
4435
+
4436
+func ModifySickHistoryTemplate(id int64, content string) error {
4437
+
4438
+	err := XTReadDB().Model(&models.XtSickHistoryTemplate{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"content": content}).Error
4439
+	return err
4440
+}
4441
+
4442
+func DeleteSickHistoryTemplate(id int64) error {
4443
+
4444
+	err := XTWriteDB().Model(&models.XtSickHistoryTemplate{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
4445
+
4446
+	return err
4447
+}
4448
+
4449
+func CreateNewCourseOfDiaseaseRecord(course models.PatientDiseaseCourse) error {
4450
+
4451
+	err := XTWriteDB().Save(&course).Error
4452
+
4453
+	return err
4454
+}
4455
+
4456
+func GetPatientCoureseOfDiseasesList(patient_id int64, org_id int64) (list []*models.PatientDiseaseCourse, err error) {
4457
+
4458
+	err = XTReadDB().Where("patient_id = ? and org_id = ? and status=1", patient_id, org_id).Find(&list).Error
4459
+
4460
+	return list, err
4461
+
4462
+}
4463
+
4464
+func DeleteNewCourseOfDisease(id int64) error {
4465
+
4466
+	patientCourse := models.PatientDiseaseCourse{}
4467
+	err := XTWriteDB().Model(&patientCourse).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
4468
+	return err
4469
+}
4470
+
4471
+func CreateCourseTemplate(course models.XtPatientCourseTemplate) error {
4472
+
4473
+	err := XTWriteDB().Create(&course).Error
4474
+
4475
+	return err
4476
+}