Browse Source

医保对接

csx 4 years ago
parent
commit
1807b4a6db

+ 1 - 1
controllers/dialysis_record_api_controller.go View File

@@ -761,7 +761,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
761 761
 			if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
762 762
 
763 763
 				totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
764
-				if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 {
764
+				if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 36 {
765 765
 					ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
766 766
 				}
767 767
 				// 只针对方济医院

+ 19 - 8
controllers/drug_stock_api_contorller.go View File

@@ -488,7 +488,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
488 488
 		Manufacturer:     manufacturer_id,
489 489
 	}
490 490
 
491
-	service.EditDrugWarehousing(warehousing)
491
+	service.EditDrugWarehousingOne(warehousing, id)
492 492
 
493 493
 	dataBody := make(map[string]interface{}, 0)
494 494
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
@@ -541,8 +541,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
541 541
 				var productDates int64
542 542
 				var expiryDates int64
543 543
 
544
-				fmt.Println()
545
-
546 544
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
547 545
 					expiryDates = 0
548 546
 				} else {
@@ -592,6 +590,19 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
592 590
 				}
593 591
 				id := int64(items["id"].(float64))
594 592
 
593
+				if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "float64" {
594
+					utils.ErrorLog("dealer")
595
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
596
+					return
597
+				}
598
+				dealer := int64(items["dealer"].(float64))
599
+
600
+				if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "float64" {
601
+					utils.ErrorLog("manufacturer")
602
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
603
+					return
604
+				}
605
+				manufacturer := int64(items["manufacturer"].(float64))
595 606
 				if id == 0 {
596 607
 					warehouseInfo := &models.DrugWarehouseInfo{
597 608
 						WarehousingOrder: warehouse.WarehousingOrder,
@@ -608,8 +619,8 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
608 619
 						Remark:           remark,
609 620
 						OrgId:            adminUserInfo.CurrentOrgId,
610 621
 						Type:             types,
611
-						Manufacturer:     manufacturer_id,
612
-						Dealer:           dealer_id,
622
+						Manufacturer:     manufacturer,
623
+						Dealer:           dealer,
613 624
 						RetailPrice:      retail_price,
614 625
 						RetailTotalPrice: retail_price_total,
615 626
 					}
@@ -632,8 +643,8 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
632 643
 						Remark:           remark,
633 644
 						OrgId:            adminUserInfo.CurrentOrgId,
634 645
 						Type:             types,
635
-						Manufacturer:     manufacturer_id,
636
-						Dealer:           dealer_id,
646
+						Manufacturer:     manufacturer,
647
+						Dealer:           dealer,
637 648
 						RetailPrice:      retail_price,
638 649
 						RetailTotalPrice: retail_price_total,
639 650
 					}
@@ -1417,7 +1428,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1417 1428
 					sys_record_time := int64(items["sys_record_time"].(float64))
1418 1429
 
1419 1430
 					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1420
-						ID:                      id,
1431
+						ID: id,
1421 1432
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1422 1433
 						WarehouseOutId:          warehouseOut.ID,
1423 1434
 						DrugId:                  drug_id,

+ 97 - 0
controllers/gobal_config_api_controller.go View File

@@ -79,6 +79,12 @@ func GobalConfigRegistRouters() {
79 79
 	beego.Router("/api/drugstock/getdrugoutdetail", &GobalConfigApiController{}, "get:GetDrugOutDetail")
80 80
 
81 81
 	beego.Router("/api/drugstock/getdrugcanceldetail", &GobalConfigApiController{}, "get:GetDrugCancelDetail")
82
+
83
+	beego.Router("/api/monitor/open", &GobalConfigApiController{}, "get:AddMonitorOpen")
84
+	beego.Router("/api/monitor/getmonitorconfig", &GobalConfigApiController{}, "Get:GetMonitorConfig")
85
+	beego.Router("/api/order/addorderconfig", &GobalConfigApiController{}, "Get:AddOrderConfig")
86
+	beego.Router("/api/order/getorderconfig", &GobalConfigApiController{}, "Get:GetOrderConfig")
87
+
82 88
 }
83 89
 
84 90
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1603,3 +1609,94 @@ func (c *GobalConfigApiController) GetDrugCancelDetail() {
1603 1609
 		"total": total,
1604 1610
 	})
1605 1611
 }
1612
+
1613
+func (c *GobalConfigApiController) AddMonitorOpen() {
1614
+
1615
+	is_open, _ := c.GetInt64("is_open")
1616
+	fmt.Println("is_open22222222", is_open)
1617
+	adminUserInfo := c.GetAdminUserInfo()
1618
+	orgId := adminUserInfo.CurrentOrgId
1619
+	config := models.XtMonitorConfig{
1620
+		IsOpen:    is_open,
1621
+		UserOrgId: orgId,
1622
+		Status:    1,
1623
+		Ctime:     time.Now().Unix(),
1624
+	}
1625
+	//查询该机构是否存在
1626
+	_, errcode := service.GetMonitorConfigById(orgId)
1627
+	if errcode == gorm.ErrRecordNotFound {
1628
+		err := service.AddMonitorOpen(&config)
1629
+		if err != nil {
1630
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1631
+			return
1632
+		}
1633
+		c.ServeSuccessJSON(map[string]interface{}{
1634
+			"config": config,
1635
+		})
1636
+	} else if errcode == nil {
1637
+		err := service.UpdateMonitorOpen(orgId, &config)
1638
+		fmt.Println("err", err)
1639
+	}
1640
+
1641
+}
1642
+
1643
+func (c *GobalConfigApiController) GetMonitorConfig() {
1644
+
1645
+	userInfo := c.GetAdminUserInfo()
1646
+	orgId := userInfo.CurrentOrgId
1647
+
1648
+	config, err := service.GetMonitorConfig(orgId)
1649
+	if err != nil {
1650
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1651
+		return
1652
+	}
1653
+	c.ServeSuccessJSON(map[string]interface{}{
1654
+		"config": config,
1655
+	})
1656
+
1657
+}
1658
+
1659
+func (c *GobalConfigApiController) AddOrderConfig() {
1660
+
1661
+	is_open, _ := c.GetInt64("is_open")
1662
+	fmt.Println("344555555555555", is_open)
1663
+	adminUserInfo := c.GetAdminUserInfo()
1664
+	orgId := adminUserInfo.CurrentOrgId
1665
+	config := models.XtOrderConfig{
1666
+		IsOpen:    is_open,
1667
+		UserOrgId: orgId,
1668
+		Status:    1,
1669
+		Ctime:     time.Now().Unix(),
1670
+	}
1671
+	//查询
1672
+	_, errcode := service.GetOrderConfigById(orgId)
1673
+	if errcode == gorm.ErrRecordNotFound {
1674
+		err := service.AddOrderConfig(&config)
1675
+		if err != nil {
1676
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1677
+			return
1678
+		}
1679
+		c.ServeSuccessJSON(map[string]interface{}{
1680
+			"config": config,
1681
+		})
1682
+	} else if errcode == nil {
1683
+
1684
+		err := service.UpdateOrderConfig(orgId, &config)
1685
+		fmt.Println("2222", err)
1686
+	}
1687
+
1688
+}
1689
+
1690
+func (c *GobalConfigApiController) GetOrderConfig() {
1691
+
1692
+	adminUserInfo := c.GetAdminUserInfo()
1693
+	orgId := adminUserInfo.CurrentOrgId
1694
+	config, err := service.GetOrderConfig(orgId)
1695
+	if err != nil {
1696
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1697
+		return
1698
+	}
1699
+	c.ServeSuccessJSON(map[string]interface{}{
1700
+		"config": config,
1701
+	})
1702
+}

+ 449 - 0
controllers/his_api_controller.go View File

@@ -84,6 +84,7 @@ func HisManagerApiRegistRouters() {
84 84
 
85 85
 	beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
86 86
 
87
+	beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
87 88
 }
88 89
 
89 90
 func (c *HisApiController) Sscard() {
@@ -3082,3 +3083,451 @@ func (this *HisApiController) GetIncomeStatisticsData() {
3082 3083
 	}
3083 3084
 
3084 3085
 }
