Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
348c3a06e6

+ 8 - 4
controllers/his_api_controller.go View File

@@ -520,6 +520,7 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
520 520
 		return
521 521
 	}
522 522
 	recordDateTime := theTime.Unix()
523
+	fmt.Println("recordDataTime", recordDateTime)
523 524
 	sickTime, err := time.ParseInLocation(timeLayout+" 15:04:05", sick_date+" 00:00:00", loc)
524 525
 	if err != nil {
525 526
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -559,12 +560,15 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
559 560
 		Remark:                  remark,
560 561
 	}
561 562
 
562
-	err = service.SaveHisPatientCaseHistory(caseHistory)
563
+	err = service.SaveHisPatientCaseHistory(&caseHistory)
563 564
 	if err != nil {
564
-		c.ServeSuccessJSON(map[string]interface{}{
565
-			"msg": "保存成功",
566
-		})
565
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
566
+		return
567 567
 	}
568
+	c.ServeSuccessJSON(map[string]interface{}{
569
+		"caseHistory": caseHistory,
570
+	})
571
+	return
568 572
 
569 573
 	//查询该患者是否有病历
570 574
 	//_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)

+ 317 - 0
controllers/his_project_api_controller.go View File

@@ -60,6 +60,22 @@ func HisProjectRouters() {
60 60
 	beego.Router("/api/doctorworkstation/gettemplatedetail", &HisProjectApiController{}, "Get:GetTemplateDetail")
61 61
 	beego.Router("/api/doctorworkstation/updaterecordtemplate", &HisProjectApiController{}, "Get:UpdateRecordTemplate")
62 62
 	beego.Router("/api/hispatient/gehispatient", &HisProjectApiController{}, "Get:GetHisPatient")
63
+
64
+	//获取处方打印单
65
+	beego.Router("/api/hispatient/getprescriptionprint", &HisProjectApiController{}, "Get:GetDoctorAdvicePrint")
66
+	//获取项目打印单
67
+	//beego.Router("/api/hispatient/getprojectprint",&HisApiController{},"Get:GetProjectPrint")
68
+
69
+	beego.Router("/api/hispatient/postprinthistemplate", &HisProjectApiController{}, "Get:PostPrintHisTemplate")
70
+	beego.Router("/api/gethisprinttemplate", &HisProjectApiController{}, "Get:GetHisPrintTemplate")
71
+	beego.Router("/api/hispatient/postprescriptiontemplate", &HisProjectApiController{}, "Get:PostPrescriptionTempalte")
72
+	beego.Router("/api/hispatient/getprescriptiontemplate", &HisProjectApiController{}, "Get:GetPrescriptionTemplate")
73
+	beego.Router("/api/hispatient/posttreatprinttemplate", &HisProjectApiController{}, "Get:PostTreatPrintTemplate")
74
+	beego.Router("/api/hispatient/gettreatprinttemplate", &HisProjectApiController{}, "Get:GetTreatPrintTemplate")
75
+	beego.Router("/api/hispatient/postchargeprinttemplate", &HisProjectApiController{}, "Get:PostChargePrintTemplate")
76
+	beego.Router("/api/hispatient/getchargeprinttemplate", &HisProjectApiController{}, "Get:GetChargePrintTemplate")
77
+	beego.Router("/api/hispatient/getallhispatient", &HisProjectApiController{}, "Get:GetAllHisPatient")
78
+	beego.Router("/api/hispatient/getchargeprint", &HisProjectApiController{}, "Get:GetChargePrint")
63 79
 }
64 80
 
65 81
 func (this *HisProjectApiController) SaveProject() {
@@ -997,3 +1013,304 @@ func (this *HisProjectApiController) GetHisPatient() {
997 1013
 		"patient": patient,
998 1014
 	})
999 1015
 }
