Browse Source

医保对接

csx 3 years ago
parent
commit
bf78f10070

+ 11 - 4
controllers/his_api_controller.go View File

@@ -543,13 +543,9 @@ func (c *HisApiController) GetHisPatientInfo() {
543 543
 							}
544 544
 						}
545 545
 					}
546
-
547 546
 				}
548
-
549 547
 			}
550
-
551 548
 			sch_prescriptions = append(sch_prescriptions, cus)
552
-
553 549
 		}
554 550
 
555 551
 		for _, item := range sch_prescriptions {
@@ -562,6 +558,17 @@ func (c *HisApiController) GetHisPatientInfo() {
562 558
 
563 559
 		}
564 560
 	}
561
+	_, config := service.FindHisStockPriceRecordByOrgId(admin.CurrentOrgId)
562
+	if config.ID > 0 && config.IsOpen == 1 {
563
+		for _, item := range sch_prescriptions {
564
+			for _, subItem := range item.HisPrescriptionAdviceTemplate {
565
+				info, _ := service.GetWarehoseInfoByDrugId(subItem.DrugId, admin.CurrentOrgId)
566
+				if info.RetailPrice > 0 {
567
+					subItem.Drug.MinPrice = info.RetailPrice
568
+				}
569
+			}
570
+		}
571
+	}
565 572
 
566 573
 	//prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
567 574
 	//monthPrescriptions, _ := service.GetMonthHisPrescriptionTwo(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)

+ 47 - 1
models/his_models.go View File

@@ -518,7 +518,7 @@ type HisPrescription struct {
518 518
 	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
519 519
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
520 520
 	HisAdditionalCharge    []*HisAdditionalCharge    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
521
-	HisPrescriptionInfo    HisPrescriptionInfo       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"info"`
521
+	HisPrescriptionInfo    HisPrescriptionInfo       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,RecordDate" json:"info"`
522 522
 	HisOrder               HisOrder                  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
523 523
 	Total                  string                    `gorm:"-" json:"total" form:"total"`
524 524
 	PType                  int64                     `gorm:"column:p_type" json:"p_type" form:"p_type"`
@@ -751,6 +751,52 @@ func (HisDoctorAdviceTemplate) TableName() string {
751 751
 	return "his_doctor_advice_template"
752 752
 }
753 753
 
754
+type HisPrintPrescriptionProject struct {
755
+	ID                 int64      `gorm:"column:id" json:"id" form:"id"`
756
+	ProjectId          int64      `gorm:"column:project_id" json:"project_id" form:"project_id"`
757
+	Price              float64    `gorm:"column:price" json:"price" form:"price"`
758
+	UserOrgId          int64      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
759
+	Status             int64      `gorm:"column:status" json:"status" form:"status"`
760
+	Ctime              int64      `gorm:"column:ctime" json:"ctime" form:"ctime"`
761
+	Mtime              int64      `gorm:"column:mtime" json:"mtime" form:"mtime"`
762
+	PatientId          int64      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
763
+	HisPatientId       int64      `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
764
+	RecordDate         int64      `gorm:"column:record_date" json:"record_date" form:"record_date"`
765
+	PrescriptionId     int64      `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
766
+	Count              string     `gorm:"column:count" json:"count" form:"count"`
767
+	FeedetlSn          string     `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
768
+	MedListCodg        string     `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
769
+	SingleDose         string     `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
770
+	DeliveryWay        string     `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
771
+	ExecutionFrequency string     `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
772
+	Day                string     `gorm:"column:day" json:"day" form:"day"`
773
+	HisProject         HisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
774
+	GoodInfo           GoodInfo   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
775
+	Remark             string     `gorm:"column:remark" json:"remark" form:"remark"`
776
+	Unit               string     `gorm:"column:unit" json:"unit" form:"unit"`
777
+	Type               int64      `gorm:"column:type" json:"type" form:"type"`
778
+	Doctor             int64      `gorm:"column:doctor" json:"doctor" form:"doctor"`
779
+	ExecutionTime      int64      `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
780
+	ExecutionStaff     int64      `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
781
+	ExecutionState     int64      `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
782
+	CheckTime          int64      `gorm:"column:check_time" json:"check_time" form:"check_time"`
783
+	CheckState         int64      `gorm:"column:check_state" json:"check_state" form:"check_state"`
784
+	Checker            int64      `gorm:"column:checker" json:"checker" form:"checker"`
785
+	StartTime          int64      `gorm:"column:start_time" json:"start_time" form:"start_time"`
786
+	TeamId             int64      `gorm:"column:team_id" json:"team_id" form:"team_id"`
787
+
788
+	XtHisProjectTeam XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
789
+
790
+	FrequencyType int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
791
+	DayCount      int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
792
+	WeekDay       string `gorm:"column:week_day" json:"week_day" form:"week_day"`
793
+	IsCheckTeam   int64  `gorm:"-" json:"is_check_team" form:"is_check_team"`
794
+}
795
+
796
+func (HisPrintPrescriptionProject) TableName() string {
797
+	return "his_prescription_project"
798
+}
799
+
754 800
 type HisPrescriptionProject struct {
755 801
 	ID                 int64      `gorm:"column:id" json:"id" form:"id"`
756 802
 	ProjectId          int64      `gorm:"column:project_id" json:"project_id" form:"project_id"`

+ 22 - 24
models/his_print_models.go View File

@@ -64,30 +64,28 @@ func (HisPrintPatient) TableName() string {
64 64
 }
65 65
 
66 66
 type HisPrintPrescription struct {
67
-	ID                     int64                     `gorm:"column:id" json:"id" form:"id"`
68
-	UserOrgId              int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
69
-	RecordDate             int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
70
-	PatientId              int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
71
-	HisPatientId           int64                     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
72
-	Status                 int64                     `gorm:"column:status" json:"status" form:"status"`
73
-	Ctime                  int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
74
-	Mtime                  int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
75
-	Number                 string                    `gorm:"column:number" json:"number" form:"number"`
76
-	Type                   int64                     `gorm:"column:type" json:"type" form:"type"`
77
-	Doctor                 string                    `gorm:"column:doctor" json:"doctor" form:"doctor"`
78
-	Creator                int64                     `gorm:"column:creator" json:"creator" form:"creator"`
79
-	Modifier               int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
80
-	OrderStatus            int64                     `gorm:"column:order_status" json:"order_status" form:"order_status"`
81
-	PreTime                int64                     `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
82
-	BatchNumber            string                    `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
83
-	PrescriptionNumber     string                    `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
84
-	Patients               Patients                  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
85
-	HisPatient             VMHisPatient              `gorm:"ForeignKey:PatientId;AssociationForeignKey:patient_id" json:"hisPatient"`
86
-	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
87
-	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
88
-	Total                  string                    `gorm:"-" json:"total" form:"total"`
89
-	PType                  int64                     `gorm:"column:p_type" json:"p_type" form:"p_type"`
90
-	MedType                string                    `gorm:"column:med_type" json:"med_type" form:"med_type"`
67
+	ID                     int64                          `gorm:"column:id" json:"id" form:"id"`
68
+	UserOrgId              int64                          `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
69
+	RecordDate             int64                          `gorm:"column:record_date" json:"record_date" form:"record_date"`
70
+	PatientId              int64                          `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
71
+	HisPatientId           int64                          `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
72
+	Status                 int64                          `gorm:"column:status" json:"status" form:"status"`
73
+	Ctime                  int64                          `gorm:"column:ctime" json:"ctime" form:"ctime"`
74
+	Mtime                  int64                          `gorm:"column:mtime" json:"mtime" form:"mtime"`
75
+	Number                 string                         `gorm:"column:number" json:"number" form:"number"`
76
+	Type                   int64                          `gorm:"column:type" json:"type" form:"type"`
77
+	Doctor                 string                         `gorm:"column:doctor" json:"doctor" form:"doctor"`
78
+	Creator                int64                          `gorm:"column:creator" json:"creator" form:"creator"`
79
+	Modifier               int64                          `gorm:"column:modifier" json:"modifier" form:"modifier"`
80
+	OrderStatus            int64                          `gorm:"column:order_status" json:"order_status" form:"order_status"`
81
+	PreTime                int64                          `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
82
+	BatchNumber            string                         `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
83
+	PrescriptionNumber     string                         `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
84
+	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo         `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
85
+	HisPrescriptionProject []*HisPrintPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
86
+	Total                  string                         `gorm:"-" json:"total" form:"total"`
87
+	PType                  int64                          `gorm:"column:p_type" json:"p_type" form:"p_type"`
88
+	MedType                string                         `gorm:"column:med_type" json:"med_type" form:"med_type"`
91 89
 }
92 90
 
93 91
 func (HisPrintPrescription) TableName() string {

+ 1 - 1
service/his_print_service.go View File

@@ -37,7 +37,7 @@ func GetBatchInspectionProjectHisPrescription(ids []string, record_time int64, u
37 37
 		Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
38 38
 			return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1 AND p_type = 2", user_org_id, record_time).
39 39
 				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
40
-					return db.Where("status = 1 ").Preload("HisProject", "status = 1 AND cost_classify = 3")
40
+					return db.Where("status = 1 ").Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1 AND cost_classify = 3")
41 41
 				})
42 42
 		}).
