소스 검색

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

28169 1 개월 전
부모
커밋
bdd5d26aab
2개의 변경된 파일53개의 추가작업 그리고 15개의 파일을 삭제
  1. 5 5
      controllers/new_mobile_api_controllers/mobile_his_api_controller.go
  2. 48 10
      service/his_service.go

+ 5 - 5
controllers/new_mobile_api_controllers/mobile_his_api_controller.go 파일 보기

@@ -691,7 +691,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
691 691
 					tempPrescription.MedType = med_type
692 692
 
693 693
 				}
694
-				service.SaveHisPrescription(tempPrescription)
694
+				service.SaveHisPrescriptionTwo(tempPrescription)
695 695
 
696 696
 				//更改患者挂号状态
697 697
 				_, err2 := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.Org.Id)
@@ -725,7 +725,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
725 725
 								c.ServeFailJSONWithSGJErrorCode(errcode)
726 726
 								return
727 727
 							}
728
-							service.CreateHisDoctorAdvice(&s)
728
+							service.CreateHisDoctorAdviceTwo(&s)
729 729
 							redis := service.RedisClient()
730 730
 							key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
731 731
 							fmt.Println("key111111111111111111", key)
@@ -741,7 +741,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
741 741
 							tempTime := time.Unix(timestamp, 0)
742 742
 							timeFormat := tempTime.Format("20060102150405")
743 743
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
744
-							service.CreateHisDoctorAdvice(&s)
744
+							service.CreateHisDoctorAdviceTwo(&s)
745 745
 
746 746
 							redis.Set(key, "", time.Second)
747 747
 							keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
@@ -773,7 +773,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
773 773
 								c.ServeFailJSONWithSGJErrorCode(errcode)
774 774
 								return
775 775
 							}
776
-							service.CreateHisProjectTwo(&p)
776
+							service.CreateHisProjectThree(&p)
777 777
 
778 778
 							var randNum int
779 779
 							randNum = rand.Intn(10000) + 1000
@@ -781,7 +781,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
781 781
 							tempTime := time.Unix(timestamp, 0)
782 782
 							timeFormat := tempTime.Format("20060102150405")
783 783
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
784
-							service.SaveHisProjectTwo(&p)
784
+							service.CreateHisProjectThree(&p)
785 785
 
786 786
 							if p.Type == 3 { //处理透前准备耗材数量数据
787 787
 								consumables, _ := service.FindHisConsumablesByID(adminInfo.Org.Id, patient_id, recordDateTime, p.ProjectId)

+ 48 - 10
service/his_service.go 파일 보기

@@ -402,9 +402,7 @@ func UpdatePatientCaseHistory(patient_id int64, record_date int64, user_org_id i
402 402
 	return err
403 403
 }
404 404
 
405
-func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
406
-	tx := writeDb.Begin()
407
-
405
+func SaveHisPrescription(tx *gorm.DB, prescription *models.HisPrescription) (err error) {
408 406
 	if err = tx.Model(&models.HisPrescription{}).Save(prescription).Error; err != nil {
409 407
 		tx.Rollback()
410 408
 		return
@@ -413,6 +411,12 @@ func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
413 411
 	return
414 412
 }
415 413
 
414
+func SaveHisPrescriptionTwo(prescription *models.HisPrescription) (err error) {
415
+
416
+	err = writeDb.Model(&models.HisPrescription{}).Save(prescription).Error
417
+	return
418
+}
419
+
416 420
 func DelelteHisPrescription(id int64, user_org_id int64) (err error) {
417 421
 	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
418 422
 	err = writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
@@ -881,8 +885,17 @@ func GetHisAdminUserDoctors(org_id int64) (doctors []*models.UserAdminRole, err
881 885
 	return
882 886
 }
883 887
 
884
-func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
888
+func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo, tx *gorm.DB) (err error) {
889
+	if err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error; err != nil {
890
+		tx.Rollback()
891
+		return
892
+	}
893
+	tx.Commit()
885 894
 
895
+	return
896
+}
897
+
898
+func CreateHisDoctorAdviceTwo(s *models.HisDoctorAdviceInfo) (err error) {
886 899
 	tx := writeDb.Begin()
887 900
 	if err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error; err != nil {
888 901
 		tx.Rollback()
@@ -893,7 +906,17 @@ func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
893 906
 	return
894 907
 }
895 908
 
896
-func CreateHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
909
+func CreateHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
910
+	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {
911
+		tx.Rollback()
912
+		return
913
+	}
914
+	tx.Commit()
915
+
916
+	return
917
+}
918
+
919
+func CreateHisProjectThree(project *models.HisPrescriptionProject) (err error) {
897 920
 	tx := writeDb.Begin()
898 921
 	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {
899 922
 		tx.Rollback()
@@ -904,8 +927,14 @@ func CreateHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
904 927
 	return
905 928
 }
906 929
 
907
-func SaveHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
908
-	err = writeDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
930
+func SaveHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
931
+	//err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
932
+	if err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error; err != nil {
933
+		tx.Rollback()
934
+		return
935
+	}
936
+	tx.Commit()
937
+
909 938
 	return
910 939
 }
911 940
 
@@ -2593,9 +2622,18 @@ func DeletePrintInfo(id int64) {
2593 2622
 	writeDb.Model(&models.HisLabelPrintInfo{}).Where("p_project_id = ?", id).Updates(map[string]interface{}{"status": 0})
2594 2623
 }
2595 2624
 
2596
-func CreateHisLabelRecord(label *models.HisLabelPrintInfo) error {
2597
-	err := writeDb.Save(&label).Error
2598
-	return err
2625
+func CreateHisLabelRecord(label *models.HisLabelPrintInfo, tx *gorm.DB) (err error) {
2626
+	if err = tx.Save(&label).Error; err != nil {
2627
+		tx.Rollback()
2628
+		return
2629
+	}
2630
+	tx.Commit()
2631
+	return
2632
+}
2633
+
2634
+func CreateHisLabelRecordTwo(label *models.HisLabelPrintInfo) (err error) {
2635
+	err = writeDb.Save(&label).Error
2636
+	return
2599 2637
 }
2600 2638
 
2601 2639
 func DeletePsnNCDSRecordById(id int64) (err error) {