3086
+
3087
+func (c *HisApiController) PostProjectInformation() {
3088
+	adminUser := c.GetAdminUserInfo()
3089
+	orgId := adminUser.CurrentOrgId
3090
+	dataBody := make(map[string]interface{}, 0)
3091
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
3092
+	if err != nil {
3093
+		utils.ErrorLog(err.Error())
3094
+		return
3095
+	}
3096
+	utils.ErrorLog("%v", dataBody)
3097
+	var projectList []*models.HisProject
3098
+	var total_goods []interface{}
3099
+	tempProjects := dataBody["projects"].([]interface{})
3100
+	fmt.Println("666666666666", tempProjects)
3101
+	total_goods = tempProjects
3102
+	for index, projectMap := range tempProjects {
3103
+
3104
+		projectM := projectMap.(map[string]interface{})
3105
+
3106
+		var project models.HisProject
3107
+		if projectM["project_name"] == nil || reflect.TypeOf(projectM["project_name"]).String() != "string" {
3108
+			utils.ErrorLog("project_name")
3109
+			return
3110
+		}
3111
+
3112
+		project_name, _ := projectM["project_name"].(string)
3113
+		if len(project_name) == 0 { //名字为空则生成一条导入错误日志
3114
+			err_log := models.ExportErrLog{
3115
+				LogType:    6,
3116
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3117
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的项目名称不能为空",
3118
+				Status:     1,
3119
+				CreateTime: time.Now().Unix(),
3120
+				UpdateTime: time.Now().Unix(),
3121
+				ExportTime: time.Now().Unix(),
3122
+			}
3123
+			service.CreateExportErrLog(&err_log)
3124
+			continue
3125
+		}
3126
+
3127
+		project.ProjectName = project_name
3128
+
3129
+		prices := projectM["price"].(string)
3130
+
3131
+		price, _ := strconv.ParseFloat(prices, 64)
3132
+		if price <= 0 { //名字为空则生成一条导入错误日志
3133
+			err_log := models.ExportErrLog{
3134
+				LogType:    6,
3135
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3136
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的零价不能为空",
3137
+				Status:     1,
3138
+				CreateTime: time.Now().Unix(),
3139
+				UpdateTime: time.Now().Unix(),
3140
+				ExportTime: time.Now().Unix(),
3141
+			}
3142
+			service.CreateExportErrLog(&err_log)
3143
+			continue
3144
+		}
3145
+
3146
+		project.Price = price
3147
+
3148
+		if projectM["unit"] == nil || reflect.TypeOf(projectM["unit"]).String() != "string" {
3149
+			utils.ErrorLog("unit_id")
3150
+			return
3151
+		}
3152
+
3153
+		unit := projectM["unit"].(string)
3154
+		if len(unit) == 0 { //名字为空则生成一条导入错误日志
3155
+			err_log := models.ExportErrLog{
3156
+				LogType:    6,
3157
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3158
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的单位不能为空或内容与系统不匹配",
3159
+				Status:     1,
3160
+				CreateTime: time.Now().Unix(),
3161
+				UpdateTime: time.Now().Unix(),
3162
+				ExportTime: time.Now().Unix(),
3163
+			}
3164
+			service.CreateExportErrLog(&err_log)
3165
+			continue
3166
+		}
3167
+		project.Unit = unit
3168
+
3169
+		cost_classify := projectM["cost_classify"].(string)
3170
+		if len(cost_classify) == 0 { //名字为空则生成一条导入错误日志
3171
+			err_log := models.ExportErrLog{
3172
+				LogType:    6,
3173
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3174
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空或内容与系统不匹配",
3175
+				Status:     1,
3176
+				CreateTime: time.Now().Unix(),
3177
+				UpdateTime: time.Now().Unix(),
3178
+				ExportTime: time.Now().Unix(),
3179
+			}
3180
+			service.CreateExportErrLog(&err_log)
3181
+			continue
3182
+		}
3183
+		var costClassify = "费用类别"
3184
+		var cost_classify_id int64
3185
+
3186
+		costClassifyConfig, _ := service.GetDrugDataConfig(0, costClassify)
3187
+
3188
+		if len(cost_classify) != 0 {
3189
+			_, errcode := service.IsExistDicConfig(costClassifyConfig.ID, cost_classify, orgId)
3190
+			if errcode == gorm.ErrRecordNotFound {
3191
+				dataconfig := models.DictDataconfig{
3192
+					ParentId:       costClassifyConfig.ID,
3193
+					Module:         "system",
3194
+					OrgId:          orgId,
3195
+					Name:           cost_classify,
3196
+					FieldName:      "",
3197
+					Value:          index + 50,
3198
+					CreatedTime:    "",
3199
+					UpdatedTime:    "",
3200
+					CreateUserId:   adminUser.AdminUser.Id,
3201
+					Status:         1,
3202
+					Remark:         "",
3203
+					DeleteIdSystem: 0,
3204
+					Title:          "",
3205
+					Content:        "",
3206
+					Order:          0,
3207
+					Code:           "",
3208
+				}
3209
+				service.CreatedDicConfig(&dataconfig)
3210
+			}
3211
+		}
3212
+
3213
+		costClassList, _ := service.GetParentDataConfig(costClassifyConfig.ID, orgId)
3214
+
3215
+		for _, it := range costClassList {
3216
+			if cost_classify == it.Name {
3217
+				cost_classify_id = int64(it.Value)
3218
+			}
3219
+		}
3220
+		project.CostClassify = cost_classify_id
3221
+
3222
+		executive_section := projectM["executive_section"].(string)
3223
+		if len(executive_section) == 0 { //名字为空则生成一条导入错误日志
3224
+			err_log := models.ExportErrLog{
3225
+				LogType:    6,
3226
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3227
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空或内容与系统不匹配",
3228
+				Status:     1,
3229
+				CreateTime: time.Now().Unix(),
3230
+				UpdateTime: time.Now().Unix(),
3231
+				ExportTime: time.Now().Unix(),
3232
+			}
3233
+			service.CreateExportErrLog(&err_log)
3234
+			continue
3235
+		}
3236
+
3237
+		if len(executive_section) != 0 {
3238
+			//查找科室是否有内容
3239
+			_, errcodedepart := service.GetDepartMentByName(executive_section, orgId)
3240
+			if errcodedepart == gorm.ErrRecordNotFound {
3241
+				department := models.XtHisDepartment{
3242
+					Name:        executive_section,
3243
+					Status:      1,
3244
+					UserOrgId:   adminUser.CurrentOrgId,
3245
+					CreatedTime: time.Now().Unix(),
3246
+				}
3247
+				service.CreateDePartment(&department)
3248
+			}
3249
+		}
3250
+		var executive_section_id int64
3251
+		departMentList, _ := service.GetAllDepartMent(orgId)
3252
+		for _, it := range departMentList {
3253
+			if executive_section == it.Name {
3254
+				executive_section_id = it.ID
3255
+			}
3256
+		}
3257
+		project.ExecutiveSection = executive_section_id
3258
+
3259
+		medical_coverage := projectM["medical_coverage"].(string)
3260
+		fmt.Println("3333333333333", medical_coverage)
3261
+		if len(medical_coverage) == 0 { //名字为空则生成一条导入错误日志
3262
+			err_log := models.ExportErrLog{
3263
+				LogType:    6,
3264
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3265
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空",
3266
+				Status:     1,
3267
+				CreateTime: time.Now().Unix(),
3268
+				UpdateTime: time.Now().Unix(),
3269
+				ExportTime: time.Now().Unix(),
3270
+			}
3271
+			service.CreateExportErrLog(&err_log)
3272
+			continue
3273
+		}
3274
+
3275
+		var medicalCoverage = "医保等级"
3276
+		var medical_coverage_id int64
3277
+
3278
+		medicalCoverageConfig, _ := service.GetDrugDataConfig(0, medicalCoverage)
3279
+		if len(medical_coverage) != 0 {
3280
+
3281
+			_, errormedicalcoverage := service.IsExistDicConfig(medicalCoverageConfig.ID, medical_coverage, orgId)
3282
+			if errormedicalcoverage == gorm.ErrRecordNotFound {
3283
+				dataconfig := models.DictDataconfig{
3284
+					ParentId:       medicalCoverageConfig.ID,
3285
+					Module:         "system",
3286
+					OrgId:          orgId,
3287
+					Name:           medical_coverage,
3288
+					FieldName:      "",
3289
+					Value:          index + 50,
3290
+					CreatedTime:    "",
3291
+					UpdatedTime:    "",
3292
+					CreateUserId:   adminUser.AdminUser.Id,
3293
+					Status:         1,
3294
+					Remark:         "",
3295
+					DeleteIdSystem: 0,
3296
+					Title:          "",
3297
+					Content:        "",
3298
+					Order:          0,
3299
+					Code:           "",
3300
+				}
3301
+				service.CreatedDicConfig(&dataconfig)
3302
+			}
3303
+		}
3304
+		medicalCoverageList, _ := service.GetParentDataConfig(medicalCoverageConfig.ID, orgId)
3305
+		for _, it := range medicalCoverageList {
3306
+			if medical_coverage == it.Name {
3307
+				medical_coverage_id = int64(it.Value)
3308
+			}
3309
+		}
3310
+		project.MedicalCoverage = medical_coverage_id
3311
+
3312
+		pinyin := projectM["pinyin"].(string)
3313
+		project.Pinyin = pinyin
3314
+
3315
+		wubi := projectM["wubi"].(string)
3316
+		fmt.Println("五笔333333333333333333333333333333", wubi)
3317
+		project.Wubi = wubi
3318
+
3319
+		statistical_classification := projectM["statistical_classification"].(string)
3320
+
3321
+		var statisticalClassification = "统计分类"
3322
+		var statistical_classification_id int64
3323
+		classiFication, _ := service.GetDrugDataConfig(0, statisticalClassification)
3324
+		if len(statistical_classification) != 0 {
3325
+
3326
+			_, classificationerrcodes := service.IsExistDicConfig(classiFication.ID, statistical_classification, orgId)
3327
+
3328
+			if classificationerrcodes == gorm.ErrRecordNotFound {
3329
+				dataconfig := models.DictDataconfig{
3330
+					ParentId:       classiFication.ID,
3331
+					Module:         "system",
3332
+					OrgId:          orgId,
3333
+					Name:           statistical_classification,
3334
+					FieldName:      "",
3335
+					Value:          index + 50,
3336
+					CreatedTime:    "",
3337
+					UpdatedTime:    "",
3338
+					CreateUserId:   adminUser.AdminUser.Id,
3339
+					Status:         1,
3340
+					Remark:         "",
3341
+					DeleteIdSystem: 0,
3342
+					Title:          "",
3343
+					Content:        "",
3344
+					Order:          0,
3345
+					Code:           "",
3346
+				}
3347
+				service.CreatedDicConfig(&dataconfig)
3348
+			}
3349
+
3350
+		}
3351
+		classiFicationList, _ := service.GetParentDataConfig(classiFication.ID, orgId)
3352
+
3353
+		for _, it := range classiFicationList {
3354
+			if statistical_classification == it.Name {
3355
+
3356
+				statistical_classification_id = int64(it.Value)
3357
+			}
3358
+		}
3359
+
3360
+		project.StatisticalClassification = statistical_classification_id
3361
+
3362
+		disease_directory := int64(projectM["disease_directory"].(float64))
3363
+		project.DiseaseDirectory = disease_directory
3364
+
3365
+		is_record := int64(projectM["is_record"].(float64))
3366
+		project.IsRecord = is_record
3367
+
3368
+		medical_code := projectM["medical_code"].(string)
3369
+		project.MedicalCode = medical_code
3370
+
3371
+		tube_color := projectM["tube_color"].(string)
3372
+
3373
+		var tubeColor = "试管颜色"
3374
+		var tube_color_id int64
3375
+		tubeColorConfig, _ := service.GetDrugDataConfig(0, tubeColor)
3376
+		if len(tube_color) != 0 {
3377
+			_, errcodetube := service.IsExistDicConfig(tubeColorConfig.ID, tube_color, orgId)
3378
+			if errcodetube == gorm.ErrRecordNotFound {
3379
+				dataconfig := models.DictDataconfig{
3380
+					ParentId:       tubeColorConfig.ID,
3381
+					Module:         "system",
3382
+					OrgId:          orgId,
3383
+					Name:           tube_color,
3384
+					FieldName:      "",
3385
+					Value:          index + 50,
3386
+					CreatedTime:    "",
3387
+					UpdatedTime:    "",
3388
+					CreateUserId:   adminUser.AdminUser.Id,
3389
+					Status:         1,
3390
+					Remark:         "",
3391
+					DeleteIdSystem: 0,
3392
+					Title:          "",
3393
+					Content:        "",
3394
+					Order:          0,
3395
+					Code:           "",
3396
+				}
3397
+				service.CreatedDicConfig(&dataconfig)
3398
+			}
3399
+
3400
+		}
3401
+
3402
+		tubeColorList, _ := service.GetParentDataConfig(tubeColorConfig.ID, orgId)
3403
+		for _, it := range tubeColorList {
3404
+			if tube_color == it.Name {
3405
+				tube_color_id = int64(it.Value)
3406
+			}
3407
+		}
3408
+
3409
+		project.TubeColor = tube_color_id
3410
+
3411
+		single_dose := projectM["single_dose"].(string)
3412
+		project.SingleDose = single_dose
3413
+		execution_frequency := projectM["execution_frequency"].(string)
3414
+		project.ExecutionFrequency = execution_frequency
3415
+
3416
+		delivery_way := projectM["delivery_way"].(string)
3417
+		project.DeliveryWay = delivery_way
3418
+
3419
+		number_days := projectM["number_days"].(string)
3420
+		project.NumberDays = number_days
3421
+
3422
+		total := projectM["total"].(string)
3423
+		project.Total = total
3424
+
3425
+		medical_status := int64(projectM["medical_status"].(float64))
3426
+		project.MedicalStatus = medical_status
3427
+
3428
+		category := int64(projectM["category"].(float64))
3429
+		project.Category = category
3430
+
3431
+		specail_project := int64(projectM["specail_project"].(float64))
3432
+		project.SpecailProject = specail_project
3433
+
3434
+		social_security_directory_code := projectM["social_security_directory_code"].(string)
3435
+		fmt.Println("社保目录编码22222222222", social_security_directory_code)
3436
+		project.SocialSecurityDirectoryCode = social_security_directory_code
3437
+
3438
+		remark := projectM["remark"].(string)
3439
+		project.Remark = remark
3440
+
3441
+		record_date := projectM["record_date"].(string)
3442
+		fmt.Println("日期222222222", record_date)
3443
+		timeLayout := "2006-01-02"
3444
+		loc, _ := time.LoadLocation("Local")
3445
+
3446
+		theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
3447
+		project.RecordDate = theTime.Unix()
3448
+		projectList = append(projectList, &project)
3449
+	}
3450
+
3451
+	export_time := time.Now().Unix()
3452
+
3453
+	errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
3454
+	if len(projectList) > 0 {
3455
+		for _, item := range projectList {
3456
+			project := models.HisProject{
3457
+				ProjectName:      item.ProjectName,
3458
+				Price:            item.Price,
3459
+				Unit:             item.Unit,
3460
+				CostClassify:     item.CostClassify,
3461
+				ExecutiveSection: item.ExecutiveSection,
3462
+				MedicalCoverage:  item.MedicalCoverage,
3463
+				UserOrgId:        orgId,
3464
+				Status:           1,
3465
+				CreatedTime:      time.Now().Unix(),
3466
+				Pinyin:           item.Pinyin,
3467
+				Wubi:             item.Wubi,
3468
+				StatisticalClassification: item.StatisticalClassification,
3469
+				DiseaseDirectory:          item.DiseaseDirectory,
3470
+				IsRecord:                  item.IsRecord,
3471
+				MedicalCode:               item.MedicalCode,
3472
+				TubeColor:                 item.TubeColor,
3473
+				SingleDose:                item.SingleDose,
3474
+				DeliveryWay:               item.DeliveryWay,
3475
+				NumberDays:                item.NumberDays,
3476
+				Total:                     item.Total,
3477
+				Category:                  item.Category,
3478
+				MedicalStatus:             item.MedicalStatus,
3479
+				SpecailProject:            item.SpecailProject,
3480
+				RecordDate:                item.RecordDate,
3481
+				Remark:                    item.Remark,
3482
+				SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
3483
+				ExecutionFrequency:          item.ExecutionFrequency,
3484
+			}
3485
+
3486
+			_, errcodeproject := service.GetProjectByNameIsExsit(item.ProjectName, orgId)
3487
+			if errcodeproject == gorm.ErrRecordNotFound {
3488
+				service.CreateProjectInfomation(&project)
3489
+			} else if errcodeproject == nil {
3490
+				service.UpdateProjectByName(&project, item.ProjectName, orgId)
3491
+			}
3492
+
3493
+			log := models.ExportLog{
3494
+				LogType:    6,
3495
+				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3496
+				TotalNum:   int64(len(total_goods)),
3497
+				FailNum:    int64(len(errLogs)),
3498
+				SuccessNum: int64(len(projectList)),
3499
+				CreateTime: time.Now().Unix(),
3500
+				UpdateTime: time.Now().Unix(),
3501
+				ExportTime: export_time,
3502
+				Status:     1,
3503
+			}
3504
+			service.CreateExportLog(&log)
3505
+			c.ServeSuccessJSON(map[string]interface{}{
3506
+				"msg":         "导入成功",
3507
+				"total_num":   len(total_goods),
3508
+				"success_num": len(projectList),
3509
+				"fail_num":    int64(len(errLogs)),
3510
+			})
3511
+		}
3512
+	} else {
3513
+		log := models.ExportLog{
3514
+			LogType:    6,
3515
+			UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3516
+			TotalNum:   int64(len(total_goods)),
3517
+			FailNum:    int64(len(errLogs)),
3518
+			SuccessNum: int64(len(projectList)),
3519
+			CreateTime: time.Now().Unix(),
3520
+			UpdateTime: time.Now().Unix(),
3521
+			ExportTime: export_time,
3522
+			Status:     1,
3523
+		}
3524
+		service.CreateExportLog(&log)
3525
+
3526
+		c.ServeSuccessJSON(map[string]interface{}{
3527
+			"msg":         "导入成功",
3528
+			"total_num":   len(total_goods),
3529
+			"success_num": len(projectList),
3530
+			"fail_num":    int64(len(errLogs)),
3531
+		})
3532
+	}
3533
+}