43 43
 		Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).

+ 1 - 1
service/his_project_service.go View File

@@ -407,7 +407,7 @@ func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, schIDs []strin
407 407
 		return db.Where("status = 1 and user_org_id = ?", orgid).Preload("Drug", "status = 1")
408 408
 	}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
409 409
 		return db.Where("status = 1 AND user_org_id = ?", orgid).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
410
-	}).Preload("HisPrescriptionInfo", "status =1 and user_org_id = ? and p_type = ? ", orgid, p_type).Preload("HisAdditionalCharge", "status = 1 and user_org_id = ?", orgid).Find(&prescription).Error
410
+	}).Preload("HisPrescriptionInfo", "status =1 and user_org_id = ? and p_type = ? AND record_date = ?", orgid, p_type).Preload("HisAdditionalCharge", "status = 1 and user_org_id = ?", orgid).Find(&prescription).Error
411 411
 
412 412
 	return prescription, err
413 413
 }

+ 4 - 0
service/his_service.go View File

@@ -2304,3 +2304,7 @@ func UpdateBatchHisPrescriptionMedType(ids []string, med_type string, start_time
2304 2304
 	tx.Commit()
2305 2305
 	return
2306 2306
 }
2307
+func GetWarehoseInfoByDrugId(drug_id int64, org_id int64) (info OtherDrugWarehouseInfo, err error) {
2308
+	err = readDb.Model(&OtherDrugWarehouseInfo{}).Where("(drug_id = ? AND org_id = ? AND  status = 1 and stock_max_number > 0)  or  (drug_id = ? AND org_id = ? AND status = 1  AND stock_min_number >0)", drug_id, org_id, drug_id, org_id).First(&info).Error
2309
+	return
2310
+}