Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
5d48d5f40e

+ 3 - 0
controllers/his_api_controller.go View File

@@ -319,6 +319,9 @@ func (c *HisApiController) CreateHisPrescription() {
319 319
 				}
320 320
 				service.SaveHisPrescription(prescription)
321 321
 
322
+				//更改患者挂号状态
323
+				_, err := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.CurrentOrgId)
324
+				fmt.Println("更改失败", err)
322 325
 				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
323 326
 					advices := items["advices"].([]interface{})
324 327
 					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)

+ 25 - 15
controllers/his_project_api_controller.go View File

@@ -764,6 +764,7 @@ func (this *HisProjectApiController) SaveHisPatient() {
764 764
 			Phone:                  phone,
765 765
 			SocialType:             social_type,
766 766
 		}
767
+
767 768
 		err := service.CreateHisPatient(&patient)
768 769
 		lastPatient, err := service.GetLastPatient(orgId)
769 770
 		timeStr := time.Now().Format("2006-01-02")
@@ -810,24 +811,33 @@ func (this *HisProjectApiController) SaveHisPatient() {
810 811
 			Status:                 1,
811 812
 			IsReturn:               1,
812 813
 		}
813
-		err := service.CreateHisPatient(&patient)
814
-		lastPatient, err := service.GetLastPatient(orgId)
815
-		timeStr := time.Now().Format("2006-01-02")
816
-		timeArr := strings.Split(timeStr, "-")
817
-		var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
818 814
 
819
-		hisPatient := models.HisPatient{
820
-			Number: str,
821
-		}
822
-		err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
823
-		//fmt.Println("er", err)
824
-		if err != nil {
815
+		//查询今日没有退号的患者是否已挂号
816
+		_, errcode := service.GetTodayHisPatient(nowtime, bloodPatient.ID, adminUserInfo.CurrentOrgId)
817
+		if errcode == gorm.ErrRecordNotFound {
818
+			err := service.CreateHisPatient(&patient)
819
+			lastPatient, err := service.GetLastPatient(orgId)
820
+			timeStr := time.Now().Format("2006-01-02")
821
+			timeArr := strings.Split(timeStr, "-")
822
+			var str = timeArr[0] + timeArr[1] + timeArr[2] + strconv.FormatInt(lastPatient.ID, 10)
823
+
824
+			hisPatient := models.HisPatient{
825
+				Number: str,
826
+			}
827
+			err = service.UpdateHisPatient(lastPatient.ID, hisPatient)
828
+			//fmt.Println("er", err)
829
+			if err != nil {
830
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
831
+				return
832
+			}
833
+			this.ServeSuccessJSON(map[string]interface{}{
834
+				"patient": patient,
835
+			})
836
+		} else if errcode == nil {
825 837
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
826 838
 			return
827 839
 		}
828
-		this.ServeSuccessJSON(map[string]interface{}{
829
-			"patient": patient,
830
-		})
840
+
831 841
 	}
832 842
 }
833 843
 
@@ -1020,7 +1030,7 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1020 1030
 	recordDateTime := theTime.Unix()
1021 1031
 	//prescription_id, _ := this.GetInt64("prescription_id")
1022 1032
 	adminUserInfo := this.GetAdminUserInfo()
1023
-	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs)
1033
+	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId)
1024 1034
 	projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId)
1025 1035
 	//doctorPorject, err := service.GetDoctorProjectItem(patient_id, recordDateTime)
1026 1036
 	//patient, err := service.GetBloodPatientByPatient(patient_id)

+ 18 - 4
service/his_project_service.go View File

@@ -344,7 +344,7 @@ func GetBloodPatientInfoById(patientid int64) (models.XtPatients, error) {
344 344
 func GetPatientCaseHistory(patientid int64) (models.HisPatientCaseHistory, error) {
345 345
 
346 346
 	history := models.HisPatientCaseHistory{}
347
-	err := XTReadDB().Model(&history).Where("patient_id = ? and status = 1", patientid).Find(&history).Error
347
+	err := XTReadDB().Model(&history).Where("patient_id = ? and status = 1", patientid).Last(&history).Error
348 348
 	return history, err
349 349
 }
350 350
 
@@ -387,10 +387,10 @@ func GetHistPatient(orgid int64, keyword string) (hisPatient []*models.HisPatien
387 387
 	return hisPatient, err
388 388
 }
389 389
 
390
-func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, schIDs []string) (prescription []*models.HisPrescription, err error) {
390
+func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, schIDs []string, orgid int64) (prescription []*models.HisPrescription, err error) {
391
+
392
+	err = XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and id in(?) and  status = 1 ", his_patient_id, recorddate, schIDs).Preload("Patients", "status = 1 and user_org_id = ?", orgid).Preload("HisDoctorAdviceInfo", "status = 1 and user_org_id = ?", orgid).Preload("HisPrescriptionProject", "status = 1 and user_org_id = ?", orgid).Preload("XtHisAdditionalCharge", "status = 1", orgid).Find(&prescription).Error
391 393
 
392
-	err = XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and id in(?) and  status = 1 ", his_patient_id, recorddate, schIDs).Preload("Patients", "status = 1").Preload("HisDoctorAdviceInfo", "status = 1").Preload("HisPrescriptionProject", "status = 1").Preload("XtHisAdditionalCharge", "status = 1").Find(&prescription).Error
393
-	//err = XTReadDB().Model(&prescription).Where("patient_id = ? and status = 1 and advice_date = ? and prescription_id = ?", his_patient_id, recorddate, prescription_id).Find(&prescription).Error
394 394
 	return prescription, err
395 395
 }
396 396
 
@@ -588,3 +588,17 @@ func GetPrescriptionByPatientId(patient_id int64, startime int64) (prescritpion
588 588
 	err = XTReadDB().Model(&prescritpion).Where("patient_id = ? and record_date =?", patient_id, startime).Find(&prescritpion).Error
589 589
 	return prescritpion, err
590 590
 }
591
+
592
+func GetTodayHisPatient(recod_date int64, patientid int64, user_org_id int64) (*models.XtHisPatient, error) {
593
+
594
+	patient := models.XtHisPatient{}
595
+	err := XTReadDB().Model(&patient).Where("record_date = ? and patient_id = ? and user_org_id = ? and is_return = 1 and status = 1", recod_date, patientid, user_org_id).Find(&patient).Error
596
+	if err != nil {
597
+		if err == gorm.ErrRecordNotFound {
598
+			return nil, err
599
+		} else {
600
+			return nil, err
601
+		}
602
+	}
603
+	return &patient, nil
604
+}

+ 7 - 0
service/his_service.go View File

@@ -686,3 +686,10 @@ func GetHisPatientPrescriptionList(org_id int64, keywords string, record_date in
686 686
 	err = db.Limit(limit).Offset(offset).Find(&patients).Error
687 687
 	return
688 688
 }
689
+
690
+func UpdateHisPatientIsReturn(patientid int64, recorddate int64, orgid int64) (models.VMHisPatient, error) {
691
+
692
+	patient := models.VMHisPatient{}
693
+	err := XTWriteDB().Model(&patient).Where("patient_id = ? and record_date = ? and user_org_id = ? and status = 1", patientid, recorddate, orgid).Updates(map[string]interface{}{"is_return": 3}).Error
694
+	return patient, err
695
+}