XMLWAN 4 lat temu
rodzic
commit
9cec1ee8b5

+ 44 - 35
controllers/his_project_api_controller.go Wyświetl plik

@@ -749,19 +749,19 @@ func (this *HisProjectApiController) SaveHisPatient() {
749 749
 			IsNeedCostOfProduction: cost_checked,
750 750
 			TreatmentCost:          medicalExpense_float,
751 751
 			MedicalInsuranceNumber: medicalinsurancecard,
752
-			Name:                name,
753
-			RegisterType:        register,
754
-			RegisterCost:        registrationfees_float,
755
-			BalanceAccountsType: settlementValue,
756
-			Gender:              sex,
757
-			Total:               totals_float,
758
-			UserOrgId:           orgId,
759
-			Status:              1,
760
-			RecordDate:          nowtime,
761
-			IsReturn:            1,
762
-			Ctime:               time.Now().Unix(),
763
-			Phone:               phone,
764
-			SocialType:          social_type,
752
+			Name:                   name,
753
+			RegisterType:           register,
754
+			RegisterCost:           registrationfees_float,
755
+			BalanceAccountsType:    settlementValue,
756
+			Gender:                 sex,
757
+			Total:                  totals_float,
758
+			UserOrgId:              orgId,
759
+			Status:                 1,
760
+			RecordDate:             nowtime,
761
+			IsReturn:               1,
762
+			Ctime:                  time.Now().Unix(),
763
+			Phone:                  phone,
764
+			SocialType:             social_type,
765 765
 		}
766 766
 		err := service.CreateHisPatient(&patient)
767 767
 		lastPatient, err := service.GetLastPatient(orgId)
@@ -794,17 +794,17 @@ func (this *HisProjectApiController) SaveHisPatient() {
794 794
 			IsNeedCostOfProduction: cost_checked,
795 795
 			TreatmentCost:          medicalExpense_float,
796 796
 			MedicalInsuranceNumber: medicalinsurancecard,
797
-			Name:                name,
798
-			RegisterType:        register,
799
-			RegisterCost:        registrationfees_float,
800
-			BalanceAccountsType: settlementValue,
801
-			Gender:              sex,
802
-			Total:               totals_float,
803
-			UserOrgId:           orgId,
804
-			PatientId:           bloodPatient.ID,
805
-			Ctime:               time.Now().Unix(),
806
-			Phone:               phone,
807
-			SocialType:          social_type,
797
+			Name:                   name,
798
+			RegisterType:           register,
799
+			RegisterCost:           registrationfees_float,
800
+			BalanceAccountsType:    settlementValue,
801
+			Gender:                 sex,
802
+			Total:                  totals_float,
803
+			UserOrgId:              orgId,
804
+			PatientId:              bloodPatient.ID,
805
+			Ctime:                  time.Now().Unix(),
806
+			Phone:                  phone,
807
+			SocialType:             social_type,
808 808
 		}
809 809
 		err := service.CreateHisPatient(&patient)
810 810
 		if err != nil {
@@ -993,25 +993,34 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
993 993
 
994 994
 	patient_id, _ := this.GetInt64("patient_id")
995 995
 	record_date := this.GetString("record_date")
996
+	schIDStr := this.GetString("ids")
997
+	if len(schIDStr) == 0 {
998
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
999
+		return
1000
+	}
1001
+	idStrs := strings.Split(schIDStr, ",")
1002
+
996 1003
 	timeLayout := "2006-01-02"
997 1004
 	loc, _ := time.LoadLocation("Local")
998 1005
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
999 1006
 	recordDateTime := theTime.Unix()
1000
-	prescription_id, _ := this.GetInt64("prescription_id")
1001
-	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, prescription_id)
1002
-
1003
-	doctorPorject, err := service.GetDoctorProjectItem(patient_id, recordDateTime)
1004
-	patient, err := service.GetBloodPatientByPatient(patient_id)
1005
-	prescriptionInfo, err := service.GetPrscriptionInfo(patient_id, recordDateTime)
1007
+	//prescription_id, _ := this.GetInt64("prescription_id")
1008
+	adminUserInfo := this.GetAdminUserInfo()
1009
+	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs)
1010
+	projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId)
1011
+	//doctorPorject, err := service.GetDoctorProjectItem(patient_id, recordDateTime)
1012
+	//patient, err := service.GetBloodPatientByPatient(patient_id)
1013
+	//prescriptionInfo, err := service.GetPrscriptionInfo(patient_id, recordDateTime)
1006 1014
 	if err != nil {
1007 1015
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1008 1016
 		return
1009 1017
 	}
