csx 3 年 前
コミット
0e407d375a

+ 47 - 47
controllers/his_api_controller.go ファイルの表示

@@ -350,21 +350,21 @@ func (c *HisApiController) GetHisPatientList() {
350 350
 }
351 351
 
352 352
 type CustomTemplate struct {
353
-	ID                             int64                                   `gorm:"column:id" json:"id" form:"id"`
354
-	UserOrgId                      int64                                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
355
-	RecordDate                     int64                                   `gorm:"column:record_date" json:"record_date" form:"record_date"`
356
-	PatientId                      int64                                   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
357
-	Status                         int64                                   `gorm:"column:status" json:"status" form:"status"`
358
-	Ctime                          int64                                   `gorm:"column:ctime" json:"ctime" form:"ctime"`
359
-	Mtime                          int64                                   `gorm:"column:mtime" json:"mtime" form:"mtime"`
360
-	Type                           int64                                   `gorm:"column:type" json:"type" form:"type"`
361
-	Creator                        int64                                   `gorm:"column:creator" json:"creator" form:"creator"`
362
-	Modifier                       int64                                   `gorm:"column:modifier" json:"modifier" form:"modifier"`
363
-	PType                          int64                                   `gorm:"column:p_type" json:"p_type" form:"p_type"`
364
-	PTemplateId                    int64                                   `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
365
-	HisPrescriptionAdviceTemplate  []models.HisPrescriptionAdviceTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
366
-	HisPrescriptionProjectTemplate []models.HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
367
-	MedType                        string                                  `gorm:"column:med_type" json:"med_type" form:"med_type"`
353
+	ID                             int64                                    `gorm:"column:id" json:"id" form:"id"`
354
+	UserOrgId                      int64                                    `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
355
+	RecordDate                     int64                                    `gorm:"column:record_date" json:"record_date" form:"record_date"`
356
+	PatientId                      int64                                    `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
357
+	Status                         int64                                    `gorm:"column:status" json:"status" form:"status"`
358
+	Ctime                          int64                                    `gorm:"column:ctime" json:"ctime" form:"ctime"`
359
+	Mtime                          int64                                    `gorm:"column:mtime" json:"mtime" form:"mtime"`
360
+	Type                           int64                                    `gorm:"column:type" json:"type" form:"type"`
361
+	Creator                        int64                                    `gorm:"column:creator" json:"creator" form:"creator"`
362
+	Modifier                       int64                                    `gorm:"column:modifier" json:"modifier" form:"modifier"`
363
+	PType                          int64                                    `gorm:"column:p_type" json:"p_type" form:"p_type"`
364
+	PTemplateId                    int64                                    `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
365
+	HisPrescriptionAdviceTemplate  []*models.HisPrescriptionAdviceTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
366
+	HisPrescriptionProjectTemplate []*models.HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
367
+	MedType                        string                                   `gorm:"column:med_type" json:"med_type" form:"med_type"`
368 368
 }
369 369
 
370 370
 func (c *HisApiController) GetHisPatientInfo() {
@@ -515,10 +515,10 @@ func (c *HisApiController) GetHisPatientInfo() {
515 515
 
516 516
 		for _, item := range sch_prescriptions {
517 517
 			if len(item.HisPrescriptionProjectTemplate) == 0 {
518
-				item.HisPrescriptionProjectTemplate = make([]models.HisPrescriptionProjectTemplate, 0)
518
+				item.HisPrescriptionProjectTemplate = make([]*models.HisPrescriptionProjectTemplate, 0)
519 519
 			}
520 520
 			if len(item.HisPrescriptionAdviceTemplate) == 0 {
521
-				item.HisPrescriptionAdviceTemplate = make([]models.HisPrescriptionAdviceTemplate, 0)
521
+				item.HisPrescriptionAdviceTemplate = make([]*models.HisPrescriptionAdviceTemplate, 0)
522 522
 			}
523 523
 
524 524
 		}
@@ -2008,21 +2008,21 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
2008 2008
 		advice.PrescribingNumber = prescribingNumber
2009 2009
 	}
2010 2010
 
2011
-	if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
2012
-		frequency_type := int64(json["frequency_type"].(float64))
2013
-		advice.FrequencyType = frequency_type
2014
-	}
2015
-
2016
-	if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
2017
-		day_count := int64(json["day_count"].(float64))
2018
-		advice.DayCount = day_count
2019
-	}
2020
-
2021
-	if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "string" {
2022
-		//week_day, _ := strconv.ParseFloat(json["week_day"].(string), 64)
2023
-		week_day, _ := json["week_day"].(string)
2024
-		advice.WeekDay = week_day
2025
-	}
2011
+	//if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
2012
+	//	frequency_type := int64(json["frequency_type"].(float64))
2013
+	//	advice.FrequencyType = frequency_type
2014
+	//}
2015
+	//
2016
+	//if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
2017
+	//	day_count := int64(json["day_count"].(float64))
2018
+	//	advice.DayCount = day_count
2019
+	//}
2020
+	//
2021
+	//if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "string" {
2022
+	//	//week_day, _ := strconv.ParseFloat(json["week_day"].(string), 64)
2023
+	//	week_day, _ := json["week_day"].(string)
2024
+	//	advice.WeekDay = week_day
2025
+	//}
2026 2026
 
2027 2027
 	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
2028 2028
 		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
@@ -2286,21 +2286,21 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
2286 2286
 		project.Unit = unit
2287 2287
 	}
2288 2288
 
2289
-	if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
2290
-		frequency_type := int64(json["frequency_type"].(float64))
2291
-		project.FrequencyType = frequency_type
2292
-	}
2293
-
2294
-	if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
2295
-		day_count := int64(json["day_count"].(float64))
2296
-		project.DayCount = day_count
2297
-	}
2298
-
2299
-	if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "string" {
2300
-		//week_day, _ := strconv.ParseFloat(json["week_day"].(string), 64)
2301
-		week_day, _ := json["week_day"].(string)
2302
-		project.WeekDay = week_day
2303
-	}
2289
+	//if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
2290
+	//	frequency_type := int64(json["frequency_type"].(float64))
2291
+	//	project.FrequencyType = frequency_type
2292
+	//}
2293
+	//
2294
+	//if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
2295
+	//	day_count := int64(json["day_count"].(float64))
2296
+	//	project.DayCount = day_count
2297
+	//}
2298
+	//
2299
+	//if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "string" {
2300
+	//	//week_day, _ := strconv.ParseFloat(json["week_day"].(string), 64)
2301
+	//	week_day, _ := json["week_day"].(string)
2302
+	//	project.WeekDay = week_day
2303
+	//}
2304 2304
 
2305 2305
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(project.UserOrgId)
2306 2306
 

+ 36 - 0
controllers/his_config_api_controller.go ファイルの表示

@@ -80,6 +80,13 @@ func (c *HisConfigApiController) CreatePrescriptionTemplate() {
80 80
 	types = 1
81 81
 	adminInfo := c.GetAdminUserInfo()
82 82
 
83
+	if id == 0 {
84
+		mode_template, _ := service.GetHisPrescriptionTemplateByModeId(mode_id, patient_id)
85
+		if mode_template.ID > 0 {
86
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorModeTemplateCodeParamWrong)
87
+			return
88
+		}
89
+	}
83 90
 	src_template, _ := service.GetHisPrescriptionTemplateByID(id)
