Pārlūkot izejas kodu

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

csx 4 gadus atpakaļ
vecāks
revīzija
1a49c84cf2

+ 4 - 0
controllers/his_api_controller.go Parādīt failu

@@ -731,6 +731,8 @@ func (c *HisApiController) CreateCaseHistoryTemplate() {
731 731
 	personal_history := c.GetString("personal_history")
732 732
 	family_history := c.GetString("family_history")
733 733
 	user_name := c.GetString("user_name")
734
+	doctor_advice := c.GetString("doctor_advice")
735
+	remark := c.GetString("remark")
734 736
 	//record_date := c.GetString("record_date")
735 737
 	//fmt.Println("record_date--------",record_date)
736 738
 	//timeLayout := "2006-01-02"
@@ -762,6 +764,8 @@ func (c *HisApiController) CreateCaseHistoryTemplate() {
762 764
 		Creator:                 doctor,
763 765
 		Modifier:                doctor,
764 766
 		UserName:                user_name,
767
+		DoctorAdvice:            doctor_advice,
768
+		Remark:                  remark,
765 769
 	}
766 770
 
767 771
 	err := service.SaveHisPatientCaseHistoryTemplate(template)

+ 117 - 2
controllers/his_project_api_controller.go Parādīt failu

@@ -80,6 +80,11 @@ func HisProjectRouters() {
80 80
 	beego.Router("/api/hispatient/getalldepartmentlist", &HisProjectApiController{}, "Get:GetAllDepartmentList")
81 81
 	beego.Router("/api/hispatient/getprescription", &HisProjectApiController{}, "Get:GetPrescription")
82 82
 	beego.Router("/api/histpatient/getpatientdetail", &HisProjectApiController{}, "Get:GetPatientDetail")
83
+	beego.Router("/api/hispatient/savemaintemplate", &HisProjectApiController{}, "Get:SaveMainTemplate")
84
+	beego.Router("/api/hispatient/getmedicaltemplatelist", &HisProjectApiController{}, "Get:GetMedicalTempalteList")
85
+	beego.Router("/api/hispatient/getmaintemplatebyid", &HisProjectApiController{}, "Get:GetMainTemplateById")
86
+	beego.Router("/api/hispatient/updatemaintemplate", &HisProjectApiController{}, "Get:UpdateMainTemplate")
87
+	beego.Router("/api/hispatient/deletemaintemplate", &HisProjectApiController{}, "Get:DeleteMainTemplate")
83 88
 }
84 89
 
85 90
 func (this *HisProjectApiController) SaveProject() {
@@ -932,8 +937,8 @@ func (this *HisProjectApiController) ChangePatient() {
932 937
 func (this *HisProjectApiController) GetPatientcaseHistory() {
933 938
 
934 939
 	patient_id, _ := this.GetInt64("patient_id")
935
-	patient, _ := service.GetBloodPatientInfoById(patient_id)
936
-	history, err := service.GetPatientCaseHistory(patient_id)
940
+	patient, err := service.GetBloodPatientInfoById(patient_id)
941
+	history, _ := service.GetPatientCaseHistory(patient_id)
937 942
 	hispatient, _ := service.GetHisPatientById(patient_id)
938 943
 
939 944
 	if err != nil {
@@ -972,6 +977,8 @@ func (this *HisProjectApiController) UpdateRecordTemplate() {
972 977
 	past_history := this.GetString("past_history")
973 978
 	personal_history := this.GetString("personal_history")
974 979
 	family_history := this.GetString("family_history")
980
+	doctor_advice := this.GetString("doctor_advice")
981
+	remark := this.GetString("remark")
975 982
 	adminUserInfo := this.GetAdminUserInfo()
976 983
 	creater := adminUserInfo.AdminUser.Id
977 984
 	historyTemplate := models.HisCaseHistoryTemplate{
@@ -987,6 +994,8 @@ func (this *HisProjectApiController) UpdateRecordTemplate() {
987 994
 		TemplateName:            template_name,
988 995
 		TemplateRemark:          template_remark,
989 996
 		Modifier:                creater,
997
+		DoctorAdvice:            doctor_advice,
998
+		Remark:                  remark,
990 999
 	}
991 1000
 	err := service.UpdateCaseHistoryTemplate(&historyTemplate, id)
992 1001
 	if err != nil {
@@ -1403,3 +1412,109 @@ func (this *HisProjectApiController) GetPatientDetail() {
1403 1412
 		"patient": patient,
1404 1413
 	})
1405 1414
 }
1415
+
1416
+func (this *HisProjectApiController) SaveMainTemplate() {
1417
+
1418
+	title := this.GetString("title")
1419
+	content := this.GetString("content")
1420
+	remark := this.GetString("remark")
1421
+	template_id, _ := this.GetInt64("template_id")
1422
+	adminUserInfo := this.GetAdminUserInfo()
1423
+	orgId := adminUserInfo.CurrentOrgId
1424
+	template := models.XtHisMedicalTemplate{
1425
+		Title:      title,
1426
+		Content:    content,
1427
+		Remark:     remark,
1428
+		UserOrgId:  orgId,
1429
+		TemplateId: template_id,
1430
+		Status:     1,
1431
+		Ctime:      time.Now().Unix(),
1432
+	}
1433
+	err := service.CreateHisMedicalTemplate(&template)
1434
+	if err != nil {
1435
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1436
+		return
1437
+	}
1438
+	this.ServeSuccessJSON(map[string]interface{}{
1439
+		"template": template,
1440
+	})
1441
+}
1442
+
1443
+func (this *HisProjectApiController) GetMedicalTempalteList() {
1444
+
1445
+	adminUserInfo := this.GetAdminUserInfo()
1446
+	orgId := adminUserInfo.CurrentOrgId
1447
+	list, err := service.GetMedicalTemplateList(orgId)
1448
+	listOne, err := service.GetMedicalTemplateListOne(orgId)
1449
+	listTwo, err := service.GetMedicalTemplateListTwo(orgId)
1450
+	listThree, err := service.GetMedicalTemplateListThree(orgId)
1451
+	listFour, err := service.GetMedicalTemplateListFour(orgId)
1452
+	listFive, err := service.GetMedicalTemplateListFive(orgId)
1453
+	listSix, err := service.GetMedicalTemplateListSix(orgId)
1454
+	listSeven, err := service.GetMedicalTemplateListSeven(orgId)
1455
+	if err != nil {
1456
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1457
+		return
1458
+	}
1459
+	this.ServeSuccessJSON(map[string]interface{}{
1460
+		"list":      list,
1461
+		"listOne":   listOne,
1462
+		"listTwo":   listTwo,
1463
+		"listThree": listThree,
1464
+		"listFour":  listFour,
1465
+		"listFive":  listFive,
1466
+		"listSix":   listSix,
1467
+		"listSeven": listSeven,
1468
+	})
1469
+}
1470
+
1471
+func (this *HisProjectApiController) GetMainTemplateById() {
1472
+
1473
+	id, _ := this.GetInt64("id")
1474
+	template, err := service.GetMainTemplateById(id)
1475
+	if err != nil {
1476
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1477
+		return
1478
+	}
1479
+	this.ServeSuccessJSON(map[string]interface{}{
1480
+		"template": template,
1481
+	})
1482
+}
1483
+
1484
+func (this *HisProjectApiController) UpdateMainTemplate() {
1485
+
1486
+	title := this.GetString("title")
1487
+	content := this.GetString("content")
1488
+	remark := this.GetString("remark")
1489
+	id, _ := this.GetInt64("id")
1490
+
1491
+	template := models.XtHisMedicalTemplate{
1492
+		Title:   title,
1493
+		Content: content,
1494
+		Remark:  remark,
1495
+	}
1496
+
1497
+	err := service.UpdateMainTemplate(&template, id)
1498
+	if err != nil {
1499
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1500
+		return
1501
+	}
1502
+	this.ServeSuccessJSON(map[string]interface{}{
1503
+		"template": template,
1504
+	})
1505
+}
1506
+
1507
+func (this *HisProjectApiController) DeleteMainTemplate() {
1508
+
1509
+	id, _ := this.GetInt64("id")
1510
+	err := service.DeleteMainTemplateById(id)
1511
+	if err != nil {
1512
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1513
+		return
1514
+	}
1515
+	returnData := make(map[string]interface{}, 0)
1516
+	returnData["msg"] = "ok"
1517
+	this.ServeSuccessJSON(returnData)
1518
+	return
1519
+
1520
+}

+ 18 - 0
models/his_models.go Parādīt failu

@@ -158,6 +158,8 @@ type HisCaseHistoryTemplate struct {
158 158
 	Creator                 int64  `gorm:"column:creator" json:"creator" form:"creator"`
159 159
 	Modifier                int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
160 160
 	UserName                string `gorm:"column:user_name" json:"user_name" form:"user_name"`
161
+	DoctorAdvice            string `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
162
+	Remark                  string `gorm:"column:remark" json:"remark" form:"remark"`
161 163
 }
162 164
 
163 165
 func (HisCaseHistoryTemplate) TableName() string {
@@ -852,6 +854,22 @@ func (XtHisAdditionalCharge) TableName() string {
852 854
 	return "his_additional_charge"
853 855
 }
854 856
 
857
+type XtHisMedicalTemplate struct {
858
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
859
+	Title      string `gorm:"column:title" json:"title" form:"title"`
860
+	Content    string `gorm:"column:content" json:"content" form:"content"`
861
+	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
862
+	TemplateId int64  `gorm:"column:template_id" json:"template_id" form:"template_id"`
863
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
864
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
865
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
866
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
867
+}
868
+
869
+func (XtHisMedicalTemplate) TableName() string {
870
+	return "xt_his_medical_template"
871
+}
872
+
855 873
 type HisXtDiagnoseConfig struct {
856 874
 	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
857 875
 	ClassName          string `gorm:"column:class_name" json:"class_name" form:"class_name"`

+ 76 - 1
service/his_project_service.go Parādīt failu

@@ -377,7 +377,7 @@ func GetTemplateDetail(id int64) (models.HisCaseHistoryTemplate, error) {
377 377
 
378 378
 func UpdateCaseHistoryTemplate(tem *models.HisCaseHistoryTemplate, id int64) error {
379 379
 
380
-	err := XTWriteDB().Model(&tem).Where("id = ? ", id).Updates(map[string]interface{}{"history_of_present_illness": tem.HistoryOfPresentIllness, "past_history": tem.PastHistory, "chief_conplaint": tem.ChiefConplaint, "personal_history": tem.PersonalHistory, "family_history": tem.FamilyHistory, "diagnostic": tem.Diagnostic, "template_name": tem.TemplateName, "template_remark": tem.TemplateRemark, "modifier": tem.Modifier}).Error
380
+	err := XTWriteDB().Model(&tem).Where("id = ? ", id).Updates(map[string]interface{}{"history_of_present_illness": tem.HistoryOfPresentIllness, "past_history": tem.PastHistory, "chief_conplaint": tem.ChiefConplaint, "personal_history": tem.PersonalHistory, "family_history": tem.FamilyHistory, "diagnostic": tem.Diagnostic, "template_name": tem.TemplateName, "template_remark": tem.TemplateRemark, "modifier": tem.Modifier, "doctor_advice": tem.DoctorAdvice, "remark": tem.Remark}).Error
381 381
 	return err
382 382
 }
383 383
 
@@ -602,3 +602,78 @@ func GetTodayHisPatient(recod_date int64, patientid int64, user_org_id int64) (*
602 602
 	}
603 603
 	return &patient, nil
604 604
 }
605
+
606
+func CreateHisMedicalTemplate(template *models.XtHisMedicalTemplate) error {
607
+
608
+	err := XTWriteDB().Create(&template).Error
609
+	return err
610
+}
611
+
612
+func GetMedicalTemplateList(orgid int64) (template []*models.XtHisMedicalTemplate, err error) {
613
+
614
+	err = XTReadDB().Model(&template).Where("user_org_id =? and status = 1 and template_id = 1", orgid).Find(&template).Error
615
+	return template, err
616
+}
617
+
618
+func GetMedicalTemplateListOne(orgid int64) (template []*models.XtHisMedicalTemplate, err error) {
619
+
620
+	err = XTReadDB().Model(&template).Where("user_org_id =? and status = 1 and template_id = 2", orgid).Find(&template).Error
621
+	return template, err
622
+}
623
+
624
+func GetMedicalTemplateListTwo(orgid int64) (template []*models.XtHisMedicalTemplate, err error) {
625
+
626
+	err = XTReadDB().Model(&template).Where("user_org_id =? and status = 1 and template_id = 3", orgid).Find(&template).Error
627
+	return template, err
628
+}
629
+
630
+func GetMedicalTemplateListThree(orgid int64) (template []*models.XtHisMedicalTemplate, err error) {
631
+
632
+	err = XTReadDB().Model(&template).Where("user_org_id =? and status = 1 and template_id = 4", orgid).Find(&template).Error
633
+	return template, err
634
+}
635
+
636
+func GetMedicalTemplateListFour(orgid int64) (template []*models.XtHisMedicalTemplate, err error) {
637
+
638
+	err = XTReadDB().Model(&template).Where("user_org_id =? and status = 1 and template_id = 5", orgid).Find(&template).Error
639
+	return template, err
640
+}
641
+
642
+func GetMedicalTemplateListFive(orgid int64) (template []*models.XtHisMedicalTemplate, err error) {
643
+
644
+	err = XTReadDB().Model(&template).Where("user_org_id =? and status = 1 and template_id = 6", orgid).Find(&template).Error
645
+	return template, err
646
+}
647
+
648
+func GetMedicalTemplateListSix(orgid int64) (template []*models.XtHisMedicalTemplate, err error) {
649
+
650
+	err = XTReadDB().Model(&template).Where("user_org_id =? and status = 1 and template_id = 7", orgid).Find(&template).Error
651
+	return template, err
652
+}
653
+
654
+func GetMedicalTemplateListSeven(orgid int64) (template []*models.XtHisMedicalTemplate, err error) {
655
+
656
+	err = XTReadDB().Model(&template).Where("user_org_id =? and status = 1 and template_id = 8", orgid).Find(&template).Error
657
+	return template, err
658
+}
659
+
660
+func GetMainTemplateById(id int64) (models.XtHisMedicalTemplate, error) {
661
+
662
+	template := models.XtHisMedicalTemplate{}
663
+	err := XTReadDB().Model(&template).Where("id=? and status = 1", id).Find(&template).Error
664
+	return template, err
665
+}
666
+
667
+func UpdateMainTemplate(template *models.XtHisMedicalTemplate, id int64) error {
668
+
669
+	err := XTWriteDB().Model(&template).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"title": template.Title, "content": template.Content, "remark": template.Remark, "mtime": time.Now().Unix()}).Error
670
+	return err
671
+}
672
+
673
+func DeleteMainTemplateById(id int64) error {
674
+
675
+	template := models.XtHisMedicalTemplate{}
676
+	err := XTWriteDB().Model(&template).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
677
+	return err
678
+
679
+}

+ 6 - 2
service/stock_service.go Parādīt failu

@@ -1148,10 +1148,14 @@ func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string, star
1148 1148
 
1149 1149
 	db := readDb.Model(&models.StockInfo{})
1150 1150
 	if startime > 0 {
1151
-		db = db.Where("ctime >=?", startime)
1151
+		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
1152
+			return db.Where("org_id = ? AND status = 1 and sys_record_time>=?", orgId, startime)
1153
+		})
1152 1154
 	}
1153 1155
 	if endtime > 0 {
1154
-		db = db.Where("ctime<=?", endtime)
1156
+		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
1157
+			return db.Where("org_id = ? AND status = 1 and sys_record_time>=? and  sys_record_time<=?", orgId, startime, endtime)
1158
+		})
1155 1159
 	}
1156 1160
 	db = db.Where("xt_good_information.org_id = ? AND xt_good_information.status = 1", orgId)
1157 1161
 	db = db.Group("xt_good_information.id")