张保健 4 gadus atpakaļ
vecāks
revīzija
cf96d361d1

+ 1 - 1
controllers/base_api_controller.go Parādīt failu

@@ -96,7 +96,7 @@ func (this *BaseAuthAPIController) Prepare() {
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
98 98
 		this.SetSession("admin_user_info", &adminUserInfo)
99
-		//
99
+
100 100
 		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101 101
 		//this.StopRun()
102 102
 

+ 13 - 7
controllers/dialysis_api_controller.go Parādīt failu

@@ -243,6 +243,7 @@ func (c *DialysisApiController) PostPrescription() {
243 243
 	//push_the_protamine := c.GetString("push_the_protamine")
244 244
 	//fmt.Println("下机前推注鱼精蛋白",push_the_protamine)
245 245
 	// var prescription_doctor int64
246
+	blood := c.GetString("blood")
246 247
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
247 248
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
248 249
 
@@ -321,6 +322,7 @@ func (c *DialysisApiController) PostPrescription() {
321 322
 		PreImpulse:                 preImpules,
322 323
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
323 324
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
325
+		Blood:                      blood,
324 326
 	}
325 327
 
326 328
 	if appRole.UserType == 2 || appRole.UserType == 1 {
@@ -486,7 +488,7 @@ func (c *DialysisApiController) PostSoulution() {
486 488
 
487 489
 	anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
488 490
 	anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
489
-
491
+	blood := c.GetString("blood")
490 492
 	var prescription_doctor int64
491 493
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
492 494
 
@@ -576,6 +578,7 @@ func (c *DialysisApiController) PostSoulution() {
576 578
 
577 579
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
578 580
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
581
+		Blood:                     blood,
579 582
 	}
580 583
 
581 584
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
@@ -1011,6 +1014,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1011 1014
 	assessment.SupineDiastolicBloodPressure = data.SupineDiastolicBloodPressure
1012 1015
 	assessment.DiastolicPressure = data.DiastolicPressure
1013 1016
 	assessment.AdditionalWeight = data.AdditionalWeight
1017
+	assessment.OtherComplication = data.OtherComplication
1014 1018
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1015 1019
 
1016 1020
 	if assessment.ID > 0 {
@@ -1135,6 +1139,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1135 1139
 	edema := c.GetString("edema")
1136 1140
 	urine_volume, _ := c.GetFloat("urine_volume", 0)
1137 1141
 	special_treatment := c.GetString("special_treatment")
1142
+	catheter_maintenance := c.GetString("catheter_maintenance")
1138 1143
 	assessmentBeforeDislysis := models.PredialysisEvaluation{
1139 1144
 		DialysisCount:                  dialysis_count,
1140 1145
 		EmergencyTreatment:             emergency_treatment,
@@ -1191,6 +1196,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1191 1196
 		Edema:                          edema,
1192 1197
 		UrineVolume:                    urine_volume,
1193 1198
 		SpecialTreatment:               special_treatment,
1199
+		CatheterMaintenance:            catheter_maintenance,
1194 1200
 	}
1195 1201
 
1196 1202
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
@@ -2537,12 +2543,12 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
2537 2543
 		utils.ErrorLog("len(start_time) == 0")
2538 2544
 		return
2539 2545
 	}
2540
-	//theTimeUnix, err := time.ParseInLocation(timeLayout2, startTime, loc2)
2541
-	//if err != nil {
2542
-	//	utils.ErrorLog(err.Error())
2543
-	//	return
2544
-	//}
2545
-	StartTime := theTime.Unix()
2546
+	theTimeUnix, err := time.ParseInLocation(timeLayout2, startTime, loc2)
2547
+	if err != nil {
2548
+		utils.ErrorLog(err.Error())
2549
+		return
2550
+	}
2551
+	StartTime := theTimeUnix.Unix()
2546 2552
 	fmt.Println("startTIME", StartTime)
2547 2553
 	Remark := ""
2548 2554
 	if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {

+ 228 - 76
controllers/his_api_controller.go Parādīt failu

@@ -9,6 +9,7 @@ import (
9 9
 	"encoding/json"
10 10
 	"fmt"
11 11
 	"github.com/astaxie/beego"
12
+	"github.com/jinzhu/gorm"
12 13
 	"io/ioutil"
13 14
 	"math/rand"
14 15
 	"net/http"
@@ -32,14 +33,21 @@ func HisManagerApiRegistRouters() {
32 33
 	beego.Router("/api/advice/delete", &HisApiController{}, "post:DeleteDoctorAdvice")
33 34
 	beego.Router("/api/project/delete", &HisApiController{}, "post:DeleteProject")
34 35
 
36
+	beego.Router("/api/hisprescription/list", &HisApiController{}, "get:GetHisPrescriptionList")
37
+	beego.Router("/api/hisprescription/info", &HisApiController{}, "get:GetHisPrescriptionInfo")
38
+
35 39
 	beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
36 40
 
37 41
 	beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
38 42
 	beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
39
-	beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "post:CreateHisPatientCaseHistory")
40
-	beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "post:CreateCaseHistoryTemplate")
43
+	beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
44
+	beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
41 45
 	beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
42
-	beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
46
+	//beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
47
+
48
+	beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
49
+
50
+	beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
43 51
 
44 52
 	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
45 53
 	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
@@ -168,39 +176,48 @@ func (c *HisApiController) CreateHisPrescription() {
168 176
 	adminInfo := c.GetAdminUserInfo()
169 177
 	recordDateTime := theTime.Unix()
170 178
 
179
+	var randNum int
180
+	randNum = rand.Intn(10000) + 1000
181
+	timestamp := time.Now().Unix()
182
+	tempTime := time.Unix(timestamp, 0)
183
+	timeFormat := tempTime.Format("20060102150405")
184
+	number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
185
+
171 186
 	info, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
172 187
 	if info.ID == 0 {
173 188
 		hpInfo := models.HisPrescriptionInfo{
174
-			UserOrgId:    adminInfo.CurrentOrgId,
175
-			RecordDate:   theTime.Unix(),
176
-			PatientId:    patient_id,
177
-			Status:       1,
178
-			Ctime:        time.Now().Unix(),
179
-			Mtime:        time.Now().Unix(),
180
-			Creator:      adminInfo.AdminUser.Id,
181
-			Modifier:     adminInfo.AdminUser.Id,
182
-			Diagnosis:    diagnose,
183
-			SickHistory:  sick_history,
184
-			Departments:  department,
185
-			RegisterType: reg_type,
189
+			UserOrgId:          adminInfo.CurrentOrgId,
190
+			RecordDate:         theTime.Unix(),
191
+			PatientId:          patient_id,
192
+			Status:             1,
193
+			Ctime:              time.Now().Unix(),
194
+			Mtime:              time.Now().Unix(),
195
+			Creator:            adminInfo.AdminUser.Id,
196
+			Modifier:           adminInfo.AdminUser.Id,
197
+			Diagnosis:          diagnose,
198
+			SickHistory:        sick_history,
199
+			Departments:        department,
200
+			RegisterType:       reg_type,
201
+			PrescriptionNumber: number,
186 202
 		}
187 203
 		service.SavePatientPrescriptionInfo(hpInfo)
188 204
 
189 205
 	} else {
190 206
 		hpInfo := models.HisPrescriptionInfo{
191
-			ID:           info.ID,
192
-			UserOrgId:    adminInfo.CurrentOrgId,
193
-			RecordDate:   info.RecordDate,
194
-			PatientId:    info.PatientId,
195
-			Status:       1,
196
-			Ctime:        info.Ctime,
197
-			Mtime:        time.Now().Unix(),
198
-			Creator:      info.Creator,
199
-			Modifier:     adminInfo.AdminUser.Id,
200
-			Diagnosis:    diagnose,
201
-			SickHistory:  sick_history,
202
-			Departments:  department,
203
-			RegisterType: reg_type,
207
+			ID:                 info.ID,
208
+			UserOrgId:          adminInfo.CurrentOrgId,
209
+			RecordDate:         info.RecordDate,
210
+			PatientId:          info.PatientId,
211
+			Status:             1,
212
+			Ctime:              info.Ctime,
213
+			Mtime:              time.Now().Unix(),
214
+			Creator:            info.Creator,
215
+			Modifier:           adminInfo.AdminUser.Id,
216
+			Diagnosis:          diagnose,
217
+			SickHistory:        sick_history,
218
+			Departments:        department,
219
+			RegisterType:       reg_type,
220
+			PrescriptionNumber: info.PrescriptionNumber,
204 221
 		}
205 222
 		service.SavePatientPrescriptionInfo(hpInfo)
206 223
 	}
@@ -452,25 +469,50 @@ func (c *HisApiController) CreateHisAdditionalCharge() {
452 469
 }
453 470
 
454 471
 func (c *HisApiController) CreateHisPatientCaseHistory() {
455
-	diagnostic := c.GetString("diagnostic")
456
-	temperature, _ := c.GetFloat("temperature")
457
-	blood_sugar, _ := c.GetFloat("blood_sugar")
458
-	pulse, _ := c.GetFloat("pulse")
459
-	sbp, _ := c.GetFloat("sbp")
460
-	dbp, _ := c.GetFloat("dbp")
461
-	blood_fat, _ := c.GetFloat("blood_fat")
462
-	height, _ := c.GetFloat("height")
463
-	sick_type, _ := c.GetInt64("sick_type")
464
-	symptom := c.GetString("symptom")
465
-	sick_date := c.GetString("sick_date")
466
-	is_infect, _ := c.GetInt64("is_infect")
472
+
473
+	blood_fat := c.GetString("blood_fat")
474
+	bloodfatfloat, _ := strconv.ParseFloat(blood_fat, 64)
475
+	fmt.Println("33333333", bloodfatfloat)
476
+	blood_sugar := c.GetString("blood_sugar")
477
+	bloodsugarfloat, _ := strconv.ParseFloat(blood_sugar, 64)
478
+	fmt.Println(bloodsugarfloat)
467 479
 	chief_conplaint := c.GetString("chief_conplaint")
480
+
481
+	dbp := c.GetString("dbp")
482
+	dbpfloat, _ := strconv.ParseFloat(dbp, 64)
483
+	delivery_way, _ := c.GetInt64("delivery_way")
484
+	diagnostic := c.GetString("diagnostic")
485
+	fmt.Println("diagnostic", diagnostic)
486
+	family_history := c.GetString("family_history")
487
+	fmt.Println(family_history)
488
+	height := c.GetString("height")
468 489
 	history_of_present_illness := c.GetString("history_of_present_illness")
490
+	is_infect, _ := c.GetInt64("is_infect")
491
+	fmt.Println("is", is_infect)
469 492
 	past_history := c.GetString("past_history")
493
+	patient_id, _ := c.GetInt64("patient_id")
494
+	his_patient_id, _ := c.GetInt64("his_patient_id")
495
+	fmt.Println("patient_id", patient_id)
470 496
 	personal_history := c.GetString("personal_history")
471
-	family_history := c.GetString("family_history")
497
+	pulse := c.GetString("pulse")
498
+	pulsefloat, _ := strconv.ParseFloat(pulse, 64)
499
+	sbp := c.GetString("sbp")
500
+	sbpfloat, _ := strconv.ParseFloat(sbp, 64)
501
+	heightfloat, _ := strconv.ParseFloat(height, 64)
502
+	sicktype := c.GetString("sick_type")
503
+	fmt.Println("sicketype", sicktype)
504
+	sick_type, _ := strconv.ParseInt(sicktype, 10, 64)
505
+	symptom := c.GetString("symptom")
506
+	sick_date := c.GetString("sick_date")
507
+	temperatures := c.GetString("temperature")
508
+	fmt.Println("temperatures", temperatures)
509
+	temperature, _ := strconv.ParseFloat(temperatures, 64)
472 510
 	record_date := c.GetString("record_date")
473
-	patient_id, _ := c.GetInt64("patient_id")
511
+	breathing := c.GetString("breathing")
512
+	doctor_advice := c.GetString("doctor_advice")
513
+	remark := c.GetString("remark")
514
+	breathingfloat, _ := strconv.ParseFloat(breathing, 64)
515
+	fmt.Println("breathingfloat", breathingfloat)
474 516
 	timeLayout := "2006-01-02"
475 517
 	loc, _ := time.LoadLocation("Local")
476 518
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
@@ -487,14 +529,15 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
487 529
 	sickTimes := sickTime.Unix()
488 530
 	ctime := time.Now().Unix()
489 531
 	caseHistory := models.HisPatientCaseHistory{
490
-		HisPatientId:            patient_id,
532
+		HisPatientId:            his_patient_id,
533
+		PatientId:               patient_id,
491 534
 		Temperature:             temperature,
492
-		BloodSugar:              blood_sugar,
493
-		Pulse:                   pulse,
494
-		Sbp:                     sbp,
495
-		Dbp:                     dbp,
496
-		Height:                  height,
497
-		BloodFat:                blood_fat,
535
+		BloodSugar:              bloodsugarfloat,
536
+		Pulse:                   pulsefloat,
537
+		Sbp:                     sbpfloat,
538
+		Dbp:                     dbpfloat,
539
+		Height:                  heightfloat,
540
+		BloodFat:                bloodfatfloat,
498 541
 		SickType:                sick_type,
499 542
 		Symptom:                 symptom,
500 543
 		SickDate:                sickTimes,
@@ -511,13 +554,26 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
511 554
 		Ctime:                   ctime,
512 555
 		Mtime:                   ctime,
513 556
 		RecordDate:              recordDateTime,
557
+		DeliveryWay:             delivery_way,
558
+		Breathing:               breathingfloat,
559
+		DoctorAdvice:            doctor_advice,
560
+		Remark:                  remark,
514 561
 	}
515
-	err = service.SaveHisPatientCaseHistory(caseHistory)
516
-	if err != nil {
517
-		c.ServeSuccessJSON(map[string]interface{}{
518
-			"msg": "保存成功",
519
-		})
562
+
563
+	//查询该患者是否有病历
564
+	_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)
565
+	if errcode == gorm.ErrRecordNotFound {
566
+		err = service.SaveHisPatientCaseHistory(caseHistory)
567
+		if err != nil {
568
+			c.ServeSuccessJSON(map[string]interface{}{
569
+				"msg": "保存成功",
570
+			})
571
+		}
572
+	} else if errcode == nil {
573
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
574
+		return
520 575
 	}
576
+
521 577
 }
522 578
 func (c *HisApiController) GetHisPatientCaseHistoryList() {
523 579
 	patient_id, _ := c.GetInt64("patient_id", 0)
@@ -542,25 +598,27 @@ func (c *HisApiController) GetHisPatientCaseHistory() {
542 598
 }
543 599
 func (c *HisApiController) CreateCaseHistoryTemplate() {
544 600
 	template_name := c.GetString("template_name")
601
+	fmt.Println("template_name22222222222222", template_name)
545 602
 	template_remark := c.GetString("template_remark")
546 603
 	doctor := c.GetAdminUserInfo().AdminUser.Id
547 604
 	diagnostic := c.GetString("diagnostic")
548
-	chief_conplaint := c.GetString("chief_conplaint")
605
+	chief_conplaint := c.GetString("chief_conplain")
549 606
 	history_of_present_illness := c.GetString("history_of_present_illness")
550 607
 	past_history := c.GetString("past_history")
551 608
 	personal_history := c.GetString("personal_history")
552 609
 	family_history := c.GetString("family_history")
553
-	record_date := c.GetString("record_date")
554
-
555
-	timeLayout := "2006-01-02"
556
-	loc, _ := time.LoadLocation("Local")
557
-
558
-	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
559
-	if err != nil {
560
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
561
-		return
562
-	}
563
-	recordDateTime := theTime.Unix()
610
+	user_name := c.GetString("user_name")
611
+	//record_date := c.GetString("record_date")
612
+	//fmt.Println("record_date--------",record_date)
613
+	//timeLayout := "2006-01-02"
614
+	//loc, _ := time.LoadLocation("Local")
615
+	//
616
+	//theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
617
+	//if err != nil {
618
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
619
+	//	return
620
+	//}
621
+	//recordDateTime := theTime.Unix()
564 622
 
565 623
 	ctime := time.Now().Unix()
566 624
 
@@ -575,14 +633,15 @@ func (c *HisApiController) CreateCaseHistoryTemplate() {
575 633
 		Status:                  1,
576 634
 		Ctime:                   ctime,
577 635
 		Mtime:                   ctime,
578
-		RecordDate:              recordDateTime,
636
+		RecordDate:              time.Now().Unix(),
579 637
 		TemplateName:            template_name,
580 638
 		TemplateRemark:          template_remark,
581 639
 		Creator:                 doctor,
582 640
 		Modifier:                doctor,
641
+		UserName:                user_name,
583 642
 	}
584 643
 
585
-	err = service.SaveHisPatientCaseHistoryTemplate(template)
644
+	err := service.SaveHisPatientCaseHistoryTemplate(template)
586 645
 
587 646
 	if err == nil {
588 647
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -596,10 +655,19 @@ func (c *HisApiController) CreateCaseHistoryTemplate() {
596 655
 
597 656
 }
598 657
 func (c *HisApiController) GetCaseHistoryTemplate() {
658
+	timeLayout := "2006-01-02"
659
+	loc, _ := time.LoadLocation("Local")
660
+	keyword := c.GetString("keyword")
661
+	start_time := c.GetString("start_time")
662
+	end_time := c.GetString("end_time")
663
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
664
+	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
599 665
 	admin := c.GetAdminUserInfo()
600
-	template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId)
666
+	template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId, startTime.Unix(), endTime.Unix(), keyword)
667
+	history, _ := service.GetHisPatientCaseHistory(admin.CurrentOrgId)
601 668
 	c.ServeSuccessJSON(map[string]interface{}{
602 669
 		"template": template,
670
+		"history":  history,
603 671
 	})
604 672
 
605 673
 }
@@ -814,9 +882,9 @@ func (c *HisApiController) GetRegisterInfo() {
814 882
 
815 883
 }
816 884
 
817
-func (c *HisApiController) GetPrintHisPatientCaseHistory() {
818
-
819
-}
885
+//func (c *HisApiController) GetPrintHisPatientCaseHistory() {
886
+//
887
+//}
820 888
 func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
821 889
 
822 890
 	if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
@@ -901,26 +969,22 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
901 969
 }
902 970
 
903 971
 func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionProject, json map[string]interface{}) int {
904
-
905 972
 	if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
906 973
 		id := int64(json["id"].(float64))
907 974
 		project.ID = id
908 975
 	}
909
-
910 976
 	if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
911 977
 		project_id := int64(json["project_id"].(float64))
912 978
 		project.ProjectId = project_id
913 979
 		fmt.Println(project_id)
914 980
 		fmt.Println(project.ProjectId)
915 981
 	}
916
-
917 982
 	if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
918 983
 		price := int64(json["price"].(float64))
919 984
 		formatInt_price := strconv.FormatInt(price, 10)
920 985
 		float_price, _ := strconv.ParseFloat(formatInt_price, 64)
921 986
 		project.Price = float_price
922 987
 	}
923
-
924 988
 	if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
925 989
 		total, _ := json["total"].(string)
926 990
 		totals, _ := strconv.ParseInt(total, 10, 64)
@@ -931,6 +995,23 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
931 995
 		medical_code, _ := json["medical_code"].(string)
932 996
 		project.MedListCodg = medical_code
933 997
 	}
998
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
999
+		single_dose, _ := json["single_dose"].(string)
1000
+		project.SingleDose = single_dose
1001
+	}
1002
+
1003
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
1004
+		delivery_way, _ := json["delivery_way"].(string)
1005
+		project.DeliveryWay = delivery_way
1006
+	}
1007
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
1008
+		execution_frequency, _ := json["execution_frequency"].(string)
1009
+		project.ExecutionFrequency = execution_frequency
1010
+	}
1011
+	if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
1012
+		day, _ := json["number_days"].(string)
1013
+		project.Day = day
1014
+	}
934 1015
 	return 0