1010 1018
 	this.ServeSuccessJSON(map[string]interface{}{
1011
-		"advicePrint":      advicePrint,
1012
-		"patient":          patient,
1013
-		"doctorPorject":    doctorPorject,
1014
-		"prescriptionInfo": prescriptionInfo,
1019
+		"advicePrint": advicePrint,
1020
+		"projectlist": projectlist,
1021
+		//"patient":          patient,
1022
+		//"doctorPorject":    doctorPorject,
1023
+		//"prescriptionInfo": prescriptionInfo,
1015 1024
 	})
1016 1025
 }
1017 1026
 
@@ -1036,7 +1045,7 @@ func (this *HisProjectApiController) PostPrintHisTemplate() {
1036 1045
 	adminUserInfo := this.GetAdminUserInfo()
1037 1046
 	orgId := adminUserInfo.CurrentOrgId
1038 1047
 	_, errcode := service.GetHisTemplateId(template_id, orgId)
1039
-	fmt.Println("errcode0-------", errcode)
1048
+	fmt.Println("errcode", errcode)
1040 1049
 	if errcode == gorm.ErrRecordNotFound {
1041 1050
 		template := models.XtHisTemplate{
1042 1051
 			TemplateId: template_id,

+ 19 - 18
models/his_models.go Wyświetl plik

@@ -274,23 +274,24 @@ func (HisPrescriptionInfo) TableName() string {
274 274
 }
275 275
 
276 276
 type HisPrescription struct {
277
-	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
278
-	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
279
-	RecordDate         int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
280
-	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
281
-	HisPatientId       int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
282
-	Status             int64  `gorm:"column:status" json:"status" form:"status"`
283
-	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
284
-	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
285
-	Number             string `gorm:"column:number" json:"number" form:"number"`
286
-	Type               int64  `gorm:"column:type" json:"type" form:"type"`
287
-	Doctor             string `gorm:"column:doctor" json:"doctor" form:"doctor"`
288
-	Creator            int64  `gorm:"column:creator" json:"creator" form:"creator"`
289
-	Modifier           int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
290
-	OrderStatus        int64  `gorm:"column:order_status" json:"order_status" form:"order_status"`
291
-	BatchNumber        string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
292
-	PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
293
-
277
+	ID                     int64                     `gorm:"column:id" json:"id" form:"id"`
278
+	UserOrgId              int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
279
+	RecordDate             int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
280
+	PatientId              int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
281
+	HisPatientId           int64                     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
282
+	Status                 int64                     `gorm:"column:status" json:"status" form:"status"`
283
+	Ctime                  int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
284
+	Mtime                  int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
285
+	Number                 string                    `gorm:"column:number" json:"number" form:"number"`
286
+	Type                   int64                     `gorm:"column:type" json:"type" form:"type"`
287
+	Doctor                 string                    `gorm:"column:doctor" json:"doctor" form:"doctor"`
288
+	Creator                int64                     `gorm:"column:creator" json:"creator" form:"creator"`
289
+	Modifier               int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
290
+	OrderStatus            int64                     `gorm:"column:order_status" json:"order_status" form:"order_status"`
291
+	BatchNumber            string                    `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
292
+	PrescriptionNumber     string                    `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
293
+	Patients               Patients                  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
294
+	HisPatient             VMHisPatient              `gorm:"ForeignKey:PatientId;AssociationForeignKey:patient_id" json:"hisPatient"`
294 295
 	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
295 296
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
296 297
 }
@@ -446,7 +447,7 @@ type HisPrescriptionProject struct {
446 447
 	DeliveryWay        string     `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
447 448
 	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
448 449
 	Day                string     `gorm:"column:day" json:"day" form:"day"`
449
-	HisProject         HisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
450
+	HisProject         HisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
450 451
 	Remark             string     `gorm:"column:remark" json:"remark" form:"remark"`
451 452
 }
452 453
 

+ 3 - 2
service/his_project_service.go Wyświetl plik

@@ -387,9 +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, prescription_id int64) (prescription []*models.HisDoctorAdviceInfo, err error) {
390
+func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, schIDs []string) (prescription []*models.HisPrescription, err error) {
391 391
 
392
-	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
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").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
393 394
 	return prescription, err
394 395
 }
395 396