|
@@ -98,6 +98,318 @@ func HisManagerApiRegistRouters() {
|
98
|
98
|
|
99
|
99
|
beego.Router("/api/test/get", &HisApiController{}, "get:GetTestOrder")
|
100
|
100
|
|
|
101
|
+ beego.Router("/api/batch/settleaccount", &HisApiController{}, "get:GetBatchSettleAccounts")
|
|
102
|
+
|
|
103
|
+}
|
|
104
|
+
|
|
105
|
+func (c *HisApiController) GetBatchSettleAccounts() {
|
|
106
|
+ order_ids := c.GetString("order_ids")
|
|
107
|
+ admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
108
|
+ adminUser := c.GetAdminUserInfo()
|
|
109
|
+ orders := strings.Split(order_ids, ",")
|
|
110
|
+ var newOrders []models.Orders
|
|
111
|
+ for _, item := range orders {
|
|
112
|
+ order, _ := service.GetHisOrderByIDTenOne(item)
|
|
113
|
+ his, _ := service.GetHisPatientByNumber(order.MdtrtId)
|
|
114
|
+ orderInfos, _ := service.GetHisOrderInfoByNumberOne(order.Number)
|
|
115
|
+ orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
|
|
116
|
+ orderInfos = append(orderInfos, orderInfos_two...)
|
|
117
|
+ his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
|
|
118
|
+ //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
|
|
119
|
+ var diagnosis_ids []string
|
|
120
|
+ if his.ID > 0 {
|
|
121
|
+ diagnosis_ids = strings.Split(his.Diagnosis, ",")
|
|
122
|
+
|
|
123
|
+ } else {
|
|
124
|
+ diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
|
|
125
|
+
|
|
126
|
+ }
|
|
127
|
+ patient, _ := service.GetPatientByIDTenTwo(adminUser.CurrentOrgId, order.PatientId)
|
|
128
|
+ var dia_config []*models.HisXtDiagnoseConfig
|
|
129
|
+ var name string
|
|
130
|
+ for _, item := range diagnosis_ids {
|
|
131
|
+ id, _ := strconv.ParseInt(item, 10, 64)
|
|
132
|
+ diagnosisConfig, _ := service.FindDiagnoseById(id)
|
|
133
|
+ dia_config = append(dia_config, diagnosisConfig)
|
|
134
|
+ if len(name) == 0 {
|
|
135
|
+ name = diagnosisConfig.ClassName
|
|
136
|
+
|
|
137
|
+ } else {
|
|
138
|
+ name = name + "," + diagnosisConfig.ClassName
|
|
139
|
+ }
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ var bedCostTotal float64 = 0 //床位总费
|
|
143
|
+ var bedCostSelfTotal float64 = 0 //床位自费
|
|
144
|
+ var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
|
|
145
|
+ var bedSelfTotal float64 = 0 //床位部分项目自费
|
|
146
|
+ var bedInscpTotal float64 = 0 //床位部分项目自费
|
|
147
|
+
|
|
148
|
+ var operationCostTotal float64 = 0 //手术费
|
|
149
|
+ var operationCostSelfTotal float64 = 0 //手术费
|
|
150
|
+ var operationCostPartSelfTotal float64 = 0 //手术费
|
|
151
|
+ var operationSelfTotal float64 = 0 //床位部分项目自费
|
|
152
|
+ var operationInscpTotal float64 = 0 //床位部分项目自费
|
|
153
|
+
|
|
154
|
+ var otherCostTotal float64 = 0 //其他费用
|
|
155
|
+ var otherCostSelfTotal float64 = 0 //其他费用
|
|
156
|
+ var otherCostPartSelfTotal float64 = 0 //其他费用
|
|
157
|
+ var otherSelfTotal float64 = 0 //床位部分项目自费
|
|
158
|
+ var otherInscpTotal float64 = 0 //床位部分项目自费
|
|
159
|
+
|
|
160
|
+ var materialCostTotal float64 = 0 //材料费
|
|
161
|
+ var materialCostSelfTotal float64 = 0 //材料费
|
|
162
|
+ var materialCostPartSelfTotal float64 = 0 //材料费
|
|
163
|
+ var materialSelfTotal float64 = 0 //床位部分项目自费
|
|
164
|
+ var materialInscpTotal float64 = 0 //床位部分项目自费
|
|
165
|
+
|
|
166
|
+ var westernMedicineCostTotal float64 = 0 //西药费
|
|
167
|
+ var westernMedicineCostSelfTotal float64 = 0 //西药费
|
|
168
|
+ var westernMedicineCostPartSelfTotal float64 = 0 //西药费
|
|
169
|
+ var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
|
|
170
|
+ var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
|
|
171
|
+
|
|
172
|
+ var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
|
|
173
|
+ var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
|
|
174
|
+ var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
|
|
175
|
+ var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
|
|
176
|
+ var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
|
|
177
|
+
|
|
178
|
+ var checkCostTotal float64 = 0 //检查费
|
|
179
|
+ var checkCostSelfTotal float64 = 0 //检查费
|
|
180
|
+ var checkCostPartSelfTotal float64 = 0 //检查费
|
|
181
|
+ var checkSelfTotal float64 = 0 //床位部分项目自费
|
|
182
|
+ var checkInscpTotal float64 = 0 //床位部分项目自费
|
|
183
|
+
|
|
184
|
+ var laboratoryCostTotal float64 = 0 //化验费
|
|
185
|
+ var laboratoryCostSelfTotal float64 = 0 //化验费
|
|
186
|
+ var laboratoryCostPartSelfTotal float64 = 0 //化验费
|
|
187
|
+ var laboratorySelfTotal float64 = 0 //床位部分项目自费
|
|
188
|
+ var laboratoryInscpTotal float64 = 0 //床位部分项目自费
|
|
189
|
+
|
|
190
|
+ var treatCostTotal float64 = 0 //治疗费用
|
|
191
|
+ var treatCostSelfTotal float64 = 0 //治疗费用
|
|
192
|
+ var treatCostPartSelfTotal float64 = 0 //治疗费用
|
|
193
|
+ var treatSelfTotal float64 = 0 //床位部分项目自费
|
|
194
|
+ var treatInscpTotal float64 = 0 //床位部分项目自费
|
|
195
|
+
|
|
196
|
+ decimal.DivisionPrecision = 2
|
|
197
|
+
|
|
198
|
+ for _, item := range orderInfos {
|
|
199
|
+ if item.MedChrgitmType == "01" { //床位费
|
|
200
|
+ bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
201
|
+ bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
202
|
+ bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
203
|
+ bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
204
|
+ bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
205
|
+
|
|
206
|
+ }
|
|
207
|
+
|
|
208
|
+ if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
|
|
209
|
+ if item.MedChrgitmType == "03" { //检查费
|
|
210
|
+ laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
211
|
+ laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
212
|
+ laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
213
|
+ laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
214
|
+ laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
215
|
+
|
|
216
|
+ }
|
|
217
|
+ } else {
|
|
218
|
+
|
|
219
|
+ if item.MedChrgitmType == "03" { //检查费
|
|
220
|
+ checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
221
|
+ checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
222
|
+ checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
223
|
+ checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
224
|
+ checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
225
|
+
|
|
226
|
+ }
|
|
227
|
+
|
|
228
|
+ }
|
|
229
|
+
|
|
230
|
+ if item.MedChrgitmType == "04" { //化验费
|
|
231
|
+ laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
232
|
+ laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
233
|
+ laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
234
|
+ laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
235
|
+ laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
236
|
+
|
|
237
|
+ }
|
|
238
|
+
|
|
239
|
+ if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
|
|
240
|
+
|
|
241
|
+ treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
242
|
+ treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
243
|
+ treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
244
|
+ treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
245
|
+ treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
246
|
+
|
|
247
|
+ }
|
|
248
|
+
|
|
249
|
+ if item.MedChrgitmType == "06" { //手术费
|
|
250
|
+ operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
251
|
+ operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
252
|
+ operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
253
|
+ operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
254
|
+ operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
255
|
+
|
|
256
|
+ }
|
|
257
|
+
|
|
258
|
+ if item.MedChrgitmType == "08" { //材料费
|
|
259
|
+ materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
260
|
+ materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
261
|
+ materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
262
|
+ materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
263
|
+ materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
264
|
+
|
|
265
|
+ }
|
|
266
|
+
|
|
267
|
+ if item.MedChrgitmType == "09" { //西药费
|
|
268
|
+ westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
269
|
+ westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
270
|
+ westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
271
|
+ westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
272
|
+ westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
273
|
+
|
|
274
|
+ }
|
|
275
|
+
|
|
276
|
+ if item.MedChrgitmType == "11" { //中成费
|
|
277
|
+ chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
278
|
+ chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
279
|
+ chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
280
|
+ chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
281
|
+ chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
282
|
+
|
|
283
|
+ }
|
|
284
|
+
|
|
285
|
+ if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
|
|
286
|
+ otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
|
287
|
+ otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
|
288
|
+ otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
|
289
|
+ otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
|
|
290
|
+ otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
|
|
291
|
+
|
|
292
|
+ }
|
|
293
|
+ }
|
|
294
|
+
|
|
295
|
+ miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
|
|
296
|
+
|
|
297
|
+ printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
|
|
298
|
+ charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
|
|
299
|
+
|
|
300
|
+ doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
|
|
301
|
+
|
|
302
|
+ roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
|
|
303
|
+
|
|
304
|
+ var doctor_name string
|
|
305
|
+ if roles.ID == 0 {
|
|
306
|
+ doctor_name = "管理员"
|
|
307
|
+ } else {
|
|
308
|
+ doctor_name = roles.UserName
|
|
309
|
+ }
|
|
310
|
+
|
|
311
|
+ yiliao_leibie := ""
|
|
312
|
+
|
|
313
|
+ switch order.MedType {
|
|
314
|
+ case "11":
|
|
315
|
+ yiliao_leibie = "普通门诊"
|
|
316
|
+ break
|
|
317
|
+ case "12":
|
|
318
|
+ yiliao_leibie = "门诊挂号"
|
|
319
|
+ break
|
|
320
|
+ case "13":
|
|
321
|
+ yiliao_leibie = "急诊"
|
|
322
|
+ break
|
|
323
|
+ case "14":
|
|
324
|
+ yiliao_leibie = "门诊特殊病"
|
|
325
|
+ break
|
|
326
|
+ case "15":
|
|
327
|
+ yiliao_leibie = "门诊统筹"
|
|
328
|
+ break
|
|
329
|
+ case "16":
|
|
330
|
+ yiliao_leibie = "门诊慢性病"
|
|
331
|
+ break
|
|
332
|
+ case "21":
|
|
333
|
+ yiliao_leibie = "普通住院"
|
|
334
|
+ break
|
|
335
|
+ }
|
|
336
|
+ var newOrder models.Orders
|
|
337
|
+
|
|
338
|
+ newOrder.Diagnosis = name
|
|
339
|
+ newOrder.OrderInfos = orderInfos
|
|
340
|
+ newOrder.Number = order.MdtrtId
|
|
341
|
+ newOrder.Date = order.SettleAccountsDate
|
|
342
|
+ newOrder.ChargeAdmin = charge_admin
|
|
343
|
+ newOrder.PrintorAdmin = printor_admin
|
|
344
|
+ newOrder.Order = order
|
|
345
|
+ newOrder.BedCostTotal = bedCostTotal
|
|
346
|
+ newOrder.BedCostSelfTotal = bedCostSelfTotal
|
|
347
|
+ newOrder.BedCostPartSelfTotal = bedCostPartSelfTotal
|
|
348
|
+ newOrder.BedSelfTotal = bedSelfTotal
|
|
349
|
+ newOrder.BedInscpTotal = bedInscpTotal
|
|
350
|
+ newOrder.OperationCostTotal = operationCostTotal
|
|
351
|
+ newOrder.OperationCostSelfTotal = operationCostSelfTotal
|
|
352
|
+ newOrder.OperationCostPartSelfTotal = operationCostPartSelfTotal
|
|
353
|
+ newOrder.OperationSelfTotal = operationSelfTotal
|
|
354
|
+ newOrder.OperationInscpTotal = operationInscpTotal
|
|
355
|
+ newOrder.OtherCostTotal = otherCostTotal
|
|
356
|
+ newOrder.OtherCostSelfTotal = otherCostSelfTotal
|
|
357
|
+ newOrder.OtherCostPartSelfTotal = otherCostPartSelfTotal
|
|
358
|
+ newOrder.OtherSelfTotal = otherSelfTotal
|
|
359
|
+ newOrder.OtherInscpTotal = otherInscpTotal
|
|
360
|
+
|
|
361
|
+ newOrder.MaterialCostTotal = materialCostTotal
|
|
362
|
+ newOrder.MaterialCostSelfTotal = materialCostSelfTotal
|
|
363
|
+ newOrder.MaterialCostPartSelfTotal = materialCostPartSelfTotal
|
|
364
|
+ newOrder.MaterialSelfTotal = materialSelfTotal
|
|
365
|
+ newOrder.MaterialInscpTotal = materialInscpTotal
|
|
366
|
+
|
|
367
|
+ newOrder.WesternMedicineCostTotal = westernMedicineCostTotal
|
|
368
|
+ newOrder.WesternMedicineCostSelfTotal = westernMedicineCostSelfTotal
|
|
369
|
+ newOrder.WesternMedicineCostPartSelfTotal = westernMedicineCostPartSelfTotal
|
|
370
|
+ newOrder.WesternMedicineSelfTotal = westernMedicineSelfTotal
|
|
371
|
+ newOrder.WesternMedicineInscpTotal = westernMedicineInscpTotal
|
|
372
|
+
|
|
373
|
+ newOrder.ChineseTraditionalMedicineCostTotal = chineseTraditionalMedicineCostTotal
|
|
374
|
+ newOrder.ChineseTraditionalMedicineCostSelfTotal = chineseTraditionalMedicineCostSelfTotal
|
|
375
|
+ newOrder.ChineseTraditionalMedicineCostPartSelfTotal = chineseTraditionalMedicineCostPartSelfTotal
|
|
376
|
+ newOrder.ChineseTraditionalSelfTotal = chineseTraditionalSelfTotal
|
|
377
|
+ newOrder.ChineseTraditionalInscpTotal = chineseTraditionalInscpTotal
|
|
378
|
+
|
|
379
|
+ newOrder.CheckCostTotal = checkCostTotal
|
|
380
|
+ newOrder.CheckCostSelfTotal = checkCostSelfTotal
|
|
381
|
+ newOrder.CheckCostPartSelfTotal = checkCostPartSelfTotal
|
|
382
|
+ newOrder.CheckSelfTotal = checkSelfTotal
|
|
383
|
+ newOrder.CheckInscpTotal = checkInscpTotal
|
|
384
|
+
|
|
385
|
+ newOrder.LaboratoryCostTotal = laboratoryCostTotal
|
|
386
|
+ newOrder.LaboratoryCostSelfTotal = laboratoryCostSelfTotal
|
|
387
|
+ newOrder.LaboratoryCostPartSelfTotal = laboratoryCostPartSelfTotal
|
|
388
|
+ newOrder.LaboratorySelfTotal = laboratorySelfTotal
|
|
389
|
+ newOrder.LaboratoryInscpTotal = laboratoryInscpTotal
|
|
390
|
+
|
|
391
|
+ newOrder.TreatCostTotal = treatCostTotal
|
|
392
|
+ newOrder.TreatCostSelfTotal = treatCostSelfTotal
|
|
393
|
+ newOrder.TreatCostPartSelfTotal = treatCostPartSelfTotal
|
|
394
|
+ newOrder.TreatSelfTotal = treatSelfTotal
|
|
395
|
+ newOrder.TreatInscpTotal = treatInscpTotal
|
|
396
|
+
|
|
397
|
+ newOrder.DoctorInfo = doctor_info
|
|
398
|
+ newOrder.DoctorName = doctor_name
|
|
399
|
+ newOrder.HealthCardNo = order.PsnNo
|
|
400
|
+ newOrder.YiliaoLeibie = yiliao_leibie
|
|
401
|
+ newOrder.Patient = patient
|
|
402
|
+ newOrder.OrgName = miConfig.OrgName
|
|
403
|
+ newOrder.OrgCode = miConfig.Code
|
|
404
|
+ newOrder.OrderNumber = order.Number
|
|
405
|
+ newOrder.HisPatient = his
|
|
406
|
+ newOrder.DiaConfig = dia_config
|
|
407
|
+
|
|
408
|
+ newOrders = append(newOrders, newOrder)
|
|
409
|
+ }
|
|
410
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
411
|
+ "orders": newOrders,
|
|
412
|
+ })
|
101
|
413
|
}
|
102
|
414
|
|
103
|
415
|
func (c *HisApiController) GetTestOrder() {
|
|
@@ -5569,7 +5881,7 @@ func (c *HisApiController) setAdviceTemplateWithJSON(advice *models.HisPrescript
|
5569
|
5881
|
day := int64(json["day"].(float64))
|
5570
|
5882
|
advice.Day = day
|
5571
|
5883
|
}
|
5572
|
|
-
|
|
5884
|
+ advice.FrequencyType = 1
|
5573
|
5885
|
return 0
|
5574
|
5886
|
}
|
5575
|
5887
|
|
|
@@ -5624,6 +5936,8 @@ func (c *HisApiController) setProjectTemplateWithJSON(project *models.HisPrescri
|
5624
|
5936
|
unit, _ := json["unit"].(string)
|
5625
|
5937
|
project.Unit = unit
|
5626
|
5938
|
}
|
|
5939
|
+ project.FrequencyType = 1
|
|
5940
|
+
|
5627
|
5941
|
return 0
|
5628
|
5942
|
}
|
5629
|
5943
|
|
|
@@ -5637,6 +5951,8 @@ func (c *HisApiController) GetHisOrderList() {
|
5637
|
5951
|
p_type, _ := c.GetInt64("p_type", 0)
|
5638
|
5952
|
sort_type, _ := c.GetInt64("sort_type", 0)
|
5639
|
5953
|
charge_type, _ := c.GetInt64("charge_type", 0)
|
|
5954
|
+ sch_type, _ := c.GetInt64("sch_type", 0)
|
|
5955
|
+ zone_type, _ := c.GetInt64("zone_type", 0)
|
5640
|
5956
|
|
5641
|
5957
|
timeLayout := "2006-01-02"
|
5642
|
5958
|
loc, _ := time.LoadLocation("Local")
|
|
@@ -5663,7 +5979,7 @@ func (c *HisApiController) GetHisOrderList() {
|
5663
|
5979
|
|
5664
|
5980
|
adminUser := c.GetAdminUserInfo()
|
5665
|
5981
|
org_id := adminUser.CurrentOrgId
|
5666
|
|
- order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type)
|
|
5982
|
+ order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type, sort_type, start_time, end_time, charge_type, sch_type, zone_type)
|
5667
|
5983
|
|
5668
|
5984
|
for _, item := range order {
|
5669
|
5985
|
info, _ := service.GetHisPrescriptionByPatientID(item.PatientId, item.UserOrgId)
|
|
@@ -6205,12 +6521,6 @@ func (c *HisApiController) GetUploadInfo() {
|
6205
|
6521
|
pay_way, _ := c.GetInt64("pay_way")
|
6206
|
6522
|
pay_ways := c.GetString("pay_ways")
|
6207
|
6523
|
|
6208
|
|
- cash_pay := c.GetString("cash_pay")
|
6209
|
|
- band_card_pay := c.GetString("band_card_pay")
|
6210
|
|
- wechat_pay := c.GetString("wechat_pay")
|
6211
|
|
- ali_pay := c.GetString("ali_pay")
|
6212
|
|
- jifen_pay := c.GetString("jifen_pay")
|
6213
|
|
-
|
6214
|
6524
|
pay_price, _ := c.GetFloat("pay_price")
|
6215
|
6525
|
pay_card_no := c.GetString("pay_card_no")
|
6216
|
6526
|
discount_price, _ := c.GetFloat("discount_price")
|
|
@@ -6231,6 +6541,12 @@ func (c *HisApiController) GetUploadInfo() {
|
6231
|
6541
|
reg_type, _ := c.GetInt64("p_type")
|
6232
|
6542
|
order_id, _ := c.GetInt64("order_id")
|
6233
|
6543
|
|
|
6544
|
+ cash_pay := c.GetString("cash_pay")
|
|
6545
|
+ wechat_pay := c.GetString("wechat_pay")
|
|
6546
|
+ ali_pay := c.GetString("ali_pay")
|
|
6547
|
+ jifen_pay := c.GetString("jifen_pay")
|
|
6548
|
+ band_card_pay := c.GetString("band_card_pay")
|
|
6549
|
+
|
6234
|
6550
|
dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
|
6235
|
6551
|
tmp_decimal := c.GetString("tmp_decimal")
|
6236
|
6552
|
var decimal float64 //本次使用的押金
|
|
@@ -6258,10 +6574,7 @@ func (c *HisApiController) GetUploadInfo() {
|
6258
|
6574
|
}
|
6259
|
6575
|
tt, errs := strconv.ParseFloat(tmp_decimal, 64)
|
6260
|
6576
|
fmt.Println(errs)
|
6261
|
|
- //if errs != nil {
|
6262
|
|
- // c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
|
6263
|
|
- // return
|
6264
|
|
- //}
|
|
6577
|
+
|
6265
|
6578
|
decimal = tt
|
6266
|
6579
|
|
6267
|
6580
|
his, _ := service.GetHisPatientByIdThreeTX(his_patient_id, tx)
|
|
@@ -6828,232 +7141,8 @@ func (c *HisApiController) GetUploadInfo() {
|
6828
|
7141
|
})
|
6829
|
7142
|
|
6830
|
7143
|
}
|
6831
|
|
- } else {
|
6832
|
|
- if tempOrder.IsPre > 0 {
|
6833
|
|
- allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
|
6834
|
|
- totals, _ := strconv.ParseFloat(allTotal, 64)
|
6835
|
|
- tempOrder.OrderStatus = 2
|
6836
|
|
- tempOrder.PayWay = pay_way
|
6837
|
|
- tempOrder.PayPrice = pay_price
|
6838
|
|
- tempOrder.PayCardNo = pay_card_no
|
6839
|
|
- tempOrder.DiscountPrice = discount_price
|
6840
|
|
- tempOrder.PreferentialPrice = preferential_price
|
6841
|
|
- tempOrder.RealityPrice = reality_price
|
6842
|
|
- tempOrder.FoundPrice = found_price
|
6843
|
|
- tempOrder.MedicalInsurancePrice = medical_insurance_price
|
6844
|
|
- tempOrder.PrivatePrice = private_price
|
6845
|
|
- tempOrder.FaPiaoCode = fapiao_code
|
6846
|
|
- tempOrder.FaPiaoNumber = fapiao_number
|
6847
|
|
- tempOrder.PType = 2
|
6848
|
|
- tempOrder.MedfeeSumamt = totals
|
6849
|
|
- tempOrder.Diagnosis = diagnosis_id
|
6850
|
|
- err = service.SaveHisOrder(&tempOrder)
|
6851
|
|
- err = service.UpdataOrderStatusTwo(tempOrder.Number, adminUser.CurrentOrgId)
|
6852
|
|
- if err != nil {
|
6853
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
6854
|
|
- return
|
6855
|
|
- }
|
6856
|
|
- if err == nil {
|
6857
|
|
- houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
|
6858
|
|
- var goods []*models.DialysisBeforePrepareGoods
|
6859
|
|
- var newGoods []*models.NewDialysisBeforePrepareGoods
|
6860
|
|
- var infos []*models.HisDoctorAdviceInfo
|
6861
|
|
- var hisAdvice []*models.HisDoctorAdviceInfo
|
6862
|
|
- var newGoodOne []*models.NewDialysisBeforePrepareGoods
|
6863
|
|
- var infolist []*models.HisDoctorAdviceInfo
|
6864
|
|
- var oldGoods []*models.OldDialysisBeforePrepareGoods
|
6865
|
|
- for _, info := range prescriptions {
|
6866
|
|
- if info.Type == 1 {
|
6867
|
|
- infos = append(infos, info.HisDoctorAdviceInfo...)
|
6868
|
|
- }
|
6869
|
|
- if info.Type == 2 {
|
6870
|
|
- for _, sumItem := range info.HisPrescriptionProject {
|
6871
|
|
- if sumItem.Type == 3 {
|
6872
|
|
- var good models.DialysisBeforePrepareGoods
|
6873
|
|
- var newGood models.NewDialysisBeforePrepareGoods
|
6874
|
|
- good.GoodId = sumItem.GoodInfo.ID
|
6875
|
|
- good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
|
6876
|
|
- count, _ := strconv.Atoi(sumItem.Count)
|
6877
|
|
- good.Count = int64(count)
|
6878
|
|
- good.StorehouseId = houseConfig.StorehouseOutInfo
|
6879
|
|
- good.ProjectId = sumItem.ID
|
6880
|
|
- goods = append(goods, &good)
|
6881
|
|
-
|
6882
|
|
- newGood.GoodId = sumItem.GoodInfo.ID
|
6883
|
|
- newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
|
6884
|
|
- count2, _ := strconv.Atoi(sumItem.Count)
|
6885
|
|
- newGood.Count = int64(count2)
|
6886
|
|
- newGood.StorehouseId = houseConfig.StorehouseOutInfo
|
6887
|
|
- newGood.ProjectId = sumItem.ID
|
6888
|
|
- newGoods = append(newGoods, &newGood)
|
6889
|
|
- }
|
6890
|
|
-
|
6891
|
|
- }
|
6892
|
|
-
|
6893
|
|
- }
|
6894
|
|
- }
|
6895
|
|
-
|
6896
|
|
- settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
|
6897
|
|
- if settConfig.IsOpen == 1 {
|
6898
|
|
-
|
6899
|
|
- //判断库存的地方
|
6900
|
|
- for _, info := range prescriptions {
|
6901
|
|
- if info.Type == 1 {
|
6902
|
|
- infolist = append(infolist, info.HisDoctorAdviceInfo...)
|
6903
|
|
-
|
6904
|
|
- }
|
6905
|
|
- if info.Type == 2 {
|
6906
|
|
- for _, sumItem := range info.HisPrescriptionProject {
|
6907
|
|
- if sumItem.Type == 3 {
|
6908
|
|
- var good models.DialysisBeforePrepareGoods
|
6909
|
|
- var newGood models.NewDialysisBeforePrepareGoods
|
6910
|
|
- var oldGood models.OldDialysisBeforePrepareGoods
|
6911
|
|
- good.GoodId = sumItem.GoodInfo.ID
|
6912
|
|
- good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
|
6913
|
|
- count, _ := strconv.Atoi(sumItem.Count)
|
6914
|
|
- good.Count = int64(count)
|
6915
|
|
- good.StorehouseId = houseConfig.StorehouseOutInfo
|
6916
|
|
- good.ProjectId = sumItem.ID
|
6917
|
|
- goods = append(goods, &good)
|
6918
|
|
-
|
6919
|
|
- newGood.GoodId = sumItem.GoodInfo.ID
|
6920
|
|
- newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
|
6921
|
|
- count2, _ := strconv.Atoi(sumItem.Count)
|
6922
|
|
- newGood.Count = int64(count2)
|
6923
|
|
- newGood.StorehouseId = houseConfig.StorehouseOutInfo
|
6924
|
|
- newGood.ProjectId = sumItem.ID
|
6925
|
|
- newGoods = append(newGoods, &newGood)
|
6926
|
|
-
|
6927
|
|
- oldGood.GoodId = sumItem.GoodInfo.ID
|
6928
|
|
- oldGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
|
6929
|
|
- count3, _ := strconv.Atoi(sumItem.Count)
|
6930
|
|
- oldGood.Count = int64(count3)
|
6931
|
|
- oldGood.StorehouseId = houseConfig.StorehouseOutInfo
|
6932
|
|
- oldGood.ProjectId = sumItem.ID
|
6933
|
|
- oldGood.RecordDate = sumItem.RecordDate
|
6934
|
|
-
|
6935
|
|
- oldGoods = append(oldGoods, &oldGood)
|
6936
|
|
- }
|
6937
|
|
- }
|
6938
|
|
- }
|
6939
|
|
- }
|
6940
|
|
-
|
6941
|
|
- for _, info := range prescriptionsOne {
|
6942
|
|
- if info.Type == 1 {
|
6943
|
|
- hisAdvice = append(hisAdvice, info.HisDoctorAdviceInfo...)
|
6944
|
|
- }
|
6945
|
|
-
|
6946
|
|
- if info.Type == 2 {
|
6947
|
|
- for _, sumItem := range info.HisPrescriptionProject {
|
6948
|
|
- if sumItem.Type == 3 {
|
6949
|
|
- var newGood models.NewDialysisBeforePrepareGoods
|
6950
|
|
-
|
6951
|
|
- newGood.GoodId = sumItem.GoodInfo.ID
|
6952
|
|
- newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
|
6953
|
|
- count2, _ := strconv.Atoi(sumItem.Count)
|
6954
|
|
- newGood.Count = int64(count2)
|
6955
|
|
- newGood.StorehouseId = houseConfig.StorehouseOutInfo
|
6956
|
|
- newGood.ProjectId = sumItem.ID
|
6957
|
|
- newGoodOne = append(newGoodOne, &newGood)
|
6958
|
|
- }
|
6959
|
|
- }
|
6960
|
|
- }
|
6961
|
|
- }
|
6962
|
|
-
|
6963
|
|
- //判断
|
6964
|
|
- for _, itemOne := range infos {
|
6965
|
|
- for _, itemTwo := range hisAdvice {
|
6966
|
|
- if itemOne.DrugId == itemTwo.DrugId {
|
6967
|
|
- itemTwo.Child = append(itemTwo.ChildDoctorAdvice, itemOne)
|
6968
|
|
- }
|
6969
|
|
- }
|
6970
|
|
- }
|
6971
|
|
-
|
6972
|
|
- for _, itemTwo := range hisAdvice {
|
6973
|
|
- medical, _ := service.GetBaseDrugMedical(itemTwo.DrugId)
|
6974
|
|
- var sum_out_count int64
|
6975
|
|
- for _, itemThree := range itemTwo.Child {
|
6976
|
|
- var prescribing_number int64
|
6977
|
|
- stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
|
6978
|
|
- parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
|
6979
|
|
- if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
|
6980
|
|
- prescribing_number = parseIntPrescribingNumber * medical.MinNumber
|
6981
|
|
- }
|
6982
|
|
- if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
|
6983
|
|
- prescribing_number = parseIntPrescribingNumber
|
6984
|
|
- }
|
6985
|
|
- if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
|
6986
|
|
- prescribing_number = parseIntPrescribingNumber
|
6987
|
|
- }
|
6988
|
|
- sum_out_count += prescribing_number
|
6989
|
|
- }
|
6990
|
|
- houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
|
6991
|
|
- drugStockOut, _ := service.GetDrugSumOutCountByDrugId(itemTwo.DrugId, adminUser.CurrentOrgId, houseConfig.DrugStorehouseOut)
|
6992
|
|
-
|
6993
|
|
- if sum_out_count > drugStockOut.FlushCount {
|
6994
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
6995
|
|
- "msg": "2",
|
6996
|
|
- "drug": medical,
|
6997
|
|
- })
|
6998
|
|
- return
|
6999
|
|
- }
|
7000
|
|
- }
|
7001
|
|
-
|
7002
|
|
- for _, itemOne := range newGoods {
|
7003
|
|
- for _, item := range newGoodOne {
|
7004
|
|
- if itemOne.ProjectId == item.ProjectId {
|
7005
|
|
- item.ChildNewDialysisBeforePrepareGoods = append(item.ChildNewDialysisBeforePrepareGoods, item)
|
7006
|
|
- }
|
7007
|
|
- }
|
7008
|
|
- }
|
7009
|
|
-
|
7010
|
|
- for _, item := range newGoodOne {
|
7011
|
|
- var sum_out_count_one int64
|
7012
|
|
- good, _ := service.GetGoodInformationByGoodIdOne(item.GoodId)
|
7013
|
|
-
|
7014
|
|
- for _, itemOne := range item.ChildNewDialysisBeforePrepareGoods {
|
7015
|
|
- sum_out_count_one += itemOne.Count
|
7016
|
|
- }
|
7017
|
|
- list, _ := service.GetStockGoodList(item.GoodId, adminUser.CurrentOrgId, houseConfig.StorehouseOutInfo)
|
7018
|
|
- fmt.Println("sum_out_count_one", sum_out_count_one)
|
7019
|
|
- fmt.Println("list.FlushCount", list.FlushCount)
|
7020
|
|
- if sum_out_count_one > list.FlushCount {
|
7021
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
7022
|
|
- "msg": "3",
|
7023
|
|
- "good": good,
|
7024
|
|
- })
|
7025
|
|
- return
|
7026
|
|
- }
|
7027
|
|
- }
|
7028
|
|
- for _, item := range infolist {
|
7029
|
|
- service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
|
7030
|
|
- }
|
7031
|
|
- for _, item := range oldGoods {
|
7032
|
|
- dialyPrepareOne := models.DialysisBeforePrepare{
|
7033
|
|
- GoodTypeId: item.GoodTypeId,
|
7034
|
|
- GoodId: item.GoodId,
|
7035
|
|
- PatientId: item.PatientId,
|
7036
|
|
- RecordDate: item.RecordDate,
|
7037
|
|
- UserOrgId: item.UserOrgId,
|
7038
|
|
- Count: item.Count,
|
7039
|
|
- Ctime: time.Now().Unix(),
|
7040
|
|
- Creater: adminUser.AdminUser.Id,
|
7041
|
|
- CommdityCode: item.CommdityCode,
|
7042
|
|
- Status: 1,
|
7043
|
|
- StorehouseId: houseConfig.StorehouseOutInfo,
|
7044
|
|
- }
|
7045
|
|
- err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
|
7046
|
|
- }
|
7047
|
|
-
|
7048
|
|
- service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
|
7049
|
|
- }
|
7050
|
|
-
|
7051
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
7052
|
|
- "msg": "结算成功",
|
7053
|
|
- })
|
7054
|
|
- }
|
7055
|
|
- }
|
7056
|
7144
|
}
|
|
7145
|
+
|
7057
|
7146
|
}
|
7058
|
7147
|
|
7059
|
7148
|
// 退款
|
|
@@ -9188,96 +9277,198 @@ func (c *HisApiController) CreateHisPrescriptionTemplate() {
|
9188
|
9277
|
return
|
9189
|
9278
|
}
|
9190
|
9279
|
|
9191
|
|
- err = service.CreateHisPrescriptionTemplate(template)
|
9192
|
|
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
9193
|
|
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
9194
|
|
- if len(prescriptions) > 0 {
|
9195
|
|
- for _, item := range prescriptions {
|
9196
|
|
- items := item.(map[string]interface{})
|
9197
|
|
- if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
9198
|
|
- utils.ErrorLog("type")
|
9199
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
9200
|
|
- return
|
9201
|
|
- }
|
9202
|
|
- types := int64(items["type"].(float64))
|
|
9280
|
+ template_one, _ := service.GetHisPrescriptionTemplateByModeId(mode_id, patient_id, c.GetAdminUserInfo().CurrentOrgId)
|
9203
|
9281
|
|
9204
|
|
- if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
|
9205
|
|
- utils.ErrorLog("med_type")
|
9206
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
9207
|
|
- return
|
9208
|
|
- }
|
9209
|
|
- med_type := strconv.Itoa(int(items["med_type"].(float64)))
|
|
9282
|
+ //如果已经存在记录则删除处方
|
|
9283
|
+ if template_one.ID > 0 {
|
|
9284
|
+ ps, _ := service.GetHisPrescriptionInfoTemplates(template_one.ID, template_one.UserOrgId)
|
|
9285
|
+ for _, item := range ps {
|
|
9286
|
+ service.DelelteHisPrescriptionInfoTemplate(item.ID, item.UserOrgId)
|
|
9287
|
+ }
|
|
9288
|
+ if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
9289
|
+ prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
|
9290
|
+ if len(prescriptions) > 0 {
|
|
9291
|
+ for _, item := range prescriptions {
|
|
9292
|
+ items := item.(map[string]interface{})
|
|
9293
|
+ if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
|
9294
|
+ utils.ErrorLog("type")
|
|
9295
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
9296
|
+ return
|
|
9297
|
+ }
|
|
9298
|
+ types := int64(items["type"].(float64))
|
9210
|
9299
|
|
9211
|
|
- ctime := time.Now().Unix()
|
9212
|
|
- prescription := &models.HisPrescriptionInfoTemplate{
|
9213
|
|
- PatientId: patient_id,
|
9214
|
|
- UserOrgId: adminInfo.CurrentOrgId,
|
9215
|
|
- Ctime: ctime,
|
9216
|
|
- Mtime: ctime,
|
9217
|
|
- Type: types,
|
9218
|
|
- Modifier: adminInfo.AdminUser.Id,
|
9219
|
|
- Creator: adminInfo.AdminUser.Id,
|
9220
|
|
- Status: 1,
|
9221
|
|
- PTemplateId: template.ID,
|
9222
|
|
- MedType: med_type,
|
9223
|
|
- }
|
9224
|
|
- service.CreateHisPrescriptionInfoTemplate(prescription)
|
|
9300
|
+ if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
|
|
9301
|
+ utils.ErrorLog("med_type")
|
|
9302
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
9303
|
+ return
|
|
9304
|
+ }
|
|
9305
|
+ med_type := strconv.Itoa(int(items["med_type"].(float64)))
|
9225
|
9306
|
|
9226
|
|
- if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
9227
|
|
- advices := items["advices"].([]interface{})
|
9228
|
|
- //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
|
9229
|
9307
|
ctime := time.Now().Unix()
|
9230
|
|
- mtime := ctime
|
9231
|
|
- if len(advices) > 0 {
|
9232
|
|
- for _, advice := range advices {
|
9233
|
|
- var s models.HisPrescriptionAdviceTemplate
|
9234
|
|
- s.PrescriptionId = prescription.ID
|
9235
|
|
- s.AdviceType = 2
|
9236
|
|
- s.StopState = 2
|
9237
|
|
- s.ExecutionState = 2
|
9238
|
|
- s.Status = 1
|
9239
|
|
- s.UserOrgId = adminInfo.CurrentOrgId
|
9240
|
|
- s.CreatedTime = ctime
|
9241
|
|
- s.UpdatedTime = mtime
|
9242
|
|
- s.PatientId = patient_id
|
9243
|
|
- errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
|
9244
|
|
- if errcode > 0 {
|
9245
|
|
- c.ServeFailJSONWithSGJErrorCode(errcode)
|
9246
|
|
- return
|
9247
|
|
- }
|
|
9308
|
+ prescription := &models.HisPrescriptionInfoTemplate{
|
|
9309
|
+ PatientId: patient_id,
|
|
9310
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
9311
|
+ Ctime: ctime,
|
|
9312
|
+ Mtime: ctime,
|
|
9313
|
+ Type: types,
|
|
9314
|
+ Modifier: adminInfo.AdminUser.Id,
|
|
9315
|
+ Creator: adminInfo.AdminUser.Id,
|
|
9316
|
+ Status: 1,
|
|
9317
|
+ PTemplateId: template_one.ID,
|
|
9318
|
+ MedType: med_type,
|
|
9319
|
+ }
|
|
9320
|
+ service.CreateHisPrescriptionInfoTemplate(prescription)
|
9248
|
9321
|
|
9249
|
|
- service.CreateHisPrescriptionAdviceTemplate(&s)
|
|
9322
|
+ if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
|
9323
|
+ advices := items["advices"].([]interface{})
|
|
9324
|
+ //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
|
|
9325
|
+ ctime := time.Now().Unix()
|
|
9326
|
+ mtime := ctime
|
|
9327
|
+ if len(advices) > 0 {
|
|
9328
|
+ for _, advice := range advices {
|
|
9329
|
+ var s models.HisPrescriptionAdviceTemplate
|
|
9330
|
+ s.PrescriptionId = prescription.ID
|
|
9331
|
+ s.AdviceType = 2
|
|
9332
|
+ s.StopState = 2
|
|
9333
|
+ s.ExecutionState = 2
|
|
9334
|
+ s.Status = 1
|
|
9335
|
+ s.UserOrgId = adminInfo.CurrentOrgId
|
|
9336
|
+ s.CreatedTime = ctime
|
|
9337
|
+ s.UpdatedTime = mtime
|
|
9338
|
+ s.PatientId = patient_id
|
|
9339
|
+ errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
|
|
9340
|
+ if errcode > 0 {
|
|
9341
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
9342
|
+ return
|
|
9343
|
+ }
|
|
9344
|
+
|
|
9345
|
+ service.CreateHisPrescriptionAdviceTemplate(&s)
|
9250
|
9346
|
|
|
9347
|
+ }
|
9251
|
9348
|
}
|
9252
|
9349
|
}
|
|
9350
|
+ if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
|
9351
|
+ projects := items["project"].([]interface{})
|
|
9352
|
+ if len(projects) > 0 {
|
|
9353
|
+ for _, project := range projects {
|
|
9354
|
+ var p models.HisPrescriptionProjectTemplate
|
|
9355
|
+ p.PrescriptionId = prescription.ID
|
|
9356
|
+ p.Ctime = time.Now().Unix()
|
|
9357
|
+ p.Mtime = time.Now().Unix()
|
|
9358
|
+ p.PatientId = patient_id
|
|
9359
|
+ p.UserOrgId = adminInfo.CurrentOrgId
|
|
9360
|
+ p.Status = 1
|
|
9361
|
+ errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
|
|
9362
|
+ if errcode > 0 {
|
|
9363
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
9364
|
+ return
|
|
9365
|
+ }
|
|
9366
|
+ service.CreateHisPrescriptionProjectTemplate(&p)
|
|
9367
|
+
|
|
9368
|
+ }
|
|
9369
|
+ }
|
|
9370
|
+ }
|
|
9371
|
+
|
9253
|
9372
|
}
|
9254
|
|
- if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
9255
|
|
- projects := items["project"].([]interface{})
|
9256
|
|
- if len(projects) > 0 {
|
9257
|
|
- for _, project := range projects {
|
9258
|
|
- var p models.HisPrescriptionProjectTemplate
|
9259
|
|
- p.PrescriptionId = prescription.ID
|
9260
|
|
- p.Ctime = time.Now().Unix()
|
9261
|
|
- p.Mtime = time.Now().Unix()
|
9262
|
|
- p.PatientId = patient_id
|
9263
|
|
- p.UserOrgId = adminInfo.CurrentOrgId
|
9264
|
|
- p.Status = 1
|
9265
|
|
- errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
|
9266
|
|
- if errcode > 0 {
|
9267
|
|
- c.ServeFailJSONWithSGJErrorCode(errcode)
|
9268
|
|
- return
|
|
9373
|
+
|
|
9374
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
9375
|
+ "msg": "创建成功",
|
|
9376
|
+ })
|
|
9377
|
+ }
|
|
9378
|
+ }
|
|
9379
|
+
|
|
9380
|
+ } else {
|
|
9381
|
+ err = service.CreateHisPrescriptionTemplate(template)
|
|
9382
|
+ if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
9383
|
+ prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
|
9384
|
+ if len(prescriptions) > 0 {
|
|
9385
|
+ for _, item := range prescriptions {
|
|
9386
|
+ items := item.(map[string]interface{})
|
|
9387
|
+ if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
|
9388
|
+ utils.ErrorLog("type")
|
|
9389
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
9390
|
+ return
|
|
9391
|
+ }
|
|
9392
|
+ types := int64(items["type"].(float64))
|
|
9393
|
+
|
|
9394
|
+ if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
|
|
9395
|
+ utils.ErrorLog("med_type")
|
|
9396
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
9397
|
+ return
|
|
9398
|
+ }
|
|
9399
|
+ med_type := strconv.Itoa(int(items["med_type"].(float64)))
|
|
9400
|
+
|
|
9401
|
+ ctime := time.Now().Unix()
|
|
9402
|
+ prescription := &models.HisPrescriptionInfoTemplate{
|
|
9403
|
+ PatientId: patient_id,
|
|
9404
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
9405
|
+ Ctime: ctime,
|
|
9406
|
+ Mtime: ctime,
|
|
9407
|
+ Type: types,
|
|
9408
|
+ Modifier: adminInfo.AdminUser.Id,
|
|
9409
|
+ Creator: adminInfo.AdminUser.Id,
|
|
9410
|
+ Status: 1,
|
|
9411
|
+ PTemplateId: template.ID,
|
|
9412
|
+ MedType: med_type,
|
|
9413
|
+ }
|
|
9414
|
+ service.CreateHisPrescriptionInfoTemplate(prescription)
|
|
9415
|
+
|
|
9416
|
+ if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
|
9417
|
+ advices := items["advices"].([]interface{})
|
|
9418
|
+ //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
|
|
9419
|
+ ctime := time.Now().Unix()
|
|
9420
|
+ mtime := ctime
|
|
9421
|
+ if len(advices) > 0 {
|
|
9422
|
+ for _, advice := range advices {
|
|
9423
|
+ var s models.HisPrescriptionAdviceTemplate
|
|
9424
|
+ s.PrescriptionId = prescription.ID
|
|
9425
|
+ s.AdviceType = 2
|
|
9426
|
+ s.StopState = 2
|
|
9427
|
+ s.ExecutionState = 2
|
|
9428
|
+ s.Status = 1
|
|
9429
|
+ s.UserOrgId = adminInfo.CurrentOrgId
|
|
9430
|
+ s.CreatedTime = ctime
|
|
9431
|
+ s.UpdatedTime = mtime
|
|
9432
|
+ s.PatientId = patient_id
|
|
9433
|
+ errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
|
|
9434
|
+ if errcode > 0 {
|
|
9435
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
9436
|
+ return
|
|
9437
|
+ }
|
|
9438
|
+
|
|
9439
|
+ service.CreateHisPrescriptionAdviceTemplate(&s)
|
|
9440
|
+
|
9269
|
9441
|
}
|
9270
|
|
- service.CreateHisPrescriptionProjectTemplate(&p)
|
|
9442
|
+ }
|
|
9443
|
+ }
|
|
9444
|
+ if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
|
9445
|
+ projects := items["project"].([]interface{})
|
|
9446
|
+ if len(projects) > 0 {
|
|
9447
|
+ for _, project := range projects {
|
|
9448
|
+ var p models.HisPrescriptionProjectTemplate
|
|
9449
|
+ p.PrescriptionId = prescription.ID
|
|
9450
|
+ p.Ctime = time.Now().Unix()
|
|
9451
|
+ p.Mtime = time.Now().Unix()
|
|
9452
|
+ p.PatientId = patient_id
|
|
9453
|
+ p.UserOrgId = adminInfo.CurrentOrgId
|
|
9454
|
+ p.Status = 1
|
|
9455
|
+ errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
|
|
9456
|
+ if errcode > 0 {
|
|
9457
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
9458
|
+ return
|
|
9459
|
+ }
|
|
9460
|
+ service.CreateHisPrescriptionProjectTemplate(&p)
|
9271
|
9461
|
|
|
9462
|
+ }
|
9272
|
9463
|
}
|
9273
|
9464
|
}
|
|
9465
|
+
|
9274
|
9466
|
}
|
9275
|
9467
|
|
|
9468
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
9469
|
+ "msg": "创建成功",
|
|
9470
|
+ })
|
9276
|
9471
|
}
|
9277
|
|
-
|
9278
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
9279
|
|
- "msg": "创建成功",
|
9280
|
|
- })
|
9281
|
9472
|
}
|
9282
|
9473
|
}
|
9283
|
9474
|
|