935 1016
 }
936 1017
 
@@ -1008,6 +1089,11 @@ func (c *HisApiController) GetUploadInfo() {
1008 1089
 	data["doctor"] = patientPrescription.Doctor
1009 1090
 	data["dept"] = patientPrescription.Departments
1010 1091
 
1092
+	var ids []int64
1093
+	for _, item := range prescriptions {
1094
+		ids = append(ids, item.ID)
1095
+	}
1096
+
1011 1097
 	bytesData, _ := json.Marshal(data)
1012 1098
 	req, _ := http.NewRequest("POST", "http://127.0.0.1:9531/"+"gdyb/five", bytes.NewReader(bytesData))
1013 1099
 	resp, _ := client.Do(req)
@@ -1112,6 +1198,8 @@ func (c *HisApiController) GetUploadInfo() {
1112 1198
 			service.CreateOrderInfo(info)
1113 1199
 		}
1114 1200
 
1201
+		service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
1202
+
1115 1203
 		var total float64
1116 1204
 		for _, item := range prescriptions {
1117 1205
 			if item.Type == 1 { //药品
@@ -1179,3 +1267,67 @@ func (c *HisApiController) GetUploadInfo() {
1179 1267
 
1180 1268
 	}
1181 1269
 }
1270
+
1271
+func (c *HisApiController) GetHisOrderList() {
1272
+	adminUser := c.GetAdminUserInfo()
1273
+	org_id := adminUser.CurrentOrgId
1274
+	order, err := service.GetHisOrderList(org_id)
1275
+	if err == nil {
1276
+		c.ServeSuccessJSON(map[string]interface{}{
1277
+			"order": order,
1278
+		})
1279
+	} else {
1280
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1281
+		return
1282
+	}
1283
+}
1284
+
1285
+func (c *HisApiController) GetHisOrder() {
1286
+	patient_id, _ := c.GetInt64("patient_id", 0)
1287
+	number := c.GetString("number")
1288
+	adminInfo := c.GetAdminUserInfo()
1289
+	order, err := service.GetHisOrder(adminInfo.CurrentOrgId, number, patient_id)
1290
+	prescriptions, _ := service.GetHisPrescriptionThree(adminInfo.CurrentOrgId, patient_id, order.SettleAccountsDate, order.Number)
1291
+
1292
+	if err == nil {
1293
+		c.ServeSuccessJSON(map[string]interface{}{
1294
+			"order":        order,
1295
+			"prescription": prescriptions,
1296
+		})
1297
+	} else {
1298
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1299
+		return
1300
+	}
1301
+
1302
+}
1303
+
1304
+func (c *HisApiController) GetHisPrescriptionList() {
1305
+	adminInfo := c.GetAdminUserInfo()
1306
+	fmt.Println("11111dassdfs11")
1307
+	prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)
1308
+	fmt.Println(prescriptionOrder)
1309
+
1310
+	if err == nil {
1311
+		c.ServeSuccessJSON(map[string]interface{}{
1312
+			"order": prescriptionOrder,
1313
+		})
1314
+	} else {
1315
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1316
+		return
1317
+	}
1318
+}
1319
+
1320
+func (c *HisApiController) GetHisPrescriptionInfo() {
1321
+	patient_id, _ := c.GetInt64("patient_id")
1322
+	his_patient_id, _ := c.GetInt64("his_patient_id")
1323
+	adminInfo := c.GetAdminUserInfo()
1324
+	prescriptionOrder, err := service.GetHisPrescriptionOrderInfo(patient_id, his_patient_id, adminInfo.CurrentOrgId)
1325
+	if err == nil {
1326
+		c.ServeSuccessJSON(map[string]interface{}{
1327
+			"order": prescriptionOrder,
1328
+		})
1329
+	} else {
1330
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1331
+		return
1332
+	}
1333
+}

+ 77 - 1
controllers/his_project_api_controller.go Parādīt failu

@@ -55,6 +55,10 @@ func HisProjectRouters() {
55 55
 	beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
56 56
 	beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
57 57
 	beego.Router("/api/patient/changepatient", &HisProjectApiController{}, "Get:ChangePatient")
58
+
59
+	beego.Router("/api/patient/getpatientcasehistory", &HisProjectApiController{}, "Get:GetPatientcaseHistory")
60
+	beego.Router("/api/doctorworkstation/gettemplatedetail", &HisProjectApiController{}, "Get:GetTemplateDetail")
61
+	beego.Router("/api/doctorworkstation/updaterecordtemplate", &HisProjectApiController{}, "Get:UpdateRecordTemplate")
58 62
 }
59 63
 
60 64
 func (this *HisProjectApiController) SaveProject() {
@@ -138,7 +142,7 @@ func (this *HisProjectApiController) SaveProject() {
138 142
 		})
139 143
 		return
140 144
 	} else if errcode == nil {
141
-		fmt.Println("3333")
145
+
142 146
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
143 147
 		return
144 148
 	}