84 91
 
85 92
 	if src_template.ID == 0 {
@@ -351,6 +358,21 @@ func (c *HisConfigApiController) setAdviceTemplateWithJSON(advice *models.HisPre
351 358
 		groupno := int64(json["groupno"].(float64))
352 359
 		advice.Groupno = groupno
353 360
 	}
361
+
362
+	if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
363
+		frequency_type := int64(json["frequency_type"].(float64))
364
+		advice.FrequencyType = frequency_type
365
+	}
366
+
367
+	if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
368
+		day_count := int64(json["day_count"].(float64))
369
+		advice.DayCount = day_count
370
+	}
371
+
372
+	if json["week_day"] != nil || reflect.TypeOf(json["week_day"]).String() == "string" {
373
+		week_day, _ := json["week_day"].(string)
374
+		advice.WeekDay = week_day
375
+	}
354 376
 	return 0
355 377
 }
356 378
 
@@ -360,6 +382,20 @@ func (c *HisConfigApiController) setProjectTemplateWithJSON(project *models.HisP
360 382
 		id := int64(json["id"].(float64))
361 383
 		project.ID = id
362 384
 	}
385
+	if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
386
+		frequency_type := int64(json["frequency_type"].(float64))
387
+		project.FrequencyType = frequency_type
388
+	}
389
+
390
+	if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
391
+		day_count := int64(json["day_count"].(float64))
392
+		project.DayCount = day_count
393
+	}
394
+
395
+	if json["week_day"] != nil || reflect.TypeOf(json["week_day"]).String() == "string" {
396
+		week_day, _ := json["week_day"].(string)
397
+		project.WeekDay = week_day
398
+	}
363 399
 
364 400
 	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
365 401
 		types := int64(json["type"].(float64))

+ 401 - 58
controllers/his_hospital_api_controller.go ファイルの表示

@@ -6,6 +6,9 @@ import (
6 6
 	"XT_New/service"
7 7
 	"fmt"
8 8
 	"github.com/astaxie/beego"
9
+	"math/rand"
10
+	"strconv"
11
+	"strings"
9 12
 	"time"
10 13
 )
11 14
 
@@ -14,62 +17,17 @@ type HisHospitalApiController struct {
14 17
 }
15 18
 
16 19
 func HisHospitalManagerApiRegistRouters() {
17
-
18 20
 	beego.Router("/api/hishospitalpatient/list", &HisHospitalApiController{}, "get:GetHisHospitalPatientList")
19
-
20
-	//beego.Router("/api/hishospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
21
-
22 21
 	beego.Router("/api/hospitalcharge/list", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientList")
23 22
 	beego.Router("/api/hospotalcharge/info", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientInfo")
24
-
25 23
 	beego.Router("/api/hospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
26
-	//beego.Router("/api/hishospitalprescription/info", &HisApiController{}, "get:GetHisHospitalPrescriptionInfo")
27
-
28
-	//beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
29
-	//beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
30
-
31
-	//beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
32
-	//beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
33
-	//beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
34
-
35
-	//beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
36
-	//beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
37
-
38
-	//beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
39
-	//beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
40
-
41
-	//beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
42
-	//
43
-	//beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
44
-	//
45
-	//beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
46
-	//
47
-	//beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
48
-	//
49
-	//beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
50
-
51
-	//beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
52
-	//新增附加费用
53
-	//beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
54
-	//beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
55
-	//beego.Router("/api/hisprescription/get", &HisApiController{}, "Get:GetLastOrNextHisPrescription")
56
-	//beego.Router("/api/callhisprescription/get", &HisApiController{}, "Get:GetCallHisPrescription")
57
-	//beego.Router("/api/dayprescription/get", &HisApiController{}, "get:GetHisDayPrescription")
58
-	//beego.Router("/api/charge/list", &HisApiController{}, "get:GetHisChargePatientList")
59
-	//beego.Router("/api/charge/info", &HisApiController{}, "get:GetHisChargePatientInfo")
60
-	//beego.Router("/api/unregister/list", &HisApiController{}, "get:GetHisUnRegisterPatientList")
61
-	//beego.Router("/api/orderdetail/get", &HisApiController{}, "get:GetAllOrderDetail")
62
-	//beego.Router("/api/orderdetaicollect/get", &HisApiController{}, "get:GetAllOrderDetailCollect")
63
-	//beego.Router("/api/cost/compare", &HisApiController{}, "get:GetMedicalInsuranceCostCompareList")
64
-	//beego.Router("/api/record/list", &HisApiController{}, "get:GetPutOnRecordList")
65
-	//
66
-	//beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
67
-	//beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
68
-	//
69
-	//beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
70
-	//
71
-	//beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
72 24
 
25
+	beego.Router("/api/hospital/inhopitalcheck/get", &HisHospitalApiController{}, "get:GetZHInHospitalCheck")
26
+	beego.Router("/api/hospital/outhopitalcheck/get", &HisHospitalApiController{}, "get:GetZHOutHospitalCheck")
27
+	beego.Router("/api/hospital/settle/get", &HisHospitalApiController{}, "get:GetSettleInfo")
28
+	beego.Router("/api/hospital/inthopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHInHospitalUnCheck")
29
+	beego.Router("/api/hospital/outhopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHOutHospitalUnCheck")
30
+	beego.Router("/api/hospital/refund", &HisHospitalApiController{}, "get:ZHRefund")
73 31
 }
74 32
 
75 33
 func (c *HisHospitalApiController) GetHisHospitalPatientList() {
@@ -157,7 +115,6 @@ func (c *HisHospitalApiController) GetHisHospitalPatientList() {
157 115
 		})
158 116
 	}
159 117
 }
160
-
161 118
 func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
162 119
 	record_date := c.GetString("record_date")
163 120
 	timeLayout := "2006-01-02"
@@ -170,7 +127,8 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
170 127
 	recordDateTime := theTime.Unix()
171 128
 	adminInfo := c.GetAdminUserInfo()
172 129
 	//tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
173
-	tempPatients, _ := service.GetNewAllChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
130
+	orders, _ := service.GetNewAllChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
131
+	tempPatients, _ := service.GetNewAllUnChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
174 132
 
175 133
 	var patients []*service.HospitalPatient
176 134
 	for _, item := range tempPatients {
@@ -182,11 +140,11 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
182 140
 	}
183 141
 
184 142
 	c.ServeSuccessJSON(map[string]interface{}{
185
-		"list":     patients,
186
-		"list_two": patients,
143
+		"list":        patients,
144
+		"list_two":    patients,
145
+		"charge_list": orders,
187 146
 	})
188 147
 }
189
-
190 148
 func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
191 149
 	patient_id, _ := c.GetInt64("patient_id")
192 150
 	his_patient_id, _ := c.GetInt64("his_patient_id")
@@ -256,7 +214,6 @@ func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
256 214
 	return
257 215
 
258 216
 }
259
-
260 217
 func (c *HisHospitalApiController) GetHisHospitalrescriptionList() {
261 218
 	record_date := c.GetString("record_date")
262 219
 	keywords := c.GetString("keywords")
@@ -287,7 +244,6 @@ func (c *HisHospitalApiController) GetHisHospitalrescriptionList() {
287 244
 		return
288 245
 	}
289 246
 }
