3 Commits e8a1c7ae06 ... a71f4af45a

Autore SHA1 Messaggio Data
  张保健 a71f4af45a 1 1 anno fa
  张保健 65b258809c 1 1 anno fa
  张保健 4669f386f2 透析处方生成抗凝剂临时医嘱 1 anno fa

+ 93 - 0
controllers/dialysis_api_controller.go Vedi File

@@ -434,6 +434,99 @@ func (c *DialysisApiController) PostPrescription() {
434 434
 		DialysisRemark:             dialysis_remark,
435 435
 	}
436 436
 
437
+	//长沙南雅医院,自动生成抗凝剂的临时处方
438
+	if adminUserInfo.CurrentOrgId == 10340 {
439
+		advice := models.DoctorAdvice{
440
+			UserOrgId:             adminUserInfo.CurrentOrgId,
441
+			PatientId:             patient,
442
+			GroupNo:               0,
443
+			AdviceType:            2,
444
+			AdviceDate:            recordDate.Unix(),
445
+			StartTime:             recordDate.Unix() + 7*60*60, // 根据排班班次,给默认时间
446
+			AdviceName:            "",                          // 根据抗凝剂转换为中文 + 首剂 + 维持 + 总量
447
+			AdviceDesc:            "",
448
+			ReminderDate:          0,
449
+			SingleDose:            0,
450
+			SingleDoseUnit:        "",
451
+			DrugSpec:              0,
452
+			DrugSpecUnit:          "",
453
+			PrescribingNumber:     0, // 前端传过来的开药数量
454
+			PrescribingNumberUnit: "支",
455
+			DeliveryWay:           "静脉注射",
456
+			ExecutionFrequency:    "上机前",
457
+			AdviceDoctor:          0,
458
+			Status:                1,
459
+			CreatedTime:           time.Now().Unix(),
460
+			UpdatedTime:           time.Now().Unix(),
461
+			IsPrescription:        1,
462
+		}
463
+		// 查询排班信息
464
+		schedulePatient, _ := service.GetScheduleByPatient(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
465
+		if schedulePatient.ID > 0 {
466
+			if schedulePatient.ScheduleType == 1 {
467
+				advice.StartTime = recordDate.Unix() + 7*60*60
468
+			}
469
+
470
+			if schedulePatient.ScheduleType == 2 {
471
+				advice.StartTime = recordDate.Unix() + 11*60*60
472
+			}
473
+		}
474
+		// 抗凝剂名称
475
+		switch anticoagulant {
476
+		case 1:
477
+			advice.AdviceName = "无肝素"
478
+			break
479
+		case 2:
480
+			advice.AdviceName = "普通肝素"
481
+			break
482
+		case 3:
483
+			advice.AdviceName = "低分子肝素"
484
+			break
485
+		case 4:
486
+			advice.AdviceName = "阿加曲班"
487
+			break
488
+		case 5:
489
+			advice.AdviceName = "枸橼酸钠"
490
+			break
491
+		case 6:
492
+			advice.AdviceName = "低分子肝素钙"
493
+			break
494
+		case 7:
495
+			advice.AdviceName = "低分子肝素钠"
496
+			break
497
+		case 8:
498
+			advice.AdviceName = "依诺肝素"
499
+			break
500
+		case 9:
501
+			advice.AdviceName = "达肝素"
502
+			break
503
+		case 10:
504
+			advice.AdviceName = "体外抗凝"
505
+			break
506
+		case 11:
507
+			advice.AdviceName = "那曲肝素"
508
+			break
509
+		case 12:
510
+			advice.AdviceName = "无抗凝剂"
511
+			break
512
+		}
513
+		advice.AdviceDesc = "首剂" + strconv.FormatFloat(anticoagulant_shouji, 'f', -1, 64) + "维持" + strconv.FormatFloat(anticoagulant_weichi, 'f', -1, 64) + "总量" + strconv.FormatFloat(anticoagulant_zongliang, 'f', -1, 64)
514
+		if appRole.UserType == 2 || appRole.UserType == 1 {
515
+			advice.AdviceDoctor = appRole.AdminUserId
516
+		}
517
+
518
+		// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
519
+		advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
520
+		if advicePrescription.ID > 0 {
521
+			// 修改患者临时医嘱里的抗凝剂医嘱
522
+			advice.ID = advicePrescription.ID
523
+			service.UpdateDoctorAdvice(&advice)
524
+		} else {
525
+			// 新增患者临时医嘱里的抗凝剂医嘱
526
+			service.CreateDoctorAdvice(&advice)
527
+		}
528
+	}
529
+
437 530
 	if appRole.UserType == 2 || appRole.UserType == 1 {
438 531
 		prescription.PrescriptionDoctor = appRole.AdminUserId
439 532
 	}

+ 1 - 0
models/dialysis.go Vedi File

@@ -458,6 +458,7 @@ type DoctorAdvice struct {
458 458
 	IsMedicine            int64           `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
459 459
 	PushStartTime         int64           `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
460 460
 	IsSettle              int64           `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
461
+	IsPrescription        int64           `gorm:"column:is_prescription" json:"is_prescription" form:"is_prescription"`
461 462
 }
462 463
 
463 464
 func (DoctorAdvice) TableName() string {

+ 4 - 0
service/inspection_service.go Vedi File

@@ -33,6 +33,10 @@ func GetAdvices(orgid int64, patientid int64, recorddate int64) (advcie []*model
33 33
 	err = XTReadDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and record_date = ? and status =1", patientid, orgid, recorddate).Find(&advcie).Error
34 34
 	return
35 35
 }
36
+func GetAdvicesByPrescription(orgid int64, patientid int64, recorddate int64) (advcie *models.DoctorAdvice, err error) {
37
+	err = XTReadDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and record_date = ? and status =1 and is_prescription = 1", patientid, orgid, recorddate).Find(&advcie).Error
38
+	return
39
+}
36 40
 
37 41
 func CreatePatientInspection(inspectins []models.Inspection) (err error) {
38 42
 	if len(inspectins) == 0 {