1016
+
1017
+func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1018
+
1019
+	patient_id, _ := this.GetInt64("patient_id")
1020
+	record_date := this.GetString("record_date")
1021
+	timeLayout := "2006-01-02"
1022
+	loc, _ := time.LoadLocation("Local")
1023
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1024
+	recordDateTime := theTime.Unix()
1025
+	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime)
1026
+	//
1027
+	doctorPorject, err := service.GetDoctorProjectItem(patient_id, recordDateTime)
1028
+	patient, err := service.GetBloodPatientByPatient(patient_id)
1029
+	//hisPatient, err := service.GetHisPatientById(patient_id)
1030
+	if err != nil {
1031
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1032
+		return
1033
+	}
1034
+	this.ServeSuccessJSON(map[string]interface{}{
1035
+		"advicePrint": advicePrint,
1036
+		//"hisPatient":hisPatient,
1037
+		"patient":       patient,
1038
+		"doctorPorject": doctorPorject,
1039
+	})
1040
+}
1041
+
1042
+func (this *HisProjectApiController) GetProjectPrint() {
1043
+
1044
+	his_patient_id, _ := this.GetInt64("his_patient_id")
1045
+	hisPatient, _ := service.GetHisPatientById(his_patient_id)
1046
+	projectPrint, err := service.GetProjectPrint(his_patient_id)
1047
+	if err != nil {
1048
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1049
+		return
1050
+	}
1051
+	this.ServeSuccessJSON(map[string]interface{}{
1052
+		"hisPatient":   hisPatient,
1053
+		"projectPrint": projectPrint,
1054
+	})
1055
+}
1056
+
1057
+func (this *HisProjectApiController) PostPrintHisTemplate() {
1058
+
1059
+	template_id, _ := this.GetInt64("template_id")
1060
+	adminUserInfo := this.GetAdminUserInfo()
1061
+	orgId := adminUserInfo.CurrentOrgId
1062
+	_, errcode := service.GetHisTemplateId(template_id, orgId)
1063
+	fmt.Println("errcode0-------", errcode)
1064
+	if errcode == gorm.ErrRecordNotFound {
1065
+		template := models.XtHisTemplate{
1066
+			TemplateId: template_id,
1067
+			UserOrgId:  orgId,
1068
+			Status:     1,
1069
+			Ctime:      time.Now().Unix(),
1070
+		}
1071
+		err := service.CreateHisTemplate(&template)
1072
+		if err != nil {
1073
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1074
+			return
1075
+		}
1076
+		this.ServeSuccessJSON(map[string]interface{}{
1077
+			"template":    template,
1078
+			"template_id": template_id,
1079
+		})
1080
+	} else if errcode == nil {
1081
+
1082
+		template := models.XtHisTemplate{
1083
+			TemplateId: template_id,
1084
+			UserOrgId:  orgId,
1085
+			Status:     1,
1086
+			Ctime:      time.Now().Unix(),
1087
+			Mtime:      time.Now().Unix(),
1088
+		}
1089
+		err := service.UpdateHisTemplate(&template)
1090
+		if err != nil {
1091
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1092
+			return
1093
+		}
1094
+		this.ServeSuccessJSON(map[string]interface{}{
1095
+			"template":    template,
1096
+			"template_id": template_id,
1097
+		})
1098
+	}
1099
+}
1100
+
1101
+func (this *HisProjectApiController) GetHisPrintTemplate() {
1102
+
1103
+	adminUserInfo := this.GetAdminUserInfo()
1104
+	orgId := adminUserInfo.CurrentOrgId
1105
+	template, err := service.GetHisPrintTemplate(orgId)
1106
+	if err != nil {
1107
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1108
+		return
1109
+	}
1110
+	this.ServeSuccessJSON(map[string]interface{}{
1111
+		"template": template,
1112
+	})
1113
+}
1114
+
1115
+func (this *HisProjectApiController) PostPrescriptionTempalte() {
1116
+
1117
+	template_id, _ := this.GetInt64("template_id")
1118
+	adminUserInfo := this.GetAdminUserInfo()
1119
+	orgId := adminUserInfo.CurrentOrgId
1120
+	_, errcode := service.GetPrescriptionTemplate(template_id, orgId)
1121
+	if errcode == gorm.ErrRecordNotFound {
1122
+		template := models.XtHisAdviceTemplate{
1123
+			TemplateId: template_id,
1124
+			UserOrgId:  orgId,
1125
+			Status:     1,
1126
+			Ctime:      time.Now().Unix(),
1127
+		}
1128
+		err := service.CreatePrescriptionTemplate(&template)
1129
+		if err != nil {
1130
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1131
+			return
1132
+		}
1133
+		this.ServeSuccessJSON(map[string]interface{}{
1134
+			"template":    template,
1135
+			"template_id": template_id,
1136
+		})
1137
+	} else if errcode == nil {
1138
+		template := models.XtHisAdviceTemplate{
1139
+			TemplateId: template_id,
1140
+			UserOrgId:  orgId,
1141
+			Status:     1,
1142
+			Ctime:      time.Now().Unix(),
1143
+		}
1144
+		err := service.UpdatePrescriptionTemplate(&template)
1145
+		if err != nil {
1146
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1147
+			return
1148
+		}
1149
+		this.ServeSuccessJSON(map[string]interface{}{
1150
+			"template":    template,
1151
+			"template_id": template_id,
1152
+		})
1153
+	}
1154
+}
1155
+
1156
+func (this *HisProjectApiController) GetPrescriptionTemplate() {
1157
+
1158
+	adminUserInfo := this.GetAdminUserInfo()
1159
+	orgId := adminUserInfo.CurrentOrgId
1160
+	template, err := service.GetPrescriptionTemplateById(orgId)
1161
+	if err != nil {
1162
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1163
+		return
1164
+	}
1165
+	this.ServeSuccessJSON(map[string]interface{}{
1166
+		"template": template,
1167
+	})
1168
+}
1169
+
1170
+func (this *HisProjectApiController) PostTreatPrintTemplate() {
1171
+
1172
+	template_id, _ := this.GetInt64("template_id")
1173
+	adminUserInfo := this.GetAdminUserInfo()
1174
+	orgId := adminUserInfo.CurrentOrgId
1175
+	_, errcode := service.GetTreatPrintTemplate(template_id, orgId)
1176
+	if errcode == gorm.ErrRecordNotFound {
1177
+		template := models.XtHisTreatmentTemplate{
1178
+			TemplateId: template_id,
1179
+			UserOrgId:  orgId,
1180
+			Status:     1,
1181
+			Ctime:      time.Now().Unix(),
1182
+		}
1183
+		err := service.CreateTreatPrintTemplate(&template)
1184
+		if err != nil {
1185
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1186
+			return
1187
+		}
1188
+		this.ServeSuccessJSON(map[string]interface{}{
1189
+			"template":    template,
1190
+			"template_id": template_id,
1191
+		})
1192
+	} else if errcode == nil {
1193
+		template := models.XtHisTreatmentTemplate{
1194
+			TemplateId: template_id,
1195
+			UserOrgId:  orgId,
1196
+			Status:     1,
1197
+			Ctime:      time.Now().Unix(),
1198
+		}
1199
+		err := service.UpdatedTreateTemplate(&template)
1200
+		if err != nil {
1201
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1202
+			return
1203
+		}
1204
+		this.ServeSuccessJSON(map[string]interface{}{
1205
+			"template":    template,
1206
+			"template_id": template_id,
1207
+		})
1208
+	}
1209
+}
1210
+
1211
+func (this *HisProjectApiController) GetTreatPrintTemplate() {
1212
+
1213
+	adminUserInfo := this.GetAdminUserInfo()
1214
+	orgId := adminUserInfo.CurrentOrgId
1215
+	template, err := service.GetTreatTtreatPrintTemplate(orgId)
1216
+	if err != nil {
1217
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1218
+		return
1219
+	}
1220
+	this.ServeSuccessJSON(map[string]interface{}{
1221
+		"template": template,
1222
+	})
1223
+}
1224
+
1225
+func (this *HisProjectApiController) PostChargePrintTemplate() {
1226
+
1227
+	template_id, _ := this.GetInt64("template_id")
1228
+	adminUserInfo := this.GetAdminUserInfo()
1229
+	orgId := adminUserInfo.CurrentOrgId
1230
+	_, errcode := service.GetChargeTemplate(template_id, orgId)
1231
+	if errcode == gorm.ErrRecordNotFound {
1232
+		template := models.XtHisChargeTemplate{
1233
+			TemplateId: template_id,
1234
+			UserOrgId:  orgId,
1235
+			Ctime:      time.Now().Unix(),
1236
+			Status:     1,
1237
+		}
1238
+		err := service.CreateChargePrintTemplate(&template)
1239
+		if err != nil {
1240
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1241
+			return
1242
+		}
1243
+		this.ServeSuccessJSON(map[string]interface{}{
1244
+			"template":    template,
1245
+			"template_id": template_id,
1246
+		})
1247
+	} else if errcode == nil {
1248
+		template := models.XtHisChargeTemplate{
1249
+			TemplateId: template_id,
1250
+			UserOrgId:  orgId,
1251
+			Ctime:      time.Now().Unix(),
1252
+			Status:     1,
1253
+		}
1254
+		err := service.UpdateChargePrintTemplate(&template)
1255
+		if err != nil {
1256
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1257
+			return
1258
+		}
1259
+		this.ServeSuccessJSON(map[string]interface{}{
1260
+			"template":    template,
1261
+			"template_id": template_id,
1262
+		})
1263
+	}
1264
+}
1265
+
1266
+func (this *HisProjectApiController) GetChargePrintTemplate() {
1267
+	adminUserInfo := this.GetAdminUserInfo()
1268
+	orgId := adminUserInfo.CurrentOrgId
1269
+	template, err := service.GetChargePrintTemplate(orgId)
1270
+	if err != nil {
1271
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1272
+		return
1273
+	}
1274
+	this.ServeSuccessJSON(map[string]interface{}{
1275
+		"template": template,
1276
+	})
1277
+}
1278
+
1279
+func (this *HisProjectApiController) GetAllHisPatient() {
1280
+	record_date := this.GetString("record_date")
1281
+	timeLayout := "2006-01-02"
1282
+	loc, _ := time.LoadLocation("Local")
1283
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1284
+	recordDateTime := theTime.Unix()
1285
+	adminUserInfo := this.GetAdminUserInfo()
1286
+	patients, err := service.GetHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime)
1287
+	if err != nil {
1288
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1289
+		return
1290
+	}
1291
+	this.ServeSuccessJSON(map[string]interface{}{
1292
+		"list": patients,
1293
+	})
1294
+
1295
+}
1296
+
1297
+func (this *HisProjectApiController) GetChargePrint() {
1298
+	record_date := this.GetString("record_date")
1299
+	timeLayout := "2006-01-02"
1300
+	loc, _ := time.LoadLocation("Local")
1301
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1302
+	recordDateTime := theTime.Unix()
1303
+	patient_id, _ := this.GetInt64("patient_id")
1304
+	prescription_id, _ := this.GetInt64("prescription_id")
1305
+	adminUserInfo := this.GetAdminUserInfo()
1306
+	chargePrint, err := service.GetChargePrint(recordDateTime, patient_id, adminUserInfo.CurrentOrgId)
1307
+	prescription, err := service.GetHisPrescriptionNight(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, prescription_id)
1308
+	if err != nil {
1309
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1310
+		return
1311
+	}
1312
+	this.ServeSuccessJSON(map[string]interface{}{
1313
+		"list":         chargePrint,
1314
+		"prescription": prescription,
1315
+	})
1316
+}