290
-
291 247
 func (c *HisHospitalApiController) GetHisHospitalPrescriptionList() {
292 248
 	record_date := c.GetString("record_date")
293 249
 	keywords := c.GetString("keywords")
@@ -315,3 +271,390 @@ func (c *HisHospitalApiController) GetHisHospitalPrescriptionList() {
315 271
 	}
316 272
 
317 273
 }
274
+
275
+func (c *HisHospitalApiController) GetZHInHospitalCheck() {
276
+	id, _ := c.GetInt64("id")
277
+	record_time := c.GetString("record_time")
278
+	name := c.GetString("name")
279
+	phone := c.GetString("phone")
280
+	id_card_type, _ := c.GetInt64("id_card_type")
281
+	certificates, _ := c.GetInt64("certificates")
282
+	id_card_no := c.GetString("id_card_no")
283
+	doctor, _ := c.GetInt64("doctor")
284
+	admin_user_id, _ := c.GetInt64("admin_user_id")
285
+	department, _ := c.GetInt64("department")
286
+	adm_bed, _ := c.GetInt64("adm_bed")
287
+	diagnosis_ids := c.GetString("diagnosis")
288
+	sick_type, _ := c.GetInt64("sick_type")
289
+	start_time := c.GetString("start_time")
290
+	balance_accounts_type, _ := c.GetInt64("balance_accounts_type")
291
+	med_type, _ := c.GetInt64("med_type")
292
+	timeLayout := "2006-01-02"
293
+	loc, _ := time.LoadLocation("Local")
294
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
295
+	if err != nil {
296
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
297
+		return
298
+	}
299
+	recordDateTime := theTime.Unix()
300
+	adminInfo := c.GetAdminUserInfo()
301
+	record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
302
+	if record.ID != 0 {
303
+		if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
304
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
305
+			return
306
+		}
307
+	}
308
+	timestamp := time.Now().Unix()
309
+	tempTime := time.Unix(timestamp, 0)
310
+	timeFormat := tempTime.Format("20060102150405")
311
+	chrgBchno := rand.Intn(100000) + 10000
312
+	ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
313
+
314
+	timeStr := time.Now().Format("2006-01-02 15:04:05")
315
+	fmt.Println(timeStr)
316
+	timeArr := strings.Split(timeStr, " ")
317
+	fmt.Println(timeArr)
318
+
319
+	timeArrTwo := strings.Split(timeArr[0], "-")
320
+	timeArrThree := strings.Split(timeArr[1], ":")
321
+	var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(id, 10)
322
+
323
+	inHospital := &models.HisHospitalCheckRecord{
324
+		PatientId:            id,
325
+		Name:                 name,
326
+		MedicalTreatmentType: med_type,
327
+		RecordDate:           recordDateTime,
328
+		IdCardNo:             id_card_no,
329
+		AdminUserId:          admin_user_id,
330
+		Departments:          department,
331
+		UserOrgId:            adminInfo.CurrentOrgId,
332
+		Status:               1,
333
+		Ctime:                time.Now().Unix(),
334
+		Mtime:                time.Now().Unix(),
335
+		Number:               str,
336
+		Doctor:               doctor,
337
+		Certno:               id_card_no,
338
+		MedType:              med_type,
339
+		IptOtpNo:             ipt_otp_no,
340
+		AdmBed:               adm_bed,
341
+		IdCardType:           id_card_type,
342
+		Diagnosis:            diagnosis_ids,
343
+		SickType:             sick_type,
344
+		MdtrtCertType:        "02",
345
+		InHosptialTime:       start_time,
346
+		OutHosptialTime:      "",
347
+		InHospitalStatus:     1,
348
+		Certificates:         certificates,
349
+		Phone:                phone,
350
+		BalanceAccountsType:  balance_accounts_type,
351
+	}
352
+	service.CreateHospitalRecord(inHospital)
353
+	c.ServeSuccessJSON(map[string]interface{}{
354
+		"msg":  "办理入院成功",
355
+		"info": inHospital,
356
+	})
357
+}
358
+func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
359
+	id, _ := this.GetInt64("id")
360
+	record, _ := service.GetInHospitalRecord(id)
361
+	if record.ID == 0 {
362
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
363
+		return
364
+	}
365
+
366
+	timestamp := time.Now().Unix()
367
+	tempTime := time.Unix(timestamp, 0)
368
+	timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
369
+	record.OutHospitalStatus = 1
370
+	record.OutHosptialTime = timeFormatOne
371
+	record.OutWay = 1
372
+	service.CreateHospitalRecord(&record)
373
+	this.ServeSuccessJSON(map[string]interface{}{
374
+		"msg": "出院成功",
375
+	})
376
+
377
+}
378
+func (c *HisHospitalApiController) GetSettleInfo() {
379
+	id, _ := c.GetInt64("id")
380
+	record_time := c.GetString("record_time")
381
+	in_hospital_id, _ := c.GetInt64("in_hospital_id")
382
+	settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
383
+
384
+	patient_id, _ := c.GetInt64("patient_id")
385
+	pay_way, _ := c.GetInt64("pay_way")
386
+	pay_price, _ := c.GetFloat("pay_price")
387
+	pay_card_no := c.GetString("pay_card_no")
388
+	discount_price, _ := c.GetFloat("discount_price")
389
+	preferential_price, _ := c.GetFloat("preferential_price")
390
+	reality_price, _ := c.GetFloat("reality_price")
391
+	found_price, _ := c.GetFloat("found_price")
392
+	medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
393
+	private_price, _ := c.GetFloat("private_price")
394
+	fapiao_code := c.GetString("fapiao_code")
395
+	fapiao_number := c.GetString("fapiao_number")
396
+
397
+	timeLayout := "2006-01-02"
398
+	loc, _ := time.LoadLocation("Local")
399
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
400
+	if err != nil {
401
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
402
+		return
403
+	}
404
+	recordDateTime := theTime.Unix()
405
+	adminUser := c.GetAdminUserInfo()
406
+
407
+	var prescriptions []*models.HisPrescription
408
+
409
+	var start_time int64
410
+	var end_time int64
411
+
412
+	if settle_accounts_type == 1 { //日结
413
+		//prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
414
+
415
+	} else { //月结
416
+		start_time_str := c.GetString("start_time")
417
+		end_time_str := c.GetString("end_time")
418
+		timeLayout := "2006-01-02"
419
+		loc, _ := time.LoadLocation("Local")
420
+		theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
421
+		if err != nil {
422
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
423
+			return
424
+		}
425
+		recordStartTime := theStartTime.Unix()
426
+		start_time = recordStartTime
427
+		theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
428
+		if err != nil {
429
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
430
+			return
431
+		}
432
+		recordEndTime := theEndTime.Unix()
433
+		end_time = recordEndTime
434
+		prescriptions, _ = service.GetHospitalMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
435
+
436
+	}
437
+
438
+	record, _ := service.GetInHospitalRecord(in_hospital_id)
439
+
440
+	if record.ID == 0 {
441
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
442
+		return
443
+	}
444
+
445
+	timestamp := time.Now().Unix()
446
+	tempTime := time.Unix(timestamp, 0)
447
+	timeFormat := tempTime.Format("20060102150405")
448
+	chrgBchno := rand.Intn(100000) + 10000
449
+	chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
450
+
451
+	var ids []int64
452
+	fmt.Println(prescriptions)
453
+	for _, item := range prescriptions {
454
+		ids = append(ids, item.ID)
455
+	}
456
+	var total float64
457
+	fmt.Println(prescriptions)
458
+	for _, item := range prescriptions {
459
+		fmt.Println(item)
460
+		if item.Type == 1 { //药品
461
+			for _, subItem := range item.HisDoctorAdviceInfo {
462
+				total = total + (subItem.Price * subItem.PrescribingNumber)
463
+			}
464
+		}
465
+		if item.Type == 2 { //项目
466
+			for _, subItem := range item.HisPrescriptionProject {
467
+				total = total + (subItem.Price * float64(subItem.Count))
468
+			}
469
+		}
470
+
471
+		for _, subItem := range item.HisAdditionalCharge {
472
+			total = total + (subItem.Price * float64(subItem.Count))
473
+		}
474
+	}
475
+
476
+	allTotal := fmt.Sprintf("%.2f", total)
477
+	totals, _ := strconv.ParseFloat(allTotal, 64)
478
+	order := &models.HisOrder{
479
+		UserOrgId:          adminUser.CurrentOrgId,
480
+		HisPatientId:       record.ID,
481
+		PatientId:          patient_id,
482
+		SettleAccountsDate: recordDateTime,
483
+		Ctime:              time.Now().Unix(),
484
+		Mtime:              time.Now().Unix(),
485
+		Status:             1,
486
+		OrderStatus:        2,
487
+		MdtrtId:            record.Number,
488
+		Number:             chrg_bchno,
489
+		MedfeeSumamt:       totals,
490
+		SettleEndTime:      end_time,
491
+		SettleStartTime:    start_time,
492
+		SettleType:         settle_accounts_type,
493
+		PType:              1,
494
+	}
495
+	order.DiscountPrice = discount_price
496
+	order.MedicalInsurancePrice = medical_insurance_price
497
+	order.FaPiaoNumber = fapiao_number
498
+	order.FaPiaoCode = fapiao_code
499
+	order.PayWay = pay_way
500
+	order.PayPrice = pay_price
501
+	order.PayCardNo = pay_card_no
502
+	order.PreferentialPrice = preferential_price
503
+	order.RealityPrice = reality_price
504
+	order.FoundPrice = found_price
505
+	order.PrivatePrice = private_price
506
+	err = service.CreateOrder(order)
507
+	if err != nil {
508
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
509
+		return
510
+	}
511
+
512
+	var customs []*Custom
513
+	for _, item := range prescriptions {
514
+		if item.Type == 1 { //药品
515
+			for _, subItem := range item.HisDoctorAdviceInfo {
516
+				cus := &Custom{
517
+					AdviceId:         subItem.ID,
518
+					ProjectId:        0,
519
+					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
520
+					Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
521
+					FeedetlSn:        subItem.FeedetlSn,
522
+					Price:            fmt.Sprintf("%.2f", subItem.Price),
523
+					MedListCodg:      subItem.MedListCodg,
524
+					Type:             1,
525
+				}
526
+				customs = append(customs, cus)
527
+			}
528
+		}
529
+		if item.Type == 2 { //项目
530
+			for _, subItem := range item.HisPrescriptionProject {
531
+				cus := &Custom{
532
+					AdviceId:         0,
533
+					ProjectId:        subItem.ID,
534
+					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
535
+					Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
536
+					FeedetlSn:        subItem.FeedetlSn,
537
+					Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
538
+					MedListCodg:      subItem.MedListCodg,
539
+					Type:             2,
540
+				}
541
+				customs = append(customs, cus)
542
+			}
543
+		}
544
+		for _, item := range item.HisAdditionalCharge {
545
+			cus := &Custom{
546
+				ItemId:           item.ID,
547
+				AdviceId:         0,
548
+				ProjectId:        0,
549
+				DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
550
+				Cut:              fmt.Sprintf("%.2f", float64(item.Count)),
551
+				FeedetlSn:        item.FeedetlSn,
552
+				Price:            fmt.Sprintf("%.2f", float64(item.Price)),
553
+				MedListCodg:      item.XtHisAddtionConfig.Code,
554
+				Type:             3,
555
+			}
556
+			customs = append(customs, cus)
557
+		}
558
+	}
559
+	for _, item := range customs {
560
+		var advice_id int64 = 0
561
+		var project_id int64 = 0
562
+		var item_id int64 = 0
563
+
564
+		var types int64 = 0
565
+
566
+		if item.Type == 1 {
567
+			advice_id = item.AdviceId
568
+			project_id = 0
569
+			item_id = 0
570
+		} else if item.Type == 2 {
571
+			advice_id = 0
572
+			item_id = 0
573
+
574
+			project_id = item.ProjectId
575
+		} else if item.Type == 3 {
576
+			advice_id = 0
577
+			item_id = item.ItemId
578
+			project_id = 0
579
+		}
580
+		detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
581
+		cut, _ := strconv.ParseFloat(item.Cut, 32)
582
+		pric, _ := strconv.ParseFloat(item.Price, 32)
583
+		info := &models.HisOrderInfo{
584
+			OrderNumber:      order.Number,
585
+			UploadDate:       time.Now().Unix(),
586
+			AdviceId:         advice_id,
587
+			DetItemFeeSumamt: detItemFeeSumamt,
588
+			Cnt:              cut,
589
+			Pric:             pric,
590
+			PatientId:        id,
591
+			Status:           1,
592
+			Mtime:            time.Now().Unix(),
593
+			Ctime:            time.Now().Unix(),
594
+			UserOrgId:        adminUser.CurrentOrgId,
595
+			HisPatientId:     record.ID,
596
+			OrderId:          order.ID,
597
+			ProjectId:        project_id,
598
+			Type:             types,
599
+			ItemId:           item_id,
600
+		}
601
+		service.CreateOrderInfo(info)
602
+	}
603
+	err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
604
+	err = service.UpDateHospitalHisPrescriptionInfoNumber(adminUser.CurrentOrgId, chrg_bchno, start_time, end_time)
605
+	err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
606
+	if err == nil {
607
+		c.ServeSuccessJSON(map[string]interface{}{
608
+			"msg": "结算成功",
609
+		})
610
+	}
611
+
612
+}
613
+func (c *HisHospitalApiController) ZHRefund() {
614
+	order_id, _ := c.GetInt64("order_id")
615
+	adminUser := c.GetAdminUserInfo()
616
+	var order models.HisOrder
617
+	order, _ = service.GetHisOrderByID(order_id)
618
+
619
+	err := service.UpdataHospitalOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
620
+	if err == nil {
621
+		c.ServeSuccessJSON(map[string]interface{}{
622
+			"msg": "退费成功",
623
+		})
624
+	} else {
625
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
626
+		return
627
+	}
628
+
629
+}
630
+func (this *HisHospitalApiController) GetZHOutHospitalUnCheck() {
631
+	id, _ := this.GetInt64("id")
632
+	record, _ := service.GetInHospitalRecord(id)
633
+	if record.ID == 0 {
634
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
635
+		return
636
+	}
637
+	record.OutHospitalStatus = 0
638
+	service.CreateHospitalRecord(&record)
639
+	this.ServeSuccessJSON(map[string]interface{}{
640
+		"msg": "撤销出院成功",
641
+	})
642
+
643
+}
644
+func (this *HisHospitalApiController) GetZHInHospitalUnCheck() {
645
+	id, _ := this.GetInt64("id")
646
+
647
+	record, _ := service.GetInHospitalRecord(id)
648
+	if record.ID == 0 {
649
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
650
+		return
651
+	}
652
+
653
+	record.Status = 0
654
+	service.CreateHospitalRecord(&record)
655
+
656
+	this.ServeSuccessJSON(map[string]interface{}{
657
+		"msg": "撤销入院成功",
658
+	})
659
+
660
+}

