|
@@ -1,458 +0,0 @@
|
1
|
|
-package service
|
2
|
|
-
|
3
|
|
-import (
|
4
|
|
- "XT_New/models"
|
5
|
|
- "github.com/jinzhu/gorm"
|
6
|
|
- "time"
|
7
|
|
-)
|
8
|
|
-
|
9
|
|
-func GetAppVersionByAppType(apptype int64) (*models.AppVersion, error) {
|
10
|
|
- var version models.AppVersion
|
11
|
|
- err := readDb.Model(&models.AppVersion{}).Where("app_type=?", apptype).First(&version).Error
|
12
|
|
- if err == gorm.ErrRecordNotFound {
|
13
|
|
- return nil, nil
|
14
|
|
- }
|
15
|
|
-
|
16
|
|
- if err != nil {
|
17
|
|
- return nil, err
|
18
|
|
- }
|
19
|
|
- return &version, nil
|
20
|
|
-}
|
21
|
|
-
|
22
|
|
-func GetAllAppOrg() ([]*models.OrgApp, error) {
|
23
|
|
- var app []*models.OrgApp
|
24
|
|
- err := readUserDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
|
25
|
|
- if err == gorm.ErrRecordNotFound {
|
26
|
|
- return nil, nil
|
27
|
|
- }
|
28
|
|
-
|
29
|
|
- if err != nil {
|
30
|
|
- return nil, err
|
31
|
|
- }
|
32
|
|
- return app, nil
|
33
|
|
-}
|
34
|
|
-
|
35
|
|
-func GetSystemApp() ([]*models.OrgApp, error) {
|
36
|
|
- var app []*models.OrgApp
|
37
|
|
- err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0 ").Find(&app).Error
|
38
|
|
- if err == gorm.ErrRecordNotFound {
|
39
|
|
- return nil, nil
|
40
|
|
- }
|
41
|
|
-
|
42
|
|
- if err != nil {
|
43
|
|
- return nil, err
|
44
|
|
- }
|
45
|
|
- return app, nil
|
46
|
|
-}
|
47
|
|
-
|
48
|
|
-func GetApp() ([]*models.OrgApp, error) {
|
49
|
|
- var app []*models.OrgApp
|
50
|
|
- err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0").Find(&app).Error
|
51
|
|
- if err == gorm.ErrRecordNotFound {
|
52
|
|
- return nil, nil
|
53
|
|
- }
|
54
|
|
-
|
55
|
|
- if err != nil {
|
56
|
|
- return nil, err
|
57
|
|
- }
|
58
|
|
- return app, nil
|
59
|
|
-}
|
60
|
|
-
|
61
|
|
-func GetAppByType(orgID int64, app_type int) (*models.OrgApp, error) {
|
62
|
|
- var apps models.OrgApp
|
63
|
|
- err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
|
64
|
|
- if err != nil {
|
65
|
|
- return nil, err
|
66
|
|
- }
|
67
|
|
- return &apps, nil
|
68
|
|
-}
|
69
|
|
-
|
70
|
|
-func CreateOrgApp(app *models.OrgApp) {
|
71
|
|
- writeUserDb.Create(&app)
|
72
|
|
-
|
73
|
|
-}
|
74
|
|
-
|
75
|
|
-func GetAllUserRole(org_id int64) (appRole []*models.App_Role) {
|
76
|
|
- if org_id == 0 {
|
77
|
|
- readUserDb.Model(&models.App_Role{}).Where("status = 1").Find(&appRole)
|
78
|
|
-
|
79
|
|
- } else {
|
80
|
|
- readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? ", org_id).Find(&appRole)
|
81
|
|
-
|
82
|
|
- }
|
83
|
|
- return
|
84
|
|
-}
|
85
|
|
-
|
86
|
|
-func GetAllUserRoleByUserTypeOne(org_id int) (appRole []*models.App_Role) {
|
87
|
|
- readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type = 1").Find(&appRole)
|
88
|
|
- return
|
89
|
|
-}
|
90
|
|
-
|
91
|
|
-func GetAllUserRoleByUserTypeOther() (appRole []*models.App_Role) {
|
92
|
|
- //app, _ := GetOrgApp(int64(org_id), 3)
|
93
|
|
-
|
94
|
|
- //if org_id == 0 {
|
95
|
|
- readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type > 1").Find(&appRole)
|
96
|
|
- //
|
97
|
|
- //} else {
|
98
|
|
- // readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? AND user_type > 1 AND app_id = ? ", org_id, app.Id).Find(&appRole)
|
99
|
|
- //
|
100
|
|
- //}
|
101
|
|
- return
|
102
|
|
-}
|
103
|
|
-
|
104
|
|
-func FindRoleByUserTypeOne(org_id int64) (role models.Role) {
|
105
|
|
- readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 2 AND role_name = '医生'", org_id).First(&role)
|
106
|
|
- return
|
107
|
|
-}
|
108
|
|
-
|
109
|
|
-func FindRoleByUserTypeTwo(org_id int64) (role models.Role) {
|
110
|
|
- readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 3 AND role_name = '护士'", org_id).First(&role)
|
111
|
|
- return
|
112
|
|
-}
|
113
|
|
-
|
114
|
|
-func GetAllRole() ([]*models.Role, error) {
|
115
|
|
- var app []*models.Role
|
116
|
|
- err := readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
|
117
|
|
- if err == gorm.ErrRecordNotFound {
|
118
|
|
- return nil, nil
|
119
|
|
- }
|
120
|
|
- if err != nil {
|
121
|
|
- return nil, err
|
122
|
|
- }
|
123
|
|
- return app, nil
|
124
|
|
-}
|
125
|
|
-
|
126
|
|
-func UpdateRoleIds(id int64, ids string) {
|
127
|
|
- writeUserDb.Model(&models.App_Role{}).Where("status = 1 AND id = ?", id).Updates(map[string]interface{}{"role_ids": ids, "mtime": time.Now().Unix()})
|
128
|
|
-
|
129
|
|
-}
|
130
|
|
-
|
131
|
|
-func GetOrgAppA(orgID int64, app_type int) (*models.OrgApp, error) {
|
132
|
|
- var apps models.OrgApp
|
133
|
|
- err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
|
134
|
|
- if err != nil {
|
135
|
|
- return nil, err
|
136
|
|
- }
|
137
|
|
- return &apps, nil
|
138
|
|
-}
|
139
|
|
-
|
140
|
|
-func GetOrgByIdB(orgID int64) (*models.Org, error) {
|
141
|
|
- var org models.Org
|
142
|
|
- err := readUserDb.Model(&models.Org{}).Where("id = ?", orgID).First(&org).Error
|
143
|
|
- if err != nil {
|
144
|
|
- if err == gorm.ErrRecordNotFound {
|
145
|
|
- return nil, nil
|
146
|
|
- } else {
|
147
|
|
- return nil, err
|
148
|
|
- }
|
149
|
|
- }
|
150
|
|
- return &org, nil
|
151
|
|
-}
|
152
|
|
-
|
153
|
|
-func GetOrgAppB(orgID int64, app_type int) (*models.OrgApp, error) {
|
154
|
|
- var apps models.OrgApp
|
155
|
|
- err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
|
156
|
|
- if err != nil {
|
157
|
|
- return nil, err
|
158
|
|
- }
|
159
|
|
- return &apps, nil
|
160
|
|
-}
|
161
|
|
-
|
162
|
|
-func CreateOrgRoleB(role *models.Role) (err error) {
|
163
|
|
- err = writeUserDb.Create(&role).Error
|
164
|
|
- return
|
165
|
|
-}
|
166
|
|
-
|
167
|
|
-func CreateRolePurviewB(purview *models.RolePurview) (err error) {
|
168
|
|
- err = writeUserDb.Create(&purview).Error
|
169
|
|
- return
|
170
|
|
-}
|
171
|
|
-
|
172
|
|
-func CreateFuncRolePurviewB(purview *models.SgjUserRoleFuncPurview) (err error) {
|
173
|
|
- err = writeUserDb.Create(&purview).Error
|
174
|
|
- return
|
175
|
|
-}
|
176
|
|
-
|
177
|
|
-func GetSystemRole(orgID int64) ([]*models.Role, error) {
|
178
|
|
- var roles []*models.Role
|
179
|
|
- err := readUserDb.Where(" org_id = ? AND status = 1 AND is_system > 1", orgID).First(&roles).Error
|
180
|
|
- if err != nil {
|
181
|
|
- return nil, err
|
182
|
|
- }
|
183
|
|
- return roles, nil
|
184
|
|
-}
|
185
|
|
-
|
186
|
|
-func HandleData() {
|
187
|
|
- var pe []*models.PredialysisEvaluation
|
188
|
|
- //readDb.Model(&models.DialysisPrescription{}).Where("user_org_id = 12 AND record_date <= 1587571200").Find(&prescription)
|
189
|
|
- //for _, item := range prescription {
|
190
|
|
- // writeDb.Model(&models.AssessmentAfterDislysis{}).Where("user_org_id =12 AND assessment_date = ?", item.RecordDate).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "actual_ultrafiltration": item.Ultrafiltration})
|
191
|
|
- //}
|
192
|
|
- readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = 9538 AND dialysis_order_id > 0").Find(&pe)
|
193
|
|
-
|
194
|
|
- for _, item := range pe {
|
195
|
|
- var sch models.Schedule
|
196
|
|
- err := readDb.Model(&models.Schedule{}).Where("status = 1 AND schedule_date = ? AND patient_id = ? AND user_org_id = 9538", item.AssessmentDate, item.PatientId).First(&sch).Error
|
197
|
|
-
|
198
|
|
- if err == nil {
|
199
|
|
- if sch.ID > 0 {
|
200
|
|
- order := &models.DialysisOrder{
|
201
|
|
- DialysisDate: sch.ScheduleDate,
|
202
|
|
- UserOrgId: 9538,
|
203
|
|
- PatientId: sch.PatientId,
|
204
|
|
- Stage: 2,
|
205
|
|
- BedID: sch.BedId,
|
206
|
|
- StartNurse: 554,
|
207
|
|
- FinishNurse: 554,
|
208
|
|
- Status: 1,
|
209
|
|
- CreatedTime: sch.ScheduleDate,
|
210
|
|
- UpdatedTime: sch.ScheduleDate,
|
211
|
|
- StartTime: sch.ScheduleDate,
|
212
|
|
- EndTime: sch.ScheduleDate,
|
213
|
|
- PunctureNurse: 554,
|
214
|
|
- Creator: 554,
|
215
|
|
- Modifier: 554,
|
216
|
|
- FinishCreator: 554,
|
217
|
|
- FinishModifier: 554,
|
218
|
|
- SchedualType: sch.ScheduleType,
|
219
|
|
- }
|
220
|
|
- writeDb.Create(&order)
|
221
|
|
- }
|
222
|
|
- }
|
223
|
|
-
|
224
|
|
- }
|
225
|
|
-
|
226
|
|
-}
|
227
|
|
-
|
228
|
|
-func FindAllOrgByImportType() (org []*models.Org, err error) {
|
229
|
|
- err = readUserDb.Model(&models.Org{}).Where("status =1 AND import = 0").Find(&org).Error
|
230
|
|
- return
|
231
|
|
-}
|
232
|
|
-
|
233
|
|
-func FindAllPrescription(org_id int64) (prescription []*models.DialysisPrescription, err error) {
|
234
|
|
- err = readDb.Model(&models.DialysisPrescription{}).Where("user_org_id=? AND status= 1 AND record_date >= 1593446400", org_id).Find(&prescription).Error
|
235
|
|
- return
|
236
|
|
-}
|
237
|
|
-
|
238
|
|
-func AddSigleDialysisBeforePre(before *models.DialysisBeforePrepare) {
|
239
|
|
- writeDb.Create(&before)
|
240
|
|
-}
|
241
|
|
-
|
242
|
|
-func GetAllHisDoctorInfo(org_id int64) (his []*models.HisDoctorAdviceInfo, err error) {
|
243
|
|
- err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
|
244
|
|
- return
|
245
|
|
-}
|
246
|
|
-
|
247
|
|
-func GetAllHisInfo(org_id int64) (his []*models.HisPrescriptionProject, err error) {
|
248
|
|
- err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
|
249
|
|
- return
|
250
|
|
-}
|
251
|
|
-
|
252
|
|
-func UpDateHis(his *models.HisDoctorAdviceInfo) {
|
253
|
|
- writeDb.Save(&his)
|
254
|
|
-}
|
255
|
|
-
|
256
|
|
-func UpDateHis2(his *models.HisPrescriptionProject) {
|
257
|
|
- writeDb.Save(&his)
|
258
|
|
-}
|
259
|
|
-
|
260
|
|
-func GetAllHisOrder(org_id int64) (his []*models.HisOrder, err error) {
|
261
|
|
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND order_status = 2 AND fa_piao_code = '' AND fa_piao_number = '' ", org_id).Find(&his).Error
|
262
|
|
- return
|
263
|
|
-}
|
264
|
|
-
|
265
|
|
-func GetAllHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
|
266
|
|
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND order_status = 2 AND fa_piao_code <> '' AND fa_piao_number <> '' ", org_id).Last(&his).Error
|
267
|
|
- return
|
268
|
|
-}
|
269
|
|
-
|
270
|
|
-func GetLastHisOrder() (his models.HisOrder, err error) {
|
271
|
|
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106 AND status = 1 AND order_status = 2").Last(&his).Error
|
272
|
|
- return
|
273
|
|
-}
|
274
|
|
-
|
275
|
|
-type HisPrescriptionAdviceTemplate struct {
|
276
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
277
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
278
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
279
|
|
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
280
|
|
- AdviceType int64 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
|
281
|
|
- AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
|
282
|
|
- StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
|
283
|
|
- AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
|
284
|
|
- AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
|
285
|
|
- ReminderDate int64 `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
|
286
|
|
- SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
287
|
|
- SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
|
288
|
|
- PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
|
289
|
|
- PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
|
290
|
|
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
291
|
|
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
292
|
|
- AdviceDoctor int64 `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
|
293
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
294
|
|
- CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
|
295
|
|
- UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
|
296
|
|
- AdviceAffirm string `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
|
297
|
|
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
298
|
|
- StopTime int64 `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
|
299
|
|
- StopReason string `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
|
300
|
|
- StopDoctor int64 `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
|
301
|
|
- StopState int64 `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
|
302
|
|
- ParentId int64 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
|
303
|
|
- ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
|
304
|
|
- ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
|
305
|
|
- ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
|
306
|
|
- Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
|
307
|
|
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
308
|
|
- DialysisOrderId int64 `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
|
309
|
|
- CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
|
310
|
|
- CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
|
311
|
|
- DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
|
312
|
|
- DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
|
313
|
|
- Groupno int64 `gorm:"column:groupno" json:"groupno" form:"groupno"`
|
314
|
|
- RemindType int64 `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
|
315
|
|
- FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
|
316
|
|
- DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
|
317
|
|
- WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
|
318
|
|
- TemplateId string `gorm:"column:template_id" json:"template_id" form:"template_id"`
|
319
|
|
- Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
|
320
|
|
- DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
|
321
|
|
- Price float64 `gorm:"column:price" json:"price" form:"price"`
|
322
|
|
- PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
|
323
|
|
- MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
|
324
|
|
- FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
|
325
|
|
- Day int64 `gorm:"column:day" json:"day" form:"day"`
|
326
|
|
- Diagnosis int64 `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
|
327
|
|
- HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
|
328
|
|
- LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
|
329
|
|
-}
|
330
|
|
-
|
331
|
|
-func (HisPrescriptionAdviceTemplate) TableName() string {
|
332
|
|
- return "his_prescription_advice_template"
|
333
|
|
-}
|
334
|
|
-
|
335
|
|
-type HisPrescriptionInfoTemplateTwo struct {
|
336
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
337
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
338
|
|
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
339
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
340
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
341
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
342
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
343
|
|
- Type int64 `gorm:"column:type" json:"type" form:"type"`
|
344
|
|
- Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
|
345
|
|
- Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
|
346
|
|
- PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
|
347
|
|
- PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
|
348
|
|
- HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
|
349
|
|
- MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
|
350
|
|
-}
|
351
|
|
-
|
352
|
|
-func (HisPrescriptionInfoTemplateTwo) TableName() string {
|
353
|
|
- return "his_prescription_info_template"
|
354
|
|
-}
|
355
|
|
-
|
356
|
|
-func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
|
357
|
|
- err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
|
358
|
|
- Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
|
359
|
|
- return db.Where("status = 1")
|
360
|
|
- }).
|
361
|
|
- Where("status = 1 ").
|
362
|
|
- Find(&prescription).Error
|
363
|
|
- return
|
364
|
|
-}
|
365
|
|
-
|
366
|
|
-func SaveAdviceTemplate(advice HisPrescriptionAdviceTemplate) {
|
367
|
|
- writeDb.Save(&advice)
|
368
|
|
-}
|
369
|
|
-
|
370
|
|
-func GetAllPT(org_id int64) (his []*models.HisPrescriptionTemplate, err error) {
|
371
|
|
- err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
|
372
|
|
- return
|
373
|
|
-}
|
374
|
|
-
|
375
|
|
-type HisPrescriptionProjectTemplate struct {
|
376
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
377
|
|
- ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
378
|
|
- Price float64 `gorm:"column:price" json:"price" form:"price"`
|
379
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
380
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
381
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
382
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
383
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
384
|
|
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
385
|
|
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
386
|
|
- Count string `gorm:"column:count" json:"count" form:"count"`
|
387
|
|
- FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
|
388
|
|
- MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
|
389
|
|
- SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
390
|
|
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
391
|
|
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
392
|
|
- Day string `gorm:"column:day" json:"day" form:"day"`
|
393
|
|
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
394
|
|
- Unit string `gorm:"column:unit" json:"unit" form:"unit"`
|
395
|
|
- Type int64 `gorm:"column:type" json:"type" form:"type"`
|
396
|
|
- PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
|
397
|
|
- FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
|
398
|
|
- DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
|
399
|
|
- WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
|
400
|
|
-}
|
401
|
|
-
|
402
|
|
-func (HisPrescriptionProjectTemplate) TableName() string {
|
403
|
|
- return "his_prescription_project_template"
|
404
|
|
-}
|
405
|
|
-
|
406
|
|
-type HisPrescriptionInfoTemplateTHree struct {
|
407
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
408
|
|
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
409
|
|
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
410
|
|
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
411
|
|
- Status int64 `gorm:"column:status" json:"status" form:"status"`
|
412
|
|
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
413
|
|
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
414
|
|
- Type int64 `gorm:"column:type" json:"type" form:"type"`
|
415
|
|
- Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
|
416
|
|
- Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
|
417
|
|
- PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
|
418
|
|
- PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
|
419
|
|
- HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
|
420
|
|
- HisPrescriptionProjectTemplate []HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
|
421
|
|
- MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
|
422
|
|
-}
|
423
|
|
-
|
424
|
|
-func (HisPrescriptionInfoTemplateTHree) TableName() string {
|
425
|
|
- return "his_prescription_info_template"
|
426
|
|
-}
|
427
|
|
-
|
428
|
|
-func GetAllPTInfo(org_id int64, p_template_id int64) (his []*HisPrescriptionInfoTemplateTHree, err error) {
|
429
|
|
- err = readDb.Model(&HisPrescriptionInfoTemplateTHree{}).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
|
430
|
|
- return db.Where("status = 1")
|
431
|
|
- }).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
|
432
|
|
- return db.Where("status = 1")
|
433
|
|
- }).Where("user_org_id = ? AND status = 1 AND p_template_id = ?", org_id, p_template_id).Find(&his).Error
|
434
|
|
- return
|
435
|
|
-}
|
436
|
|
-
|
437
|
|
-func GetAllInfo(org_id int64, project_id int64) (his []*HisPrescriptionProjectTemplate, err error) {
|
438
|
|
- err = readDb.Model(&HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND status = 1 AND project_id = ? ", org_id, project_id).Find(&his).Error
|
439
|
|
- return
|
440
|
|
-}
|
441
|
|
-func UpdateStatus(project_id int64, p_id int64) {
|
442
|
|
- writeDb.Model(&HisPrescriptionProjectTemplate{}).Where("id = ?", project_id).Updates(map[string]interface{}{"status": 0})
|
443
|
|
- writeDb.Model(&HisPrescriptionInfoTemplateTwo{}).Where("id = ?", p_id).Updates(map[string]interface{}{"status": 0})
|
444
|
|
-}
|
445
|
|
-
|
446
|
|
-func SaveOrder(order *models.HisOrder) {
|
447
|
|
- writeDb.Save(&order)
|
448
|
|
-}
|
449
|
|
-
|
450
|
|
-func GetAllPrivateHis(org_id int64) (his []*models.HisPatient) {
|
451
|
|
- readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND balance_accounts_type = 2 AND status = 1", org_id).Find(&his)
|
452
|
|
- return
|
453
|
|
-}
|
454
|
|
-
|
455
|
|
-func SaveHis(his *models.HisPatient) {
|
456
|
|
- writeDb.Save(his)
|
457
|
|
- return
|
458
|
|
-}
|