+ 26 - 1
controllers/manager_center_api_controller.go View File

@@ -29,7 +29,7 @@ func ManagerCenterRegistRouters() {
29 29
 
30 30
 	beego.Router("/api/medicineinsurancepercent/get", &ManagerCenterApiController{}, "get:GetMedicineInsurancePercent")
31 31
 	//beego.Router("/api/drugunitsafeguard/get", &ManagerCenterApiController{}, "get:GetDrugUnitSafeguard")
32
-
32
+	beego.Router("/api/drug/basedruglib", &ManagerCenterApiController{}, "get:DeleteBaseDrugById")
33 33
 	//专项字典
34 34
 	beego.Router("/api/dictionary/getconfiglist", &ManagerCenterApiController{}, "get,post:GetConfigList")
35 35
 	beego.Router("/api/dictionary/createconfig", &ManagerCenterApiController{}, "Post:CreateConfig")
@@ -1625,3 +1625,28 @@ func (c *ManagerCenterApiController) GetMedicineInsurancePercent() {
1625 1625
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1626 1626
 	}
1627 1627
 }
1628
+
1629
+func (c *ManagerCenterApiController) DeleteBaseDrugById() {
1630
+
1631
+	id, _ := c.GetInt64("id")
1632
+	//查询入库单
1633
+	_, errcode := service.GetDrugWareoutInfo(id)
1634
+	if errcode == gorm.ErrRecordNotFound {
1635
+		//查询出库单
1636
+		_, errcodes := service.GetDrugWareOutById(id)
1637
+		if errcodes == gorm.ErrRecordNotFound {
1638
+			//删除
1639
+			service.DeleteBaseDrugById(id)
1640
+			returnData := make(map[string]interface{}, 0)
1641
+			returnData["msg"] = "ok"
1642
+			c.ServeSuccessJSON(returnData)
1643
+			return
1644
+		} else if errcodes == nil {
1645
+			c.ServeFailJsonSend(enums.ErrorCodeDataException, "已出库")
1646
+			return
1647
+		}
1648
+	} else if errcode == nil {
1649
+		c.ServeFailJsonSend(enums.ErrorCodeDataException, "已入库")
1650
+		return
1651
+	}
1652
+}