+ 24 - 52
controllers/new_mobile_api_controllers/mobile_his_api_controller.go ファイルの表示

@@ -47,21 +47,21 @@ func (c *MobileHisApiController) GetHisPrescriptionConfig() {
47 47
 }
48 48
 
49 49
 type CustomTemplate struct {
50
-	ID                             int64                                   `gorm:"column:id" json:"id" form:"id"`
51
-	UserOrgId                      int64                                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
52
-	RecordDate                     int64                                   `gorm:"column:record_date" json:"record_date" form:"record_date"`
53
-	PatientId                      int64                                   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
54
-	Status                         int64                                   `gorm:"column:status" json:"status" form:"status"`
55
-	Ctime                          int64                                   `gorm:"column:ctime" json:"ctime" form:"ctime"`
56
-	Mtime                          int64                                   `gorm:"column:mtime" json:"mtime" form:"mtime"`
57
-	Type                           int64                                   `gorm:"column:type" json:"type" form:"type"`
58
-	Creator                        int64                                   `gorm:"column:creator" json:"creator" form:"creator"`
59
-	Modifier                       int64                                   `gorm:"column:modifier" json:"modifier" form:"modifier"`
60
-	PType                          int64                                   `gorm:"column:p_type" json:"p_type" form:"p_type"`
61
-	PTemplateId                    int64                                   `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
62
-	HisPrescriptionAdviceTemplate  []models.HisPrescriptionAdviceTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
63
-	HisPrescriptionProjectTemplate []models.HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
64
-	MedType                        string                                  `gorm:"column:med_type" json:"med_type" form:"med_type"`
50
+	ID                             int64                                    `gorm:"column:id" json:"id" form:"id"`
51
+	UserOrgId                      int64                                    `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
52
+	RecordDate                     int64                                    `gorm:"column:record_date" json:"record_date" form:"record_date"`
53
+	PatientId                      int64                                    `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
54
+	Status                         int64                                    `gorm:"column:status" json:"status" form:"status"`
55
+	Ctime                          int64                                    `gorm:"column:ctime" json:"ctime" form:"ctime"`
56
+	Mtime                          int64                                    `gorm:"column:mtime" json:"mtime" form:"mtime"`
57
+	Type                           int64                                    `gorm:"column:type" json:"type" form:"type"`
58
+	Creator                        int64                                    `gorm:"column:creator" json:"creator" form:"creator"`
59
+	Modifier                       int64                                    `gorm:"column:modifier" json:"modifier" form:"modifier"`
60
+	PType                          int64                                    `gorm:"column:p_type" json:"p_type" form:"p_type"`
61
+	PTemplateId                    int64                                    `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
62
+	HisPrescriptionAdviceTemplate  []*models.HisPrescriptionAdviceTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
63
+	HisPrescriptionProjectTemplate []*models.HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
64
+	MedType                        string                                   `gorm:"column:med_type" json:"med_type" form:"med_type"`
65 65
 }
