Browse Source

医保对接

csx 3 years ago
parent
commit
b99bfcc818

+ 12 - 0
controllers/his_api_controller.go View File

@@ -103,6 +103,8 @@ func HisManagerApiRegistRouters() {
103 103
 	beego.Router("/api/monthcharge/info", &HisApiController{}, "get:GetHisMonthChargePatientInfo")
104 104
 	beego.Router("/api/monthhispatient/get", &HisApiController{}, "get:GetHisMonthPatientInfo")
105 105
 
106
+	beego.Router("/api/orders", &HisApiController{}, "get:GetAllOrder")
107
+
106 108
 }
107 109
 
108 110
 func (c *HisApiController) GetHisUnChargePatientList() {
@@ -5185,3 +5187,13 @@ func (c *HisApiController) GetHisMonthPatientInfo() {
5185 5187
 	return
5186 5188
 
5187 5189
 }
5190
+
5191
+func (c *HisApiController) GetAllOrder() {
5192
+	org_id := c.GetAdminUserInfo().CurrentOrgId
5193
+	orders, _ := service.GetNewHisOrderList(org_id)
5194
+	c.ServeSuccessJSON(map[string]interface{}{
5195
+		"order": orders,
5196
+	})
5197
+	return
5198
+
5199
+}

+ 11 - 7
controllers/his_project_api_controller.go View File

@@ -1537,14 +1537,18 @@ func (this *HisProjectApiController) GetPrescription() {
1537 1537
 
1538 1538
 	patient_id, _ := this.GetInt64("patient_id")
1539 1539
 	p_type, _ := this.GetInt64("p_type")
1540
+	record_date := this.GetString("record_date")
1541
+	timeLayout := "2006-01-02"
1542
+	loc, _ := time.LoadLocation("Local")
1540 1543
 
1541
-	fmt.Println("patient_id", patient_id)
1542
-	timeStr := time.Now().Format("2006-01-02")
1543
-	timeLayout := "2006-01-02 15:04:05"
1544
-	fmt.Println("timeStr:", timeStr)
1545
-	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
1546
-	timenow := timeStringToTime.Unix()
1547
-	list, err := service.GetPrescriptionByPatientId(patient_id, timenow, p_type)
1544
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1545
+	if err != nil {
1546
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1547
+		return
1548
+	}
1549
+	recordDateTime := theTime.Unix()
1550
+
1551
+	list, err := service.GetPrescriptionByPatientId(patient_id, recordDateTime, p_type)
1548 1552
 	if err != nil {
1549 1553
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1550 1554
 		return

+ 51 - 1
models/his_models.go View File

@@ -954,7 +954,7 @@ type HisOrder struct {
954 954
 
955 955
 	HisOrderInfo           HisOrderInfo           `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
956 956
 	Patients               Patients               `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
957
-	HisPatient             HisPatient             `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"his_patient"`
957
+	HisPatient             HisPatient             `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
958 958
 	HisHospitalCheckRecord HisHospitalCheckRecord `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"his_hospital_patient"`
959 959
 
960 960
 	HisPrescriptionInfo HisPrescriptionInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"p_info"`
@@ -1002,6 +1002,9 @@ type HisOrderInfo struct {
1002 1002
 	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1003 1003
 	Type             int64   `gorm:"column:type" json:"type" form:"type"`
1004 1004
 	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
1005
+
1006
+	//HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1007
+	//HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
1005 1008
 }
1006 1009
 
1007 1010
 func (HisOrderInfo) TableName() string {
@@ -1418,3 +1421,50 @@ type HisPrescriptionInfoTemplate struct {
1418 1421
 func (HisPrescriptionInfoTemplate) TableName() string {
1419 1422
 	return "his_prescription_info_template"
1420 1423
 }
1424
+
1425
+type VMHisOrderInfo struct {
1426
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
1427
+	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
1428
+	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
1429
+	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
1430
+	DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
1431
+	Cnt              float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
1432
+	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
1433
+	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1434
+	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
1435
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
1436
+	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1437
+	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
1438
+	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
1439
+	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1440
+	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1441
+	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
1442
+	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1443
+
1444
+	HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1445
+	HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
1446
+}
1447
+
1448
+func (VMHisOrderInfo) TableName() string {
1449
+	return "his_order_info"
1450
+}
1451
+
1452
+type NewHisOrder struct {
1453
+	ID                 int64             `gorm:"column:id" json:"id" form:"id"`
1454
+	UserOrgId          int64             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1455
+	HisPatientId       int64             `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1456
+	SettleAccountsDate int64             `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
1457
+	Ctime              int64             `gorm:"column:ctime" json:"ctime" form:"ctime"`
1458
+	OrderStatus        int64             `gorm:"column:order_status" json:"order_status" form:"order_status"`
1459
+	Mtime              int64             `gorm:"column:mtime" json:"mtime" form:"mtime"`
1460
+	Status             int64             `gorm:"column:status" json:"status" form:"status"`
1461
+	Number             string            `gorm:"column:number" json:"number" form:"number"`
1462
+	MdtrtId            string            `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
1463
+	PatientId          int64             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1464
+	VMHisOrderInfo     []*VMHisOrderInfo `gorm:"ForeignKey:Number;AssociationForeignKey:OrderNumber" json:"order_info"`
1465
+	HisPatient         HisPatient        `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
1466
+}
1467
+
1468
+func (NewHisOrder) TableName() string {
1469
+	return "his_order"
1470
+}

+ 19 - 0
service/his_service.go View File

@@ -2103,3 +2103,22 @@ func GetOrderCountByNumber(org_id int64, patient_id int64, record_time int64, nu
2103 2103
 
2104 2104
 	return
2105 2105
 }
2106
+
2107
+func GetNewHisOrderList(org_id int64) (order []*models.NewHisOrder, err error) {
2108
+	err = readDb.Model(&models.NewHisOrder{}).Where("user_org_id = ?  AND status = 1 AND order_status = 2", org_id).Preload("HisPatient", "status = 1").Find(&order).Error
2109
+	var numbers []string
2110
+	for _, item := range order {
2111
+		numbers = append(numbers, item.Number)
2112
+	}
2113
+
2114
+	return
2115
+}
2116
+
2117
+func GetNewHisOrderInfoList(order_numbers []string) (order []*models.VMHisOrderInfo, err error) {
2118
+	err = readDb.Model(&models.VMHisOrderInfo{}).Where("status = 1 AND order_number in (?)", order_numbers).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2119
+		return db.Where("status = 1 ").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1")
2120
+	}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
2121
+		return db.Where("status = 1 ").Preload("Drug", "status =1")
2122
+	}).Find(&order).Error
2123
+	return
2124
+}