+ 5 - 6
controllers/manager_center_api_controller.go View File

@@ -347,7 +347,6 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
347 347
 	//查询是否存在
348 348
 	_, errOne := service.GetDrugNameIsExist(id, adminInfo.CurrentOrgId)
349 349
 	if errOne == gorm.ErrRecordNotFound {
350
-		fmt.Println("进来了吗")
351 350
 		c.ServeSuccessJSON(map[string]interface{}{
352 351
 			"msg": "修改成功",
353 352
 		})
@@ -383,7 +382,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
383 382
 	_, errThree := service.GetSelfMedicalIsExist(id, adminInfo.CurrentOrgId)
384 383
 
385 384
 	if errThree == gorm.ErrRecordNotFound {
386
-		fmt.Println("进来了吗2")
385
+
387 386
 		c.ServeSuccessJSON(map[string]interface{}{
388 387
 			"msg": "修改成功",
389 388
 		})
@@ -405,7 +404,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
405 404
 
406 405
 	_, errFour := service.GetSelfStosckIsExist(id, adminInfo.CurrentOrgId)
407 406
 	if errFour == gorm.ErrRecordNotFound {
408
-		fmt.Println("进来了吗3")
407
+
409 408
 		c.ServeSuccessJSON(map[string]interface{}{
410 409
 			"msg": "修改成功",
411 410
 		})
@@ -421,7 +420,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
421 420
 
422 421
 	_, errFive := service.GetOutSelfOutStockIsExist(id, adminInfo.CurrentOrgId)
423 422
 	if errFive == gorm.ErrRecordNotFound {
424
-		fmt.Println("进来了吗4")
423
+
425 424
 		c.ServeSuccessJSON(map[string]interface{}{
426 425
 			"msg": "修改成功",
427 426
 		})
@@ -1448,7 +1447,7 @@ func (c *ManagerCenterApiController) CreateGoodInfo() {
1448 1447
 	special_medical := c.GetString("special_medical")
1449 1448
 	adminUserInfo := c.GetAdminUserInfo()
1450 1449
 
1451
-	totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId, good_id)
1450
+	totals := service.FindGoodInfoByNameTwo(specification_name, adminUserInfo.CurrentOrgId, good_id, good_name)
1452 1451
 	if totals > 0 {
1453 1452
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
1454 1453
 		return
@@ -1598,7 +1597,7 @@ func (c *ManagerCenterApiController) ModifyGoodInfo() {
1598 1597
 		ProductionType:              production_type,
1599 1598
 	}
1600 1599
 
1601
-	totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id)
1600
+	totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id, good_name)
1602 1601
 	if totals > 0 {
1603 1602
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
1604 1603
 		return

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -335,7 +335,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
335 335
 
336 336
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
337 337
 
338
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 {
338
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 {
339 339
 		dewater_amount = dewater_amount * 1000
340 340
 	}
341 341
 

+ 12 - 12
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -1158,11 +1158,11 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1158 1158
 		PreImpulse:                 pre_impulse,
1159 1159
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
1160 1160
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
1161
-		Blood:                      blood,
1162
-		DialysisDialyszers:         dialysis_dialyszers,
1163
-		DialysisIrrigation:         dialysis_irrigation,
1164
-		AntioxidantCommodityName:   antioxidant_commodity_name,
1165
-		DisplaceSpeed:              displace_speed,
1161
+		Blood:                    blood,
1162
+		DialysisDialyszers:       dialysis_dialyszers,
1163
+		DialysisIrrigation:       dialysis_irrigation,
1164
+		AntioxidantCommodityName: antioxidant_commodity_name,
1165
+		DisplaceSpeed:            displace_speed,
1166 1166
 	}
1167 1167
 
1168 1168
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -2039,11 +2039,11 @@ func (c *DialysisAPIController) PostSolution() {
2039 2039
 		ALiquid:                   a_liquid,
2040 2040
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
2041 2041
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
2042
-		Blood:                     blood,
2043
-		DialysisDialyszers:        dialysis_dialyszers,
2044
-		DialysisIrrigation:        dialysis_irrigation,
2045
-		AntioxidantCommodityName:  antioxidant_commodity_name,
2046
-		DisplaceSpeed:             displace_speed,
2042
+		Blood:                    blood,
2043
+		DialysisDialyszers:       dialysis_dialyszers,
2044
+		DialysisIrrigation:       dialysis_irrigation,
2045
+		AntioxidantCommodityName: antioxidant_commodity_name,
2046
+		DisplaceSpeed:            displace_speed,
2047 2047
 	}
2048 2048
 
2049 2049
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -2285,7 +2285,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2285 2285
 				record.UltrafiltrationRate = ultrafiltration_rate
2286 2286
 			}
2287 2287
 
2288
-			if template.TemplateId == 32 || template.TemplateId == 34 {
2288
+			if template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 {
2289 2289
 
2290 2290
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1)
2291 2291
 				record.UltrafiltrationRate = ultrafiltration_rate
@@ -2313,7 +2313,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2313 2313
 		}
2314 2314
 	}
2315 2315
 
2316
-	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 { //adminInfo.Org.Id == 9538
2316
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 { //adminInfo.Org.Id == 9538
2317 2317
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2318 2318
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2319 2319
 			record.UltrafiltrationVolume = ultrafiltration_volume

+ 10 - 3
controllers/print_data_api_controller.go View File

@@ -92,13 +92,20 @@ func (this *PrintDataAPIController) StockRecordPrintData() {
92 92
 
93 93
 	list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
94 94
 	stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
95
+
96
+	info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
97
+
98
+	infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
95 99
 	if err != nil {
96 100
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
97 101
 	} else {
98 102
 		this.ServeSuccessJSON(map[string]interface{}{
99
-			"list":       list,
100
-			"type":       types,
101
-			"stockTotal": stockTotal,
103
+			"list":           list,
104
+			"type":           types,
105
+			"stockTotal":     stockTotal,
106
+			"info":           info,
107
+			"orgid":          adminUserInfo.CurrentOrgId,
108
+			"infomationList": infomationList,
102 109
 		})
103 110
 	}
104 111
 }

+ 154 - 103
controllers/schedule_api_controller.go View File

@@ -2011,112 +2011,163 @@ func (this *ScheduleApiController) GetCopyPatientSchedules() {
2011 2011
 	//获取本周患者排班
2012 2012
 	schedules, _ := service.GetWeekSchedules(orgId, start_time, end_time)
2013 2013
 
2014
-	//查询复制中的排班日期是否存在
2015
-	_, errcode := service.GetLastWeekSchedule(orgId, copy_startime, copy_endtime)
2016
-
2017
-	if errcode == gorm.ErrRecordNotFound {
2018
-		//如果没有直接新增
2019
-
2020
-		for _, item := range schedules {
2021
-			//fmt.Println(item.StartTime+604800)
2022
-			//礼拜1
2023
-			if item.ScheduleWeek == 1 {
2024
-				item.ScheduleDate = copy_startime
2025
-			}
2026
-			if item.ScheduleWeek == 2 {
2027
-				item.ScheduleDate = copy_startime + 86400
2028
-			}
2029
-			if item.ScheduleWeek == 3 {
2030
-				item.ScheduleDate = copy_startime + 172800
2031
-			}
2032
-			if item.ScheduleWeek == 4 {
2033
-				item.ScheduleDate = copy_startime + 259200
2034
-			}
2035
-			if item.ScheduleWeek == 5 {
2036
-				item.ScheduleDate = copy_startime + 345600
2037
-			}
2038
-
2039
-			if item.ScheduleWeek == 6 {
2040
-				item.ScheduleDate = copy_startime + 432000
2041
-			}
2042
-			//礼拜天
2043
-			if item.ScheduleWeek == 0 {
2044
-				item.ScheduleDate = copy_endtime
2045
-			}
2046
-			schedule := models.XtSchedule{
2047
-				UserOrgId:    item.UserOrgId,
2048
-				PartitionId:  item.PartitionId,
2049
-				BedId:        item.BedId,
2050
-				PatientId:    item.PatientId,
2051
-				ScheduleDate: item.ScheduleDate,
2052
-				ScheduleType: item.ScheduleType,
2053
-				ScheduleWeek: item.ScheduleWeek,
2054
-				ModeId:       item.ModeId,
2055
-				Status:       1,
2056
-				CreatedTime:  time.Now().Unix(),
2057
-			}
2058
-
2059
-			err := service.AddPatientSchedule(&schedule)
2060
-			if err != nil {
2061
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2062
-				return
2063
-			}
2064
-			this.ServeSuccessJSON(map[string]interface{}{
2065
-				"schedule": schedule,
2066
-			})
2014
+	//先清除复制周的排班
2015
+	errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
2016
+	fmt.Println(errcode)
2017
+	for _, item := range schedules {
2018
+		//fmt.Println(item.StartTime+604800)
2019
+		//礼拜1
2020
+		if item.ScheduleWeek == 1 {
2021
+			item.ScheduleDate = copy_startime
2022
+		}
2023
+		if item.ScheduleWeek == 2 {
2024
+			item.ScheduleDate = copy_startime + 86400
2025
+		}
2026
+		if item.ScheduleWeek == 3 {
2027
+			item.ScheduleDate = copy_startime + 172800
2028
+		}
2029
+		if item.ScheduleWeek == 4 {
2030
+			item.ScheduleDate = copy_startime + 259200
2031
+		}
2032
+		if item.ScheduleWeek == 5 {
2033
+			item.ScheduleDate = copy_startime + 345600
2067 2034
 		}
2068
-	} else if errcode == nil {
2069
-
2070
-		//先清除复制周的排班
2071
-		errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
2072
-		fmt.Println(errcode)
2073
-		for _, item := range schedules {
2074
-			//fmt.Println(item.StartTime+604800)
2075
-			//礼拜1
2076
-			if item.ScheduleWeek == 1 {
2077
-				item.ScheduleDate = copy_startime
2078
-			}
2079
-			if item.ScheduleWeek == 2 {
2080
-				item.ScheduleDate = copy_startime + 86400
2081
-			}
2082
-			if item.ScheduleWeek == 3 {
2083
-				item.ScheduleDate = copy_startime + 172800
2084
-			}
2085
-			if item.ScheduleWeek == 4 {
2086
-				item.ScheduleDate = copy_startime + 259200
2087
-			}
2088
-			if item.ScheduleWeek == 5 {
2089
-				item.ScheduleDate = copy_startime + 345600
2090
-			}
2091 2035
 
2092
-			if item.ScheduleWeek == 6 {
2093
-				item.ScheduleDate = copy_startime + 432000
2094
-			}
2095
-			//礼拜天
2096
-			if item.ScheduleWeek == 0 {
2097
-				item.ScheduleDate = copy_endtime
2098
-			}
2099
-			schedule := models.XtSchedule{
2100
-				UserOrgId:    item.UserOrgId,
2101
-				PartitionId:  item.PartitionId,
2102
-				BedId:        item.BedId,
2103
-				PatientId:    item.PatientId,
2104
-				ScheduleDate: item.ScheduleDate,
2105
-				ScheduleType: item.ScheduleType,
2106
-				ScheduleWeek: item.ScheduleWeek,
2107
-				ModeId:       item.ModeId,
2108
-				Status:       1,
2109
-				CreatedTime:  time.Now().Unix(),
2110
-			}
2036
+		if item.ScheduleWeek == 6 {
2037
+			item.ScheduleDate = copy_startime + 432000
2038
+		}
2039
+		//礼拜天
2040
+		if item.ScheduleWeek == 0 {
2041
+			item.ScheduleDate = copy_endtime
2042
+		}
2043
+		schedule := models.XtSchedule{
2044
+			UserOrgId:    item.UserOrgId,
2045
+			PartitionId:  item.PartitionId,
2046
+			BedId:        item.BedId,
2047
+			PatientId:    item.PatientId,
2048
+			ScheduleDate: item.ScheduleDate,
2049
+			ScheduleType: item.ScheduleType,
2050
+			ScheduleWeek: item.ScheduleWeek,
2051
+			ModeId:       item.ModeId,
2052
+			Status:       1,
2053
+			CreatedTime:  time.Now().Unix(),
2054
+		}
2111 2055
 
2112
-			err := service.AddPatientSchedule(&schedule)
2113
-			if err != nil {
2114
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2115
-				return
2116
-			}
2117
-			this.ServeSuccessJSON(map[string]interface{}{
2118
-				"schedule": schedule,
2119
-			})
2056
+		err := service.AddPatientSchedule(&schedule)
2057
+		if err != nil {
2058
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2059
+			return
2120 2060
 		}
2061
+		this.ServeSuccessJSON(map[string]interface{}{
2062
+			"schedule": schedule,
2063
+		})
2121 2064
 	}
2065
+	//查询复制中的排班日期是否存在
2066
+	//_, errcode := service.GetLastWeekSchedule(orgId, copy_startime, copy_endtime)
2067
+	//
2068
+	//if errcode == gorm.ErrRecordNotFound {
2069
+	//	//如果没有直接新增
2070
+	//
2071
+	//	for _, item := range schedules {
2072
+	//		//fmt.Println(item.StartTime+604800)
2073
+	//		//礼拜1
2074
+	//		if item.ScheduleWeek == 1 {
2075
+	//			item.ScheduleDate = copy_startime
2076
+	//		}
2077
+	//		if item.ScheduleWeek == 2 {
2078
+	//			item.ScheduleDate = copy_startime + 86400
2079
+	//		}
2080
+	//		if item.ScheduleWeek == 3 {
2081
+	//			item.ScheduleDate = copy_startime + 172800
2082
+	//		}
2083
+	//		if item.ScheduleWeek == 4 {
2084
+	//			item.ScheduleDate = copy_startime + 259200
2085
+	//		}
2086
+	//		if item.ScheduleWeek == 5 {
2087
+	//			item.ScheduleDate = copy_startime + 345600
2088
+	//		}
2089
+	//
2090
+	//		if item.ScheduleWeek == 6 {
2091
+	//			item.ScheduleDate = copy_startime + 432000
2092
+	//		}
2093
+	//		//礼拜天
2094
+	//		if item.ScheduleWeek == 0 {
2095
+	//			item.ScheduleDate = copy_endtime
2096
+	//		}
2097
+	//		schedule := models.XtSchedule{
2098
+	//			UserOrgId:    item.UserOrgId,
2099
+	//			PartitionId:  item.PartitionId,
2100
+	//			BedId:        item.BedId,
2101
+	//			PatientId:    item.PatientId,
2102
+	//			ScheduleDate: item.ScheduleDate,
2103
+	//			ScheduleType: item.ScheduleType,
2104
+	//			ScheduleWeek: item.ScheduleWeek,
2105
+	//			ModeId:       item.ModeId,
2106
+	//			Status:       1,
2107
+	//			CreatedTime:  time.Now().Unix(),
2108
+	//		}
2109
+	//
2110
+	//		err := service.AddPatientSchedule(&schedule)
2111
+	//		if err != nil {
2112
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2113
+	//			return
2114
+	//		}
2115
+	//		this.ServeSuccessJSON(map[string]interface{}{
2116
+	//			"schedule": schedule,
2117
+	//		})
2118
+	//	}
2119
+	//} else if errcode == nil {
2120
+	//
2121
+	//	//先清除复制周的排班
2122
+	//	errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
2123
+	//	fmt.Println(errcode)
2124
+	//	for _, item := range schedules {
2125
+	//		//fmt.Println(item.StartTime+604800)
2126
+	//		//礼拜1
2127
+	//		if item.ScheduleWeek == 1 {
2128
+	//			item.ScheduleDate = copy_startime
2129
+	//		}
2130
+	//		if item.ScheduleWeek == 2 {
2131
+	//			item.ScheduleDate = copy_startime + 86400
2132
+	//		}
2133
+	//		if item.ScheduleWeek == 3 {
2134
+	//			item.ScheduleDate = copy_startime + 172800
2135
+	//		}
2136
+	//		if item.ScheduleWeek == 4 {
2137
+	//			item.ScheduleDate = copy_startime + 259200
2138
+	//		}
2139
+	//		if item.ScheduleWeek == 5 {
2140
+	//			item.ScheduleDate = copy_startime + 345600
2141
+	//		}
2142
+	//
2143
+	//		if item.ScheduleWeek == 6 {
2144
+	//			item.ScheduleDate = copy_startime + 432000
2145
+	//		}
2146
+	//		//礼拜天
2147
+	//		if item.ScheduleWeek == 0 {
2148
+	//			item.ScheduleDate = copy_endtime
2149
+	//		}
2150
+	//		schedule := models.XtSchedule{
2151
+	//			UserOrgId:    item.UserOrgId,
2152
+	//			PartitionId:  item.PartitionId,
2153
+	//			BedId:        item.BedId,
2154
+	//			PatientId:    item.PatientId,
2155
+	//			ScheduleDate: item.ScheduleDate,
2156
+	//			ScheduleType: item.ScheduleType,
2157
+	//			ScheduleWeek: item.ScheduleWeek,
2158
+	//			ModeId:       item.ModeId,
2159
+	//			Status:       1,
2160
+	//			CreatedTime:  time.Now().Unix(),
2161
+	//		}
2162
+	//
2163
+	//		err := service.AddPatientSchedule(&schedule)
2164
+	//		if err != nil {
2165
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2166
+	//			return
2167
+	//		}
2168
+	//		this.ServeSuccessJSON(map[string]interface{}{
2169
+	//			"schedule": schedule,
2170
+	//		})
2171
+	//	}
2172
+	//}
2122 2173
 }

File diff suppressed because it is too large
+ 1406 - 4
controllers/stock_in_api_controller.go


+ 38 - 28
models/his_models.go View File

@@ -369,34 +369,44 @@ func (HisPrescription) TableName() string {
369 369
 }
370 370
 
371 371
 type HisProject struct {
372
-	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
373
-	ProjectName               string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
374
-	Pinyin                    string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
375
-	Wubi                      string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
376
-	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
377
-	Unit                      string  `gorm:"column:unit" json:"unit" form:"unit"`
378
-	CostClassify              int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
379
-	ExecutiveSection          int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
380
-	MedicalCoverage           int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
381
-	StatisticalClassification int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
382
-	DiseaseDirectory          int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
383
-	IsRecord                  int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
384
-	MedicalCode               string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
385
-	TubeColor                 int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
386
-	MedicalStatus             int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
387
-	Remark                    string  `gorm:"column:remark" json:"remark" form:"remark"`
388
-	Sign                      int64   `gorm:"column:sign" json:"sign" form:"sign"`
389
-	DefaultNumber             string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
390
-	IsDefault                 int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
391
-	IsCharge                  int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
392
-	IsEstimate                int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
393
-	IsWorkload                int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
394
-	Sort                      string  `gorm:"column:sort" json:"sort" form:"sort"`
395
-	DoctorAdvice              int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
396
-	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
397
-	Status                    int64   `gorm:"column:status" json:"status" form:"status"`
398
-	CreatedTime               int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
399
-	UpdatedTime               int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
372
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
373
+	ProjectName                 string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
374
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
375
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
376
+	Price                       float64 `gorm:"column:price" json:"price" form:"price"`
377
+	Unit                        string  `gorm:"column:unit" json:"unit" form:"unit"`
378
+	CostClassify                int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
379
+	ExecutiveSection            int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
380
+	MedicalCoverage             int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
381
+	StatisticalClassification   int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
382
+	DiseaseDirectory            int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
383
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
384
+	MedicalCode                 string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
385
+	TubeColor                   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
386
+	MedicalStatus               int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
387
+	Remark                      string  `gorm:"column:remark" json:"remark" form:"remark"`
388
+	Sign                        int64   `gorm:"column:sign" json:"sign" form:"sign"`
389
+	DefaultNumber               string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
390
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
391
+	IsCharge                    int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
392
+	IsEstimate                  int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
393
+	IsWorkload                  int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
394
+	Sort                        string  `gorm:"column:sort" json:"sort" form:"sort"`
395
+	DoctorAdvice                int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
396
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
397
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
398
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
399
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
400
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
401
+	NumberDays                  string  `gorm:"column:number_days" json:"number_days" form:"number_days"`
402
+	Total                       string  `gorm:"column:total" json:"total" form:"total"`
403
+	Category                    int64   `gorm:"column:category" json:"category" form:"category"`
404
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
405
+	SpecailProject              int64   `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
406
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
407
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
408
+	SingleDose                  string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
409
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
400 410
 }
401 411
 
402 412
 func (HisProject) TableName() string {

+ 26 - 0
models/self_drug_models.go View File

@@ -534,3 +534,29 @@ type BloodDrugWarehouseOutInfo struct {
534 534
 	Creater                 int64   `gorm:"column:creater" json:"creater" form:"creater"`
535 535
 	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
536 536
 }
537
+
538
+type XtMonitorConfig struct {
539
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
540
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
541
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
542
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
543
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
544
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
545
+}
546
+
547
+func (XtMonitorConfig) TableName() string {
548
+	return "xt_monitor_config"
549
+}
550
+
551
+type XtOrderConfig struct {
552
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
553
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
554
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
555
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
556
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
557
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
558
+}
559
+
560
+func (XtOrderConfig) TableName() string {
561
+	return "xt_order_config"
562
+}

+ 8 - 0
models/stock_models.go View File

@@ -308,3 +308,11 @@ type AutomaticReduceDetail struct {
308 308
 func (AutomaticReduceDetail) TableName() string {
309 309
 	return "xt_automatic_reduce_detail"
310 310
 }
311
+
312
+type VmWarehouseOutInfo struct {
313
+	GoodId int64   `gorm:"column:good_id" json:"good_id"`
314
+	Count  int64   `gorm:"column:count" json:"count"`
315
+	Remark string  `gorm:"column:remark" json:"remark"`
316
+	Price  float64 `gorm:"column:price" json:"price"`
317
+	OrgId  int64   `gorm:"column:org_id" json:"org_id"`
318
+}

+ 64 - 0
service/gobal_config_service.go View File

@@ -4,6 +4,7 @@ import (
4 4
 	"XT_New/models"
5 5
 	"fmt"
6 6
 	"github.com/jinzhu/gorm"
7
+	"time"
7 8
 )
8 9
 
9 10
 func CreateAutomaticReduceRecord(config *models.GobalConfig) (err error) {
@@ -395,3 +396,66 @@ func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoM
395 396
 
396 397
 	return autoMatic, err
397 398
 }
399
+
400
+func AddMonitorOpen(config *models.XtMonitorConfig) error {
401
+
402
+	err := XTWriteDB().Create(&config).Error
403
+
404
+	return err
405
+}
406
+
407
+func UpdateMonitorOpen(orgid int64, config *models.XtMonitorConfig) error {
408
+
409
+	err := XTWriteDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"is_open": config.IsOpen, "mtime": time.Now().Unix()}).Error
410
+	return err
411
+}
412
+
413
+func GetMonitorConfig(orgid int64) (models.XtMonitorConfig, error) {
414
+
415
+	config := models.XtMonitorConfig{}
416
+	err := XTReadDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
417
+	return config, err
418
+}
419
+
420
+func AddOrderConfig(config *models.XtOrderConfig) error {
421
+
422
+	err := XTWriteDB().Create(&config).Error
423
+	return err
424
+}
425
+
426
+func UpdateOrderConfig(orgid int64, config *models.XtOrderConfig) error {
427
+
428
+	err := XTWriteDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"is_open": config.IsOpen, "mtime": time.Now().Unix()}).Error
429
+	return err
430
+}
431
+
432
+func GetOrderConfigById(orgid int64) (*models.XtOrderConfig, error) {
433
+	config := models.XtOrderConfig{}
434
+	err := XTReadDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
435
+	if err == gorm.ErrRecordNotFound {
436
+		return nil, err
437
+	}
438
+	if err != nil {
439
+		return nil, err
440
+	}
441
+	return &config, nil
442
+}
443
+
444
+func GetOrderConfig(orgid int64) (models.XtOrderConfig, error) {
445
+	config := models.XtOrderConfig{}
446
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
447
+	return config, err
448
+}
449
+
450
+func GetMonitorConfigById(orgid int64) (*models.XtMonitorConfig, error) {
451
+
452
+	config := models.XtMonitorConfig{}
453
+	err := XTReadDB().Model(&config).Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
454
+	if err == gorm.ErrRecordNotFound {
455
+		return nil, err
456
+	}
457
+	if err != nil {
458
+		return nil, err
459
+	}
460
+	return &config, nil
461
+}

+ 1 - 0
service/mobile_dialysis_service.go View File

@@ -2039,6 +2039,7 @@ func BatchAdviceExecution(ids []string, creator int64, execution_state int64) er
2039 2039
 }
2040 2040
 
2041 2041
 func BatchHisAdviceExecution(ids []string, creator int64, execution_state int64) error {
2042
+
2042 2043
 	advice := models.HisDoctorAdviceInfo{}
2043 2044
 	err := XTWriteDB().Model(&advice).Where("id IN(?) and status = 1", ids).Updates(map[string]interface{}{"execution_state": 1, "execution_staff": creator, "execution_time": execution_state}).Error
2044 2045
 	return err

+ 13 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -198,3 +198,16 @@ func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoM
198 198
 
199 199
 	return autoMatic, err
200 200
 }
201
+
202
+func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutInfo []*models.VmWarehouseOutInfo, err error) {
203
+
204
+	db := p_service.XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status  =1")
205
+	err = db.Select("x.good_id,Sum(x.count) as count,x.remark,x.price,x.org_id").Where("x.ctime >=? and x.ctime<=? and x.org_id = ?", startime, endtime, orgid).Group("x.good_id").Scan(&houseOutInfo).Error
206
+	return houseOutInfo, err
207
+}
208
+
209
+func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error) {
210
+
211
+	err = p_service.XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&goodInfo).Error
212
+	return goodInfo, err
213
+}

+ 3 - 2
service/schedule_service.go View File

@@ -738,8 +738,9 @@ func GetLastWeekSchedule(orgid int64, startime int64, endtime int64) (*models.Xt
738 738
 	return &schedule, nil
739 739
 }
740 740
 func AddPatientSchedule(schedule *models.XtSchedule) error {
741
-
742
-	err := XTWriteDB().Create(&schedule).Error
741
+	utx := XTWriteDB().Begin()
742
+	err := utx.Create(&schedule).Error
743
+	utx.Commit()
743 744
 	return err
744 745
 }
745 746
 

+ 267 - 2
service/stock_service.go View File

@@ -1975,8 +1975,13 @@ func FindGoodInfoByName(name string, org_id int64, good_type_id int64) (total in
1975 1975
 	return
1976 1976
 }
1977 1977
 
1978
-func FindGoodInfoByNameOne(name string, org_id int64, good_type_id int64, id int64) (total int64) {
1979
-	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? AND good_type_id = ? and id <> ? ", org_id, name, good_type_id, id).Count(&total)
1978
+func FindGoodInfoByNameTwo(name string, org_id int64, good_type_id int64, good_name string) (total int64) {
1979
+	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? AND good_type_id = ? and good_name = ?", org_id, name, good_type_id, good_name).Count(&total)
1980
+	return
1981
+}
1982
+
1983
+func FindGoodInfoByNameOne(name string, org_id int64, good_type_id int64, id int64, goodname string) (total int64) {
1984
+	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? AND good_type_id = ? and id <> ? and good_name = ? ", org_id, name, good_type_id, id, goodname).Count(&total)
1980 1985
 	return
1981 1986
 }
1982 1987
 
@@ -2228,3 +2233,263 @@ func GetManufacturerName(orgid int64, name string) (*models.Manufacturer, error)
2228 2233
 	}
2229 2234
 	return &manufacturer, nil
2230 2235
 }
2236
+
2237
+func CreateManufacturer(manufacturer *models.Manufacturer) error {
2238
+
2239
+	err := XTWriteDB().Create(manufacturer).Error
2240
+	return err
2241
+}
2242
+
2243
+func UpdatedManufactur(manufacturer *models.Manufacturer, orgid int64) error {
2244
+
2245
+	err := XTWriteDB().Model(&manufacturer).Where("org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"manufacturer_name": manufacturer.ManufacturerName}).Error
2246
+	return err
2247
+}
2248
+
2249
+func GetGoodsInformaitonIsExist(goodName string, goodType int64, specificationName string, orgid int64) (*models.GoodInfo, error) {
2250
+
2251
+	var good models.GoodInfo
2252
+	var err error
2253
+	err = XTReadDB().Model(&good).Where("good_name = ? and good_type_id = ? and specification_name = ? and org_id = ? and status = 1", goodName, goodType, specificationName, orgid).Find(&good).Error
2254
+	if err == gorm.ErrRecordNotFound {
2255
+		return nil, err
2256
+	}
2257
+
2258
+	if err != nil {
2259
+		return nil, err
2260
+	}
2261
+
2262
+	return &good, nil
2263
+
2264
+}
2265
+
2266
+func CreateGoodsInfomation(info *models.GoodInfo) error {
2267
+
2268
+	err := XTWriteDB().Create(&info).Error
2269
+	return err
2270
+}
2271
+
2272
+func UpdateGoodsInformation(info *models.GoodInfo, goodName string, goodType int64, specificationName string, orgid int64) error {
2273
+
2274
+	err := XTWriteDB().Model(&info).Where("good_name = ? and good_type_id = ? and specification_name = ? and org_id = ? and status = 1", goodName, goodType, specificationName, orgid).Updates(map[string]interface{}{"good_name": info.GoodName, "good_type_id": info.GoodTypeId, "medical_insurance_level": info.MedicalInsuranceLevel, "good_kind": info.GoodKind, "specification_name": info.SpecificationName, "manufacturer": info.Manufacturer, "good_unit": info.GoodUnit, "retail_price": info.RetailPrice, "stock_warn_count": info.StockWarnCount, "dealer": info.Dealer, "pinyin": info.Pinyin, "wubi": info.Wubi, "buy_price": info.BuyPrice, "medical_insurance_number": info.MedicalInsuranceNumber, "is_special_diseases": info.IsSpecialDiseases, "is_record": info.IsRecord, "statistics_category": info.StatisticsCategory, "good_status": info.GoodStatus, "social_security_directory_code": info.SocialSecurityDirectoryCode, "production_type": info.ProductionType, "special_medical": info.SpecialMedical, "remark": info.Remark}).Error
2275
+	return err
2276
+}
2277
+
2278
+func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutInfo []*models.VmWarehouseOutInfo, err error) {
2279
+
2280
+	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status  =1")
2281
+	err = db.Select("x.good_id,Sum(x.count) as count,x.remark,x.price,x.org_id").Where("x.ctime >=? and x.ctime<=? and x.org_id = ?", startime, endtime, orgid).Group("x.good_id").Scan(&houseOutInfo).Error
2282
+	return houseOutInfo, err
2283
+}
2284
+
2285
+func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error) {
2286
+
2287
+	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&goodInfo).Error
2288
+	return goodInfo, err
2289
+}
2290
+
2291
+func IsExistDrugByName(drugname string, drugdesc string, orgid int64) (*models.BaseDrugLib, error) {
2292
+	var drug models.BaseDrugLib
2293
+	var err error
2294
+	err = XTReadDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and status =1", drugname, drugdesc).Find(&drug).Error
2295
+	if err == gorm.ErrRecordNotFound {
2296
+		return nil, err
2297
+	}
2298
+	if err != nil {
2299
+		return nil, err
2300
+	}
2301
+	return &drug, nil
2302
+}
2303
+
2304
+func CreateDrugsInfomation(info *models.BaseDrugLib) error {
2305
+	err := XTWriteDB().Create(&info).Error
2306
+	return err
2307
+}
2308
+
2309
+func UpdateDrugsInformation(drug *models.BaseDrugLib, drugName string, drugSpec string, orgid int64) error {
2310
+
2311
+	err := XTWriteDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and org_id = ? and status = 1", drugName, drugSpec, orgid).Updates(map[string]interface{}{"drug_name": drug.DrugName, "drug_alias": drug.DrugAlias, "drug_spec": drug.DrugSpec, "drug_type": drug.DrugType, "drug_stock_limit": drug.DrugStockLimit, "drug_origin_place": drug.DrugOriginPlace, "drug_dosage_form": drug.DrugDosageForm, "medical_insurance_level": drug.MedicalInsuranceLevel, "max_unit": drug.MaxUnit, "min_unit": drug.MinUnit, "unit_matrixing": drug.UnitMatrixing, "retail_price": drug.RetailPrice, "last_price": drug.LastPrice, "drug_classify": drug.DrugClassify, "manufacturer": drug.Manufacturer, "dealer": drug.Dealer, "pinyin": drug.Pinyin, "wubi": drug.Wubi, "drug_alias_pinyin": drug.DrugAliasPinyin, "drug_alias_wubi": drug.DrugAliasWubi, "drug_category": drug.DrugCategory, "drug_control": drug.DrugControl, "number": drug.Number, "hosp_appr_flag": drug.HospApprFlag, "medical_insurance_number": drug.MedicalInsuranceNumber, "pharmacology_category": drug.PharmacologyCategory, "statistics_category": drug.StatisticsCategory, "code": drug.Code, "is_special_diseases": drug.IsSpecialDiseases, "is_record": drug.IsRecord, "prescription_mark": drug.PrescriptionMark, "social_security_directory_code": drug.SocialSecurityDirectoryCode, "record_date": drug.RecordDate, "drug_remark": drug.DrugRemark, "drug_status": drug.DrugStatus, "limit_remark": drug.LimitRemark, "drug_dose": drug.DrugDose, "drug_dose_unit": drug.DrugDoseUnit, "lmt_used_flag": drug.LmtUsedFlag}).Error
2312
+	return err
2313
+}
2314
+
2315
+func GetProjectByNameIsExsit(projectName string, orgid int64) (*models.HisProject, error) {
2316
+
2317
+	var projoect models.HisProject
2318
+	var err error
2319
+	err = XTReadDB().Model(&projoect).Where("project_name = ? and user_org_id = ? and status =1", projectName, orgid).Find(&projoect).Error
2320
+	if err == gorm.ErrRecordNotFound {
2321
+		return nil, err
2322
+	}
2323
+	if err != nil {
2324
+		return nil, err
2325
+	}
2326
+	return &projoect, nil
2327
+}
2328
+
2329
+func CreateProjectInfomation(info *models.HisProject) error {
2330
+
2331
+	err := XTWriteDB().Create(&info).Error
2332
+	return err
2333
+}
2334
+
2335
+func UpdateProjectByName(project *models.HisProject, projectName string, orgid int64) error {
2336
+
2337
+	err := XTWriteDB().Model(&project).Where("project_name = ? and user_org_id = ? and status = 1", projectName, orgid).Updates(map[string]interface{}{"project_name": project.ProjectName, "price": project.Price, "unit": project.Unit, "cost_classify": project.CostClassify, "executive_section": project.ExecutiveSection, "medical_coverage": project.MedicalCoverage, "pinyin": project.Pinyin, "wubi": project.Wubi, "statistical_classification": project.StatisticalClassification, "disease_directory": project.DiseaseDirectory, "is_record": project.IsRecord, "medical_code": project.MedicalCode, "tube_color": project.TubeColor, "single_dose": project.SingleDose, "delivery_way": project.DeliveryWay, "execution_frequency": project.ExecutionFrequency, "number_days": project.NumberDays, "total": project.Total, "medical_status": project.MedicalStatus, "category": project.Category, "specail_project": project.SpecailProject, "social_security_directory_code": project.SocialSecurityDirectoryCode, "record_date": project.RecordDate, "remark": project.Remark}).Error
2338
+	return err
2339
+}
2340
+func GetWareOutInfoById(warehouseoutid int64, orgid int64) (warehouseinfo []*models.WarehouseOutInfo, err error) {
2341
+
2342
+	err = XTReadDB().Model(&warehouseinfo).Where("warehouse_out_id = ? and org_id = ? and status= 1 and is_sys = 0", warehouseoutid, orgid).Find(&warehouseinfo).Error
2343
+	return warehouseinfo, err
2344
+}
2345
+
2346
+func EditDrugWarehousingOne(warehouse models.DrugWarehouse, id int64) {
2347
+	err = readDb.Model(&models.DrugWarehouse{}).Where("warehousing_order = ? AND status = 1 and id = ?", warehouse.WarehousingOrder, id).Update(map[string]interface{}{"mtime": time.Now().Unix(), "warehousing_time": warehouse.WarehousingTime, "modifier": warehouse.Modifier, "dealer": warehouse.Dealer, "manufacturer": warehouse.Manufacturer}).Error
2348
+
2349
+}
2350
+
2351
+func GetAllManufacturerList(orgid int64) (list []*models.Manufacturer, err error) {
2352
+
2353
+	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&list).Error
2354
+	return list, err
2355
+}
2356
+
2357
+func GetAllDealerList(orgid int64) (list []*models.Dealer, err error) {
2358
+
2359
+	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&list).Error
2360
+	return list, err
2361
+}
2362
+func GetDealerByName(orgid int64, name string) (*models.Dealer, error) {
2363
+	var dealer models.Dealer
2364
+	var err error
2365
+	err = XTReadDB().Model(&dealer).Where("org_id = ? and dealer_name = ? and status = 1", orgid, name).Find(&dealer).Error
2366
+	if err == gorm.ErrRecordNotFound {
2367
+		return nil, err
2368
+	}
2369
+	if err != nil {
2370
+		return nil, err
2371
+	}
2372
+	return &dealer, nil
2373
+}
2374
+
2375
+func CreateDealer(dealer *models.Dealer) error {
2376
+
2377
+	err := XTWriteDB().Create(&dealer).Error
2378
+	return err
2379
+}
2380
+
2381
+func UpdateDealer(dealer *models.Dealer, orgid int64) error {
2382
+
2383
+	err := XTWriteDB().Model(&dealer).Where("org_id = ? and status  =1", orgid).Updates(map[string]interface{}{"dealer_name": dealer.DealerName}).Error
2384
+	return err
2385
+}
2386
+
2387
+func GetDrugDataConfig(orgid int64, name string) (models.DictDataconfig, error) {
2388
+	dataconfig := models.DictDataconfig{}
2389
+	err := XTReadDB().Where("org_id = ? and name = ?", orgid, name).Find(&dataconfig).Error
2390
+	return dataconfig, err
2391
+}
2392
+
2393
+func GetParentDataConfig(parentid int64, orgid int64) (dataconfig []*models.DictDataconfig, err error) {
2394
+
2395
+	err = XTReadDB().Where("parent_id = ?  and status =1 and (org_id = ? or org_id = 0)", parentid, orgid).Find(&dataconfig).Error
2396
+	return dataconfig, err
2397
+}
2398
+
2399
+func IsExistDicConfig(parentid int64, goodKind string, orgid int64) (*models.DictDataconfig, error) {
2400
+
2401
+	var dataconfig models.DictDataconfig
2402
+	var err error
2403
+	err = XTReadDB().Where("parent_id = ? and status = 1 and name = ? and (org_id = ? or org_id = 0)", parentid, goodKind, orgid).Find(&dataconfig).Error
2404
+	if err == gorm.ErrRecordNotFound {
2405
+		return nil, err
2406
+	}
2407
+	if err != nil {
2408
+		return nil, err
2409
+	}
2410
+	return &dataconfig, nil
2411
+}
2412
+
2413
+func CreatedDicConfig(dataconfig *models.DictDataconfig) error {
2414
+
2415
+	err := XTWriteDB().Create(&dataconfig).Error
2416
+	return err
2417
+}
2418
+
2419
+func UpdatedDicConfig(parentid int64, dataconfig *models.DictDataconfig, orgid int64, goodKind string) error {
2420
+
2421
+	err := XTWriteDB().Model(&dataconfig).Where("parent_id = ? and org_id = ? and name = ?", parentid, orgid, goodKind).Updates(map[string]interface{}{"name": dataconfig.Name}).Error
2422
+	return err
2423
+}
2424
+
2425
+func GetGoodType(goodName string, orgid int64) (*models.GoodsType, error) {
2426
+
2427
+	var goodType models.GoodsType
2428
+	var err error
2429
+	err = XTReadDB().Where("type_name =? and org_id = ? and status = 1", goodName, orgid).Find(&goodType).Error
2430
+	if err == gorm.ErrRecordNotFound {
2431
+		return nil, err
2432
+	}
2433
+	if err != nil {
2434
+		return nil, err
2435
+	}
2436
+	return &goodType, nil
2437
+}
2438
+
2439
+func CreatedGoodType(goodsType *models.GoodsType) error {
2440
+
2441
+	err := XTWriteDB().Create(&goodsType).Error
2442
+	return err
2443
+}
2444
+
2445
+func GetAllGoodType(orgid int64) (goodsType []*models.GoodsType, err error) {
2446
+
2447
+	err = XTReadDB().Model(&goodsType).Where("org_id = ? and status = 1", orgid).Find(&goodsType).Error
2448
+	return goodsType, err
2449
+}
2450
+
2451
+func GetDepartMentByName(name string, orgid int64) (*models.XtHisDepartment, error) {
2452
+
2453
+	var department models.XtHisDepartment
2454
+	var err error
2455
+	err = XTReadDB().Where("name= ? and user_org_id = ? and status = 1", name, orgid).Find(&department).Error
2456
+	if err == gorm.ErrRecordNotFound {
2457
+		return nil, err
2458
+	}
2459
+	if err != nil {
2460
+		return nil, err
2461
+	}
2462
+	return &department, nil
2463
+}
2464
+
2465
+func GetDataConfigIsExist(orgid int64, name string) (models.Dataconfig, error) {
2466
+	dataconfig := models.Dataconfig{}
2467
+	err := XTReadDB().Model(&dataconfig).Where("org_id = ? and name = ? and status = 1", orgid, name).Find(&dataconfig).Error
2468
+	return dataconfig, err
2469
+}
2470
+
2471
+func GetChildeConfigIsExist(parentid int64, name string, orgid int64) (*models.Dataconfig, error) {
2472
+
2473
+	var dataconfig models.Dataconfig
2474
+	var err error
2475
+	err = XTReadDB().Model(&dataconfig).Where("parent_id = ? and (org_id = ? or org_id = 0) and name = ? and status = 1", parentid, orgid, name).Find(&dataconfig).Error
2476
+	if err == gorm.ErrRecordNotFound {
2477
+		return nil, err
2478
+	}
2479
+	if err != nil {
2480
+		return nil, err
2481
+	}
2482
+	return &dataconfig, nil
2483
+}
2484
+
2485
+func CreateDataConfig(dataconfig *models.Dataconfig) error {
2486
+
2487
+	err := XTWriteDB().Create(&dataconfig).Error
2488
+	return err
2489
+}
2490
+
2491
+func FindAllDataConfigList(orgid int64, parentId int64) (dataconfig []*models.Dataconfig, err error) {
2492
+
2493
+	err = XTReadDB().Model(&dataconfig).Where("(org_id = ? or org_id = 0) and parent_id = ? and status = 1", orgid, parentId).Find(&dataconfig).Error
2494
+	return dataconfig, err
2495
+}