66 66
 
67 67
 func (c *MobileHisApiController) GetHisPatientInfo() {
@@ -158,6 +158,8 @@ func (c *MobileHisApiController) GetHisPatientInfo() {
158 158
 			cus.Type = item.Type
159 159
 			cus.PType = item.PType
160 160
 			for _, subItem := range item.HisPrescriptionAdviceTemplate {
161
+				fmt.Println(subItem)
162
+
161 163
 				if subItem.FrequencyType == 1 { //每次必推
162 164
 					cus.HisPrescriptionAdviceTemplate = append(cus.HisPrescriptionAdviceTemplate, subItem)
163 165
 				}
@@ -173,7 +175,7 @@ func (c *MobileHisApiController) GetHisPatientInfo() {
173 175
 					dayStr2 := "-" + dayStr
174 176
 					count, _ := strconv.ParseInt(dayStr2, 10, 64)
175 177
 					oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
176
-					advices, _ := service.FindAllHisDoctorAdviceByTime(now, oldTime, patient_id, c.GetAdminUserInfo().CurrentOrgId, subItem.DrugId)
178
+					advices, _ := service.FindAllHisDoctorAdviceByTime(now, oldTime, patient_id, admin.Org.Id, subItem.DrugId)
177 179
 					if len(advices) == 0 {
178 180
 						cus.HisPrescriptionAdviceTemplate = append(cus.HisPrescriptionAdviceTemplate, subItem)
179 181
 					}
@@ -182,6 +184,7 @@ func (c *MobileHisApiController) GetHisPatientInfo() {
182 184
 			}
183 185
 
184 186
 			for _, subItem := range item.HisPrescriptionProjectTemplate {
187
+				fmt.Println(subItem)
185 188
 
186 189
 				if subItem.FrequencyType == 1 {
187 190
 					cus.HisPrescriptionProjectTemplate = append(cus.HisPrescriptionProjectTemplate, subItem)
@@ -198,7 +201,8 @@ func (c *MobileHisApiController) GetHisPatientInfo() {
198 201
 					dayStr2 := "-" + dayStr
199 202
 					count, _ := strconv.ParseInt(dayStr2, 10, 64)
200 203
 					oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
201
-					projects, _ := service.FindAllHisProjectByTime(now, oldTime, patient_id, c.GetAdminUserInfo().CurrentOrgId, subItem.ProjectId)
204
+					fmt.Println(subItem.ProjectId)
205
+					projects, _ := service.FindAllHisProjectByTime(now, oldTime, patient_id, admin.Org.Id, subItem.ProjectId)
202 206
 					if len(projects) == 0 {
203 207
 						cus.HisPrescriptionProjectTemplate = append(cus.HisPrescriptionProjectTemplate, subItem)
204 208
 					}
@@ -212,10 +216,10 @@ func (c *MobileHisApiController) GetHisPatientInfo() {
212 216
 
213 217
 		for _, item := range sch_prescriptions {
214 218
 			if len(item.HisPrescriptionProjectTemplate) == 0 {
215
-				item.HisPrescriptionProjectTemplate = make([]models.HisPrescriptionProjectTemplate, 0)
219
+				item.HisPrescriptionProjectTemplate = make([]*models.HisPrescriptionProjectTemplate, 0)
216 220
 			}
217 221
 			if len(item.HisPrescriptionAdviceTemplate) == 0 {
218
-				item.HisPrescriptionAdviceTemplate = make([]models.HisPrescriptionAdviceTemplate, 0)
222
+				item.HisPrescriptionAdviceTemplate = make([]*models.HisPrescriptionAdviceTemplate, 0)
219 223
 			}
220 224
 
221 225
 		}
@@ -846,22 +850,6 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
846 850
 		advice.HospApprFlag = hosp_appr_flag
847 851
 	}
848 852
 
849
-	if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
850
-		frequency_type := int64(json["frequency_type"].(float64))
851
-		advice.FrequencyType = frequency_type
852
-	}
853
-
854
-	if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
855
-		day_count := int64(json["day_count"].(float64))
856
-		advice.DayCount = day_count
857
-	}
858
-
859
-	if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "string" {
860
-		//week_day, _ := strconv.ParseFloat(json["week_day"].(string), 64)
861
-		week_day, _ := json["week_day"].(string)
862
-		advice.WeekDay = week_day
863
-	}
864
-
865 853
 	if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
866 854
 		advice_id := int64(json["advice_id"].(float64))
867 855
 		advice.ID = advice_id
@@ -1079,28 +1067,12 @@ func (c *MobileHisApiController) setProjectWithJSON(project *models.HisPrescript
1079 1067
 		fmt.Println(project_id)
1080 1068
 		fmt.Println(project.ProjectId)
1081 1069
 	}
1082
-	if json["team_id"] != nil || reflect.TypeOf(json["team_id"]).String() == "float64" {
1070
+	if json["team_id"] != nil && reflect.TypeOf(json["team_id"]).String() == "float64" {
1083 1071
 		team_id := int64(json["team_id"].(float64))
1084 1072
 		project.TeamId = team_id
1085 1073
 
1086 1074
 	}
1087 1075
 
1088
-	if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
1089
-		frequency_type := int64(json["frequency_type"].(float64))
1090
-		project.FrequencyType = frequency_type
1091
-	}
1092
-
1093
-	if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
1094
-		day_count := int64(json["day_count"].(float64))
1095
-		project.DayCount = day_count
1096
-	}
1097
-
1098
-	if json["week_day"] != nil && reflect.TypeOf(json["week_day"]).String() == "string" {
1099
-		//week_day, _ := strconv.ParseFloat(json["week_day"].(string), 64)
1100
-		week_day, _ := json["week_day"].(string)
1101
-		project.WeekDay = week_day
1102
-	}
1103
-
1104 1076
 	// if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
1105 1077
 	// 	price := int64(json["price"].(float64))
1106 1078
 	// 	formatInt_price := strconv.FormatInt(price, 10)

+ 14 - 0
controllers/public_api_controller.go ファイルの表示

@@ -65,6 +65,8 @@ func PublicApiRegistRouters() {
65 65
 
66 66
 	beego.Router("/handel", &PublicApiController{}, "get:HandleHIS")
67 67
 
68
+	beego.Router("/groupno", &PublicApiController{}, "get:HandleGroupNo")
69
+
68 70
 	//beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
69 71
 
70 72
 }
@@ -606,6 +608,18 @@ func (c *PublicApiController) HandleData() {
606 608
 
607 609
 }
608 610
 
611
+func (c *PublicApiController) HandleGroupNo() {
612
+	pts, _ := service.GetHisPrescriptionTemplateTwo()
613
+	for _, item := range pts {
614
+		if len(item.HisPrescriptionAdviceTemplate) > 0 {
615
+			for index, subItem := range item.HisPrescriptionAdviceTemplate {
616
+				subItem.Groupno = int64(index + 1)
617
+				service.SaveAdviceTemplate(subItem)
618
+			}
619
+		}
620
+	}
621
+}
622
+
609 623
 func InitRoleAndPurviews(org_ids []int64) {
610 624
 	roles := LoadRoleConfig("./role.json").Roles
611 625
 	for _, org_id := range org_ids {

+ 16 - 1
enums/error_code.go ファイルの表示

@@ -234,6 +234,14 @@ const ( // ErrorCode
234 234
 	ErrorCodeOutOfStockParamWrong = 300300
235 235
 
236 236
 	ErrorCodeOrderParamWrongTwo = 300500
237
+
238
+	ErrorModeTemplateCodeParamWrong = 300501
239
+
240
+	ErrorCodeInHospitalNoExistDataException = 30008
241
+
242
+	ErrorCodeHospitalNoExistDataException = 30009
243
+
244
+	ErrorCodeHospitalExistDataException = 300010
237 245
 )
238 246
 
239 247
 var ErrCodeMsgs = map[int]string{
@@ -457,7 +465,14 @@ var ErrCodeMsgs = map[int]string{
457 465
 
458 466
 	ErrorCodeOutOfStockParamWrong: "库存不足",
459 467
 
460
-	ErrorCodeOrderParamWrongTwo: "该就诊号存在结算记录,需要先退费后再退号",
468
+	ErrorCodeOrderParamWrongTwo:     "该就诊号存在结算记录,需要先退费后再退号",
469
+	ErrorModeTemplateCodeParamWrong: "一种透析模式只能存在一个模版,无法添加该模版",
470
+
471
+	ErrorCodeInHospitalNoExistDataException: "入院记录不存在",
472
+
473
+	ErrorCodeHospitalNoExistDataException: "请先办理出院才能进行结算",
474
+
475
+	ErrorCodeHospitalExistDataException: "该患者已经入院,请选办理出院结算后再进行办理入院操作",
461 476
 }
462 477
 
463 478
 type SGJError struct {

+ 1 - 0
models/his_hospital_models.go ファイルの表示

@@ -76,6 +76,7 @@ type HisHospitalCheckRecord struct {
76 76
 	OutWay               int64            `gorm:"column:out_way" json:"out_way" form:"out_way"`
77 77
 	Phone                string           `gorm:"column:phone" json:"phone" form:"phone"`
78 78
 	HisHospitalOrder     HisHospitalOrder `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"order"`
79
+	BalanceAccountsType  int64            `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
79 80
 }
80 81
 
81 82
 func (HisHospitalCheckRecord) TableName() string {

+ 15 - 15
models/his_models.go ファイルの表示

@@ -1408,21 +1408,21 @@ func (HisPrescriptionProjectTemplate) TableName() string {
1408 1408
 }
1409 1409
 
1410 1410
 type HisPrescriptionInfoTemplate struct {
1411
-	ID                             int64                            `gorm:"column:id" json:"id" form:"id"`
1412
-	UserOrgId                      int64                            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1413
-	RecordDate                     int64                            `gorm:"column:record_date" json:"record_date" form:"record_date"`
1414
-	PatientId                      int64                            `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1415
-	Status                         int64                            `gorm:"column:status" json:"status" form:"status"`
1416
-	Ctime                          int64                            `gorm:"column:ctime" json:"ctime" form:"ctime"`
1417
-	Mtime                          int64                            `gorm:"column:mtime" json:"mtime" form:"mtime"`
1418
-	Type                           int64                            `gorm:"column:type" json:"type" form:"type"`
1419
-	Creator                        int64                            `gorm:"column:creator" json:"creator" form:"creator"`
1420
-	Modifier                       int64                            `gorm:"column:modifier" json:"modifier" form:"modifier"`
1421
-	PType                          int64                            `gorm:"column:p_type" json:"p_type" form:"p_type"`
1422
-	PTemplateId                    int64                            `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
1423
-	HisPrescriptionAdviceTemplate  []HisPrescriptionAdviceTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
1424
-	HisPrescriptionProjectTemplate []HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
1425
-	MedType                        string                           `gorm:"column:med_type" json:"med_type" form:"med_type"`
1411
+	ID                             int64                             `gorm:"column:id" json:"id" form:"id"`
1412
+	UserOrgId                      int64                             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1413
+	RecordDate                     int64                             `gorm:"column:record_date" json:"record_date" form:"record_date"`
1414
+	PatientId                      int64                             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1415
+	Status                         int64                             `gorm:"column:status" json:"status" form:"status"`
1416
+	Ctime                          int64                             `gorm:"column:ctime" json:"ctime" form:"ctime"`
1417
+	Mtime                          int64                             `gorm:"column:mtime" json:"mtime" form:"mtime"`
1418
+	Type                           int64                             `gorm:"column:type" json:"type" form:"type"`
1419
+	Creator                        int64                             `gorm:"column:creator" json:"creator" form:"creator"`
1420
+	Modifier                       int64                             `gorm:"column:modifier" json:"modifier" form:"modifier"`
1421
+	PType                          int64                             `gorm:"column:p_type" json:"p_type" form:"p_type"`
1422
+	PTemplateId                    int64                             `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
1423
+	HisPrescriptionAdviceTemplate  []*HisPrescriptionAdviceTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
1424
+	HisPrescriptionProjectTemplate []*HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
1425
+	MedType                        string                            `gorm:"column:med_type" json:"med_type" form:"med_type"`
1426 1426
 }
1427 1427
 
1428 1428
 func (HisPrescriptionInfoTemplate) TableName() string {

+ 95 - 0
service/app_version.go ファイルの表示

@@ -266,3 +266,98 @@ func GetLastHisOrder() (his models.HisOrder, err error) {
266 266
 	err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 4 AND status = 1 AND order_status = 2").Last(&his).Error
267 267
 	return
268 268
 }
269
+
270
+type HisPrescriptionAdviceTemplate struct {
271
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
272
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
273
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
274
+	HisPatientId          int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
275
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
276
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
277
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
278
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
279
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
280
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
281
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
282
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
283
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
284
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
285
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
286
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
287
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
288
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
289
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
290
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
291
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
292
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
293
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
294
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
295
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
296
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
297
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
298
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
299
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
300
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
301
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
302
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
303
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
304
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
305
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
306
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
307
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
308
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
309
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
310
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
311
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
312
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
313
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
314
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
315
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
316
+	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
317
+	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
318
+	MedListCodg           string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
319
+	FeedetlSn             string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
320
+	Day                   int64   `gorm:"column:day" json:"day" form:"day"`
321
+	Diagnosis             int64   `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
322
+	HospApprFlag          int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
323
+	LmtUsedFlag           int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
324
+}
325
+
326
+func (HisPrescriptionAdviceTemplate) TableName() string {
327
+	return "his_prescription_advice_template"
328
+}
329
+
330
+type HisPrescriptionInfoTemplateTwo struct {
331
+	ID                            int64                           `gorm:"column:id" json:"id" form:"id"`
332
+	UserOrgId                     int64                           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
333
+	RecordDate                    int64                           `gorm:"column:record_date" json:"record_date" form:"record_date"`
334
+	PatientId                     int64                           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
335
+	Status                        int64                           `gorm:"column:status" json:"status" form:"status"`
336
+	Ctime                         int64                           `gorm:"column:ctime" json:"ctime" form:"ctime"`
337
+	Mtime                         int64                           `gorm:"column:mtime" json:"mtime" form:"mtime"`
338
+	Type                          int64                           `gorm:"column:type" json:"type" form:"type"`
339
+	Creator                       int64                           `gorm:"column:creator" json:"creator" form:"creator"`
340
+	Modifier                      int64                           `gorm:"column:modifier" json:"modifier" form:"modifier"`
341
+	PType                         int64                           `gorm:"column:p_type" json:"p_type" form:"p_type"`
342
+	PTemplateId                   int64                           `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
343
+	HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
344
+	MedType                       string                          `gorm:"column:med_type" json:"med_type" form:"med_type"`
345
+}
346
+
347
+func (HisPrescriptionInfoTemplateTwo) TableName() string {
348
+	return "his_prescription_info_template"
349
+}
350
+
351
+func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
352
+	err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
353
+		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
354
+			return db.Where("status = 1").Preload("Drug", "status=1")
355
+		}).
356
+		Where("status = 1 ").
357
+		Find(&prescription).Error
358
+	return
359
+}
360
+
361
+func SaveAdviceTemplate(advice HisPrescriptionAdviceTemplate) {
362
+	writeDb.Save(&advice)
363
+}

+ 5 - 0
service/his_config_service.go ファイルの表示

@@ -17,6 +17,11 @@ func GetHisPrescriptionTemplateByID(template_id int64) (prescription models.HisP
17 17
 	return
18 18
 }
19 19
 
20
+func GetHisPrescriptionTemplateByModeId(mode_id int64, patient_id int64) (prescription models.HisPrescriptionTemplate, err error) {
21
+	err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("mode = ? AND status = 1 AND patient_id = ?", mode_id, patient_id).First(&prescription).Error
22
+	return
23
+}
24
+
20 25
 func SaveHisPrescriptionTemplate(template *models.HisPrescriptionTemplate) (err error) {
21 26
 	err = writeDb.Save(&template).Error
22 27
 	return

+ 110 - 4
service/his_hospital_service.go ファイルの表示

@@ -15,24 +15,72 @@ type HospitalPatient struct {
15 15
 	Schedule               Schedule                      `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"schedule"`
16 16
 	HisHospitalCheckRecord models.HisHospitalCheckRecord `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"his_patient"`
17 17
 	VMHisPrescriptionInfo  VMHisPrescriptionInfo         `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"info"`
18
-	//HisHospitalOrder       models.HisHospitalOrder       `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"order"`
18
+	HisHospitalOrder       models.HisHospitalOrder       `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"order"`
19 19
 }
20 20
 
21 21
 func (HospitalPatient) TableName() string {
22 22
 	return "xt_patients"
23 23
 }
24 24
 
25
+type HospitalPatientTWo struct {
26
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
27
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
28
+	Name      string `gorm:"column:name" json:"name" form:"name"`
29
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
30
+	IdCardNo  string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
31
+}
32
+
33
+func (HospitalPatientTWo) TableName() string {
34
+	return "xt_patients"
35
+}
36
+
37
+type HisHospitalOrder struct {
38
+	ID                     int64                         `gorm:"column:id" json:"id" form:"id"`
39
+	UserOrgId              int64                         `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
40
+	HisPatientId           int64                         `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
41
+	SettleAccountsDate     int64                         `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
42
+	Ctime                  int64                         `gorm:"column:ctime" json:"ctime" form:"ctime"`
43
+	Mtime                  int64                         `gorm:"column:mtime" json:"mtime" form:"mtime"`
44
+	Status                 int64                         `gorm:"column:status" json:"status" form:"status"`
45
+	Number                 string                        `gorm:"column:number" json:"number" form:"number"`
46
+	PatientId              int64                         `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
47
+	MedfeeSumamt           float64                       `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
48
+	OrderStatus            float64                       `gorm:"column:order_status" json:"order_status" form:"order_status"`
49
+	PayWay                 int64                         `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
50
+	PayPrice               float64                       `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
51
+	PayCardNo              string                        `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
52
+	DiscountPrice          float64                       `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
53
+	PreferentialPrice      float64                       `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
54
+	RealityPrice           float64                       `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
55
+	FoundPrice             float64                       `gorm:"column:found_price" json:"found_price" form:"found_price"`
56
+	MedicalInsurancePrice  float64                       `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
57
+	PrivatePrice           float64                       `gorm:"column:private_price" json:"private_price" form:"private_price"`
58
+	Creator                int64                         `gorm:"column:creator" json:"creator" form:"creator"`
59
+	MdtrtId                string                        `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
60
+	MzNumber               string                        `gorm:"column:mz_number" json:"mz_number" form:"mz_number"`
61
+	FaPiaoCode             string                        `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
62
+	FaPiaoNumber           string                        `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
63
+	IsPre                  int64                         `gorm:"column:is_pre" json:"is_pre" form:"is_pre"`
64
+	Diagnosis              string                        `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
65
+	Patient                models.Patients               `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patient"`
66
+	HisHospitalCheckRecord models.HisHospitalCheckRecord `gorm:"ForeignKey:Number;AssociationForeignKey:MdtrtId" json:"his_patient"`
67
+}
68
+
69
+func (HisHospitalOrder) TableName() string {
70
+	return "his_order"
71
+}
72
+
25 73
 func GetHisHospitalPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
26 74
 	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
27
-	db = db.Joins("join his_hospital_check_record as record ON record.patient_id = xt_patients.id AND record.status = 1 AND record.user_org_id = ? AND record.in_hospital_status = 1 AND record.out_hospital_status = 0", org_id)
75
+	db = db.Joins("join his_hospital_check_record as record ON record.patient_id = xt_patients.id AND record.status = 1 AND record.user_org_id = ? AND record.in_hospital_status = 1 ", org_id)
28 76
 	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
29
-		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id)
77
+		return db.Where("user_org_id = ? AND status = 1  AND in_hospital_status = 1 AND out_hospital_status = 0", org_id).Order("id desc")
30 78
 	})
31 79
 	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type = 1", org_id, record_date).Group("id").Find(&patients).Error
32 80
 	return
33 81
 }
34 82
 
35
-func GetNewAllChargeHisHospitalPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
83
+func GetNewAllUnChargeHisHospitalPatientList(org_id int64, record_date int64) (patients []*HospitalPatient, err error) {
36 84
 	db := readDb.Model(&HospitalPatient{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
37 85
 	db = db.Joins("join his_hospital_check_record as hp ON hp.patient_id = xt_patients.id  AND hp.status = 1 AND hp.user_org_id = ? ", org_id)
38 86
 
@@ -44,6 +92,16 @@ func GetNewAllChargeHisHospitalPatientList(org_id int64, record_date int64) (pat
44 92
 	return
45 93
 }
46 94
 
95
+func GetNewAllChargeHisHospitalPatientList(org_id int64, record_date int64) (orders []*HisHospitalOrder, err error) {
96
+	db := readDb.Model(&HisHospitalOrder{}).Where("his_order.user_org_id = ? AND his_order.status = 1 AND his_order.settle_accounts_date = ? AND his_order.p_type = 1", org_id, record_date)
97
+	db = db.Preload("Patient", "status = 1")
98
+	db = db.Preload("HisHospitalCheckRecord", func(db *gorm.DB) *gorm.DB {
99
+		return db.Where("status = 1 AND user_org_id = ? AND in_hospital_status = 1", org_id)
100
+	})
101
+	err = db.Find(&orders).Error
102
+	return
103
+}
104
+
47 105
 func GetNewHisHospitalPatientInfo(his_patient_id int64) (info models.HisHospitalCheckRecord, err error) {
48 106
 	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1 ", his_patient_id).First(&info).Error
49 107
 	return
@@ -172,3 +230,51 @@ func GetHisHospitalPatientPrescriptionList(org_id int64, keywords string, record
172 230
 	err = db.Limit(limit).Offset(offset).Find(&patients).Error
173 231
 	return
174 232
 }
233
+
234
+func CreateHospitalRecord(record *models.HisHospitalCheckRecord) (err error) {
235
+	err = writeDb.Save(&record).Error
236
+	return
237
+}
238
+
239
+func GetInHospitalRecord(id int64) (record models.HisHospitalCheckRecord, err error) {
240
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
241
+	return
242
+}
243
+
244
+func GetInHospitalRecordByNumber(number string) (record models.HisHospitalCheckRecord, err error) {
245
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("number = ? AND status = 1", number).First(&record).Error
246
+	return
247
+}
248
+
249
+func GetLastHospitalRecord(id int64, user_org_id int64) (record models.HisHospitalCheckRecord, err error) {
250
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1 AND user_org_id = ?", id, user_org_id).Last(&record).Error
251
+	return
252
+}
253
+
254
+func FindDiagnoseByIds(ids []string) ([]*models.HisXtDiagnoseConfig, error) {
255
+	dealer := []*models.HisXtDiagnoseConfig{}
256
+	err := readDb.Model(&models.HisXtDiagnoseConfig{}).Where("id IN (?) AND status = 1", ids).Find(&dealer).Error
257
+	return dealer, err
258
+}
259
+
260
+func FindSickById(id int64) (*models.OutpatientServiceSick, error) {
261
+	outPatient := &models.OutpatientServiceSick{}
262
+	err := readDb.Model(&models.OutpatientServiceSick{}).Where("id = ? AND status = 1", id).First(&outPatient).Error
263
+	return outPatient, err
264
+}
265
+
266
+func GetHospitalMonthHisPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
267
+	err = readDb.Model(&models.HisPrescription{}).
268
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
269
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
270
+		}).
271
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
272
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
273
+		}).
274
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
275
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
276
+		}).
277
+		Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
278
+		Find(&prescription).Error
279
+	return
280
+}