@@ -151,7 +155,9 @@ func (this *HisProjectApiController) GetProjectList() {
151 155
 	limit, _ := this.GetInt64("limit")
152 156
 	page, _ := this.GetInt64("page")
153 157
 	is_charge, _ := this.GetInt64("is_charge")
158
+	fmt.Println("is_charge==================", is_charge)
154 159
 	is_start, _ := this.GetInt64("is_start")
160
+	fmt.Println("is_start--------------------", is_start)
155 161
 	keyword := this.GetString("keyword")
156 162
 	projecList, total, err := service.GetHisProjectList(orgId, limit, page, is_charge, is_start, keyword)
157 163
 	fmt.Println("err", err)
@@ -918,3 +924,73 @@ func (this *HisProjectApiController) ChangePatient() {
918 924
 	}
919 925
 
920 926
 }
927
+
928
+func (this *HisProjectApiController) GetPatientcaseHistory() {
929
+
930
+	patient_id, _ := this.GetInt64("patient_id")
931
+	patient, _ := service.GetBloodPatientInfoById(patient_id)
932
+	history, err := service.GetPatientCaseHistory(patient_id)
933
+	hispatient, _ := service.GetHisPatientById(patient_id)
934
+
935
+	if err != nil {
936
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
937
+		return
938
+	}
939
+	this.ServeSuccessJSON(map[string]interface{}{
940
+		"patient":    patient,
941
+		"history":    history,
942
+		"hispatient": hispatient,
943
+	})
944
+}
945
+
946
+func (this *HisProjectApiController) GetTemplateDetail() {
947
+
948
+	id, _ := this.GetInt64("id")
949
+	templateDetail, err := service.GetTemplateDetail(id)
950
+
951
+	if err != nil {
952
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
953
+		return
954
+	}
955
+	this.ServeSuccessJSON(map[string]interface{}{
956
+		"templateDetail": templateDetail,
957
+	})
958
+}
959
+
960
+func (this *HisProjectApiController) UpdateRecordTemplate() {
961
+	id, _ := this.GetInt64("id")
962
+	template_name := this.GetString("template_name")
963
+	fmt.Println("template_name22222222222222", template_name)
964
+	template_remark := this.GetString("template_remark")
965
+
966
+	diagnostic := this.GetString("diagnostic")
967
+	chief_conplaint := this.GetString("chief_conplaint")
968
+	history_of_present_illness := this.GetString("history_of_present_illness")
969
+	past_history := this.GetString("past_history")
970
+	personal_history := this.GetString("personal_history")
971
+	family_history := this.GetString("family_history")
972
+	adminUserInfo := this.GetAdminUserInfo()
973
+	creater := adminUserInfo.AdminUser.Id
974
+	historyTemplate := models.HisCaseHistoryTemplate{
975
+		HistoryOfPresentIllness: history_of_present_illness,
976
+		PastHistory:             past_history,
977
+		ChiefConplaint:          chief_conplaint,
978
+		PersonalHistory:         personal_history,
979
+		FamilyHistory:           family_history,
980
+		Diagnostic:              diagnostic,
981
+		Status:                  1,
982
+		Mtime:                   time.Now().Unix(),
983
+		RecordDate:              time.Now().Unix(),
984
+		TemplateName:            template_name,
985
+		TemplateRemark:          template_remark,
986
+		Modifier:                creater,
987
+	}
988
+	err := service.UpdateCaseHistoryTemplate(&historyTemplate, id)
989
+	if err != nil {
990
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
991
+		return
992
+	}
993
+	this.ServeSuccessJSON(map[string]interface{}{
994
+		"templateDetail": historyTemplate,
995
+	})
996
+}

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Parādīt failu

