Kaynağa Gözat

医保对接

csx 3 yıl önce
ebeveyn
işleme
107cc2e206

+ 69 - 0
controllers/gobal_config_api_controller.go Dosyayı Görüntüle

@@ -67,6 +67,12 @@ func GobalConfigRegistRouters() {
67 67
 	beego.Router("/api/xtconfig/get", &GobalConfigApiController{}, "get:GetXTHisConfig")
68 68
 	beego.Router("/api/xtconfig/isopen", &GobalConfigApiController{}, "post:PostXTHisConfig")
69 69
 
70
+	beego.Router("/api/hisstockpriceconfig/get", &GobalConfigApiController{}, "get:GetHisStockPriceConfig")
71
+	beego.Router("/api/hisstockpriceconfig/isopen", &GobalConfigApiController{}, "post:PostHisStockPriceConfig")
72
+
73
+	beego.Router("/api/xtconfig/get", &GobalConfigApiController{}, "get:GetXTHisConfig")
74
+	beego.Router("/api/xtconfig/isopen", &GobalConfigApiController{}, "post:PostXTHisConfig")
75
+
70 76
 	beego.Router("/api/xtconfigproject/isopen", &GobalConfigApiController{}, "post:PostXTHisProjectConfig")
71 77
 
72 78
 	beego.Router("/api/isopen/init", &GobalConfigApiController{}, "get:GetAllIsOpenConfig")
@@ -1405,6 +1411,60 @@ func (c *GobalConfigApiController) PostXTHisConfig() {
1405 1411
 	return
1406 1412
 }
1407 1413
 
1414
+func (c *GobalConfigApiController) PostHisStockPriceConfig() {
1415
+	is_open, _ := c.GetBool("is_open", false)
1416
+	adminUserInfo := c.GetAdminUserInfo()
1417
+	org_id := adminUserInfo.CurrentOrgId
1418
+	isOpen := 0
1419
+
1420
+	if is_open {
1421
+		isOpen = 1
1422
+	} else {
1423
+		isOpen = 2
1424
+	}
1425
+
1426
+	config := models.HisStockPriceConfig{
1427
+		UserOrgId: org_id,
1428
+		IsOpen:    int64(isOpen),
1429
+		Status:    1,
1430
+		Ctime:     time.Now().Unix(),
1431
+		Mtime:     time.Now().Unix(),
1432
+	}
1433
+
1434
+	errs, configs := service.FindHisStockPriceRecordByOrgId(org_id)
1435
+
1436
+	if errs == gorm.ErrRecordNotFound {
1437
+		err := service.CreateHisStockPriceRecord(&config)
1438
+		if err != nil {
1439
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1440
+			return
1441
+		}
1442
+
1443
+	} else if errs == nil {
1444
+		modifyConfig := models.HisStockPriceConfig{
1445
+			ID:        configs.ID,
1446
+			UserOrgId: org_id,
1447
+			Status:    1,
1448
+			Ctime:     time.Now().Unix(),
1449
+			Mtime:     time.Now().Unix(),
1450
+			IsOpen:    int64(isOpen),
1451
+		}
1452
+
1453
+		err := service.UpdateHisStockPriceRecord(&modifyConfig)
1454
+		if err != nil {
1455
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1456
+			return
1457
+		}
1458
+
1459
+	}
1460
+
1461
+	c.ServeSuccessJSON(map[string]interface{}{
1462
+		"is_open": is_open,
1463
+	})
1464
+
1465
+	return
1466
+}
1467
+
1408 1468
 func (c *GobalConfigApiController) PostXTHisProjectConfig() {
1409 1469
 	is_open, _ := c.GetBool("is_open", false)
1410 1470
 	adminUserInfo := c.GetAdminUserInfo()
@@ -1470,6 +1530,15 @@ func (c *GobalConfigApiController) GetXTHisConfig() {
1470 1530
 	})
1471 1531
 }
1472 1532
 
1533
+func (c *GobalConfigApiController) GetHisStockPriceConfig() {
1534
+	adminUserInfo := c.GetAdminUserInfo()
1535
+	_, config := service.FindHisStockPriceRecordByOrgId(adminUserInfo.CurrentOrgId)
1536
+
1537
+	c.ServeSuccessJSON(map[string]interface{}{
1538
+		"config": config,
1539
+	})
1540
+}
1541
+
1473 1542
 func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1474 1543
 	adminUserInfo := c.GetAdminUserInfo()
1475 1544
 	_, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)

+ 19 - 0
controllers/his_api_controller.go Dosyayı Görüntüle

@@ -559,12 +559,29 @@ func (c *HisApiController) GetHisPatientInfo() {
559 559
 	return
560 560
 
561 561
 }