+ 14 - 0
service/his_service.go ファイルの表示

@@ -891,6 +891,12 @@ func UpDateHisPrescriptionInfoNumber(user_org_id int64, id int64, number string,
891 891
 	return
892 892
 }
893 893
 
894
+func UpDateHospitalHisPrescriptionInfoNumber(user_org_id int64, number string, start_time int64, end_time int64) (err error) {
895
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1  AND record_date <= ? AND record_date >= ? ", user_org_id, end_time, start_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
896
+
897
+	return
898
+}
899
+
894 900
 type HisOrder struct {
895 901
 	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
896 902
 	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -1026,6 +1032,14 @@ func UpdataOrderStatus(id int64, number string, user_org_id int64) (err error) {
1026 1032
 	return
1027 1033
 }
1028 1034
 
1035
+func UpdataHospitalOrderStatus(id int64, number string, user_org_id int64, log string, result string) (err error) {
1036
+	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "refund_request_log": log, "refund_log": result, "status": 0}).Error
1037
+	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
1038
+	err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
1039
+	return
1040
+
1041
+}
1042
+
1029 1043
 func UpdataOrderInfoStatus(id int64, number string, user_org_id int64) {
1030 1044
 	err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "status": 0}).Error
1031 1045
 	err = writeDb.Model(&models.HisOrderInfo{}).Where("status = 1 AND user_org_id = ? AND order_number = ?", user_org_id, number).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "status": 0}).Error