@@ -336,7 +336,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
336 336
 
337 337
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
338 338
 
339
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 {
339
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 {
340 340
 		dewater_amount = dewater_amount * 1000
341 341
 
342 342
 		if dewater_amount < 0 {

+ 6 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go Parādīt failu

@@ -821,6 +821,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
821 821
 	setting_pressure := c.GetString("setting_pressure")
822 822
 	supine_diastolic_blood_pressure := c.GetString("supine_diastolic_blood_pressure")
823 823
 	diastolic_pressure := c.GetString("diastolic_pressure")
824
+	other_complication := c.GetString("other_complication")
824 825
 	if id <= 0 {
825 826
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
826 827
 		return
@@ -912,6 +913,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
912 913
 		SupineSystolicBloodPressure:  supine_systolic_blood_pressure,
913 914
 		SettingPressure:              setting_pressure,
914 915
 		DiastolicPressure:            diastolic_pressure,
916
+		OtherComplication:            other_complication,
915 917
 	}
916 918
 
917 919
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
@@ -1045,7 +1047,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1045 1047
 	fmt.Println("预冲量====", pre_impulse)
1046 1048
 	anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
1047 1049
 	anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
1048
-
1050
+	blood := c.GetString("blood")
1049 1051
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1050 1052
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1051 1053
 	//
@@ -1128,6 +1130,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1128 1130
 		PreImpulse:                 pre_impulse,
1129 1131
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
1130 1132
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
1133
+		Blood:                      blood,
1131 1134
 	}
1132 1135
 
1133 1136
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -1806,7 +1809,7 @@ func (c *DialysisAPIController) PostSolution() {
1806 1809
 
1807 1810
 	anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
1808 1811
 	anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
1809
-
1812
+	blood := c.GetString("blood")
1810 1813
 	if mode_id > 0 {
1811 1814
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
1812 1815
 	}
@@ -1890,6 +1893,7 @@ func (c *DialysisAPIController) PostSolution() {
1890 1893
 		ALiquid:                   a_liquid,
1891 1894
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
1892 1895
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
1896
+		Blood:                     blood,
1893 1897
 	}
1894 1898
 
1895 1899
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)

+ 5 - 0
controllers/mobile_api_controllers/patient_api_controller.go Parādīt failu

@@ -2245,6 +2245,11 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2245 2245
 		evaluation.SpecialTreatment = specialTreatment
2246 2246
 	}
2247 2247
 
2248
+	if dataBody["catheter_maintenance"] != nil && reflect.TypeOf(dataBody["catheter_maintenance"]).String() == "string" {
2249
+		catheter_maintenance := dataBody["catheter_maintenance"].(string)
2250
+		evaluation.CatheterMaintenance = catheter_maintenance
2251
+	}
2252
+
2248 2253
 	return
2249 2254
 }