+ 53 - 0
models/his_models.go View File

@@ -100,6 +100,7 @@ type HisPatient struct {
100 100
 	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
101 101
 	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
102 102
 	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
103
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
103 104
 }
104 105
 
105 106
 func (HisPatient) TableName() string {
@@ -676,3 +677,55 @@ type VMHisPatient struct {
676 677
 func (VMHisPatient) TableName() string {
677 678
 	return "his_patient"
678 679
 }
680
+
681
+type XtHisTemplate struct {
682
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
683
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
684
+	TemplateId int64 `gorm:"column:template_id" json:"template_id" form:"template_id"`
685
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
686
+	Ctime      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
687
+	Mtime      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
688
+}
689
+
690
+func (XtHisTemplate) TableName() string {
691
+	return "xt_his_template"
692
+}
693
+
694
+type XtHisAdviceTemplate struct {
695
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
696
+	TemplateId int64 `gorm:"column:template_id" json:"template_id" form:"template_id"`
697
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
698
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
699
+	Ctime      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
700
+	Mtime      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
701
+}
702
+
703
+func (XtHisAdviceTemplate) TableName() string {
704
+	return "xt_his_advice_template"
705
+}
706
+
707
+type XtHisChargeTemplate struct {
708
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
709
+	TemplateId int64 `gorm:"column:template_id" json:"template_id" form:"template_id"`
710
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
711
+	Ctime      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
712
+	Mtime      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
713
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
714
+}
715
+
716
+func (XtHisChargeTemplate) TableName() string {
717
+	return "xt_his_charge_template"
718
+}
719
+
720
+type XtHisTreatmentTemplate struct {
721
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
722
+	TemplateId int64 `gorm:"column:template_id" json:"template_id" form:"template_id"`
723
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
724
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
725
+	Ctime      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
726
+	Mtime      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
727
+}
728
+
729
+func (XtHisTreatmentTemplate) TableName() string {
730
+	return "xt_his_treatment_template"
731
+}

+ 169 - 0
service/his_project_service.go View File

@@ -348,6 +348,13 @@ func GetPatientCaseHistory(patientid int64) (models.HisPatientCaseHistory, error
348 348
 	return history, err
349 349
 }
350 350
 
351
+func GetBloodPatientByPatient(id int64) (models.XtPatients, error) {
352
+
353
+	patients := models.XtPatients{}
354
+	err := XTReadDB().Model(&patients).Where("id = ? and status = 1", id).Find(&patients).Error
355
+	return patients, err
356
+}
357
+
351 358
 func GetHisPatientById(patientid int64) (models.HisPatient, error) {
352 359
 	patient := models.HisPatient{}
353 360
 	err := XTReadDB().Model(&patient).Where("patient_id = ? and status = 1", patientid).Find(&patient).Error
@@ -372,3 +379,165 @@ func GetHistPatient(orgid int64, keyword string) (hisPatient []*models.HisPatien
372 379
 	err = XTReadDB().Model(&hisPatient).Where("user_org_id = ? and name like ?", orgid, likeKey).Find(&hisPatient).Error
373 380
 	return hisPatient, err
374 381
 }
382
+
383
+func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64) (prescription []*models.HisDoctorAdviceInfo, err error) {
384
+
385
+	err = XTReadDB().Model(&prescription).Where("patient_id = ? and status = 1 and advice_date = ?", his_patient_id, recorddate).Find(&prescription).Error
386
+	return prescription, err
387
+}
388
+
389
+func GetProjectPrint(his_patient_id int64) (models.HisPrescriptionProject, error) {
390
+	project := models.HisPrescriptionProject{}
391
+	err := XTReadDB().Model(&project).Where("his_patient_id = ? and status = 1", his_patient_id).Find(&project).Error
392
+	return project, err
393
+}
394
+
395
+func GetHisTemplateId(templateid int64, orgid int64) (*models.XtHisTemplate, error) {
396
+
397
+	template := models.XtHisTemplate{}
398
+	err := XTReadDB().Model(&template).Where("template_id = ? and user_org_id = ? and status = 1", templateid, orgid).Find(&template).Error
399
+	if err != nil {
400
+		if err == gorm.ErrRecordNotFound {
401
+			return nil, err
402
+		} else {
403
+			return nil, err
404
+		}
405
+	}
406
+	return &template, nil
407
+}
408
+
409
+func CreateHisTemplate(template *models.XtHisTemplate) error {
410
+
411
+	err := XTWriteDB().Create(&template).Error
412
+	return err
413
+}
414
+
415
+func UpdateHisTemplate(template *models.XtHisTemplate) error {
416
+
417
+	err := XTWriteDB().Save(&template).Error
418
+	return err
419
+}
420
+
421
+func GetHisPrintTemplate(orgid int64) (models.XtHisTemplate, error) {
422
+
423
+	template := models.XtHisTemplate{}
424
+	err := XTReadDB().Model(&template).Where("user_org_id = ? and status = 1", orgid).Find(&template).Error
425
+	return template, err
426
+}
427
+
428
+func GetPrescriptionTemplate(templateid int64, orgid int64) (*models.XtHisAdviceTemplate, error) {
429
+
430
+	template := models.XtHisAdviceTemplate{}
431
+	err := XTReadDB().Model(&template).Where("template_id = ? and user_org_id = ? and status = 1", templateid, orgid).Find(&template).Error
432
+	if err != nil {
433
+		if err == gorm.ErrRecordNotFound {
434
+			return nil, err
435
+		} else {
436
+			return nil, err
437
+		}
438
+	}
439
+	return &template, nil
440
+}
441
+
442
+func CreatePrescriptionTemplate(template *models.XtHisAdviceTemplate) error {
443
+
444
+	err = XTWriteDB().Create(&template).Error
445
+	return err
446
+}
447
+
448
+func UpdatePrescriptionTemplate(template *models.XtHisAdviceTemplate) error {
449
+
450
+	err := XTWriteDB().Save(&template).Error
451
+	return err
452
+}
453
+
454
+func GetPrescriptionTemplateById(orgid int64) (models.XtHisAdviceTemplate, error) {
455
+
456
+	template := models.XtHisAdviceTemplate{}
457
+	err := XTReadDB().Model(&template).Where("user_org_id = ? and status = 1", orgid).Find(&template).Error
458
+	return template, err
459
+}
460
+
461
+func GetTreatPrintTemplate(templateid int64, orgid int64) (*models.XtHisTreatmentTemplate, error) {
462
+
463
+	template := models.XtHisTreatmentTemplate{}
464
+	err := XTReadDB().Model(&template).Where("template_id = ? and user_org_id = ? and status = 1", templateid, orgid).Find(&template).Error
465
+	if err != nil {
466
+		if err == gorm.ErrRecordNotFound {
467
+			return nil, err
468
+		} else {
469
+			return nil, err
470
+		}
471
+	}
472
+	return &template, nil
473
+}
474
+
475
+func CreateTreatPrintTemplate(template *models.XtHisTreatmentTemplate) error {
476
+
477
+	err := XTWriteDB().Create(&template).Error
478
+	return err
479
+}
480
+
481
+func UpdatedTreateTemplate(template *models.XtHisTreatmentTemplate) error {
482
+
483
+	err := XTWriteDB().Save(&template).Error
484
+	return err
485
+}
486
+
487
+func GetTreatTtreatPrintTemplate(orgid int64) (models.XtHisTreatmentTemplate, error) {
488
+	template := models.XtHisTreatmentTemplate{}
489
+	err := XTReadDB().Where("user_org_id = ? and status =1", orgid).Find(&template).Error
490
+	return template, err
491
+}
492
+
493
+func GetChargeTemplate(templateid int64, orgid int64) (*models.XtHisChargeTemplate, error) {
494
+
495
+	template := models.XtHisChargeTemplate{}
496
+	err := XTReadDB().Model(&template).Where("template_id = ? and user_org_id = ? and status = 1", templateid, orgid).Find(&template).Error
497
+	if err != nil {
498
+		if err == gorm.ErrRecordNotFound {
499
+			return nil, err
500
+		} else {
501
+			return nil, err
502
+		}
503
+	}
504
+	return &template, nil
505
+}
506
+
507
+func CreateChargePrintTemplate(template *models.XtHisChargeTemplate) error {
508
+
509
+	err := XTWriteDB().Create(&template).Error
510
+	return err
511
+}
512
+
513
+func UpdateChargePrintTemplate(template *models.XtHisChargeTemplate) error {
514
+
515
+	err := XTWriteDB().Save(&template).Error
516
+	return err
517
+}
518
+
519
+func GetChargePrintTemplate(orgid int64) (models.XtHisChargeTemplate, error) {
520
+	template := models.XtHisChargeTemplate{}
521
+	err := XTReadDB().Model(&template).Where("user_org_id = ? and status = 1", orgid).Find(&template).Error
522
+	return template, err
523
+}
524
+
525
+func GetDoctorProjectItem(patientid int64, record_date int64) (models.HisPrescriptionProject, error) {
526
+
527
+	project := models.HisPrescriptionProject{}
528
+	err := XTReadDB().Model(&project).Where("patient_id = ? and record_date = ? and status = 1", patientid, record_date).Error
529
+	return project, err
530
+}
531
+
532
+func GetChargePrint(record int64, patient_id int64, user_org_id int64) (order XtHisOrder, err error) {
533
+
534
+	err = readDb.Model(&HisOrder{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND settle_accounts_date=?", user_org_id, patient_id, record).
535
+		Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
536
+		Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
537
+		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
538
+		Preload("HisPrescriptionInfo", "status = 1 AND user_org_id = ?", user_org_id).
539
+		Order("ctime desc").
540
+		Find(&order).Error
541
+	return
542
+
543
+}

+ 36 - 3
service/his_service.go View File

@@ -136,9 +136,9 @@ func GetHisPatientCaseHistoryById(hispatientid int64) (*models.HisPatientCaseHis
136 136
 	return &history, nil
137 137
 }
138 138
 
139
-func SaveHisPatientCaseHistory(caseHistory models.HisPatientCaseHistory) (err error) {
140
-	err = writeDb.Create(&caseHistory).Error
141
-	return
139
+func SaveHisPatientCaseHistory(caseHistory *models.HisPatientCaseHistory) error {
140
+	err := writeDb.Create(&caseHistory).Error
141
+	return err
142 142
 }
143 143
 
144 144
 func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
@@ -347,3 +347,36 @@ func GetHisPrescriptionOrderInfo(patient_id, his_patient_id, org_id int64) (pres
347 347
 	return
348 348
 
349 349
 }
350
+
351
+type XtHisOrder struct {
352
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
353
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
354
+	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
355
+	SettleAccountsDate int64  `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
356
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
357
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
358
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
359
+	Number             string `gorm:"column:number" json:"number" form:"number"`
360
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
361
+
362
+	HisOrderInfo        models.HisOrderInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
363
+	Patients            models.Patients            `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
364
+	HisPatient          models.HisPatient          `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
365
+	HisPrescriptionInfo models.HisPrescriptionInfo `gorm:"ForeignKey:PatientId,SettleAccountsDate;AssociationForeignKey:PatientId,RecordDate" json:"p_info"`
366
+	HisPrescription     []*models.HisPrescription  `gorm:"ForeignKey:SettleAccountsDate;AssociationForeignKey:RecordDate" json:"prescriptions"`
367
+}
368
+
369
+func (XtHisOrder) TableName() string {
370
+	return "his_order"
371
+}
372
+
373
+func GetHisPrescriptionNight(org_id int64, patient_id int64, record_date int64, prescription_id int64) (prescription []*models.HisPrescription, err error) {
374
+	err = readDb.Model(&models.HisPrescription{}).
375
+		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? and prescription_id =?", org_id, prescription_id).
376
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
377
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
378
+		}).
379
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).
380
+		Find(&prescription).Error
381
+	return
382
+}

+ 37 - 1
service/manage_center_service.go View File

@@ -1,6 +1,9 @@
1 1
 package service
2 2
 
3
-import "XT_New/models"
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
4 7
 
5 8
 func GetDictionaryConfigList(orgID int64) (dataconfig interface{}, err error) {
6 9
 	var configList []*models.DictionaryDataconfig
@@ -218,3 +221,36 @@ func CreateUnitSafeguard(dus *models.DrugUnitSafeguard) (err error) {
218 221
 	err = writeDb.Create(dus).Error
219 222
 	return
220 223
 }
224
+
225
+func GetDrugWareoutInfo(id int64) (*models.XtDrugWarehouseInfo, error) {
226
+
227
+	info := models.XtDrugWarehouseInfo{}
228
+	err = XTReadDB().Model(&info).Where("drug_id = ? and status = 1", id).Find(&info).Error
229
+	if err == gorm.ErrRecordNotFound {
230
+		return nil, err
231
+	}
232
+	if err != nil {
233
+		return nil, err
234
+	}
235
+	return &info, nil
236
+}
237
+
238
+func GetDrugWareOutById(id int64) (*models.XtDrugWarehouseOutInfo, error) {
239
+
240
+	info := models.XtDrugWarehouseOutInfo{}
241
+	err := XTReadDB().Model(&info).Where("drug_id = ? and status = 1", id).Find(&info).Error
242
+	if err == gorm.ErrRecordNotFound {
243
+		return nil, err
244
+	}
245
+	if err != nil {
246
+		return nil, err
247
+	}
248
+	return &info, nil
249
+}
250
+
251
+func DeleteBaseDrugById(id int64) error {
252
+
253
+	drug := models.XtBaseDrug{}
254
+	err := XTWriteDB().Model(&drug).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
255
+	return err
256
+}