|
@@ -0,0 +1,983 @@
|
|
1
|
+package service
|
|
2
|
+
|
|
3
|
+import (
|
|
4
|
+ "fmt"
|
|
5
|
+ "github.com/jinzhu/gorm"
|
|
6
|
+ "strconv"
|
|
7
|
+ "strings"
|
|
8
|
+ "time"
|
|
9
|
+)
|
|
10
|
+
|
|
11
|
+type HisOrder struct {
|
|
12
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
13
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
14
|
+ HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
|
15
|
+ SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
|
|
16
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
17
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
18
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
19
|
+ Number string `gorm:"column:number" json:"number" form:"number"`
|
|
20
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
21
|
+ OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
|
|
22
|
+ MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
|
|
23
|
+ XtHisPatient XtHisPatient `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
|
|
24
|
+}
|
|
25
|
+
|
|
26
|
+func (HisOrder) TableName() string {
|
|
27
|
+ return "his_order"
|
|
28
|
+}
|
|
29
|
+
|
|
30
|
+type XtHisPatient struct {
|
|
31
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
32
|
+ BalanceAccountsType int64 `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
|
|
33
|
+ MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
|
|
34
|
+ Name string `gorm:"column:name" json:"name" form:"name"`
|
|
35
|
+ Gender int64 `gorm:"column:gender" json:"gender" form:"gender"`
|
|
36
|
+ IdType int64 `gorm:"column:id_type" json:"id_type" form:"id_type"`
|
|
37
|
+ MedicalTreatmentType int64 `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
|
|
38
|
+ Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
|
|
39
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
|
40
|
+ Age int64 `gorm:"column:age" json:"age" form:"age"`
|
|
41
|
+ PhoneNumber string `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
|
|
42
|
+ IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
|
|
43
|
+ RegisterType int64 `gorm:"column:register_type" json:"register_type" form:"register_type"`
|
|
44
|
+ AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
|
|
45
|
+ Departments int64 `gorm:"column:departments" json:"departments" form:"departments"`
|
|
46
|
+ IsNeedCostOfProduction int64 `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
|
|
47
|
+ RegisterCost float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
|
|
48
|
+ TreatmentCost float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
|
|
49
|
+ CostOfProduction float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
|
|
50
|
+ Total float64 `gorm:"column:total" json:"total" form:"total"`
|
|
51
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
52
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
53
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
54
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
55
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
56
|
+ Number string `gorm:"column:number" json:"number" form:"number"`
|
|
57
|
+ Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
|
|
58
|
+ IsReturn int64 `gorm:"column:is_return" json:"is_return" form:"is_return"`
|
|
59
|
+ Phone string `gorm:"column:phone" json:"phone" form:"phone"`
|
|
60
|
+ SocialType int64 `gorm:"column:social_type" json:"social_type" form:"social_type"`
|
|
61
|
+ IdCardType int64 `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
|
|
62
|
+ PType string `gorm:"column:p_type" json:"p_type" form:"p_type"`
|
|
63
|
+ Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
|
|
64
|
+ SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
|
|
65
|
+}
|
|
66
|
+
|
|
67
|
+func (XtHisPatient) TableName() string {
|
|
68
|
+ return "his_patient"
|
|
69
|
+}
|
|
70
|
+
|
|
71
|
+type HisPrescription struct {
|
|
72
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
73
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
74
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
|
75
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
76
|
+ HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
|
77
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
78
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
79
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
80
|
+ Number string `gorm:"column:number" json:"number" form:"number"`
|
|
81
|
+ Type int64 `gorm:"column:type" json:"type" form:"type"`
|
|
82
|
+ Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
|
|
83
|
+ Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
|
|
84
|
+ Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
|
|
85
|
+ OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
|
|
86
|
+ PreTime int64 `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
|
|
87
|
+ BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
|
|
88
|
+ PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
|
|
89
|
+ HisOrder HisOrder `gorm:"ForeignKey:Number;AssociationForeignKey:BatchNumber" json:"order"`
|
|
90
|
+ Total string `gorm:"-" json:"total" form:"total"`
|
|
91
|
+ PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
|
|
92
|
+ MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
|
|
93
|
+}
|
|
94
|
+
|
|
95
|
+func (HisPrescription) TableName() string {
|
|
96
|
+ return "his_prescription"
|
|
97
|
+}
|
|
98
|
+
|
|
99
|
+type CmSample struct {
|
|
100
|
+ HospitalBarcode string `gorm:"column:hospital_barcode" json:"hospital_barcode" form:"hospital_barcode"`
|
|
101
|
+ Hospsamplenumber string `gorm:"column:hospsamplenumber" json:"hospsamplenumber" form:"hospsamplenumber"`
|
|
102
|
+ Pno string `gorm:"column:pno" json:"pno" form:"pno"`
|
|
103
|
+ Ptype string `gorm:"column:ptype" json:"ptype" form:"ptype"`
|
|
104
|
+ Bedno string `gorm:"column:bedno" json:"bedno" form:"bedno"`
|
|
105
|
+ Pname string `gorm:"column:pname" json:"pname" form:"pname"`
|
|
106
|
+ Psex string `gorm:"column:psex" json:"psex" form:"psex"`
|
|
107
|
+ Page string `gorm:"column:page" json:"page" form:"page"`
|
|
108
|
+ Pageunit string `gorm:"column:pageunit" json:"pageunit" form:"pageunit"`
|
|
109
|
+ Ptel string `gorm:"column:ptel" json:"ptel" form:"ptel"`
|
|
110
|
+ Stature string `gorm:"column:stature" json:"stature" form:"stature"`
|
|
111
|
+ Avoirdupois string `gorm:"column:avoirdupois" json:"avoirdupois" form:"avoirdupois"`
|
|
112
|
+ Gravweek string `gorm:"column:gravweek" json:"gravweek" form:"gravweek"`
|
|
113
|
+ Collectiongravday string `gorm:"column:collectiongravday" json:"collectiongravday" form:"collectiongravday"`
|
|
114
|
+ Birthday time.Time `gorm:"column:birthday" json:"birthday" form:"birthday"`
|
|
115
|
+ Departname string `gorm:"column:departname" json:"departname" form:"departname"`
|
|
116
|
+ Docname string `gorm:"column:docname" json:"docname" form:"docname"`
|
|
117
|
+ Doctortel string `gorm:"column:doctortel" json:"doctortel" form:"doctortel"`
|
|
118
|
+ Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
|
|
119
|
+ Stype string `gorm:"column:stype" json:"stype" form:"stype"`
|
|
120
|
+ Samstate string `gorm:"column:samstate" json:"samstate" form:"samstate"`
|
|
121
|
+ Desccode string `gorm:"column:desccode" json:"desccode" form:"desccode"`
|
|
122
|
+ Descr string `gorm:"column:descr" json:"descr" form:"descr"`
|
|
123
|
+ Sampletime time.Time `gorm:"column:sampletime" json:"sampletime" form:"sampletime"`
|
|
124
|
+ Senddate time.Time `gorm:"column:senddate" json:"senddate" form:"senddate"`
|
|
125
|
+ Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
|
126
|
+ Idcard string `gorm:"column:idcard" json:"idcard" form:"idcard"`
|
|
127
|
+ CardClass string `gorm:"column:cardclass" json:"cardclass" form:"cardclass"`
|
|
128
|
+}
|
|
129
|
+
|
|
130
|
+func (CmSample) TableName() string {
|
|
131
|
+ return "v_cm_sample"
|
|
132
|
+}
|
|
133
|
+
|
|
134
|
+type CmLisitems struct {
|
|
135
|
+ ItemCode string `gorm:"column:item_code" json:"item_code" form:"item_code"`
|
|
136
|
+ ItemName string `gorm:"column:item_name" json:"item_name" form:"item_name"`
|
|
137
|
+ Testmethod string `gorm:"column:testmethod" json:"testmethod" form:"testmethod"`
|
|
138
|
+ Iscompound string `gorm:"column:iscmpound" json:"iscmpound" form:"iscmpound"`
|
|
139
|
+ DepartmentName string `gorm:"column:department_name" json:"department_name" form:"department_name"`
|
|
140
|
+}
|
|
141
|
+
|
|
142
|
+func (CmLisitems) TableName() string {
|
|
143
|
+ return "v_cm_listtems"
|
|
144
|
+}
|
|
145
|
+
|
|
146
|
+type HisLabelPrintInfo struct {
|
|
147
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
148
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
149
|
+ Number string `gorm:"column:number" json:"number" form:"number"`
|
|
150
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
151
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
152
|
+ DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
|
|
153
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
154
|
+ ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
|
|
155
|
+ ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
|
156
|
+ IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
|
|
157
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
|
158
|
+ ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
|
|
159
|
+ PProjectId int64 `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
|
|
160
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
161
|
+ DoctorName string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
|
|
162
|
+ PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
|
|
163
|
+ FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
|
|
164
|
+ PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
|
|
165
|
+ HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:PProjectId" json:"project"`
|
|
166
|
+}
|
|
167
|
+
|
|
168
|
+func (HisLabelPrintInfo) TableName() string {
|
|
169
|
+ return "his_label_print_info"
|
|
170
|
+}
|
|
171
|
+
|
|
172
|
+type LisSyncProcessStatusInfo struct {
|
|
173
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
174
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
175
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
176
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
177
|
+ LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
|
|
178
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
179
|
+ IsInsert int64 `gorm:"column:is_insert" json:"is_insert" form:"is_insert"`
|
|
180
|
+ IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
|
|
181
|
+ ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
|
|
182
|
+}
|
|
183
|
+
|
|
184
|
+func (LisSyncProcessStatusInfo) TableName() string {
|
|
185
|
+ return "lis_sync_process_status_info"
|
|
186
|
+}
|
|
187
|
+
|
|
188
|
+type CmResult struct {
|
|
189
|
+ Barcode string `gorm:"column:barcode" json:"barcode" form:"barcode"`
|
|
190
|
+ Itemcode string `gorm:"column:itemcode" json:"itemcode" form:"itemcode"`
|
|
191
|
+ Itemname string `gorm:"column:itemname" json:"itemname" form:"itemname"`
|
|
192
|
+ Unit string `gorm:"column:unit" json:"unit" form:"unit"`
|
|
193
|
+ Result string `gorm:"column:result" json:"result" form:"result"`
|
|
194
|
+ Refrange string `gorm:"column:refrange" json:"refrange" form:"refrange"`
|
|
195
|
+ Ts string `gorm:"column:ts" json:"ts" form:"ts"`
|
|
196
|
+ Jyys string `gorm:"column:jyys" json:"jyys" form:"jyys"`
|
|
197
|
+ Shys string `gorm:"column:shys" json:"shys" form:"shys"`
|
|
198
|
+ Hycode string `gorm:"column:hycode" json:"hycode" form:"hycode"`
|
|
199
|
+ Reptype string `gorm:"column:reptype" json:"reptype" form:"reptype"`
|
|
200
|
+ TJH string `gorm:"column:tjh" json:"tjh" form:"tjh"`
|
|
201
|
+ Repdate string `gorm:"column:repdate" json:"repdate" form:"repdate"`
|
|
202
|
+ Groupname string `gorm:"column:groupname" json:"groupname" form:"groupname"`
|
|
203
|
+ Groupcode string `gorm:"column:groupcode" json:"groupcode" form:"groupcode"`
|
|
204
|
+ Brkb string `gorm:"column:brkb" json:"brkb" form:"brkb"`
|
|
205
|
+ Mic string `gorm:"column:mic" json:"mic" form:"mic"`
|
|
206
|
+ Yjjy string `gorm:"column:yjjy" json:"yjjy" form:"yjjy"`
|
|
207
|
+ Name string `gorm:"column:name" json:"name" form:"name"`
|
|
208
|
+}
|
|
209
|
+
|
|
210
|
+func (CmResult) TableName() string {
|
|
211
|
+ return "v_cm_result"
|
|
212
|
+}
|
|
213
|
+
|
|
214
|
+type LisSyncResultStatusInfo struct {
|
|
215
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
216
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
217
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
218
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
219
|
+ LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
|
|
220
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
221
|
+ IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
|
|
222
|
+ ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
|
|
223
|
+}
|
|
224
|
+
|
|
225
|
+func (LisSyncResultStatusInfo) TableName() string {
|
|
226
|
+ return "lis_sync_result_status_info"
|
|
227
|
+}
|
|
228
|
+
|
|
229
|
+func GetLastSyncRecord(org_id int64) (record LisSyncProcessStatusInfo, err error) {
|
|
230
|
+ err = readMiddleDb.Model(&LisSyncProcessStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
|
|
231
|
+ return
|
|
232
|
+}
|
|
233
|
+
|
|
234
|
+func GetLastSyncResultRecord(org_id int64) (record LisSyncResultStatusInfo, err error) {
|
|
235
|
+ err = readDb.Model(&LisSyncResultStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
|
|
236
|
+ return
|
|
237
|
+}
|
|
238
|
+
|
|
239
|
+func GetResultRecord() (record []*CmResult, err error) {
|
|
240
|
+ err = dataBase.Model(&CmResult{}).Order("barcode desc").Find(&record).Error
|
|
241
|
+ return
|
|
242
|
+}
|
|
243
|
+
|
|
244
|
+func GetResultRecordByID(id int64) (record []*CmResult, err error) {
|
|
245
|
+ err = readDb.Model(&CmResult{}).Where("barcode > ?", id).Order("barcode desc").Find(&record).Error
|
|
246
|
+ return
|
|
247
|
+}
|
|
248
|
+
|
|
249
|
+func GetSaveResultRecord(record LisSyncResultStatusInfo) (err error) {
|
|
250
|
+ err = dataBase.Save(record).Error
|
|
251
|
+ return
|
|
252
|
+}
|
|
253
|
+
|
|
254
|
+func GetLisDataById(org_id int64, last_id int64) (list []*HisLabelPrintInfo, err error) {
|
|
255
|
+ //err = readDb.Model(&HisLabelPrintInfo{}).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Find(&list).Error
|
|
256
|
+
|
|
257
|
+ err = readDb.Model(&HisLabelPrintInfo{}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
258
|
+ return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
|
|
259
|
+ return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
|
|
260
|
+ return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
|
|
261
|
+ return db.Where("status = 1")
|
|
262
|
+ }).Where("status = 1")
|
|
263
|
+ }).Where("status = 1")
|
|
264
|
+ }).Where("status = 1")
|
|
265
|
+ }).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Limit(100).Find(&list).Error
|
|
266
|
+ return
|
|
267
|
+}
|
|
268
|
+
|
|
269
|
+func GetAllLisData(org_id int64) (list []*HisLabelPrintInfo, err error) {
|
|
270
|
+ err = readDb.Model(&HisLabelPrintInfo{}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
|
271
|
+ return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
|
|
272
|
+ return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
|
|
273
|
+ return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
|
|
274
|
+ return db.Where("status = 1")
|
|
275
|
+ }).Where("status = 1")
|
|
276
|
+ }).Where("status = 1")
|
|
277
|
+ }).Where("status = 1")
|
|
278
|
+ }).Where("user_org_id = ? AND status = 1", org_id).Limit(100).Find(&list).Error
|
|
279
|
+ return
|
|
280
|
+}
|
|
281
|
+
|
|
282
|
+func GetAllLisResultData(org_id int64) (list []*CmResult, err error) {
|
|
283
|
+ err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1 ", org_id).Find(&list).Error
|
|
284
|
+ return
|
|
285
|
+}
|
|
286
|
+
|
|
287
|
+func GetLisResultDataByRecord(org_id int64) (list []*CmResult, err error) {
|
|
288
|
+ err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1", org_id).Find(&list).Error
|
|
289
|
+ return
|
|
290
|
+}
|
|
291
|
+
|
|
292
|
+//插入中间件逻辑
|
|
293
|
+func GetDataInsertDB(org_id int64) {
|
|
294
|
+ record, _ := GetLastSyncRecord(org_id)
|
|
295
|
+ if record.ID == 0 {
|
|
296
|
+ var cms_arr []CmSample
|
|
297
|
+ list, _ := GetAllLisData(org_id)
|
|
298
|
+ //插入中间库中
|
|
299
|
+ for _, item := range list {
|
|
300
|
+ fmt.Println(item.HisPrescriptionProject)
|
|
301
|
+
|
|
302
|
+ if item.ItemId > 0 {
|
|
303
|
+
|
|
304
|
+ var cms CmSample
|
|
305
|
+ cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
|
|
306
|
+ cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
|
|
307
|
+ cms.Ptype = "门诊"
|
|
308
|
+ cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
|
|
309
|
+ if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
|
|
310
|
+ cms.Psex = "男"
|
|
311
|
+ } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
|
|
312
|
+ cms.Psex = "女"
|
|
313
|
+ }
|
|
314
|
+ cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
|
|
315
|
+ cms.Pageunit = "岁"
|
|
316
|
+ cms.Departname = "肾病学专业"
|
|
317
|
+ role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
|
|
318
|
+ cms.Docname = role.UserName
|
|
319
|
+
|
|
320
|
+ diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
|
|
321
|
+
|
|
322
|
+ //var config []*models.HisXtDiagnoseConfig
|
|
323
|
+ var name string
|
|
324
|
+ for _, item := range diagnosis_ids {
|
|
325
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
326
|
+ diagnosisConfig, _ := FindDiagnoseById(id)
|
|
327
|
+ if len(name) == 0 {
|
|
328
|
+ name = diagnosisConfig.ClassName
|
|
329
|
+
|
|
330
|
+ } else {
|
|
331
|
+ name = name + "," + diagnosisConfig.ClassName
|
|
332
|
+ }
|
|
333
|
+ }
|
|
334
|
+
|
|
335
|
+ cms.Diagnosis = name
|
|
336
|
+ cms.Stype = ""
|
|
337
|
+ cms.Samstate = ""
|
|
338
|
+ cms.Desccode = strconv.FormatInt(item.ID, 10)
|
|
339
|
+ cms.Descr = item.ProjectName
|
|
340
|
+
|
|
341
|
+ data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
|
|
342
|
+ datatime := time.Unix(data/1000, 0)
|
|
343
|
+ cms.Sampletime = datatime
|
|
344
|
+ cms.Senddate = time.Now()
|
|
345
|
+ cms_arr = append(cms_arr, cms)
|
|
346
|
+
|
|
347
|
+ } else {
|
|
348
|
+ var cms CmSample
|
|
349
|
+ cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
|
|
350
|
+ cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
|
|
351
|
+ cms.Ptype = "门诊"
|
|
352
|
+ cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
|
|
353
|
+ if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
|
|
354
|
+ cms.Psex = "男"
|
|
355
|
+ } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
|
|
356
|
+ cms.Psex = "女"
|
|
357
|
+ }
|
|
358
|
+ cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
|
|
359
|
+ cms.Pageunit = "岁"
|
|
360
|
+ cms.Departname = "肾病学专业"
|
|
361
|
+ role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
|
|
362
|
+ cms.Docname = role.UserName
|
|
363
|
+
|
|
364
|
+ diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
|
|
365
|
+
|
|
366
|
+ //var config []*models.HisXtDiagnoseConfig
|
|
367
|
+ var name string
|
|
368
|
+ for _, item := range diagnosis_ids {
|
|
369
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
370
|
+ diagnosisConfig, _ := FindDiagnoseById(id)
|
|
371
|
+ if len(name) == 0 {
|
|
372
|
+ name = diagnosisConfig.ClassName
|
|
373
|
+
|
|
374
|
+ } else {
|
|
375
|
+ name = name + "," + diagnosisConfig.ClassName
|
|
376
|
+ }
|
|
377
|
+ }
|
|
378
|
+
|
|
379
|
+ cms.Diagnosis = name
|
|
380
|
+ cms.Stype = ""
|
|
381
|
+ cms.Samstate = ""
|
|
382
|
+ cms.Desccode = strconv.FormatInt(item.ID, 10)
|
|
383
|
+ cms.Descr = item.ProjectName
|
|
384
|
+
|
|
385
|
+ tm := time.Unix(item.Ctime, 0)
|
|
386
|
+ //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
|
|
387
|
+ //datatime := time.Unix(data/1000, 0)
|
|
388
|
+ cms.Sampletime = tm
|
|
389
|
+ cms.Senddate = time.Now()
|
|
390
|
+ cms_arr = append(cms_arr, cms)
|
|
391
|
+ }
|
|
392
|
+ }
|
|
393
|
+ //插入到中间库
|
|
394
|
+ for _, item := range cms_arr {
|
|
395
|
+ if len(item.Pno) > 0 {
|
|
396
|
+ blDb.Save(item)
|
|
397
|
+ }
|
|
398
|
+ }
|
|
399
|
+ //插入一条插入中间库记录数据
|
|
400
|
+ var info LisSyncProcessStatusInfo
|
|
401
|
+ info.Ctime = time.Now().Unix()
|
|
402
|
+ info.Status = 1
|
|
403
|
+ info.Mtime = time.Now().Unix()
|
|
404
|
+ info.OrgId = org_id
|
|
405
|
+ info.IsInsert = 1
|
|
406
|
+ info.IsResult = 0
|
|
407
|
+ info.LastId = list[len(list)-1].ID
|
|
408
|
+ info.ResultDate = 0
|
|
409
|
+ writeMiddleDb.Save(&info)
|
|
410
|
+
|
|
411
|
+ } else {
|
|
412
|
+ var cms_arr []CmSample
|
|
413
|
+ if record.LastId != 0 {
|
|
414
|
+ list, _ := GetLisDataById(org_id, record.LastId)
|
|
415
|
+
|
|
416
|
+ //插入中间库中
|
|
417
|
+ for _, item := range list {
|
|
418
|
+ if item.ItemId > 0 {
|
|
419
|
+ fmt.Println()
|
|
420
|
+ //teams, _ := GetProjectTeamList(org_id, item.ItemId, item.PrescriptionId)
|
|
421
|
+ //for _, subItem := range teams {
|
|
422
|
+ var cms CmSample
|
|
423
|
+ cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
|
|
424
|
+ //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
|
|
425
|
+ cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
|
|
426
|
+ cms.Ptype = "门诊"
|
|
427
|
+ cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
|
|
428
|
+ if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
|
|
429
|
+ cms.Psex = "男"
|
|
430
|
+ } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
|
|
431
|
+ cms.Psex = "女"
|
|
432
|
+ }
|
|
433
|
+ cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
|
|
434
|
+ cms.Pageunit = "岁"
|
|
435
|
+ cms.Departname = "肾病学专业"
|
|
436
|
+ role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
|
|
437
|
+ cms.Docname = role.UserName
|
|
438
|
+ diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
|
|
439
|
+ //var config []*models.HisXtDiagnoseConfig
|
|
440
|
+ var name string
|
|
441
|
+ for _, item := range diagnosis_ids {
|
|
442
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
443
|
+ diagnosisConfig, _ := FindDiagnoseById(id)
|
|
444
|
+ if len(name) == 0 {
|
|
445
|
+ name = diagnosisConfig.ClassName
|
|
446
|
+
|
|
447
|
+ } else {
|
|
448
|
+ name = name + "," + diagnosisConfig.ClassName
|
|
449
|
+ }
|
|
450
|
+ }
|
|
451
|
+ cms.Diagnosis = name
|
|
452
|
+ cms.Stype = ""
|
|
453
|
+ cms.Samstate = ""
|
|
454
|
+ cms.Desccode = strconv.FormatInt(item.ID, 10)
|
|
455
|
+ cms.Descr = item.ProjectName
|
|
456
|
+
|
|
457
|
+ //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
|
|
458
|
+ //datatime := time.Unix(data/1000, 0)
|
|
459
|
+ //cms.Sampletime = datatime
|
|
460
|
+ tm := time.Unix(item.Ctime, 0)
|
|
461
|
+ cms.Sampletime = tm
|
|
462
|
+ cms.Senddate = time.Now()
|
|
463
|
+ cms_arr = append(cms_arr, cms)
|
|
464
|
+ } else {
|
|
465
|
+ var cms CmSample
|
|
466
|
+ cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
|
|
467
|
+ //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
|
|
468
|
+ cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
|
|
469
|
+ cms.Ptype = "门诊"
|
|
470
|
+ cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
|
|
471
|
+ if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
|
|
472
|
+ cms.Psex = "男"
|
|
473
|
+ } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
|
|
474
|
+ cms.Psex = "女"
|
|
475
|
+ }
|
|
476
|
+ cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
|
|
477
|
+ cms.Pageunit = "岁"
|
|
478
|
+ cms.Departname = "肾病学专业"
|
|
479
|
+ role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
|
|
480
|
+ cms.Docname = role.UserName
|
|
481
|
+ diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
|
|
482
|
+ var name string
|
|
483
|
+ for _, item := range diagnosis_ids {
|
|
484
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
485
|
+ diagnosisConfig, _ := FindDiagnoseById(id)
|
|
486
|
+ if len(name) == 0 {
|
|
487
|
+ name = diagnosisConfig.ClassName
|
|
488
|
+
|
|
489
|
+ } else {
|
|
490
|
+ name = name + "," + diagnosisConfig.ClassName
|
|
491
|
+ }
|
|
492
|
+ }
|
|
493
|
+
|
|
494
|
+ cms.Diagnosis = name
|
|
495
|
+ cms.Stype = ""
|
|
496
|
+ cms.Samstate = ""
|
|
497
|
+ cms.Desccode = strconv.FormatInt(item.ID, 10)
|
|
498
|
+ cms.Descr = item.ProjectName
|
|
499
|
+ tm := time.Unix(item.Ctime, 0)
|
|
500
|
+ cms.Sampletime = tm
|
|
501
|
+ cms.Senddate = time.Now()
|
|
502
|
+ cms_arr = append(cms_arr, cms)
|
|
503
|
+ }
|
|
504
|
+ }
|
|
505
|
+ //插入一条插入中间库记录数据
|
|
506
|
+ for _, item := range cms_arr {
|
|
507
|
+ if len(item.Pno) > 0 {
|
|
508
|
+ blDb.Save(item)
|
|
509
|
+ }
|
|
510
|
+ }
|
|
511
|
+ //插入一条插入中间库记录数据
|
|
512
|
+ var info LisSyncProcessStatusInfo
|
|
513
|
+ info.Ctime = time.Now().Unix()
|
|
514
|
+ info.Status = 1
|
|
515
|
+ info.Mtime = time.Now().Unix()
|
|
516
|
+ info.OrgId = org_id
|
|
517
|
+ info.IsInsert = 1
|
|
518
|
+ info.IsResult = 0
|
|
519
|
+ info.LastId = list[len(list)-1].ID
|
|
520
|
+ info.ResultDate = 0
|
|
521
|
+ writeMiddleDb.Save(&info)
|
|
522
|
+ }
|
|
523
|
+ }
|
|
524
|
+}
|
|
525
|
+
|
|
526
|
+//获取lis返回检验检查结果数据
|
|
527
|
+func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
|
|
528
|
+ record, _ := GetLastSyncResultRecord(org_id)
|
|
529
|
+ if record.ID == 0 {
|
|
530
|
+ list, err := GetResultRecord()
|
|
531
|
+ if err == nil {
|
|
532
|
+ //插入一条查询检验检查结果记录状态数据
|
|
533
|
+ var info LisSyncResultStatusInfo
|
|
534
|
+ info.Ctime = time.Now().Unix()
|
|
535
|
+ info.Status = 1
|
|
536
|
+ info.Mtime = time.Now().Unix()
|
|
537
|
+ info.OrgId = org_id
|
|
538
|
+ info.IsResult = 1
|
|
539
|
+ code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
|
|
540
|
+ info.LastId = code
|
|
541
|
+ info.ResultDate = time.Now().Unix()
|
|
542
|
+ writeMiddleDb.Save(&info)
|
|
543
|
+ //插入到系统检验检查数据
|
|
544
|
+ //for _, item := range list{}
|
|
545
|
+ //for _, item := range list {
|
|
546
|
+ //
|
|
547
|
+ // project_id := int64(0)
|
|
548
|
+ // if len(item.Barcode) > 0 {
|
|
549
|
+ // project_id, _ = GetGzjhProjectID(org_id, item.Groupname)
|
|
550
|
+ // } else {
|
|
551
|
+ // continue
|
|
552
|
+ // }
|
|
553
|
+ // printInfo, _ := GetHisLabelPrintInfoById(item.Barcode)
|
|
554
|
+ //
|
|
555
|
+ // item_id, _ := GetItemID(org_id, item.Groupname, item.Itemname, project_id)
|
|
556
|
+ //
|
|
557
|
+ // tx := writeMiddleDb.Begin()
|
|
558
|
+ // var inspection models.MiddleInspection
|
|
559
|
+ // var inspection_reference models.MiddleInspectionReference
|
|
560
|
+ //
|
|
561
|
+ // recordDateStr := ""
|
|
562
|
+ //
|
|
563
|
+ // if len(item.Repdate) == 0 {
|
|
564
|
+ // recordDateStr = time.Now().Format("2006-01-02 15:04")
|
|
565
|
+ // }
|
|
566
|
+ //
|
|
567
|
+ // inspect_date := item.Repdate
|
|
568
|
+ // date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
|
|
569
|
+ // record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
|
|
570
|
+ // var total int
|
|
571
|
+ // var RangeOptions string
|
|
572
|
+ // var RangeMin string
|
|
573
|
+ // var RangeMax string
|
|
574
|
+ // // 判断检查类型
|
|
575
|
+ // var ItemType int
|
|
576
|
+ // if strings.Contains(item.Refrange, "[") && strings.Contains(item.Refrange, "]") {
|
|
577
|
+ // ItemType = 1
|
|
578
|
+ //
|
|
579
|
+ // } else {
|
|
580
|
+ // ItemType = 2
|
|
581
|
+ //
|
|
582
|
+ // }
|
|
583
|
+ //
|
|
584
|
+ // if ItemType == 1 {
|
|
585
|
+ // item.Refrange = strings.Trim(item.Refrange, "[")
|
|
586
|
+ // item.Refrange = strings.Trim(item.Refrange, "]")
|
|
587
|
+ // Range := strings.Split(item.Refrange, "-")
|
|
588
|
+ // RangeMin = Range[0]
|
|
589
|
+ // RangeMax = Range[1]
|
|
590
|
+ // } else {
|
|
591
|
+ // RangeOptions = item.Refrange
|
|
592
|
+ // }
|
|
593
|
+ //
|
|
594
|
+ // err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
|
595
|
+ // if inspection_reference.ID > 0 {
|
|
596
|
+ // ItemType = inspection_reference.RangeType
|
|
597
|
+ // }
|
|
598
|
+ // if total <= 0 {
|
|
599
|
+ // inspection_reference.OrgId = org_id
|
|
600
|
+ // inspection_reference.ProjectName = item.Groupname
|
|
601
|
+ // inspection_reference.Project = item.Groupname
|
|
602
|
+ // inspection_reference.ProjectId = project_id
|
|
603
|
+ // inspection_reference.ItemName = item.Itemname
|
|
604
|
+ // inspection_reference.ItemNameAddition = item.Barcode
|
|
605
|
+ // inspection_reference.ItemId = item_id
|
|
606
|
+ // inspection_reference.RangeType = ItemType
|
|
607
|
+ // inspection_reference.RangeMin = RangeMin
|
|
608
|
+ // inspection_reference.RangeMax = RangeMax
|
|
609
|
+ // inspection_reference.RangeOptions = RangeOptions
|
|
610
|
+ // inspection_reference.Unit = item.Unit
|
|
611
|
+ // inspection_reference.Status = 1
|
|
612
|
+ // inspection_reference.CreatedTime = time.Now().Unix()
|
|
613
|
+ // inspection_reference.UpdatedTime = time.Now().Unix()
|
|
614
|
+ // inspection_reference.InspectDate = inspect_date
|
|
615
|
+ // inspection_reference.UTime = inspect_date
|
|
616
|
+ // err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
|
|
617
|
+ // if err != nil {
|
|
618
|
+ // tx.Rollback()
|
|
619
|
+ // }
|
|
620
|
+ // }
|
|
621
|
+ //
|
|
622
|
+ // var itotal int
|
|
623
|
+ // err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date, printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
|
624
|
+ // if itotal <= 0 {
|
|
625
|
+ // //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
|
626
|
+ // //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
|
627
|
+ // inspection.PatientId = printInfo.PatientId
|
|
628
|
+ // inspection.OrgId = org_id
|
|
629
|
+ // inspection.ProjectId = project_id
|
|
630
|
+ // inspection.ItemName = inspection_reference.ItemName
|
|
631
|
+ // inspection.ProjectName = inspection_reference.ProjectName
|
|
632
|
+ // inspection.InspectType = ItemType
|
|
633
|
+ // inspection.ItemId = item_id
|
|
634
|
+ // inspection.InspectValue = item.Result
|
|
635
|
+ // inspection.InspectDate = inspect_date
|
|
636
|
+ // inspection.RecordDate = record_date.Unix()
|
|
637
|
+ // inspection.Status = 1
|
|
638
|
+ // inspection.CreatedTime = time.Now().Unix()
|
|
639
|
+ // inspection.UpdatedTime = time.Now().Unix()
|
|
640
|
+ // inspection.UTime = inspect_date
|
|
641
|
+ // inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
|
642
|
+ // err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
|
643
|
+ // if err != nil {
|
|
644
|
+ // tx.Rollback()
|
|
645
|
+ // }
|
|
646
|
+ // }
|
|
647
|
+ //
|
|
648
|
+ // tx.Commit()
|
|
649
|
+ //
|
|
650
|
+ //}
|
|
651
|
+
|
|
652
|
+ }
|
|
653
|
+
|
|
654
|
+ } else {
|
|
655
|
+ if record.LastId != 0 {
|
|
656
|
+ list, err := GetResultRecordByID(record.LastId)
|
|
657
|
+ //插入中间库中
|
|
658
|
+ //插入一条插入中间库记录数据
|
|
659
|
+ if err == nil {
|
|
660
|
+
|
|
661
|
+ //插入一条查询检验检查结果记录状态数据
|
|
662
|
+ var info LisSyncResultStatusInfo
|
|
663
|
+ info.Ctime = time.Now().Unix()
|
|
664
|
+ info.Status = 1
|
|
665
|
+ info.Mtime = time.Now().Unix()
|
|
666
|
+ info.OrgId = org_id
|
|
667
|
+ info.IsResult = 1
|
|
668
|
+ code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
|
|
669
|
+ info.LastId = code
|
|
670
|
+ info.ResultDate = time.Now().Unix()
|
|
671
|
+ writeMiddleDb.Save(&info)
|
|
672
|
+ //插入到系统检验检查数据
|
|
673
|
+ //for _, item := range list {
|
|
674
|
+ //
|
|
675
|
+ // project_id := int64(0)
|
|
676
|
+ // if len(item.Barcode) > 0 {
|
|
677
|
+ // project_id, _ = GetGzjhProjectID(org_id, item.Groupname)
|
|
678
|
+ // } else {
|
|
679
|
+ // continue
|
|
680
|
+ // }
|
|
681
|
+ // printInfo, _ := GetHisLabelPrintInfoById(item.Barcode)
|
|
682
|
+ //
|
|
683
|
+ // item_id, _ := GetItemID(org_id, item.Groupname, item.Itemname, project_id)
|
|
684
|
+ //
|
|
685
|
+ // tx := writeMiddleDb.Begin()
|
|
686
|
+ // var inspection models.MiddleInspection
|
|
687
|
+ // var inspection_reference models.MiddleInspectionReference
|
|
688
|
+ //
|
|
689
|
+ // recordDateStr := ""
|
|
690
|
+ //
|
|
691
|
+ // if len(item.Repdate) == 0 {
|
|
692
|
+ // recordDateStr = time.Now().Format("2006-01-02 15:04")
|
|
693
|
+ // }
|
|
694
|
+ //
|
|
695
|
+ // inspect_date := item.Repdate
|
|
696
|
+ // date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
|
|
697
|
+ // record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
|
|
698
|
+ // var total int
|
|
699
|
+ // var RangeOptions string
|
|
700
|
+ // var RangeMin string
|
|
701
|
+ // var RangeMax string
|
|
702
|
+ // // 判断检查类型
|
|
703
|
+ // var ItemType int
|
|
704
|
+ // if strings.Contains(item.Refrange, "[") && strings.Contains(item.Refrange, "]") {
|
|
705
|
+ // ItemType = 1
|
|
706
|
+ //
|
|
707
|
+ // } else {
|
|
708
|
+ // ItemType = 2
|
|
709
|
+ //
|
|
710
|
+ // }
|
|
711
|
+ //
|
|
712
|
+ // if ItemType == 1 {
|
|
713
|
+ // item.Refrange = strings.Trim(item.Refrange, "[")
|
|
714
|
+ // item.Refrange = strings.Trim(item.Refrange, "]")
|
|
715
|
+ // Range := strings.Split(item.Refrange, "-")
|
|
716
|
+ // RangeMin = Range[0]
|
|
717
|
+ // RangeMax = Range[1]
|
|
718
|
+ // } else {
|
|
719
|
+ // RangeOptions = item.Refrange
|
|
720
|
+ // }
|
|
721
|
+ //
|
|
722
|
+ // err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
|
723
|
+ // if inspection_reference.ID > 0 {
|
|
724
|
+ // ItemType = inspection_reference.RangeType
|
|
725
|
+ // }
|
|
726
|
+ // if total <= 0 {
|
|
727
|
+ // inspection_reference.OrgId = org_id
|
|
728
|
+ // inspection_reference.ProjectName = item.Groupname
|
|
729
|
+ // inspection_reference.Project = item.Groupname
|
|
730
|
+ // inspection_reference.ProjectId = project_id
|
|
731
|
+ // inspection_reference.ItemName = item.Itemname
|
|
732
|
+ // inspection_reference.ItemNameAddition = item.Barcode
|
|
733
|
+ // inspection_reference.ItemId = item_id
|
|
734
|
+ // inspection_reference.RangeType = ItemType
|
|
735
|
+ // inspection_reference.RangeMin = RangeMin
|
|
736
|
+ // inspection_reference.RangeMax = RangeMax
|
|
737
|
+ // inspection_reference.RangeOptions = RangeOptions
|
|
738
|
+ // inspection_reference.Unit = item.Unit
|
|
739
|
+ // inspection_reference.Status = 1
|
|
740
|
+ // inspection_reference.CreatedTime = time.Now().Unix()
|
|
741
|
+ // inspection_reference.UpdatedTime = time.Now().Unix()
|
|
742
|
+ // inspection_reference.InspectDate = inspect_date
|
|
743
|
+ // inspection_reference.UTime = inspect_date
|
|
744
|
+ // err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
|
|
745
|
+ // if err != nil {
|
|
746
|
+ // tx.Rollback()
|
|
747
|
+ // }
|
|
748
|
+ // }
|
|
749
|
+ //
|
|
750
|
+ // var itotal int
|
|
751
|
+ // err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date, printInfo.PatientId).Find(&inspection).Count(&itotal).Error
|
|
752
|
+ // if itotal <= 0 {
|
|
753
|
+ // //item.Result = strings.Replace(item.Result, ">", ">", -1)
|
|
754
|
+ // //item.Result = strings.Replace(item.Result, "<", "<", -1)
|
|
755
|
+ // inspection.PatientId = printInfo.PatientId
|
|
756
|
+ // inspection.OrgId = org_id
|
|
757
|
+ // inspection.ProjectId = project_id
|
|
758
|
+ // inspection.ItemName = inspection_reference.ItemName
|
|
759
|
+ // inspection.ProjectName = inspection_reference.ProjectName
|
|
760
|
+ // inspection.InspectType = ItemType
|
|
761
|
+ // inspection.ItemId = item_id
|
|
762
|
+ // inspection.InspectValue = item.Result
|
|
763
|
+ // inspection.InspectDate = inspect_date
|
|
764
|
+ // inspection.RecordDate = record_date.Unix()
|
|
765
|
+ // inspection.Status = 1
|
|
766
|
+ // inspection.CreatedTime = time.Now().Unix()
|
|
767
|
+ // inspection.UpdatedTime = time.Now().Unix()
|
|
768
|
+ // inspection.UTime = inspect_date
|
|
769
|
+ // inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
|
|
770
|
+ // err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
|
|
771
|
+ // if err != nil {
|
|
772
|
+ // tx.Rollback()
|
|
773
|
+ // }
|
|
774
|
+ // }
|
|
775
|
+ //
|
|
776
|
+ // tx.Commit()
|
|
777
|
+ //
|
|
778
|
+ //}
|
|
779
|
+
|
|
780
|
+ }
|
|
781
|
+
|
|
782
|
+ }
|
|
783
|
+
|
|
784
|
+ }
|
|
785
|
+ return
|
|
786
|
+
|
|
787
|
+}
|
|
788
|
+
|
|
789
|
+func GetAdminUserInfoByID(org_id int64, admin_user_id int64) (role UserAdminRole, err error) {
|
|
790
|
+ err = readUserDb.Model(&UserAdminRole{}).Where("org_id = ? AND status = 1 AND admin_user_id = ?", org_id, admin_user_id).First(&role).Error
|
|
791
|
+ return
|
|
792
|
+}
|
|
793
|
+
|
|
794
|
+type UserAdminRole struct {
|
|
795
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
796
|
+ AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
|
|
797
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
798
|
+ AppId int64 `gorm:"column:app_id" json:"app_id" form:"app_id"`
|
|
799
|
+ RoleId int64 `gorm:"column:role_id" json:"role_id" form:"role_id"`
|
|
800
|
+ UserName string `gorm:"column:user_name" json:"user_name" form:"user_name"`
|
|
801
|
+ Avatar string `gorm:"column:avatar" json:"avatar" form:"avatar"`
|
|
802
|
+ UserType int64 `gorm:"column:user_type" json:"user_type" form:"user_type"`
|
|
803
|
+ UserTitle int64 `gorm:"column:user_title" json:"user_title" form:"user_title"`
|
|
804
|
+ Intro string `gorm:"column:intro" json:"intro" form:"intro"`
|
|
805
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
806
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
807
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
808
|
+ UserTitleName string `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
|
|
809
|
+ RoleIds string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
|
|
810
|
+ Message string `gorm:"column:message" json:"message" form:"message"`
|
|
811
|
+ Sex int64 `gorm:"column:sex" json:"sex" form:"sex"`
|
|
812
|
+ Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
|
|
813
|
+ Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
|
|
814
|
+ IsSort int64 `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
|
|
815
|
+ Department string `gorm:"column:department" json:"department" form:"department"`
|
|
816
|
+ DepartmentId int64 `gorm:"column:department_id" json:"department_id" form:"department_id"`
|
|
817
|
+ Age int64 `gorm:"column:age" json:"age" form:"age"`
|
|
818
|
+ Nation string `gorm:"column:nation" json:"nation" form:"nation"`
|
|
819
|
+ CardType int64 `gorm:"column:card_type" json:"card_type" form:"card_type"`
|
|
820
|
+ IdCard string `gorm:"column:id_card" json:"id_card" form:"id_card"`
|
|
821
|
+ Education int64 `gorm:"column:education" json:"education" form:"education"`
|
|
822
|
+ StudyMajorName string `gorm:"column:study_major_name" json:"study_major_name" form:"study_major_name"`
|
|
823
|
+ WorkMajorName string `gorm:"column:work_major_name" json:"work_major_name" form:"work_major_name"`
|
|
824
|
+ RoleType int64 `gorm:"column:role_type" json:"role_type" form:"role_type"`
|
|
825
|
+ MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
|
|
826
|
+ DoctorCode string `gorm:"column:doctor_code" json:"doctor_code" form:"doctor_code"`
|
|
827
|
+ Licensing int64 `gorm:"column:licensing" json:"licensing" form:"licensing"`
|
|
828
|
+ JobNumber string `gorm:"column:job_number" json:"job_number" form:"job_number"`
|
|
829
|
+ PrescriptionQualificationIdentification int64 `gorm:"column:prescription_qualification_identification" json:"prescription_qualification_identification" form:"prescription_qualification_identification"`
|
|
830
|
+ IdentificationOutpatients int64 `gorm:"column:identification_outpatients" json:"identification_outpatients" form:"identification_outpatients"`
|
|
831
|
+ StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
|
|
832
|
+ MedicalRangeCode int64 `gorm:"column:medical_range_code" json:"medical_range_code" form:"medical_range_code"`
|
|
833
|
+ MedicalLevel int64 `gorm:"column:medical_level" json:"medical_level" form:"medical_level"`
|
|
834
|
+ MedicalTypeJob int64 `gorm:"column:medical_type_job" json:"medical_type_job" form:"medical_type_job"`
|
|
835
|
+ PharmacistRegistrationNumber string `gorm:"column:pharmacist_registration_number" json:"pharmacist_registration_number" form:"pharmacist_registration_number"`
|
|
836
|
+ DoctorRangeCode int64 `gorm:"column:doctor_range_code" json:"doctor_range_code" form:"doctor_range_code"`
|
|
837
|
+ DoctorLevel int64 `gorm:"column:doctor_level" json:"doctor_level" form:"doctor_level"`
|
|
838
|
+ DoctorTypeJob int64 `gorm:"column:doctor_type_job" json:"doctor_type_job" form:"doctor_type_job"`
|
|
839
|
+ DoctorNumber string `gorm:"column:doctor_number" json:"doctor_number" form:"doctor_number"`
|
|
840
|
+ OutpatientIllnessCategory string `gorm:"column:outpatient_illness_category" json:"outpatient_illness_category" form:"outpatient_illness_category"`
|
|
841
|
+ IsActive int64 `gorm:"column:is_active" json:"is_active" form:"is_active"`
|
|
842
|
+ ActiveStatus int64 `gorm:"column:active_status" json:"active_status" form:"active_status"`
|
|
843
|
+}
|
|
844
|
+
|
|
845
|
+func (UserAdminRole) TableName() string {
|
|
846
|
+ return "sgj_user_admin_role"
|
|
847
|
+}
|
|
848
|
+
|
|
849
|
+func FindDiagnoseById(id int64) (*HisXtDiagnoseConfig, error) {
|
|
850
|
+ dealer := &HisXtDiagnoseConfig{}
|
|
851
|
+ err := readDb.Model(&HisXtDiagnoseConfig{}).Where("id = ? AND status = 1", id).First(&dealer).Error
|
|
852
|
+ return dealer, err
|
|
853
|
+}
|
|
854
|
+
|
|
855
|
+type HisXtDiagnoseConfig struct {
|
|
856
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
857
|
+ ClassName string `gorm:"column:class_name" json:"class_name" form:"class_name"`
|
|
858
|
+ Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
|
|
859
|
+ Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
|
|
860
|
+ ContentCode string `gorm:"column:content_code" json:"content_code" form:"content_code"`
|
|
861
|
+ CountryCode string `gorm:"column:country_code" json:"country_code" form:"country_code"`
|
|
862
|
+ CountryContentName string `gorm:"column:country_content_name" json:"country_content_name" form:"country_content_name"`
|
|
863
|
+ Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
|
864
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
865
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
866
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
867
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
868
|
+}
|
|
869
|
+
|
|
870
|
+func (HisXtDiagnoseConfig) TableName() string {
|
|
871
|
+ return "his_xt_diagnose_config"
|
|
872
|
+}
|
|
873
|
+
|
|
874
|
+type VMHisProjectTeam struct {
|
|
875
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
876
|
+ ProjectTeam string `gorm:"column:project_team" json:"project_team" form:"project_team"`
|
|
877
|
+ Price float64 `gorm:"column:price" json:"price" form:"price"`
|
|
878
|
+ Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
|
|
879
|
+ Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
|
|
880
|
+ TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
|
|
881
|
+ TeamType int64 `gorm:"column:team_type" json:"team_type" form:"team_type"`
|
|
882
|
+ Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
|
883
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
884
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
885
|
+ CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
|
|
886
|
+ UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
|
|
887
|
+ ProjectId string `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
|
888
|
+ VMItemProjectList []*VMItemProjectList `gorm:"-" json:"list" form:"list"`
|
|
889
|
+ ItemId string `gorm:"column:item_id" json:"item_id" form:"item_id"`
|
|
890
|
+}
|
|
891
|
+
|
|
892
|
+func (VMHisProjectTeam) TableName() string {
|
|
893
|
+ return "xt_his_project_team"
|
|
894
|
+}
|
|
895
|
+
|
|
896
|
+type VMItemProjectList struct {
|
|
897
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
898
|
+ Number int64 `gorm:"column:number" json:"number" form:"number"`
|
|
899
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
900
|
+ ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
|
901
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
902
|
+ CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
|
|
903
|
+ UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
|
|
904
|
+ TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
|
|
905
|
+ Type int64 `gorm:"column:type" json:"type" form:"type"`
|
|
906
|
+ VMHisProject VMHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
|
|
907
|
+}
|
|
908
|
+
|
|
909
|
+func (VMItemProjectList) TableName() string {
|
|
910
|
+ return "xt_his_project_list"
|
|
911
|
+}
|
|
912
|
+
|
|
913
|
+type VMHisProject struct {
|
|
914
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
915
|
+ ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
|
|
916
|
+ Price float64 `gorm:"column:price" json:"price" form:"price"`
|
|
917
|
+ Unit string `gorm:"column:unit" json:"unit" form:"unit"`
|
|
918
|
+ CostClassify int64 `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
|
|
919
|
+ StatisticalClassification int64 `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
|
|
920
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
921
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
922
|
+ SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
|
923
|
+ ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
|
924
|
+ DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
|
925
|
+ NumberDays string `gorm:"column:number_days" json:"number_days" form:"number_days"`
|
|
926
|
+ MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
|
|
927
|
+}
|
|
928
|
+
|
|
929
|
+func (VMHisProject) TableName() string {
|
|
930
|
+ return "xt_his_project"
|
|
931
|
+}
|
|
932
|
+
|
|
933
|
+type HisPrescriptionProject struct {
|
|
934
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
935
|
+ ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
|
936
|
+ Price float64 `gorm:"column:price" json:"price" form:"price"`
|
|
937
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
938
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
939
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
940
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
941
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
942
|
+ HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
|
|
943
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
|
944
|
+ PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
|
|
945
|
+ Count int64 `gorm:"column:count" json:"count" form:"count"`
|
|
946
|
+ FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
|
|
947
|
+ MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
|
|
948
|
+ SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
|
949
|
+ DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
|
950
|
+ ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
|
951
|
+ Day string `gorm:"column:day" json:"day" form:"day"`
|
|
952
|
+ VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
|
|
953
|
+ Remark string `gorm:"column:remark" json:"remark" form:"remark"`
|
|
954
|
+ Unit string `gorm:"column:unit" json:"unit" form:"unit"`
|
|
955
|
+ Type int64 `gorm:"column:type" json:"type" form:"type"`
|
|
956
|
+ Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
|
|
957
|
+ ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
|
|
958
|
+ ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
|
|
959
|
+ ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
|
|
960
|
+ CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
|
|
961
|
+ CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
|
|
962
|
+ Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
|
|
963
|
+ StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
|
|
964
|
+ TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
|
|
965
|
+
|
|
966
|
+ FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
|
|
967
|
+ DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
|
|
968
|
+ WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
|
|
969
|
+ HisPrescription HisPrescription `gorm:"ForeignKey:ID;AssociationForeignKey:PrescriptionId" json:"his_prescription"`
|
|
970
|
+}
|
|
971
|
+
|
|
972
|
+func (HisPrescriptionProject) TableName() string {
|
|
973
|
+ return "his_prescription_project"
|
|
974
|
+}
|
|
975
|
+func GetProjectTeamList(orgid int64, id int64, p_id int64) (project []*HisPrescriptionProject, err error) {
|
|
976
|
+ err = readDb.Model(&HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1 AND team_id = ? AND prescription_id = ?", orgid, id, p_id).Find(&project).Error
|
|
977
|
+ return
|
|
978
|
+}
|
|
979
|
+
|
|
980
|
+func GetHisLabelPrintInfoById(id string) (info HisLabelPrintInfo, err error) {
|
|
981
|
+ err = readDb.Model(&HisLabelPrintInfo{}).Where("id = ?", id).First(&info).Error
|
|
982
|
+ return
|
|
983
|
+}
|