Browse Source

11月8日库存管理

XMLWAN 2 years ago
parent
commit
a1cfea98df

+ 2 - 2
conf/app.conf View File

@@ -1,6 +1,6 @@
1 1
 appname = 血透
2
-httpport = 9531
3
-runmode = prod
2
+httpport = 9529
3
+runmode = dev
4 4
 
5 5
 #
6 6
 copyrequestbody = true

+ 5 - 4
controllers/his_api_controller.go View File

@@ -4572,10 +4572,11 @@ func (c *HisApiController) GetUploadInfo() {
4572 4572
 		}
4573 4573
 	}
4574 4574
 	tt, errs := strconv.ParseFloat(tmp_decimal, 64)
4575
-	if errs != nil {
4576
-		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
4577
-		return
4578
-	}
4575
+	fmt.Println(errs)
4576
+	//if errs != nil {
4577
+	//	c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
4578
+	//	return
4579
+	//}
4579 4580
 	decimal = tt
4580 4581
 
4581 4582
 	his, _ := service.GetHisPatientByIdThreeTX(his_patient_id, tx)

+ 450 - 2
controllers/his_config_api_controller.go View File

@@ -27,6 +27,14 @@ func HisConfigApiRegistRouters() {
27 27
 	beego.Router("/api/his/projecttemplate/delete", &HisConfigApiController{}, "post:DeleteProjectTemplate")
28 28
 	//beego.Router("/api/his/responsibilitydoctor/get", &HisConfigApiController{}, "get:GetResponsibilityDoctor")
29 29
 
30
+	beego.Router("/api/his/getmodetemplatename", &HisConfigApiController{}, "get:GetModeTemplateName")
31
+	beego.Router("/api/his/getprescriptiontemplatedetail", &HisConfigApiController{}, "get:GetPrescriptionTemplateDetail")
32
+	beego.Router("/api/his/prescriptionmodetemplate/create", &HisConfigApiController{}, "post:CreatePrescriptionModeTemplate")
33
+	beego.Router("/api/his/prescriptionmodetemplate/info", &HisConfigApiController{}, "get:GetPrescriptionModeTemplateInfo")
34
+	beego.Router("/api/his/prescriptionmodetemplate/delete", &HisConfigApiController{}, "post:DeleteModePrescriptionTemplate")
35
+	beego.Router("/api/his/projectmodetemplate/delete", &HisConfigApiController{}, "post:DeleteModeProjectTemplate")
36
+	beego.Router("/api/his/advicempdetemplate/delete", &HisConfigApiController{}, "post:DeleteModeAdviceTemplate")
37
+	beego.Router("/api/his/prescriptioninfomodetemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionInfoModeTemplate")
30 38
 }
31 39
 
32 40
 func (c *HisConfigApiController) GetAllHisPatientsList() {
@@ -82,14 +90,20 @@ func (c *HisConfigApiController) CreatePrescriptionTemplate() {
82 90
 	adminInfo := c.GetAdminUserInfo()
83 91
 
84 92
 	if id == 0 {
85
-		mode_template, _ := service.GetHisPrescriptionTemplateByModeId(mode_id, patient_id)
93
+		mode_template, _ := service.GetHisPrescriptionTemplateByModeId(mode_id, patient_id, adminInfo.CurrentOrgId)
94
+		if mode_template.ID > 0 {
95
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorModeTemplateCodeParamWrong)
96
+			return
97
+		}
98
+	}
99
+	if id > 0 {
100
+		mode_template, _ := service.GetHisPrescriptionTemplateByModeIdTwo(mode_id, patient_id, adminInfo.CurrentOrgId, id)
86 101
 		if mode_template.ID > 0 {
87 102
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorModeTemplateCodeParamWrong)
88 103
 			return
89 104
 		}
90 105
 	}
91 106
 	src_template, _ := service.GetHisPrescriptionTemplateByID(id)