2250 2255
 

+ 15 - 14
models/dialysis.go Parādīt failu

@@ -275,6 +275,7 @@ type PredialysisEvaluation struct {
275 275
 	UrineVolume                    float64 `gorm:"column:urine_volume" json:"urine_volume" form:"urine_volume"`
276 276
 	Edema                          string  `gorm:"column:edema" json:"edema" form:"edema"`
277 277
 	SpecialTreatment               string  `gorm:"column:special_treatment" json:"special_treatment" form:"special_treatment"`
278
+	CatheterMaintenance            string  `gorm:"column:catheter_maintenance" json:"catheter_maintenance" form:"catheter_maintenance"`
278 279
 }
279 280
 
280 281
 func (PredialysisEvaluation) TableName() string {
@@ -572,6 +573,7 @@ type AssessmentAfterDislysis struct {
572 573
 	SettingPressure                 string  `gorm:"column:setting_pressure" json:"setting_pressure" form:"setting_pressure"`
573 574
 	SupineDiastolicBloodPressure    string  `gorm:"column:supine_diastolic_blood_pressure" json:"supine_diastolic_blood_pressure" form:"supine_diastolic_blood_pressure"`
574 575
 	DiastolicPressure               string  `gorm:"column:diastolic_pressure" json:"diastolic_pressure" form:"diastolic_pressure"`
576
+	OtherComplication               string  `gorm:"column:other_complication" json:"other_complication" form:"other_complication"`
575 577
 }
576 578
 
577 579
 func (AssessmentAfterDislysis) TableName() string {
@@ -957,20 +959,19 @@ func (DialysisBeforePrepare) TableName() string {
957 959
 }
958 960
 
959 961
 type QueueCallConfig struct {
960
-	ID         	int64 `gorm:"column:id" json:"id" form:"id"`
961
-	OrgId     	int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
962
-	Qhsj  		int64 `gorm:"column:qhsj" json:"qhsj" form:"qhsj"`
963
-	Jzdcbbcs	int64 `gorm:"column:jzdcbbcs" json:"jzdcbbcs" form:"jzdcbbcs"`
964
-	Jzbbsy		int64 `gorm:"column:jzbbsy" json:"jzbbsy" form:"jzbbsy"`
965
-	Jzjhyc		int64 `gorm:"column:jzjhyc" json:"jzjhyc" form:"jzjhyc"`
966
-	Sjdcbbcs 	int64 `gorm:"column:sjdcbbcs" json:"sjdcbbcs" form:"sjdcbbcs"`
967
-	Sjbbsy 		int64 `gorm:"column:sjbbsy" json:"sjbbsy" form:"sjbbsy"`
968
-	Sjjhyc		int64 `gorm:"column:sjjhyc" json:"sjjhyc" form:"sjjhyc"`
969
-	Txxqyxs		int64 `gorm:"column:txxqyxs" json:"txxqyxs" form:"txxqyxs"`
970
-	Txglsyxs	int64 `gorm:"column:txglsyxs" json:"txglsyxs" form:"txglsyxs"`
971
-	CreateTime	int64 `gorm:"column:create_time" json:"create_time" form:"create_time"`
972
-	UpdateTime  int64 `gorm:"column:update_time" json:"update_time" form:"update_time"`
973
-
962
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
963
+	OrgId      int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
964
+	Qhsj       int64 `gorm:"column:qhsj" json:"qhsj" form:"qhsj"`
965
+	Jzdcbbcs   int64 `gorm:"column:jzdcbbcs" json:"jzdcbbcs" form:"jzdcbbcs"`
966
+	Jzbbsy     int64 `gorm:"column:jzbbsy" json:"jzbbsy" form:"jzbbsy"`
967
+	Jzjhyc     int64 `gorm:"column:jzjhyc" json:"jzjhyc" form:"jzjhyc"`
968
+	Sjdcbbcs   int64 `gorm:"column:sjdcbbcs" json:"sjdcbbcs" form:"sjdcbbcs"`
969
+	Sjbbsy     int64 `gorm:"column:sjbbsy" json:"sjbbsy" form:"sjbbsy"`
970
+	Sjjhyc     int64 `gorm:"column:sjjhyc" json:"sjjhyc" form:"sjjhyc"`
971
+	Txxqyxs    int64 `gorm:"column:txxqyxs" json:"txxqyxs" form:"txxqyxs"`
972
+	Txglsyxs   int64 `gorm:"column:txglsyxs" json:"txglsyxs" form:"txglsyxs"`
973
+	CreateTime int64 `gorm:"column:create_time" json:"create_time" form:"create_time"`
974
+	UpdateTime int64 `gorm:"column:update_time" json:"update_time" form:"update_time"`
974 975
 }
975 976
 
976 977
 func (QueueCallConfig) TableName() string {

+ 111 - 48
models/his_models.go Parādīt failu

@@ -1,5 +1,7 @@
1 1
 package models
2 2
 
3
+import "time"
4
+
3 5
 type XtHisProject struct {
4 6
 	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
5 7
 	ProjectName               string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
@@ -83,7 +85,7 @@ type HisPatient struct {
83 85
 	IdType                 int64   `gorm:"column:id_type" json:"id_type" form:"id_type"`
84 86
 	Birthday               int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
85 87
 	RecordDate             int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
86
-	Age                    int64   `gorm:"column:age" json:"age" form:"age"`
88
+	Age                    float64 `gorm:"column:age" json:"age" form:"age"`
87 89
 	PhoneNumber            string  `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
88 90
 	IdNumber               string  `gorm:"column:id_number" json:"id_number" form:"id_number"`
89 91
 	RegisterType           int64   `gorm:"column:register_type" json:"register_type" form:"register_type"`
@@ -138,10 +140,11 @@ type HisCaseHistoryTemplate struct {
138 140
 	TemplateRemark          string `gorm:"column:template_remark" json:"template_remark" form:"template_remark"`
139 141
 	Creator                 int64  `gorm:"column:creator" json:"creator" form:"creator"`
140 142
 	Modifier                int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
143
+	UserName                string `gorm:"column:user_name" json:"user_name" form:"user_name"`
141 144
 }
142 145
 
143 146
 func (HisCaseHistoryTemplate) TableName() string {
144
-	return "his_patient"
147
+	return "his_case_history_template"
145 148
 }
146 149
 
147 150
 type HisDoctorAdviceInfo struct {
@@ -232,6 +235,10 @@ type HisPatientCaseHistory struct {
232 235
 	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
233 236
 	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
234 237
 	RecordDate              int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
238
+	DeliveryWay             int64   `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
239
+	Breathing               float64 `gorm:"column:breathing" json:"breathing" form:"breathing"`
240
+	DoctorAdvice            string  `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
241
+	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
235 242
 }
236 243
 
237 244
 func (HisPatientCaseHistory) TableName() string {
@@ -239,21 +246,22 @@ func (HisPatientCaseHistory) TableName() string {
239 246
 }
240 247
 
241 248
 type HisPrescriptionInfo struct {
242
-	ID           int64  `gorm:"column:id" json:"id" form:"id"`
243
-	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
244
-	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
245
-	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
246
-	HisPatientId int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
247
-	Status       int64  `gorm:"column:status" json:"status" form:"status"`
248
-	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
249
-	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
250
-	Creator      int64  `gorm:"column:creator" json:"creator" form:"creator"`
251
-	Modifier     int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
252
-	Diagnosis    string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
253
-	RegisterType int64  `gorm:"column:register_type" json:"register_type" form:"register_type"`
254
-	Doctor       string `gorm:"column:doctor" json:"doctor" form:"doctor"`
255
-	Departments  string `gorm:"column:departments" json:"departments" form:"departments"`
256
-	SickHistory  string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
249
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
250
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
251
+	RecordDate         int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
252
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
253
+	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
254
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
255
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
256
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
257
+	Creator            int64  `gorm:"column:creator" json:"creator" form:"creator"`
258
+	Modifier           int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
259
+	Diagnosis          string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
260
+	RegisterType       int64  `gorm:"column:register_type" json:"register_type" form:"register_type"`
261
+	Doctor             string `gorm:"column:doctor" json:"doctor" form:"doctor"`
262
+	Departments        string `gorm:"column:departments" json:"departments" form:"departments"`
263
+	SickHistory        string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
264
+	PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
257 265
 }
258 266
 
259 267
 func (HisPrescriptionInfo) TableName() string {
@@ -408,21 +416,25 @@ func (HisDoctorAdviceTemplate) TableName() string {
408 416
 }
409 417
 
410 418
 type HisPrescriptionProject struct {
411
-	ID             int64       `gorm:"column:id" json:"id" form:"id"`
412
-	ProjectId      int64       `gorm:"column:project_id" json:"project_id" form:"project_id"`
413
-	Price          float64     `gorm:"column:price" json:"price" form:"price"`
414
-	UserOrgId      int64       `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
415
-	Status         int64       `gorm:"column:status" json:"status" form:"status"`
416
-	Ctime          int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
417
-	Mtime          int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
418
-	PatientId      int64       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
419
-	HisPatientId   int64       `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
420
-	RecordDate     int64       `gorm:"column:record_date" json:"record_date" form:"record_date"`
421
-	PrescriptionId int64       `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
422
-	Count          int64       `gorm:"column:count" json:"count" form:"count"`
423
-	HisProject     *HisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
424
-	FeedetlSn      string      `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
425
-	MedListCodg    string      `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
419
+	ID                 int64      `gorm:"column:id" json:"id" form:"id"`
420
+	ProjectId          int64      `gorm:"column:project_id" json:"project_id" form:"project_id"`
421
+	Price              float64    `gorm:"column:price" json:"price" form:"price"`
422
+	UserOrgId          int64      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
423
+	Status             int64      `gorm:"column:status" json:"status" form:"status"`
424
+	Ctime              int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
425
+	Mtime              int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
426
+	PatientId          int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
427
+	HisPatientId       int64      `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
428
+	RecordDate         int64      `gorm:"column:record_date" json:"record_date" form:"record_date"`
429
+	PrescriptionId     int64      `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
430
+	Count              int64      `gorm:"column:count" json:"count" form:"count"`
431
+	FeedetlSn          string     `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
432
+	MedListCodg        string     `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
433
+	SingleDose         string     `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
434
+	DeliveryWay        string     `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
435
+	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
436
+	Day                string     `gorm:"column:day" json:"day" form:"day"`
437
+	HisProject         HisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
426 438
 }
427 439
 
428 440
 func (HisPrescriptionProject) TableName() string {
@@ -508,22 +520,73 @@ func (XtHisPatient) TableName() string {
508 520
 }
509 521
 
510 522
 type HisOrder struct {
511
-	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
512
-	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
513
-	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
514
-	SettleAccountsDate int64  `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
515
-	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
516
-	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
517
-	Status             int64  `gorm:"column:status" json:"status" form:"status"`
518
-	Number             string `gorm:"column:number" json:"number" form:"number"`
519
-	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
520
-	Infcode            int64  `gorm:"column:infcode" json:"infcode" form:"infcode"`
521
-	WarnMsg            string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
522
-	Cainfo             string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
523
-	ErrMsg             string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
524
-	RespondTime        string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
525
-	InfRefmsgid        string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
526
-	OrderStatus        int64  `gorm:"column:order_status" json:"order_status" form:"order_status"`
523
+	ID                 int64     `gorm:"column:id" json:"id" form:"id"`
524
+	UserOrgId          int64     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
525
+	HisPatientId       int64     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
526
+	SettleAccountsDate int64     `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
527
+	Ctime              int64     `gorm:"column:ctime" json:"ctime" form:"ctime"`
528
+	Mtime              int64     `gorm:"column:mtime" json:"mtime" form:"mtime"`
529
+	Status             int64     `gorm:"column:status" json:"status" form:"status"`
530
+	Number             string    `gorm:"column:number" json:"number" form:"number"`
531
+	PatientId          int64     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
532
+	Infcode            int64     `gorm:"column:infcode" json:"infcode" form:"infcode"`
533
+	WarnMsg            string    `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
534
+	Cainfo             string    `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
535
+	ErrMsg             string    `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
536
+	RespondTime        string    `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
537
+	InfRefmsgid        string    `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
538
+	OrderStatus        int64     `gorm:"column:order_status" json:"order_status" form:"order_status"`
539
+	MdtrtId            string    `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
540
+	SetlId             string    `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
541
+	PsnNo              string    `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
542
+	PsnName            string    `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
543
+	PsnCertType        string    `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
544
+	Certno             string    `gorm:"column:certno" json:"certno" form:"certno"`
545
+	Gend               string    `gorm:"column:gend" json:"gend" form:"gend"`
546
+	Naty               string    `gorm:"column:naty" json:"naty" form:"naty"`
547
+	Brdy               time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
548
+	Age                float64   `gorm:"column:age" json:"age" form:"age"`
549
+	Insutype           string    `gorm:"column:insutype" json:"insutype" form:"insutype"`
550
+	PsnType            string    `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
551
+	CvlservFlag        string    `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
552
+	SetlTime           time.Time `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
553
+	MdtrtCertType      string    `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
554
+	MedType            string    `gorm:"column:med_type" json:"med_type" form:"med_type"`
555
+	MedfeeSumamt       float64   `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
556
+	FulamtOwnpayAmt    float64   `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
557
+	OverlmtSelfPay     float64   `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
558
+	PreselfpayAmt      float64   `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
559
+	InscpScpAmt        float64   `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
560
+	ActPayDedc         float64   `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
561
+	HifpPay            float64   `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
562
+	CvlservPay         float64   `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
563
+	PoolPropSelfpay    float64   `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
564
+	HifesPay           float64   `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
565
+	HifmiPay           float64   `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
566
+	HifobPay           float64   `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
567
+	MafPay             float64   `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
568
+	OthPay             float64   `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
569
+	FundPaySumamt      float64   `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
570
+	PsnPartAmt         float64   `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
571
+	AcctPay            float64   `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
572
+	PsnCashPay         float64   `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
573
+	HospPartAmt        float64   `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
574
+	Balc               float64   `gorm:"column:balc" json:"balc" form:"balc"`
575
+	AcctMulaidPay      float64   `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
576
+	MedinsSetlId       string    `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
577
+	ClrOptins          string    `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
578
+	ClrWay             string    `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
579
+	ClrType            string    `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
580
+	FundPayType        string    `gorm:"column:fund_pay_type" json:"fund_pay_type" form:"fund_pay_type"`
581
+	CrtPaybLmtAmt      float64   `gorm:"column:crt_payb_lmt_amt" json:"crt_payb_lmt_amt" form:"crt_payb_lmt_amt"`
582
+	FundPayamt         float64   `gorm:"column:fund_payamt" json:"fund_payamt" form:"fund_payamt"`
583
+	FundPayTypeName    string    `gorm:"column:fund_pay_type_name" json:"fund_pay_type_name" form:"fund_pay_type_name"`
584
+	SetlProcInfo       string    `gorm:"column:setl_proc_info" json:"setl_proc_info" form:"setl_proc_info"`
585
+
586
+	HisOrderInfo        HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
587
+	Patients            Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
588
+	HisPatient          HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
589
+	HisPrescriptionInfo HisPrescriptionInfo `gorm:"ForeignKey:PatientId,SettleAccountsDate;AssociationForeignKey:PatientId,RecordDate" json:"p_info"`
527 590
 }
528 591
 
529 592
 func (HisOrder) TableName() string {

+ 1 - 0
models/patient_models.go Parādīt failu

@@ -224,6 +224,7 @@ type DialysisPrescription struct {
224 224
 	PreImpulse                 float64       `gorm:"column:pre_impulse" json:"pre_impulse" form:"pre_impulse"`
225 225
 	AnticoagulantStopTimeMin   int64         `gorm:"column:anticoagulant_stop_time_min" json:"anticoagulant_stop_time_min" form:"anticoagulant_stop_time_min"`
226 226
 	AnticoagulantStopTimeHour  int64         `gorm:"column:anticoagulant_stop_time_hour" json:"anticoagulant_stop_time_hour" form:"anticoagulant_stop_time_hour"`
227
+	Blood                      string        `gorm:"column:blood" json:"blood"`
227 228
 }
228 229
 
229 230
 func (DialysisPrescription) TableName() string {

+ 17 - 17
service/gdyb_service.go Parādīt failu

@@ -948,23 +948,23 @@ func SetInputMessage(nonce string, timestamp int64, org_name string, doctor stri
948 948
 	// 生成输入报文
949 949
 	inputMessage := make(map[string]interface{})
950 950
 
951
-	inputMessage["infno"] = "1101"                                                             // 交易编码
952
-	inputMessage["msgid"] = FixmedinsCOde + timeFormat + strconv.FormatInt(int64(randNum), 10) // 发送方报文 ID
953
-	inputMessage["mdtrtarea_admvs"] = "440200"                                                 // 就医地医保区划
954
-	inputMessage["insuplc_admdvs"] = "440200"                                                  // 参保地医保区划
955
-	inputMessage["recer_sys_code"] = "01"                                                      // 接收方系统代码
956
-	inputMessage["dev_no"] = ""                                                                // 设备编号
957
-	inputMessage["dev_safe_info"] = ""                                                         // 设备安全信息
958
-	inputMessage["cainfo"] = ""                                                                // 数字签名信息
959
-	inputMessage["signtype"] = ""                                                              // 签名类型
960
-	inputMessage["infver"] = "V1.1"                                                            // 接收方系统代码
961
-	inputMessage["opter_type"] = "1"                                                           // 经办人类别
962
-	inputMessage["opter"] = "mockuser"                                                         // 经办人
963
-	inputMessage["opter_name"] = doctor                                                        // 经办人姓名
964
-	inputMessage["inf_time"] = timeFormatOne                                                   // 交易时间
965
-	inputMessage["fixmedins_code"] = FixmedinsCOde                                             // 定点医药机构编号
966
-	inputMessage["fixmedins_name"] = org_name                                                  //定点医药机构名称
967
-	inputMessage["sign_no"] = ""                                                               //交易签到流水号
951
+	inputMessage["infno"] = "1101"                                                              // 交易编码
952
+	inputMessage["msgid"] = "H44022900158" + timeFormat + strconv.FormatInt(int64(randNum), 10) // 发送方报文 ID
953
+	inputMessage["mdtrtarea_admvs"] = "440200"                                                  // 就医地医保区划
954
+	inputMessage["insuplc_admdvs"] = "440200"                                                   // 参保地医保区划
955
+	inputMessage["recer_sys_code"] = "01"                                                       // 接收方系统代码
956
+	inputMessage["dev_no"] = ""                                                                 // 设备编号
957
+	inputMessage["dev_safe_info"] = ""                                                          // 设备安全信息
958
+	inputMessage["cainfo"] = ""                                                                 // 数字签名信息
959
+	inputMessage["signtype"] = ""                                                               // 签名类型
960
+	inputMessage["infver"] = "V1.1"                                                             // 接收方系统代码
961
+	inputMessage["opter_type"] = "1"                                                            // 经办人类别
962
+	inputMessage["opter"] = "mockuser"                                                          // 经办人
963
+	inputMessage["opter_name"] = doctor                                                         // 经办人姓名
964
+	inputMessage["inf_time"] = timeFormatOne                                                    // 交易时间
965
+	inputMessage["fixmedins_code"] = FixmedinsCOde                                              // 定点医药机构编号
966
+	inputMessage["fixmedins_name"] = ""                                                         //定点医药机构名称
967
+	inputMessage["sign_no"] = ""                                                                //交易签到流水号
968 968
 	return inputMessage
969 969
 }
970 970
 

+ 35 - 2
service/his_project_service.go Parādīt failu

@@ -36,10 +36,10 @@ func GetHisProjectList(orgid int64, limit int64, page int64, start int64, charge
36 36
 		db = db.Where("x.user_org_id = ?", orgid)
37 37
 	}
38 38
 	if start > 0 {
39
-		db = db.Where("x.medical_status = ?", start)
39
+		db = db.Where("x.medical_status = ?", charge)
40 40
 	}
41 41
 	if charge > 0 {
42
-		db = db.Where("x.is_charge = ? ", charge)
42
+		db = db.Where("x.is_charge = ? ", start)
43 43
 	}
44 44
 	if len(keyword) > 0 {
45 45
 		db = db.Where("x.project_name like ?", likeKey)
@@ -333,3 +333,36 @@ func UpdatedHisPatient(hispatientid int64, orgid int64, recorddate int64) error
333 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 334
 	return err
335 335
 }
336
+
337
+func GetBloodPatientInfoById(patientid int64) (models.XtPatients, error) {
338
+
339
+	patients := models.XtPatients{}
340
+	err := XTReadDB().Model(&patients).Where("id = ? and status = 1", patientid).Find(&patients).Error
341
+	return patients, err
342
+}
343
+
344
+func GetPatientCaseHistory(patientid int64) (models.HisPatientCaseHistory, error) {
345
+
346
+	history := models.HisPatientCaseHistory{}
347
+	err := XTReadDB().Model(&history).Where("patient_id = ? and status = 1", patientid).Find(&history).Error
348
+	return history, err
349
+}
350
+
351
+func GetHisPatientById(patientid int64) (models.HisPatient, error) {
352
+	patient := models.HisPatient{}
353
+	err := XTReadDB().Model(&patient).Where("patient_id = ? and status = 1", patientid).Find(&patient).Error
354
+	return patient, err
355
+}
356
+
357
+func GetTemplateDetail(id int64) (models.HisCaseHistoryTemplate, error) {
358
+
359
+	template := models.HisCaseHistoryTemplate{}
360
+	err := XTReadDB().Model(&template).Where("id= ? and status = 1", id).Find(&template).Error
361
+	return template, err
362
+}
363
+
364
+func UpdateCaseHistoryTemplate(tem *models.HisCaseHistoryTemplate, id int64) error {
365
+
366
+	err := XTWriteDB().Model(&tem).Where("id = ? ", id).Updates(map[string]interface{}{"history_of_present_illness": tem.HistoryOfPresentIllness, "past_history": tem.PastHistory, "chief_conplaint": tem.ChiefConplaint, "personal_history": tem.PersonalHistory, "family_history": tem.FamilyHistory, "diagnostic": tem.Diagnostic, "template_name": tem.TemplateName, "template_remark": tem.TemplateRemark, "modifier": tem.Modifier}).Error
367
+	return err
368
+}

+ 129 - 1
service/his_service.go Parādīt failu

@@ -96,17 +96,46 @@ func GetHisPatientCaseHistoryList(org_id int64, patient_id int64) (caseHistorys
96 96
 	return
97 97
 }
98 98
 
99
-func GetHisPatientCaseHistoryTemplate(org_id int64) (caseHistorys []*models.HisCaseHistoryTemplate, err error) {
99
+func GetHisPatientCaseHistoryTemplate(org_id int64, startime int64, endtime int64, keyword string) (caseHistorys []*models.HisCaseHistoryTemplate, err error) {
100
+	likekey := "%" + keyword + "%"
100 101
 	db := readDb.Model(&models.HisCaseHistoryTemplate{}).Where("user_org_id = ? AND status = 1", org_id)
102
+	if startime > 0 {
103
+		db = db.Where("record_date>=?", startime)
104
+	}
105
+	if endtime > 0 {
106
+		db = db.Where("record_date<=?", endtime)
107
+	}
108
+	if len(keyword) > 0 {
109
+		db = db.Where("template_name like ? ", likekey)
110
+	}
101 111
 	err = db.Find(&caseHistorys).Error
102 112
 	return
103 113
 }
104 114
 
115
+func GetHisPatientCaseHistory(org_id int64) (caseHistory []*models.HisPatientCaseHistory, err error) {
116
+
117
+	err = readDb.Model(&models.HisPatientCaseHistory{}).Where("user_org_id = ? and status = 1", org_id).Find(&caseHistory).Error
118
+	return caseHistory, err
119
+}
120
+
105 121
 func SaveHisPatientCaseHistoryTemplate(template models.HisCaseHistoryTemplate) (err error) {
106 122
 	err = writeDb.Create(&template).Error
107 123
 	return
108 124
 }
109 125
 
126
+func GetHisPatientCaseHistoryById(hispatientid int64) (*models.HisPatientCaseHistory, error) {
127
+	history := models.HisPatientCaseHistory{}
128
+	err := XTReadDB().Model(&history).Where("his_patient_id = ? and status = 1", hispatientid).Find(&history).Error
129
+	if err != nil {
130
+		if err == gorm.ErrRecordNotFound {
131
+			return nil, err
132
+		} else {
133
+			return nil, err
134
+		}
135
+	}
136
+	return &history, nil
137
+}
138
+
110 139
 func SaveHisPatientCaseHistory(caseHistory models.HisPatientCaseHistory) (err error) {
111 140
 	err = writeDb.Create(&caseHistory).Error
112 141
 	return
@@ -219,3 +248,102 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
219 248
 	return
220 249
 
221 250
 }
251
+
252
+func GetHisOrderList(user_org_id int64) (order []*models.HisOrder, err error) {
253
+	err = readDb.Model(&models.HisOrder{}).Where("status = 1 AND user_org_id = ?", user_org_id).
254
+		Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
255
+		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
256
+		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
257
+		Preload("HisPrescriptionInfo", "status = 1 AND user_org_id = ?", user_org_id).Order("ctime desc").
258
+		Find(&order).Error
259
+	return
260
+}
261
+
262
+func UpDatePrescriptionNumber(user_org_id int64, ids []int64, number string) (err error) {
263
+	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
264
+	return
265
+}
266
+
267
+type HisOrder struct {
268
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
269
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
270
+	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
271
+	SettleAccountsDate int64  `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
272
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
273
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
274
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
275
+	Number             string `gorm:"column:number" json:"number" form:"number"`
276
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
277
+
278
+	HisOrderInfo        models.HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
279
+	Patients            models.Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
280
+	HisPatient          models.HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
281
+	HisPrescriptionInfo models.HisPrescriptionInfo `gorm:"ForeignKey:PatientId,SettleAccountsDate;AssociationForeignKey:PatientId,RecordDate" json:"p_info"`
282
+	HisPrescription     []*models.HisPrescription  `gorm:"ForeignKey:SettleAccountsDate;AssociationForeignKey:RecordDate" json:"prescriptions"`
283
+}
284
+
285
+func (HisOrder) TableName() string {
286
+	return "his_order"
287
+}
288
+
289
+func GetHisOrder(user_org_id int64, number string, patient_id int64) (order HisOrder, err error) {
290
+	err = readDb.Model(&HisOrder{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND number=?", user_org_id, patient_id, number).
291
+		Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
292
+		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
293
+		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
294
+		Preload("HisPrescriptionInfo", "status = 1 AND user_org_id = ?", user_org_id).
295
+		Order("ctime desc").
296
+		Find(&order).Error
297
+	return
298
+}
299
+
300
+func GetHisPrescriptionThree(org_id int64, patient_id int64, record_date int64, number string) (prescription []*models.HisPrescription, err error) {
301
+	err = readDb.Model(&models.HisPrescription{}).
302
+		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
303
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
304
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
305
+		}).
306
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND batch_number=?", org_id, record_date, patient_id, number).
307
+		Find(&prescription).Error
308
+	return
309
+}
310
+
311
+type HisPrescriptionInfo struct {
312
+	ID           int64             `gorm:"column:id" json:"id" form:"id"`
313
+	UserOrgId    int64             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
314
+	RecordDate   int64             `gorm:"column:record_date" json:"record_date" form:"record_date"`
315
+	PatientId    int64             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
316
+	HisPatientId int64             `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
317
+	Status       int64             `gorm:"column:status" json:"status" form:"status"`
318
+	Ctime        int64             `gorm:"column:ctime" json:"ctime" form:"ctime"`
319
+	Mtime        int64             `gorm:"column:mtime" json:"mtime" form:"mtime"`
320
+	Creator      int64             `gorm:"column:creator" json:"creator" form:"creator"`
321
+	Modifier     int64             `gorm:"column:modifier" json:"modifier" form:"modifier"`
322
+	Diagnosis    string            `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
323
+	RegisterType int64             `gorm:"column:register_type" json:"register_type" form:"register_type"`
324
+	Doctor       string            `gorm:"column:doctor" json:"doctor" form:"doctor"`
325
+	Departments  string            `gorm:"column:departments" json:"departments" form:"departments"`
326
+	SickHistory  string            `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
327
+	Patients     models.Patients   `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
328
+	HisPatient   models.HisPatient `gorm:"ForeignKey:HisPatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"his_patient"`
329
+}
330
+
331
+func (HisPrescriptionInfo) TableName() string {
332
+	return "his_prescription_info"
333
+}
334
+
335
+func GetHisPrescriptionOrderList(org_id int64) (prescriptionOrder []*HisPrescriptionInfo, err error) {
336
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ?", org_id).
337
+		Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
338
+		Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).Order("ctime desc").Find(&prescriptionOrder).Error
339
+	return
340
+
341
+}
342
+
343
+func GetHisPrescriptionOrderInfo(patient_id, his_patient_id, org_id int64) (prescriptionOrder []*HisPrescriptionInfo, err error) {
344
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ?", org_id).
345
+		Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
346
+		Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).Error
347
+	return
348
+
349
+}

+ 1 - 1
service/mobile_dialysis_service.go Parādīt failu

@@ -1073,7 +1073,7 @@ func BatchUpdateMonitors(monitors []*models.MonitoringRecord) error {
1073 1073
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
1074 1074
 	tx := writeDb.Begin()
1075 1075
 	updateTime := time.Now().Unix()
1076
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType}).Error
1076
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse}).Error
1077 1077
 	if err != nil {
1078 1078
 		tx.Rollback()
1079 1079
 		return err