562
+
562 563
 func (c *HisApiController) GetHisPrescriptionConfig() {
563 564
 	adminInfo := c.GetAdminUserInfo()
564 565
 	//获取医嘱模版
565 566
 	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
566 567
 	//获取所有基础药
567 568
 	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
569
+
570
+	_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
571
+	if config.ID > 0 && config.IsOpen == 1 {
572
+		for _, item := range drugs {
573
+			var index = 0
574
+			for _, subItem := range item.OtherDrugWarehouseInfo {
575
+				if index == 0 {
576
+					if subItem.StockMaxNumber*item.MinNumber+subItem.StockMinNumber > 0 {
577
+						index = index + 1
578
+						item.MinPrice = subItem.Price
579
+					}
580
+				}
581
+			}
582
+		}
583
+	}
584
+
568 585
 	drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
569 586
 	efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
570 587
 	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
@@ -1341,6 +1358,7 @@ func (c *HisApiController) DeletePrescription() {
1341 1358
 	if err == nil {
1342 1359
 		if len(projects) > 0 {
1343 1360
 			for _, item := range projects {
1361
+				service.DeletePrintInfo(item.ID) //删除打印信息
1344 1362
 				if stockConfig.IsOpen == 1 {
1345 1363
 					if item.Type == 3 {
1346 1364
 						good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
@@ -1429,6 +1447,7 @@ func (c *HisApiController) DeleteProject() {
1429 1447
 	}
1430 1448
 	err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
1431 1449
 	if err == nil {
1450
+		service.DeletePrintInfo(id)
1432 1451
 		label, _ := service.GetProjectById(adminInfo.CurrentOrgId, id, project.RecordDate, project.PatientId)
1433 1452
 		label.Status = 0
1434 1453
 		service.CreateHisLabelRecord(&label)

+ 9 - 2
controllers/his_project_api_controller.go Dosyayı Görüntüle

@@ -809,12 +809,19 @@ func (this *HisProjectApiController) DeleteProject() {
809 809
 }
810 810
 
811 811
 func (this *HisProjectApiController) GetHisProject() {
812
-
813 812
 	adminUserInfo := this.GetAdminUserInfo()
814 813
 	orgId := adminUserInfo.CurrentOrgId
815 814
 	project, err := service.GetHisProject(orgId)
816 815
 	good_info, err := service.GetGoodInfoMation(orgId)
817
-
816
+	_, config := service.FindHisStockPriceRecordByOrgId(orgId)
817
+	if config.ID > 0 && config.IsOpen == 1 {
818
+		//处理耗材不同批号价格问题
819
+		for _, item := range good_info {
820
+			if len(item.GoodSotckInfo) > 0 {
821
+				item.PackingPrice = item.GoodSotckInfo[0].Price
822
+			}
823
+		}
824
+	}
818 825
 	if err != nil {
819 826
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
820 827
 		return

+ 4 - 1
controllers/new_mobile_api_controllers/mobile_his_api_controller.go Dosyayı Görüntüle

@@ -270,12 +270,14 @@ func (c *MobileHisApiController) DeletePrescription() {
270 270
 	projects, _ := service.GetHisPrescriptionProjectsByID(prescription_id)
271 271
 	advices, _ := service.GetHisPrescriptionAdviceByID(prescription_id)
272 272
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetMobileAdminUserInfo().Org.Id)
273
-	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
273
+	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetMobileAdminUserInfo().Org.Id)
274 274
 
275 275
 	err := service.DelelteHisPrescription(prescription_id, c.GetMobileAdminUserInfo().Org.Id)
276 276
 	if err == nil {
277 277
 		if len(projects) > 0 {
278 278
 			for _, item := range projects {
279
+				service.DeletePrintInfo(item.ID)
280
+
279 281
 				if item.Type == 3 { //处理透前准备耗材数量数据
280 282
 					consumables, _ := service.FindHisConsumablesByID(item.UserOrgId, item.PatientId, item.RecordDate, item.ProjectId)
281 283
 					if consumables.ID > 0 {
@@ -361,6 +363,7 @@ func (c *MobileHisApiController) DeleteProject() {
361 363
 
362 364
 	err := service.DelelteProject(id, c.GetMobileAdminUserInfo().Org.Id)
363 365
 	if err == nil {
366
+		service.DeletePrintInfo(id)
364 367
 		if stockConfig.IsOpen == 1 {
365 368
 			if project.Type == 3 {
366 369
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)

+ 13 - 0
models/his_models.go Dosyayı Görüntüle

@@ -1618,3 +1618,16 @@ type VMHisOrderTwo struct {
1618 1618
 func (VMHisOrderTwo) TableName() string {
1619 1619
 	return "his_order"
1620 1620
 }
1621
+
1622
+type HisStockPriceConfig struct {
1623
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1624
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1625
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1626
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1627
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
1628
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
1629
+}
1630
+
1631
+func (HisStockPriceConfig) TableName() string {
1632
+	return "his_stock_price_config"
1633
+}

+ 5 - 4
models/stock_models.go Dosyayı Görüntüle

@@ -1116,10 +1116,11 @@ type SgjCancelStockInfo struct {
1116 1116
 }
1117 1117
 
1118 1118
 type GoodSotckInfo struct {
1119
-	GoodId            int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
1120
-	StockCount        int64  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1121
-	GoodName          string `gorm:"column:good_name" json:"good_name"`
1122
-	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1119
+	GoodId            int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
1120
+	StockCount        int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1121
+	GoodName          string  `gorm:"column:good_name" json:"good_name"`
1122
+	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1123
+	Price             float64 `gorm:"column:price" json:"price" form:"price"`
1123 1124
 }
1124 1125
 
1125 1126
 func (GoodSotckInfo) TableName() string {

+ 1 - 1
service/dialysis_service.go Dosyayı Görüntüle

@@ -1179,7 +1179,7 @@ func SaveHisDoctorAdvice(advice *models.HisDoctorAdviceInfo) (err error) {
1179 1179
 
1180 1180
 func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
1181 1181
 
1182
-	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count >0 and status = 1").Find(&goodinfo).Error
1182
+	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count > 0 and status = 1").Find(&goodinfo).Error
1183 1183
 	return goodinfo, err
1184 1184
 }
1185 1185
 

+ 15 - 0
service/gobal_config_service.go Dosyayı Görüntüle

@@ -185,6 +185,11 @@ func FindXTHisRecordByOrgId(org_id int64) (err error, config models.XtHisConfig)
185 185
 	return
186 186
 }
187 187
 
188
+func FindHisStockPriceRecordByOrgId(org_id int64) (err error, config models.HisStockPriceConfig) {
189
+	err = readDb.Model(&models.HisStockPriceConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
190
+	return
191
+}
192
+
188 193
 func UpdateXTHisRecord(config *models.XtHisConfig) (err error) {
189 194
 	err = writeDb.Save(config).Error
190 195
 	return
@@ -195,6 +200,16 @@ func CreateXTHisRecord(config *models.XtHisConfig) (err error) {
195 200
 	return
196 201
 }
197 202
 
203
+func CreateHisStockPriceRecord(config *models.HisStockPriceConfig) (err error) {
204
+	err = writeDb.Model(&models.HisStockPriceConfig{}).Create(config).Error
205
+	return
206
+}
207
+
208
+func UpdateHisStockPriceRecord(config *models.HisStockPriceConfig) (err error) {
209
+	err = writeDb.Save(config).Error
210
+	return
211
+}
212
+
198 213
 //TODO:项目开关
199 214
 func FindXTHisProjectByOrgId(org_id int64) (err error, config models.XtHisProjectConfig) {
200 215
 	err = readDb.Model(&models.XtHisProjectConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error

+ 12 - 7
service/his_service.go Dosyayı Görüntüle

@@ -588,13 +588,14 @@ func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_dat
588 588
 }
589 589
 
590 590
 type OtherDrugWarehouseInfo struct {
591
-	ID               int64 `gorm:"column:id" json:"id" form:"id"`
592
-	DrugId           int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
593
-	WarehousingCount int64 `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
594
-	Status           int64 `gorm:"column:status" json:"status" form:"status"`
595
-	OrgId            int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
596
-	StockMaxNumber   int64 `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
597
-	StockMinNumber   int64 `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
591
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
592
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
593
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
594
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
595
+	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
596
+	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
597
+	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
598
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
598 599
 }
599 600
 
600 601
 func (OtherDrugWarehouseInfo) TableName() string {
@@ -2209,6 +2210,10 @@ func GetProjectById(user_org_id int64, p_project_id int64, record_time int64, pa
2209 2210
 	return
2210 2211
 }
2211 2212
 
2213
+func DeletePrintInfo(id int64) {
2214
+	writeDb.Model(&models.HisLabelPrintInfo{}).Where("p_project_id = ?", id).Updates(map[string]interface{}{"status": 0})
2215
+}
2216
+
2212 2217
 func CreateHisLabelRecord(label *models.HisLabelPrintInfo) error {
2213 2218
 	err := writeDb.Save(&label).Error
2214 2219
 	return err