92
-
93 107
 	if src_template.ID == 0 {
94 108
 		template := models.HisPrescriptionTemplate{
95 109
 			UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
@@ -450,3 +464,437 @@ func (c *HisConfigApiController) setProjectTemplateWithJSON(project *models.HisP
450 464
 	}
451 465
 	return 0
452 466
 }
467
+
468
+func (this *HisConfigApiController) GetModeTemplateName() {
469
+
470
+	mode_id, _ := this.GetInt64("mode_id")
471
+	orgId := this.GetAdminUserInfo().CurrentOrgId
472
+	modeTeplate, err := service.GetModeTemplateName(mode_id, orgId)
473
+	if err == nil {
474
+		this.ServeSuccessJSON(map[string]interface{}{
475
+			"modeTeplate": modeTeplate,
476
+		})
477
+		return
478
+	} else {
479
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
480
+		return
481
+
482
+	}
483
+}
484
+
485
+func (this *HisConfigApiController) GetPrescriptionTemplateDetail() {
486
+
487
+	mode_id, _ := this.GetInt64("mode_id")
488
+	orgId := this.GetAdminUserInfo().CurrentOrgId
489
+	template, _ := service.GetModeTemplateNameDetail(mode_id, orgId)
490
+
491
+	prescriptions, err := service.GetHisPrescriptionModeTemplate(template.ID, orgId)
492
+
493
+	if err == nil {
494
+		this.ServeSuccessJSON(map[string]interface{}{
495
+			"template":      template,
496
+			"prescriptions": prescriptions,
497
+		})
498
+		return
499
+	} else {
500
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
501
+		return
502
+
503
+	}
504
+}
505
+
506
+func (c *HisConfigApiController) CreatePrescriptionModeTemplate() {
507
+	id, _ := c.GetInt64("id")
508
+	name := c.GetString("name")
509
+	mode_id, _ := c.GetInt64("mode_id", 0)
510
+	types, _ := c.GetInt64("type", 0)
511
+	patient_id, _ := c.GetInt64("patient_id", 0)
512
+	types = 1
513
+	adminInfo := c.GetAdminUserInfo()
514
+
515
+	if id == 0 {
516
+		mode_template, _ := service.GetHisModePrescriptionTemplateByModeId(mode_id, patient_id, adminInfo.CurrentOrgId)
517
+		if mode_template.ID > 0 {
518
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorModeTemplateCodeParamWrong)
519
+			return
520
+		}
521
+	}
522
+	if id > 0 {
523
+		mode_template, _ := service.GetHisModePrescriptionTemplateByModeIdTwo(mode_id, patient_id, adminInfo.CurrentOrgId, id)
524
+		if mode_template.ID > 0 {
525
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorModeTemplateCodeParamWrong)
526
+			return
527
+		}
528
+	}
529
+	src_template, _ := service.GetHisModePrescriptionTemplateByID(id)
530
+
531
+	if src_template.ID == 0 {
532
+		template := models.HisPrescriptionModeTemplate{
533
+			UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
534
+			PatientId: patient_id,
535
+			Type:      types,
536
+			Status:    1,
537
+			Ctime:     time.Now().Unix(),
538
+			Mtime:     time.Now().Unix(),
539
+			Name:      name,
540
+			Mode:      mode_id,
541
+		}
542
+		src_template = template
543
+		service.CreateHisModePrescriptionTemplate(&src_template)
544
+	} else {
545
+		src_template.Name = name
546
+		src_template.Mode = mode_id
547
+		service.SaveHisModePrescriptionTemplate(&src_template)
548
+	}
549
+
550
+	dataBody := make(map[string]interface{}, 0)
551
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
552
+	if err != nil {
553
+		utils.ErrorLog(err.Error())
554
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
555
+		return
556
+	}
557
+
558
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
559
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
560
+		if len(prescriptions) > 0 {
561
+			for _, item := range prescriptions {
562
+				items := item.(map[string]interface{})
563
+
564
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
565
+					utils.ErrorLog("id")
566
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
567
+					return
568
+				}
569
+
570
+				id := int64(items["id"].(float64))
571
+
572
+				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
573
+					utils.ErrorLog("type")
574
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
575
+					return
576
+				}
577
+				types := int64(items["type"].(float64))
578
+
579
+				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
580
+					utils.ErrorLog("med_type")
581
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
582
+					return
583
+				}
584
+				med_type := strconv.Itoa(int(items["med_type"].(float64)))
585
+
586
+				ctime := time.Now().Unix()
587
+				prescription := &models.HisPrescriptionInfoModeTemplate{
588
+					ID:          id,
589
+					PatientId:   patient_id,
590
+					UserOrgId:   adminInfo.CurrentOrgId,
591
+					Ctime:       ctime,
592
+					Mtime:       ctime,
593
+					Type:        types,
594
+					Modifier:    adminInfo.AdminUser.Id,
595
+					Creator:     adminInfo.AdminUser.Id,
596
+					Status:      1,
597
+					PTemplateId: src_template.ID,
598
+					MedType:     med_type,
599
+				}
600
+				service.CreateHisModePrescriptionInfoTemplate(prescription)
601
+
602
+				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
603
+					advices := items["advices"].([]interface{})
604
+					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
605
+					groupNo := int64(0)
606
+					ctime := time.Now().Unix()
607
+					mtime := ctime
608
+					if len(advices) > 0 {
609
+						for _, advice := range advices {
610
+							var s models.HisPrescriptionAdviceModeTemplate
611
+							s.PrescriptionId = prescription.ID
612
+							s.AdviceType = 2
613
+							s.StopState = 2
614
+							s.ExecutionState = 2
615
+							s.Status = 1
616
+							s.UserOrgId = adminInfo.CurrentOrgId
617
+							s.Groupno = groupNo
618
+							s.CreatedTime = ctime
619
+							s.UpdatedTime = mtime
620
+							s.PatientId = patient_id
621
+							errcode := c.setAdviceModeTemplateWithJSON(&s, advice.(map[string]interface{}))
622
+							if errcode > 0 {
623
+								c.ServeFailJSONWithSGJErrorCode(errcode)
624
+								return
625
+							}
626
+							service.CreateHisModePrescriptionAdviceTemplate(&s)
627
+						}
628
+					}
629
+				}
630
+				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
631
+					projects := items["project"].([]interface{})
632
+					if len(projects) > 0 {
633
+						for _, project := range projects {
634
+							var p models.HisPrescriptionProjectModeTemplate
635
+							p.PrescriptionId = prescription.ID
636
+							p.Ctime = time.Now().Unix()
637
+							p.Mtime = time.Now().Unix()
638
+							p.PatientId = patient_id
639
+							p.UserOrgId = adminInfo.CurrentOrgId
640
+							p.Status = 1
641
+							errcode := c.setProjectModeTemplateWithJSON(&p, project.(map[string]interface{}))
642
+							if errcode > 0 {
643
+								c.ServeFailJSONWithSGJErrorCode(errcode)
644
+								return
645
+							}
646
+							service.CreateHisModePrescriptionProjectTemplate(&p)
647
+
648
+						}
649
+					}
650
+				}
651
+			}
652
+			c.ServeSuccessJSON(map[string]interface{}{
653
+				"msg": "创建成功",
654
+			})
655
+		}
656
+	}
657
+
658
+}
659
+
660
+func (c *HisConfigApiController) GetPrescriptionModeTemplateInfo() {
661
+
662
+	id, _ := c.GetInt64("id", 0)
663
+	template, _ := service.GetHisModePrescriptionTemplateByID(id)
664
+	prescriptions, _ := service.GetHisPrescriptionModeTemplate(template.ID, c.GetAdminUserInfo().CurrentOrgId)
665
+
666
+	c.ServeSuccessJSON(map[string]interface{}{
667
+		"template":      template,
668
+		"prescriptions": prescriptions,
669
+	})
670
+}
671
+
672
+func (c *HisConfigApiController) setAdviceModeTemplateWithJSON(advice *models.HisPrescriptionAdviceModeTemplate, json map[string]interface{}) int {
673
+
674
+	if json["advice_id"] != nil || reflect.TypeOf(json["advice_id"]).String() == "float64" {
675
+		advice_id := int64(json["advice_id"].(float64))
676
+		advice.ID = advice_id
677
+	}
678
+
679
+	if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
680
+		utils.ErrorLog("drug_name")
681
+		return enums.ErrorCodeParamWrong
682
+	}
683
+	adviceName, _ := json["drug_name"].(string)
684
+	if len(adviceName) == 0 {
685
+		utils.ErrorLog("len(advice_name) == 0")
686
+		return enums.ErrorCodeParamWrong
687
+	}
688
+	advice.AdviceName = adviceName
689
+	adviceDesc, _ := json["advice_desc"].(string)
690
+	advice.AdviceDesc = adviceDesc
691
+	if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
692
+		drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
693
+		advice.DrugSpec = drugSpec
694
+	}
695
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
696
+		remark, _ := json["remark"].(string)
697
+		advice.Remark = remark
698
+	}
699
+	if json["id"] == nil {
700
+		advice.DrugId = 0
701
+	} else {
702
+		if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
703
+			drug_id := int64(json["id"].(float64))
704
+			advice.DrugId = drug_id
705
+		}
706
+	}
707
+
708
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
709
+		drugSpecUnit, _ := json["min_unit"].(string)
710
+		advice.DrugSpecUnit = drugSpecUnit
711
+	}
712
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
713
+		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
714
+		advice.SingleDose = singleDose
715
+	}
716
+	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
717
+		singleDoseUnit, _ := json["single_dose_unit"].(string)
718
+		advice.SingleDoseUnit = singleDoseUnit
719
+	}
720
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
721
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
722
+		advice.PrescribingNumber = prescribingNumber
723
+	}
724
+	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
725
+		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
726
+		advice.PrescribingNumberUnit = prescribingNumberUnit
727
+	}
728
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
729
+		deliveryWay, _ := json["delivery_way"].(string)
730
+		advice.DeliveryWay = deliveryWay
731
+	}
732
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
733
+		executionFrequency, _ := json["execution_frequency"].(string)
734
+		advice.ExecutionFrequency = executionFrequency
735
+	}
736
+
737
+	if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
738
+		price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
739
+		advice.Price = price
740
+	}
741
+	if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
742
+		med_list_codg, _ := json["medical_insurance_number"].(string)
743
+		advice.MedListCodg = med_list_codg
744
+	}
745
+	if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
746
+		day := int64(json["day"].(float64))
747
+		advice.Day = day
748
+	}
749
+	if json["groupno"] != nil || reflect.TypeOf(json["groupno"]).String() == "float64" {
750
+		groupno := int64(json["groupno"].(float64))
751
+		advice.Groupno = groupno
752
+	}
753
+
754
+	if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
755
+		frequency_type := int64(json["frequency_type"].(float64))
756
+		advice.FrequencyType = frequency_type
757
+	}
758
+
759
+	if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
760
+		day_count := int64(json["day_count"].(float64))
761
+		advice.DayCount = day_count
762
+	}
763
+
764
+	if json["week_day"] != nil || reflect.TypeOf(json["week_day"]).String() == "string" {
765
+		week_day, _ := json["week_day"].(string)
766
+		advice.WeekDay = week_day
767
+	}
768
+	return 0
769
+}
770
+
771
+func (c *HisConfigApiController) setProjectModeTemplateWithJSON(project *models.HisPrescriptionProjectModeTemplate, json map[string]interface{}) int {
772
+
773
+	if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
774
+		id := int64(json["id"].(float64))
775
+		project.ID = id
776
+	}
777
+	if json["frequency_type"] != nil || reflect.TypeOf(json["frequency_type"]).String() == "float64" {
778
+		frequency_type := int64(json["frequency_type"].(float64))
779
+		project.FrequencyType = frequency_type
780
+	}
781
+
782
+	if json["day_count"] != nil || reflect.TypeOf(json["day_count"]).String() == "float64" {
783
+		day_count := int64(json["day_count"].(float64))
784
+		project.DayCount = day_count
785
+	}
786
+
787
+	if json["week_day"] != nil || reflect.TypeOf(json["week_day"]).String() == "string" {
788
+		week_day, _ := json["week_day"].(string)
789
+		project.WeekDay = week_day
790
+	}
791
+
792
+	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
793
+		types := int64(json["type"].(float64))
794
+		project.Type = types
795
+	}
796
+	if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
797
+		project_id := int64(json["project_id"].(float64))
798
+		project.ProjectId = project_id
799
+	}
800
+
801
+	if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
802
+		price, _ := strconv.ParseFloat(json["price"].(string), 64)
803
+		project.Price = price
804
+	}
805
+
806
+	if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
807
+		total, _ := json["total"].(string)
808
+		//totals, _ := strconv.ParseInt(total, 10, 64)
809
+		project.Count = total
810
+	}
811
+
812
+	if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
813
+		medical_code, _ := json["medical_code"].(string)
814
+		project.MedListCodg = medical_code
815
+	}
816
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
817
+		single_dose, _ := json["single_dose"].(string)
818
+		project.SingleDose = single_dose
819
+	}
820
+
821
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
822
+		delivery_way, _ := json["delivery_way"].(string)
823
+		project.DeliveryWay = delivery_way
824
+	}
825
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
826
+		execution_frequency, _ := json["execution_frequency"].(string)
827
+		project.ExecutionFrequency = execution_frequency
828
+	}
829
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
830
+		remark, _ := json["remark"].(string)
831
+		project.Remark = remark
832
+	}
833
+	if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
834
+		day, _ := json["number_days"].(string)
835
+		project.Day = day
836
+	}
837
+
838
+	if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
839
+		unit, _ := json["unit"].(string)
840
+		project.Unit = unit
841
+	}
842
+	return 0
843
+}
844
+
845
+func (c *HisConfigApiController) DeleteModePrescriptionTemplate() {
846
+	id, _ := c.GetInt64("id")
847
+	err := service.DelelteHisModePrescriptionTemplate(id, c.GetAdminUserInfo().CurrentOrgId)
848
+	if err == nil {
849
+		c.ServeSuccessJSON(map[string]interface{}{
850
+			"msg": "删除成功",
851
+		})
852
+		return
853
+	} else {
854
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
855
+		return
856
+	}
857
+
858
+}
859
+
860
+func (c *HisConfigApiController) DeleteModeProjectTemplate() {
861
+	id, _ := c.GetInt64("id")
862
+	err := service.DelelteHisModePrescriptionProjectTemplate(id, c.GetAdminUserInfo().CurrentOrgId)
863
+	if err == nil {
864
+		c.ServeSuccessJSON(map[string]interface{}{
865
+			"msg": "删除成功",
866
+		})
867
+		return
868
+	} else {
869
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
870
+		return
871
+	}
872
+}
873
+
874
+func (c *HisConfigApiController) DeleteModeAdviceTemplate() {
875
+	id, _ := c.GetInt64("id")
876
+	err := service.DelelteHisModePrescriptionAdviceTemplate(id, c.GetAdminUserInfo().CurrentOrgId)
877
+	if err == nil {
878
+		c.ServeSuccessJSON(map[string]interface{}{
879
+			"msg": "删除成功",
880
+		})
881
+		return
882
+	} else {
883
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
884
+		return
885
+	}
886
+}
887
+
888
+func (c *HisConfigApiController) DeletePrescriptionInfoModeTemplate() {
889
+	prescription_id, _ := c.GetInt64("id")
890
+	err := service.DelelteHisPrescriptionInfoModeTemplate(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
891
+	if err == nil {
892
+		c.ServeSuccessJSON(map[string]interface{}{
893
+			"msg": "删除成功",
894
+		})
895
+		return
896
+	} else {
897
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
898
+		return
899
+	}
900
+}

+ 54 - 0
controllers/his_summary_controller.go View File

@@ -0,0 +1,54 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"github.com/astaxie/beego"
7
+	"time"
8
+)
9
+
10
+type HisSummaryApiController struct {
11
+	BaseAuthAPIController
12
+}
13
+
14
+func HisSummaryApiRegistRouters() {
15
+
16
+	beego.Router("/api/gethissummarydetaillist", &HisSummaryApiController{}, "Get:GetHisSummaryDetailList")
17
+
18
+}
19
+
20
+func (this *HisSummaryApiController) GetHisSummaryDetailList() {
21
+
22
+	start_time := this.GetString("start_time")
23
+	end_time := this.GetString("end_time")
24
+	keyword := this.GetString("keyword")
25
+	item_type, _ := this.GetInt64("type")
26
+	patient_id, _ := this.GetInt64("patient_id")
27
+	adminUser := this.GetAdminUserInfo()
28
+
29
+	timeLayout := "2006-01-02"
30
+	loc, _ := time.LoadLocation("Local")
31
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
32
+	if err != nil {
33
+
34
+	}
35
+	startRecordDateTime := startTime.Unix()
36
+
37
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
38
+	if err != nil {
39
+
40
+	}
41
+	endRecordDateTime := endTime.Unix()
42
+
43
+	list, err := service.GetHisSummaryDetailList(keyword, item_type, patient_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
44
+	if err == nil {
45
+		this.ServeSuccessJSON(map[string]interface{}{
46
+			"list": list,
47
+		})
48
+		return
49
+	} else {
50
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
51
+		return
52
+
53
+	}
54
+}

+ 20 - 17
controllers/schedule_api_controller.go View File

@@ -2186,6 +2186,7 @@ func (this *ScheduleApiController) GetCopyPatientSchedules() {
2186 2186
 	//先清除复制周的排班
2187 2187
 	errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
2188 2188
 	fmt.Println(errcode)
2189
+	var err error
2189 2190
 	for _, item := range schedules {
2190 2191
 		//fmt.Println(item.StartTime+604800)
2191 2192
 		//礼拜1
@@ -2225,25 +2226,27 @@ func (this *ScheduleApiController) GetCopyPatientSchedules() {
2225 2226
 			CreatedTime:  time.Now().Unix(),
2226 2227
 		}
2227 2228
 
2228
-		err := service.AddPatientSchedule(&schedule)
2229
-		patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
2230
-		for _, it := range patientList {
2231
-			timeStr := time.Now().Format("2006-01-02")
2232
-			timeLayout := "2006-01-02 15:04:05"
2233
-			timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
2234
-			timenow := timeStringToTime.Unix()
2235
-			service.UpdateScheduleByDeathTime(it.ID, timenow)
2236
-			service.UpdateScheduleItemByPatientId(it.ID)
2237
-		}
2229
+		err = service.AddPatientSchedule(&schedule)
2238 2230
 
2239
-		if err != nil {
2240
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2241
-			return
2242
-		}
2243
-		this.ServeSuccessJSON(map[string]interface{}{
2244
-			"schedule": schedule,
2245
-		})
2246 2231
 	}
2232
+	patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
2233
+	timeStr := time.Now().Format("2006-01-02")
2234
+	timeLayout := "2006-01-02 15:04:05"
2235
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
2236
+	timenow := timeStringToTime.Unix()
2237
+	for _, it := range patientList {
2238
+		service.UpdateScheduleByDeathTime(it.ID, timenow)
2239
+		service.UpdateScheduleItemByPatientId(it.ID)
2240
+	}
2241
+
2242
+	if err != nil {
2243
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2244
+		return
2245
+	}
2246
+	this.ServeSuccessJSON(map[string]interface{}{
2247
+		"msg": "msg",
2248
+	})
2249
+	return
2247 2250
 	//查询复制中的排班日期是否存在
2248 2251
 	//_, errcode := service.GetLastWeekSchedule(orgId, copy_startime, copy_endtime)
2249 2252
 	//

+ 1 - 0
controllers/stock_in_api_controller.go View File

@@ -714,6 +714,7 @@ func (c *StockManagerApiController) EditWarehouse() {
714 714
 				SystemTime:          ctime,
715 715
 				ConsumableType:      1,
716 716
 				WarehousingDetailId: info.ID,
717
+				StorehouseId:        storehouse_id,
717 718
 			}
718 719
 			_, errcodescode := service.GetGoodStockFlowInfo(info.ID, info.GoodId)
719 720
 

+ 134 - 0
models/his_summary_models.go View File

@@ -0,0 +1,134 @@
1
+package models
2
+
3
+type HisPrescriptionModeTemplate struct {
4
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	PatientId int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
7
+	Type      int64  `gorm:"column:type" json:"type" form:"type"`
8
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
9
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
10
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
11
+	Name      string `gorm:"column:name" json:"name" form:"name"`
12
+	Mode      int64  `gorm:"column:mode" json:"mode" form:"mode"`
13
+}
14
+
15
+func (HisPrescriptionModeTemplate) TableName() string {
16
+	return "his_prescription_mode_template"
17
+}
18
+
19
+type HisPrescriptionInfoModeTemplate struct {
20
+	ID                             int64                                 `gorm:"column:id" json:"id" form:"id"`
21
+	UserOrgId                      int64                                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
22
+	RecordDate                     int64                                 `gorm:"column:record_date" json:"record_date" form:"record_date"`
23
+	PatientId                      int64                                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
24
+	Status                         int64                                 `gorm:"column:status" json:"status" form:"status"`
25
+	Ctime                          int64                                 `gorm:"column:ctime" json:"ctime" form:"ctime"`
26
+	Mtime                          int64                                 `gorm:"column:mtime" json:"mtime" form:"mtime"`
27
+	Type                           int64                                 `gorm:"column:type" json:"type" form:"type"`
28
+	Creator                        int64                                 `gorm:"column:creator" json:"creator" form:"creator"`
29
+	Modifier                       int64                                 `gorm:"column:modifier" json:"modifier" form:"modifier"`
30
+	PType                          int64                                 `gorm:"column:p_type" json:"p_type" form:"p_type"`
31
+	PTemplateId                    int64                                 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
32
+	HisPrescriptionAdviceTemplate  []*HisPrescriptionAdviceModeTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
33
+	HisPrescriptionProjectTemplate []*HisPrescriptionProjectModeTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
34
+	MedType                        string                                `gorm:"column:med_type" json:"med_type" form:"med_type"`
35
+}
36
+
37
+func (HisPrescriptionInfoModeTemplate) TableName() string {
38
+	return "his_prescription_info_mode_template"
39
+}
40
+
41
+type HisPrescriptionAdviceModeTemplate struct {
42
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
43
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
44
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
45
+	HisPatientId          int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
46
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
47
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
48
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
49
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
50
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
51
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
52
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
53
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
54
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
55
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
56
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
57
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
58
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
59
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
60
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
61
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
62
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
63
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
64
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
65
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
66
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
67
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
68
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
69
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
70
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
71
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
72
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
73
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
74
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
75
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
76
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
77
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
78
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
79
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
80
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
81
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
82
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
83
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
84
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
85
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
86
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
87
+	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
88
+	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
89
+	MedListCodg           string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
90
+	FeedetlSn             string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
91
+	Day                   int64   `gorm:"column:day" json:"day" form:"day"`
92
+	Diagnosis             int64   `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
93
+	HospApprFlag          int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
94
+	LmtUsedFlag           int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
95
+	PrescriptionModeId    int64   `gorm:"column:prescription_mode_id" json:"prescription_mode_id" form:"prescription_mode_id"`
96
+	Drug                  Drug    `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
97
+}
98
+
99
+func (HisPrescriptionAdviceModeTemplate) TableName() string {
100
+	return "his_prescription_advice_mode_template"
101
+}
102
+
103
+type HisPrescriptionProjectModeTemplate struct {
104
+	ID                 int64        `gorm:"column:id" json:"id" form:"id"`
105
+	ProjectId          int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
106
+	Price              float64      `gorm:"column:price" json:"price" form:"price"`
107
+	UserOrgId          int64        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
108
+	Status             int64        `gorm:"column:status" json:"status" form:"status"`
109
+	Ctime              int64        `gorm:"column:ctime" json:"ctime" form:"ctime"`
110
+	Mtime              int64        `gorm:"column:mtime" json:"mtime" form:"mtime"`
111
+	PatientId          int64        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
112
+	HisPatientId       int64        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
113
+	RecordDate         int64        `gorm:"column:record_date" json:"record_date" form:"record_date"`
114
+	Count              string       `gorm:"column:count" json:"count" form:"count"`
115
+	FeedetlSn          string       `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
116
+	MedListCodg        string       `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
117
+	SingleDose         string       `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
118
+	DeliveryWay        string       `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
119
+	ExecutionFrequency string       `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
120
+	Day                string       `gorm:"column:day" json:"day" form:"day"`
121
+	Remark             string       `gorm:"column:remark" json:"remark" form:"remark"`
122
+	Unit               string       `gorm:"column:unit" json:"unit" form:"unit"`
123
+	Type               int64        `gorm:"column:type" json:"type" form:"type"`
124
+	PrescriptionId     int64        `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
125
+	XtHisProject       XtHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
126
+	GoodInfo           GoodInfo     `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
127
+	FrequencyType      int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
128
+	DayCount           int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
129
+	WeekDay            string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
130
+}
131
+
132
+func (HisPrescriptionProjectModeTemplate) TableName() string {
133
+	return "his_prescription_project_mode_template"
134
+}

+ 1 - 0
routers/router.go View File

@@ -81,4 +81,5 @@ func init() {
81 81
 	controllers.SupplyOrderApiRegistRouters()
82 82
 	controllers.SecondaryOrderApiRegistRouters()
83 83
 	controllers.HisDepositApiRegistRouters()
84
+	controllers.HisSummaryApiRegistRouters()
84 85
 }

+ 48 - 25
service/dialysis_service.go View File

@@ -697,21 +697,32 @@ func GetLastAcceptsAssessment(patient int64, orgId int64) (error, models.Receive
697 697
 }
698 698
 
699 699
 func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partitionType int64, page int64, limit int64, start int64, end int64) (schedule []*models.DialysisSchedule, err error, total int64) {
700
-	db := readDb.
701
-		Model(&models.MonitorDialysisSchedule{}).
702
-		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
703
-		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
704
-		Preload("TreatmentMode", "status = 1").
705
-		Preload("Prescription", "status = 1 AND user_org_id = ? and record_date>=? and record_date <=?", orgID, start, end).
706
-		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, start, end).
707
-		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, start, end).
708
-		Preload("MonitoringRecord", func(db *gorm.DB) *gorm.DB {
709
-			return db.Where("status = 1 AND user_org_id = ? and monitoring_date >=? and monitoring_date<=? ", orgID, start, end).Order("operate_time asc")
710
-		}).
711
-		Preload("DialysisOrder", "status = 1 AND user_org_id = ? and dialysis_date>=? and dialysis_date<=?", orgID, start, end).
712
-		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
713
-	db = db.Where("xt_schedule.status = 1 AND user_org_id = ?", orgID)
700
+	db := readDb.Model(&models.MonitorDialysisSchedule{})
701
+	if start > 0 && end > 0 {
702
+		db = db.Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
703
+			Preload("TreatmentMode", "status = 1").
704
+			Preload("Prescription", "status = 1 AND user_org_id = ? and record_date>=? and record_date <=?", orgID, start, end).
705
+			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, start, end).
706
+			Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, start, end).
707
+			Preload("MonitoringRecord", func(db *gorm.DB) *gorm.DB {
708
+				return db.Where("status = 1 AND user_org_id = ? and monitoring_date >=? and monitoring_date<=? ", orgID, start, end).Order("operate_time asc")
709
+			}).
710
+			Preload("DialysisOrder", "status = 1 AND user_org_id = ? and dialysis_date>=? and dialysis_date<=?", orgID, start, end).
711
+			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
712
+		db = db.Where("xt_schedule.status = 1 AND user_org_id = ?", orgID)
713
+	}
714 714
 	if schedulDate > 0 {
715
+		db = db.Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
716
+			Preload("TreatmentMode", "status = 1").
717
+			Preload("Prescription", "status = 1 AND user_org_id = ? and record_date>=? and record_date <=?", orgID, schedulDate, schedulDate).
718
+			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, schedulDate, schedulDate).
719
+			Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, schedulDate, schedulDate).
720
+			Preload("MonitoringRecord", func(db *gorm.DB) *gorm.DB {
721
+				return db.Where("status = 1 AND user_org_id = ? and monitoring_date >=? and monitoring_date<=? ", orgID, schedulDate, schedulDate).Order("operate_time asc")
722
+			}).
723
+			Preload("DialysisOrder", "status = 1 AND user_org_id = ? and dialysis_date>=? and dialysis_date<=?", orgID, schedulDate, schedulDate).
724
+			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
725
+		db = db.Where("xt_schedule.status = 1 AND user_org_id = ?", orgID)
715 726
 		db = db.Where("schedule_date = ?", schedulDate)
716 727
 	}
717 728
 	if schedulType > 0 {
@@ -758,17 +769,29 @@ func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, p
758 769
 		patientIDs[index] = patient.ID
759 770
 	}
760 771
 
761
-	db := readDb.
762
-		Model(&models.DialysisSchedule{}).
763
-		Preload("DeviceNumber", "org_id = ?", orgID).
764
-		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
765
-		Preload("TreatmentMode", "status = 1").
766
-		Preload("Prescription", "status = 1 AND user_org_id = ? and record_date>=? and record_date<=?", orgID, start, end).
767
-		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? and assessment_date>=? and assessment_date<=?", orgID, start, end).
768
-		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? and assessment_date>=? and assessment_date<=?", orgID, start, end).
769
-		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ? and monitoring_date>=? and monitoring_date<=?", orgID, start, end).
770
-		Preload("DialysisOrder", "status = 1 AND user_org_id = ? and dialysis_date >= ? and dialysis_date<=?", orgID, start, end).
771
-		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
772
+	db := readDb.Model(&models.DialysisSchedule{})
773
+	if start > 0 && end > 0 {
774
+		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
775
+			// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
776
+			Preload("TreatmentMode", "status = 1").
777
+			Preload("Prescription", "status = 1 AND user_org_id = ? and record_date>=? and record_date<=?", orgID, start, end).
778
+			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? and assessment_date>=? and assessment_date<=?", orgID, start, end).
779
+			Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? and assessment_date>=? and assessment_date<=?", orgID, start, end).
780
+			Preload("MonitoringRecord", "status = 1 AND  user_org_id = ? and monitoring_date>=? and monitoring_date<=?", orgID, start, end).
781
+			Preload("DialysisOrder", "status = 1 AND user_org_id = ? and dialysis_date >= ? and dialysis_date<=?", orgID, start, end).
782
+			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
783
+	} else {
784
+		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
785
+			// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
786
+			Preload("TreatmentMode", "status = 1").
787
+			Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
788
+			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ?", orgID).
789
+			Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ?", orgID).
790
+			Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?", orgID).
791
+			Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
792
+			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
793
+	}
794
+
772 795
 	db = db.Where("xt_schedule.status = 1 AND patient_id in (?)", patientIDs)
773 796
 	if schedulType > 0 {
774 797
 		db = db.Where("schedule_type = ?", schedulType)

+ 7 - 2
service/his_config_service.go View File

@@ -17,8 +17,13 @@ func GetHisPrescriptionTemplateByID(template_id int64) (prescription models.HisP
17 17
 	return
18 18
 }
19 19
 
20
-func GetHisPrescriptionTemplateByModeId(mode_id int64, patient_id int64) (prescription models.HisPrescriptionTemplate, err error) {
21
-	err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("mode = ? AND status = 1 AND patient_id = ?", mode_id, patient_id).First(&prescription).Error
20
+func GetHisPrescriptionTemplateByModeId(mode_id int64, patient_id int64, user_org_id int64) (prescription models.HisPrescriptionTemplate, err error) {
21
+	err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("mode = ? AND status = 1 AND patient_id = ? and user_org_id = ?", mode_id, patient_id, user_org_id).First(&prescription).Error
22
+	return
23
+}
24
+
25
+func GetHisPrescriptionTemplateByModeIdTwo(mode_id int64, patient_id int64, user_org_id int64, id int64) (prescription models.HisPrescriptionTemplate, err error) {
26
+	err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("mode = ? AND status = 1 AND patient_id = ? and user_org_id = ? and id <> ?", mode_id, patient_id, user_org_id, id).First(&prescription).Error
22 27
 	return
23 28
 }
24 29
 

+ 265 - 0
service/his_summary_service.go View File

@@ -0,0 +1,265 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+	"time"
7
+)
8
+
9
+func GetHisSummaryDetailList(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (patients []*models.ChargePatient, err error) {
10
+
11
+	if len(keyword) == 0 {
12
+		switch item_type {
13
+		case 0:
14
+			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
15
+				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
16
+					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
17
+						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
18
+							Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
19
+								return db.Preload("Drug", "status = 1").Where("status = 1")
20
+							}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
21
+							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
22
+								return db.Select("id,project_name,unit").Where("status = 1 ")
23
+							}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
24
+								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
25
+							}).Where("status = 1 ")
26
+						})
27
+					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
28
+			}).Where("p.status = 1  AND p.user_org_id = ? and p.id = ?", org_id, patient_id).Group("id").Find(&patients).Error
29
+
30
+			break
31
+		case 1:
32
+			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
33
+				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
34
+					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
35
+						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id > 0 AND project_id = 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
36
+							return db.Preload("Drug", "status = 1").Where("status = 1")
37
+						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
38
+							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
39
+								return db.Select("id,project_name,unit").Where("status = 1 ")
40
+							}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
41
+								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
42
+							}).Where("status = 1 ")
43
+						})
44
+					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
45
+			}).Where("p.status = 1  AND p.user_org_id = ? and p.id = ?", org_id, patient_id).Group("id").Find(&patients).Error
46
+
47
+			break
48
+		case 2:
49
+			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and order.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
50
+				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
51
+					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
52
+						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
53
+							return db.Preload("Drug", "status = 1").Where("status = 1")
54
+						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
55
+							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
56
+								return db.Select("id,project_name,unit").Where("status = 1 ")
57
+							}).Where("status = 1 ")
58
+						})
59
+					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
60
+			}).Where("p.status = 1  AND p.user_org_id = ? and p.id = ?", org_id, patient_id).Group("id").Find(&patients).Error
61
+
62
+			break
63
+		case 3:
64
+			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
65
+				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
66
+					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
67
+						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
68
+							return db.Preload("Drug", "status = 1").Where("status = 1")
69
+						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
70
+							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
71
+								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
72
+							}).Where("status = 1 ")
73
+						})
74
+					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
75
+			}).Where("p.status = 1  AND p.user_org_id = ? and p.id =?", org_id, patient_id).Group("id").Find(&patients).Error
76
+
77
+			break
78
+
79
+		}
80
+
81
+	} else {
82
+		keyword := "%" + keyword + "%"
83
+		switch item_type {
84
+		case 0:
85
+			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
86
+				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
87
+					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
88
+						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
89
+							return db.Preload("Drug", "status = 1").Where("status = 1")
90
+						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
91
+							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
92
+								return db.Select("id,project_name,unit").Where("status = 1 ")
93
+							}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
94
+								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
95
+							}).Where("status = 1 ")
96
+						})
97
+					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
98
+			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
99
+
100
+			break
101
+		case 1:
102
+			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and AND orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
103
+				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
104
+					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
105
+						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id > 0 AND project_id = 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
106
+							return db.Preload("Drug", "status = 1").Where("status = 1")
107
+						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
108
+							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
109
+								return db.Select("id,project_name,unit").Where("status = 1 ")
110
+							}).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
111
+								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
112
+							}).Where("status = 1 ")
113
+						})
114
+					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
115
+			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
116
+
117
+			break
118
+		case 2:
119
+			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and  orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
120
+				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
121
+					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
122
+						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
123
+							return db.Preload("Drug", "status = 1").Where("status = 1")
124
+						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
125
+							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
126
+								return db.Select("id,project_name,unit").Where("status = 1 ")
127
+							}).Where("status = 1 ")
128
+						})
129
+					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
130
+			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
131
+
132
+			break
133
+		case 3:
134
+			err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
135
+				return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
136
+					Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
137
+						return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
138
+							return db.Preload("Drug", "status = 1").Where("status = 1")
139
+						}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
140
+							return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
141
+								return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
142
+							}).Where("status = 1 ")
143
+						})
144
+					}).Where("status = 1  AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
145
+			}).Where("p.status = 1  AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
146
+
147
+			break
148
+
149
+		}
150
+
151
+	}
152
+
153
+	return
154
+
155
+}
156
+
157
+func GetModeTemplateName(mode_id int64, user_org_id int64) (template []*models.HisPrescriptionModeTemplate, err error) {
158
+
159
+	err = XTReadDB().Where("mode = ? and user_org_id = ? and patient_id = ? and status = 1", mode_id, user_org_id, 0).Find(&template).Error
160
+	return template, err
161
+}
162
+
163
+func GetModeTemplateNameDetail(mode_id int64, user_org_id int64) (models.HisPrescriptionModeTemplate, error) {
164
+
165
+	template := models.HisPrescriptionModeTemplate{}
166
+	err := XTReadDB().Where("mode = ? and user_org_id = ? and status = 1 and patient_id= 0", mode_id, user_org_id).Find(&template).Error
167
+	return template, err
168
+}
169
+
170
+func GetModeTemplateInfo(id int64, user_org_id int64) (models.HisPrescriptionInfoTemplate, error) {
171
+
172
+	template := models.HisPrescriptionInfoTemplate{}
173
+	err := XTReadDB().Where("p_template_id = ? and user_org_id = ? and status = 1", id, user_org_id).Find(&template).Error
174
+	return template, err
175
+}
176
+
177
+func GetPrescriptionAdviceTemplateDetail(template_id int64, orgid int64) (template []*models.HisPrescriptionAdviceTemplate, err error) {
178
+
179
+	err = XTReadDB().Where("prescription_id in(?) and user_org_id = ? and status = 1", template_id, orgid).Find(&template).Error
180
+	return template, err
181
+}
182
+
183
+func GetPrescriptionProjectTemplateDetail(template_id int64, orgid int64) (template []*models.HisPrescriptionProjectTemplate, err error) {
184
+	err = XTReadDB().Where("prescription_id in(?) and user_org_id = ? and status = 1", template_id, orgid).Find(&template).Error
185
+	return template, err
186
+}
187
+
188
+func GetHisPrescriptionModeTemplate(template_id int64, org_id int64) (prescription []*models.HisPrescriptionInfoModeTemplate, err error) {
189
+	err = readDb.Model(&models.HisPrescriptionInfoModeTemplate{}).
190
+		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
191
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
192
+		}).
193
+		Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
194
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisProject").Preload("GoodInfo", "status=1")
195
+		}).
196
+		Where("status = 1 AND p_template_id = ? ", template_id).
197
+		Find(&prescription).Error
198
+	return
199
+}
200
+
201
+func GetHisModePrescriptionTemplateByID(template_id int64) (prescription models.HisPrescriptionModeTemplate, err error) {
202
+	err = readDb.Model(&models.HisPrescriptionModeTemplate{}).Where("id = ? AND status = 1 ", template_id).First(&prescription).Error
203
+	return
204
+}
205
+
206
+func CreateHisModePrescriptionTemplate(template *models.HisPrescriptionModeTemplate) (err error) {
207
+	err = writeDb.Create(&template).Error
208
+	return
209
+
210
+}
211
+
212
+func SaveHisModePrescriptionTemplate(template *models.HisPrescriptionModeTemplate) (err error) {
213
+	err = writeDb.Save(&template).Error
214
+	return
215
+
216
+}
217
+
218
+func CreateHisModePrescriptionInfoTemplate(s *models.HisPrescriptionInfoModeTemplate) (err error) {
219
+	err = writeDb.Save(&s).Error
220
+	return
221
+}
222
+
223
+func CreateHisModePrescriptionAdviceTemplate(s *models.HisPrescriptionAdviceModeTemplate) (err error) {
224
+	err = writeDb.Save(&s).Error
225
+	return
226
+}
227
+
228
+func GetHisModePrescriptionTemplateByModeId(mode_id int64, patient_id int64, user_org_id int64) (prescription models.HisPrescriptionModeTemplate, err error) {
229
+	err = readDb.Model(&models.HisPrescriptionModeTemplate{}).Where("mode = ? AND status = 1 AND patient_id = ? and user_org_id = ?", mode_id, patient_id, user_org_id).First(&prescription).Error
230
+	return
231
+}
232
+
233
+func GetHisModePrescriptionTemplateByModeIdTwo(mode_id int64, patient_id int64, user_org_id int64, id int64) (prescription models.HisPrescriptionModeTemplate, err error) {
234
+	err = readDb.Model(&models.HisPrescriptionModeTemplate{}).Where("mode = ? AND status = 1 AND patient_id = ? and user_org_id = ? and id <> ?", mode_id, patient_id, user_org_id, id).First(&prescription).Error
235
+	return
236
+}
237
+
238
+func CreateHisModePrescriptionProjectTemplate(project *models.HisPrescriptionProjectModeTemplate) (err error) {
239
+	err = writeDb.Save(&project).Error
240
+	return
241
+}
242
+
243
+func DelelteHisModePrescriptionTemplate(id int64, user_org_id int64) (err error) {
244
+	err = writeDb.Model(&models.HisPrescriptionModeTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
245
+	err = writeDb.Model(&models.HisPrescriptionInfoModeTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
246
+	return
247
+}
248
+
249
+func DelelteHisModePrescriptionProjectTemplate(id int64, user_org_id int64) (err error) {
250
+	err = writeDb.Model(&models.HisPrescriptionProjectModeTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
251
+
252
+	return
253
+}
254
+
255
+func DelelteHisModePrescriptionAdviceTemplate(id int64, user_org_id int64) (err error) {
256
+	err = writeDb.Model(&models.HisPrescriptionAdviceModeTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
257
+	return
258
+}
259
+
260
+func DelelteHisPrescriptionInfoModeTemplate(id int64, user_org_id int64) (err error) {
261
+	err = writeDb.Model(&models.HisPrescriptionInfoModeTemplate{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
262
+	err = writeDb.Model(&models.HisPrescriptionAdviceModeTemplate{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
263
+	err = writeDb.Model(&models.HisPrescriptionProjectModeTemplate{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
264
+	return
265
+}

+ 3 - 2
service/stock_service.go View File

@@ -420,11 +420,11 @@ func CreateWarehousingInfo(warehousingInfo []*models.WarehousingInfo) (err error
420 420
 	if len(warehousingInfo) > 0 {
421 421
 		utx := writeDb.Begin()
422 422
 		if len(warehousingInfo) > 0 {
423
-			thisSQL := "INSERT INTO xt_warehouse_info (warehousing_id, good_id, good_type_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,stock_count,license_number,packing_price) VALUES "
423
+			thisSQL := "INSERT INTO xt_warehouse_info (warehousing_id, good_id, good_type_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,stock_count,license_number,packing_price,storehouse_id) VALUES "
424 424
 			insertParams := make([]string, 0)
425 425
 			insertData := make([]interface{}, 0)
426 426
 			for _, info := range warehousingInfo {
427
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
427
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
428 428
 				insertData = append(insertData, info.WarehousingId)
429 429
 				insertData = append(insertData, info.GoodId)
430 430
 				insertData = append(insertData, info.GoodTypeId)
@@ -446,6 +446,7 @@ func CreateWarehousingInfo(warehousingInfo []*models.WarehousingInfo) (err error
446 446
 				insertData = append(insertData, info.WarehousingCount)
447 447
 				insertData = append(insertData, info.LicenseNumber)
448 448
 				insertData = append(insertData, info.PackingPrice)
449
+				insertData = append(insertData, info.StorehouseId)
449 450
 			}
450 451
 			thisSQL += strings.Join(insertParams, ", ")
451 452
 			err = utx.Exec(thisSQL, insertData...).Error