Kaynağa Gözat

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 1 yıl önce
ebeveyn
işleme
29539c231c
1 değiştirilmiş dosya ile 110 ekleme ve 18 silme
  1. 110 18
      controllers/coordinate/coordinate_controller.go

+ 110 - 18
controllers/coordinate/coordinate_controller.go Dosyayı Görüntüle

227
 		}
227
 		}
228
 		var presInfos []*models.PresInfo
228
 		var presInfos []*models.PresInfo
229
 		var presDetails []*models.PresDetail
229
 		var presDetails []*models.PresDetail
230
-		for index, item := range prescriptions {
231
-			var presDetail models.PresDetail
232
-			var presInfo models.PresInfo
233
-			presInfo.Cbmid = strconv.FormatInt(item.ID, 10)
234
-			if item.Type == 1 {
235
-				presInfo.Cbm06 = "0"
236
-			} else {
237
-				presInfo.Cbm06 = "5"
230
+
231
+		var doctoradvices []*models.HisDoctorAdviceInfo
232
+		var groups []int64
233
+		for _, item := range prescriptions {
234
+			for _, subItem := range item.HisDoctorAdviceInfo {
235
+				doctoradvices = append(doctoradvices, subItem)
238
 			}
236
 			}
237
+		}
239
 
238
 
240
-			if item.Type == 1 {
241
-				presInfo.Cbm07 = item.MedType
242
-			} else {
243
-				presInfo.Cbm07 = item.MedType
239
+		for _, item := range doctoradvices {
240
+			groups = append(groups, item.Groupno)
241
+		}
242
+		groups = RemoveRepeatedGroupElement(groups)
243
+
244
+		type DoctorAdvices struct {
245
+			GroupNo int64
246
+			item    []*models.HisDoctorAdviceInfo
247
+		}
248
+		var doctoradvice []*DoctorAdvices
249
+
250
+		for _, group := range groups {
251
+			var da DoctorAdvices
252
+			da.GroupNo = group
253
+			for _, item := range doctoradvices {
254
+				if group == item.Groupno {
255
+					da.item = append(da.item, item)
256
+				}
244
 			}
257
 			}
258
+			doctoradvice = append(doctoradvice, &da)
259
+		}
245
 
260
 
246
-			presDetail.Vaf59 = strconv.FormatInt(int64(index+1), 10)
261
+		for _, item := range doctoradvice {
262
+			var presDetail models.PresDetail
263
+			var presInfo models.PresInfo
264
+			presInfo.Cbmid = strconv.FormatInt(item.GroupNo, 10)
265
+
266
+			presInfo.Cbm06 = "0"
267
+			presInfo.Cbm07 = ""
268
+			presDetail.Vaf59 = strconv.FormatInt(item.GroupNo, 10)
247
 			var infoItems []*models.Item
269
 			var infoItems []*models.Item
248
-			for index, subItem := range item.HisDoctorAdviceInfo {
270
+			for index, subItem := range item.item {
249
 				ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
271
 				ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
250
 
272
 
251
 				var infoItem models.Item
273
 				var infoItem models.Item
252
-				infoItem.Rownr = strconv.FormatInt(int64(index+1), 10)
274
+				infoItem.Rownr = strconv.FormatInt(int64(index), 10)
253
 				infoItem.Vaf11 = "2"
275
 				infoItem.Vaf11 = "2"
254
-				infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
276
+				infoItem.Vaf36 = time.Unix(subItem.CreatedTime, 0).Format("2006-01-02 15:04:05")
255
 				infoItem.Bbx01 = subItem.BaseDrugLib.MedicalInsuranceNumber
277
 				infoItem.Bbx01 = subItem.BaseDrugLib.MedicalInsuranceNumber
256
 				infoItem.Bda01 = "1"
278
 				infoItem.Bda01 = "1"
257
 				infoItem.Bby01 = ""
279
 				infoItem.Bby01 = ""
271
 				infoItem.Vaf61 = "1"
293
 				infoItem.Vaf61 = "1"
272
 				infoItems = append(infoItems, &infoItem)
294
 				infoItems = append(infoItems, &infoItem)
273
 			}
295
 			}
296
+
297
+			presDetail.Item = infoItems
298
+			presDetails = append(presDetails, &presDetail)
299
+			presInfo.PresDetail = presDetails
300
+			presInfos = append(presInfos, &presInfo)
301
+
302
+		}
303
+
304
+		for index, item := range prescriptions {
305
+			var presDetail models.PresDetail
306
+			var presInfo models.PresInfo
307
+			presInfo.Cbmid = strconv.FormatInt(item.ID, 10)
308
+			if item.Type == 1 {
309
+				presInfo.Cbm06 = "0"
310
+			} else {
311
+				presInfo.Cbm06 = "5"
312
+			}
313
+
314
+			if item.Type == 1 {
315
+				presInfo.Cbm07 = item.MedType
316
+			} else {
317
+				presInfo.Cbm07 = item.MedType
318
+			}
319
+
320
+			presDetail.Vaf59 = strconv.FormatInt(int64(index+1), 10)
321
+			var infoItems []*models.Item
322
+			//for index, subItem := range item.HisDoctorAdviceInfo {
323
+			//	ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
324
+			//
325
+			//	var infoItem models.Item
326
+			//	infoItem.Rownr = strconv.FormatInt(int64(index+1), 10)
327
+			//	infoItem.Vaf11 = "2"
328
+			//	infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
329
+			//	infoItem.Bbx01 = subItem.BaseDrugLib.MedicalInsuranceNumber
330
+			//	infoItem.Bda01 = "1"
331
+			//	infoItem.Bby01 = ""
332
+			//	if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
333
+			//		infoItem.Vaf22 = subItem.BaseDrugLib.DrugName + " " + subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
334
+			//	}
335
+			//	infoItem.Vaf14 = subItem.BaseDrugLib.DrugName
336
+			//	infoItem.Bdi01 = ef.Code
337
+			//	infoItem.Vaf17 = strconv.FormatInt(subItem.Day, 10)
338
+			//	infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose)
339
+			//	infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
340
+			//	infoItem.Vaf35 = "0"
341
+			//	infoItem.Vaf32 = "0"
342
+			//	infoItem.Bck01b = departmwnt.Number
343
+			//	infoItem.Bck01d = departmwnt.Number
344
+			//	infoItem.Vaf58 = "0"
345
+			//	infoItem.Vaf61 = "1"
346
+			//	infoItems = append(infoItems, &infoItem)
347
+			//}
274
 			for _, subItem := range item.HisPrescriptionProject {
348
 			for _, subItem := range item.HisPrescriptionProject {
275
 				//ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
349
 				//ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId)
276
 
350
 
279
 						var infoItem models.Item
353
 						var infoItem models.Item
280
 						infoItem.Rownr = "0"
354
 						infoItem.Rownr = "0"
281
 						infoItem.Vaf11 = "2"
355
 						infoItem.Vaf11 = "2"
282
-						infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
356
+						infoItem.Vaf36 = time.Unix(subItem.Ctime, 0).Format("2006-01-02 15:04:05")
283
 						infoItem.Bbx01 = subItem.HisProject.MedicalCode
357
 						infoItem.Bbx01 = subItem.HisProject.MedicalCode
284
 						infoItem.Bda01 = "Z"
358
 						infoItem.Bda01 = "Z"
285
 						infoItem.Bby01 = ""
359
 						infoItem.Bby01 = ""
303
 						var infoItem models.Item
377
 						var infoItem models.Item
304
 						infoItem.Rownr = "0"
378
 						infoItem.Rownr = "0"
305
 						infoItem.Vaf11 = "1"
379
 						infoItem.Vaf11 = "1"
306
-						infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05")
380
+						infoItem.Vaf36 = time.Unix(subItem.Ctime, 0).Format("2006-01-02 15:04:05")
307
 						infoItem.Bbx01 = subItem.HisProject.MedicalCode
381
 						infoItem.Bbx01 = subItem.HisProject.MedicalCode
308
 
382
 
309
 						if subItem.HisProject.CostClassify == 2 {
383
 						if subItem.HisProject.CostClassify == 2 {
360
 			presInfo.PresDetail = presDetails
434
 			presInfo.PresDetail = presDetails
361
 			presInfos = append(presInfos, &presInfo)
435
 			presInfos = append(presInfos, &presInfo)
362
 		}
436
 		}
437
+
363
 		info.PresInfo = presInfos
438
 		info.PresInfo = presInfos
364
 		var result2 string
439
 		var result2 string
365
 		var request2 string
440
 		var request2 string
574
 	}
649
 	}
575
 
650
 
576
 }
651
 }
652
+
653
+func RemoveRepeatedGroupElement(arr []int64) (newArr []int64) {
654
+	newArr = make([]int64, 0)
655
+	for i := 0; i < len(arr); i++ {
656
+		repeat := false
657
+		for j := i + 1; j < len(arr); j++ {
658
+			if arr[i] == arr[j] {
659
+				repeat = true
660
+				break
661
+			}
662
+		}
663
+		if !repeat {
664
+			newArr = append(newArr, arr[i])
665
+		}
666
+	}
667
+	return
668
+}