Browse Source

医保对接

csx 3 years ago
parent
commit
4a9f616980

+ 46 - 27
controllers/his_api_controller.go View File

@@ -27,41 +27,28 @@ type HisApiController struct {
27 27
 func HisManagerApiRegistRouters() {
28 28
 
29 29
 	beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
30
-	//beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
31
-
32 30
 	beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
33 31
 	beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
34
-
35 32
 	beego.Router("/api/hisprescription/delete", &HisApiController{}, "post:DeletePrescription")
36 33
 	beego.Router("/api/advice/delete", &HisApiController{}, "post:DeleteDoctorAdvice")
37 34
 	beego.Router("/api/project/delete", &HisApiController{}, "post:DeleteProject")
38 35
 	beego.Router("/api/addition_charge/delete", &HisApiController{}, "post:DeleteAddition")
39
-
40 36
 	beego.Router("/api/hisprescription/list", &HisApiController{}, "get:GetHisPrescriptionList")
41 37
 	beego.Router("/api/hisprescription/info", &HisApiController{}, "get:GetHisPrescriptionInfo")
42
-
43 38
 	beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
44 39
 	beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
45
-
46 40
 	beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
47 41
 	beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
48 42
 	beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
49
-
50 43
 	beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
51
-
52 44
 	beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
53
-
54 45
 	beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
55
-
56 46
 	beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
57
-
58 47
 	beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
59 48
 	beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
60 49
 	beego.Router("/api/presettle/get", &HisApiController{}, "get:PreSettle")
61
-
62 50
 	beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
63 51
 	beego.Router("/api/refundnumber/post", &HisApiController{}, "post:RefundNumber")
64
-
65 52
 	beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
66 53
 	beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
67 54
 
@@ -79,15 +66,12 @@ func HisManagerApiRegistRouters() {
79 66
 	beego.Router("/api/orderdetaicollect/get", &HisApiController{}, "get:GetAllOrderDetailCollect")
80 67
 	beego.Router("/api/cost/compare", &HisApiController{}, "get:GetMedicalInsuranceCostCompareList")
81 68
 	beego.Router("/api/record/list", &HisApiController{}, "get:GetPutOnRecordList")
82
-
83 69
 	beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
84 70
 	beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
85
-
86 71
 	beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
87 72
 
88 73
 	beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
89 74
 	//beego.Router("/api/editprojectinformation", &HisApiController{}, "post:EditProjectInformation")
90
-
91 75
 	beego.Router("/api/hisprescriptiontemplate/create", &HisApiController{}, "post:CreateHisPrescriptionTemplate")
92 76
 
93 77
 	beego.Router("/api/privateexpenses/get", &HisApiController{}, "get:GetPrivateExpensesInfo")
@@ -4408,6 +4392,7 @@ func (c *HisApiController) GetUploadInfo() {
4408 4392
 			FaPiaoNumber:          fapiao_number,
4409 4393
 			Diagnosis:             diagnosis_id,
4410 4394
 			PType:                 2,
4395
+			//SetlTime:			t
4411 4396
 		}
4412 4397
 		err = service.CreateOrder(order)
4413 4398
 		if err != nil {
@@ -6440,22 +6425,56 @@ func (c *HisApiController) GetPrivateExpensesInfo() {
6440 6425
 
6441 6426
 func (this *HisApiController) ChangeMedType() {
6442 6427
 	med_type := this.GetString("med_type")
6443
-	id, _ := this.GetInt64("id")
6428
+	old_med_type := this.GetString("old_med_type")
6429
+	ids := this.GetString("ids")
6430
+	settle_type, _ := this.GetInt64("settle_type")
6431
+	start_time := this.GetString("start_time")
6432
+	end_time := this.GetString("end_time")
6433
+	ids_arr := strings.Split(ids, ",")
6434
+	if settle_type == 1 { //日结
6435
+		id, _ := strconv.ParseInt(ids_arr[0], 10, 64)
6436
+		prescription, _ := service.GetPrescriptionById(id, this.GetAdminUserInfo().CurrentOrgId)
6437
+		prescription.MedType = med_type
6438
+		err := service.SaveHisPrescription(&prescription)
6444 6439
 
6445
-	prescription, _ := service.GetPrescriptionById(id, this.GetAdminUserInfo().CurrentOrgId)
6446
-	prescription.MedType = med_type
6447
-	err := service.SaveHisPrescription(&prescription)
6440
+		if err == nil {
6441
+			this.ServeSuccessJSON(map[string]interface{}{
6442
+				"msg": "修改成功",
6443
+			})
6448 6444
 
6449
-	if err == nil {
6450
-		this.ServeSuccessJSON(map[string]interface{}{
6451
-			"msg": "修改成功",
6452
-		})
6445
+		} else {
6453 6446
 
6454
-	} else {
6447
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
6448
+			return
6455 6449
 
6456
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
6457
-		return
6450
+		}
6458 6451
 
6452
+	} else if settle_type == 2 {
6453
+		timeLayout := "2006-01-02"
6454
+		loc, _ := time.LoadLocation("Local")
6455
+		theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6456
+		if err != nil {
6457
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6458
+			return
6459
+		}
6460
+		recordStartTime := theStartTime.Unix()
6461
+		start_time_timestamp := recordStartTime
6462
+		theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
6463
+		if err != nil {
6464
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6465
+			return
6466
+		}
6467
+		recordEndTime := theEndTime.Unix()
6468
+		end_time_timestamp := recordEndTime
6469
+		updateErr := service.UpdateBatchHisPrescriptionMedType(ids_arr, med_type, start_time_timestamp, end_time_timestamp, this.GetAdminUserInfo().CurrentOrgId, old_med_type)
6470
+		if updateErr == nil {
6471
+			this.ServeSuccessJSON(map[string]interface{}{
6472
+				"msg": "修改成功",
6473
+			})
6474
+		} else {
6475
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
6476
+			return
6477
+		}
6459 6478
 	}
6460 6479
 
6461 6480
 }

+ 33 - 0
controllers/his_print_api_controller.go View File

@@ -0,0 +1,33 @@
1
+package controllers
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+)
6
+
7
+type HisPrintApiController struct {
8
+	BaseAuthAPIController
9
+}
10
+
11
+func HisPrintApiRegistRouters() {
12
+	beego.Router("/api/his/prescription/print", &HisPrintApiController{}, "get:GetBatchHisPrescriptionData")
13
+}
14
+
15
+func (c *HisPrintApiController) GetBatchHisPrescriptionData() {
16
+	//record_date := c.GetString("record_date")
17
+	//patient_ids := c.GetString("patient_ids")
18
+	//type := c.GetInt64("type")
19
+	//
20
+	//
21
+	//timeLayout := "2006-01-02"
22
+	//loc, _ := time.LoadLocation("Local")
23
+	//theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
24
+	//if err != nil {
25
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
26
+	//	return
27
+	//}
28
+	//recordDateTime := theTime.Unix()
29
+	//adminInfo := c.GetAdminUserInfo()
30
+	//
31
+	//ids := strings.Split(patient_ids,",")
32
+
33
+}

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

@@ -189,7 +189,12 @@ func (this *DialysisAPIController) Scheduals() {
189 189
 			}
190 190
 
191 191
 			//获取今日所有的处方开的耗材
192
-			project, _ := service.GetAllHisProjectPrescription(orgID, date.Unix())
192
+			_, configs := service.FindXTHisProjectByOrgId(orgID)
193
+			project := make([]*models.HisPrescriptionProjectTwo, 0)
194
+
195
+			if configs.ID > 0 && configs.IsOpen == 1 {
196
+				project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
197
+			}
193 198
 
194 199
 			//获取今日透析准备的数据
195 200
 			//goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())
@@ -220,7 +225,12 @@ func (this *DialysisAPIController) Scheduals() {
220 225
 
221 226
 		}
222 227
 		//获取今日所有的处方开的耗材
223
-		project, _ := service.GetAllHisProjectPrescription(orgID, date.Unix())
228
+		_, configs := service.FindXTHisProjectByOrgId(orgID)
229
+		project := make([]*models.HisPrescriptionProjectTwo, 0)
230
+
231
+		if configs.ID > 0 && configs.IsOpen == 1 {
232
+			project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
233
+		}
224 234
 
225 235
 		//获取今日透析准备的数据
226 236
 		//goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())

+ 47 - 0
models/his_models.go View File

@@ -1168,6 +1168,8 @@ type MedicalInsuranceOrgConfig struct {
1168 1168
 	MdtrtareaAdmvs string `gorm:"column:mdtrtarea_admvs" json:"mdtrtarea_admvs" form:"mdtrtarea_admvs"`
1169 1169
 	InsuplcAdmdvs  string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
1170 1170
 	SecretKey      string `gorm:"column:secret_key" json:"secret_key" form:"secret_key"`
1171
+	AccessKey      string `gorm:"column:access_key" json:"access_key" form:"access_key"`
1172
+	Cainfo         string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
1171 1173
 }
1172 1174
 
1173 1175
 func (MedicalInsuranceOrgConfig) TableName() string {
@@ -1875,3 +1877,48 @@ type NewCustomHisPrescriptionProject struct {
1875 1877
 func (NewCustomHisPrescriptionProject) TableName() string {
1876 1878
 	return "his_prescription_project"
1877 1879
 }
1880
+
1881
+type HisYidiClearRecord struct {
1882
+	ID              int64   `gorm:"column:id" json:"id" form:"id"`
1883
+	UserOrgId       int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1884
+	Ctime           int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1885
+	Mtime           int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1886
+	Status          int64   `gorm:"column:status" json:"status" form:"status"`
1887
+	Certno          string  `gorm:"column:certno" json:"certno" form:"certno"`
1888
+	MdtrtId         string  `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
1889
+	MdtrtSetlTime   string  `gorm:"column:mdtrt_setl_time" json:"mdtrt_setl_time" form:"mdtrt_setl_time"`
1890
+	SetlSn          string  `gorm:"column:setl_sn" json:"setl_sn" form:"setl_sn"`
1891
+	MedfeeSumant    float64 `gorm:"column:medfee_sumant" json:"medfee_sumant" form:"medfee_sumant"`
1892
+	OptinsPaySumamt float64 `gorm:"column:optins_pay_sumamt" json:"optins_pay_sumamt" form:"optins_pay_sumamt"`
1893
+	CnfmFlag        int64   `gorm:"column:cnfm_flag" json:"cnfm_flag" form:"cnfm_flag"`
1894
+	MsgId           string  `gorm:"column:msg_id" json:"msg_id" form:"msg_id"`
1895
+}
1896
+
1897
+func (HisYidiClearRecord) TableName() string {
1898
+	return "his_yidi_clear_record"
1899
+}
1900
+
1901
+type HisPrescriptionProjectTwo struct {
1902
+	ID             int64   `gorm:"column:id" json:"id" form:"id"`
1903
+	ProjectId      int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1904
+	Price          float64 `gorm:"column:price" json:"price" form:"price"`
1905
+	UserOrgId      int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1906
+	Status         int64   `gorm:"column:status" json:"status" form:"status"`
1907
+	PatientId      int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1908
+	RecordDate     int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
1909
+	PrescriptionId int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1910
+	Count          string  `gorm:"column:count" json:"count" form:"count"`
1911
+	FeedetlSn      string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1912
+	Type           int64   `gorm:"column:type" json:"type" form:"type"`
1913
+	Doctor         int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
1914
+	ExecutionTime  int64   `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
1915
+	ExecutionStaff int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1916
+	ExecutionState int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1917
+	CheckTime      int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
1918
+	CheckState     int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
1919
+	Checker        int64   `gorm:"column:checker" json:"checker" form:"checker"`
1920
+}
1921
+
1922
+func (HisPrescriptionProjectTwo) TableName() string {
1923
+	return "his_prescription_project"
1924
+}

+ 1 - 1
service/gobal_config_service.go View File

@@ -248,7 +248,7 @@ func GetExportHisOrderList(user_org_id int64, start_time int64, end_time int64,
248 248
 		Preload("HisPrescriptionInfo", func(db *gorm.DB) *gorm.DB {
249 249
 			return db.Where("status = 1 AND user_org_id = ?", user_org_id).Preload("XtHisDepartment", "status = 1")
250 250
 		})
251
-	err = db.Order("ctime desc").Find(&order).Error
251
+	err = db.Order("setl_time asc").Find(&order).Error
252 252
 	return
253 253
 }
254 254
 

+ 33 - 0
service/his_print_service.go View File

@@ -0,0 +1,33 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
7
+
8
+func GetBatchDrugHisPrescription(ids []string, record_time int64, user_org_id int64) (advices models.HisPrescription, err error) {
9
+	readDb.Model(&models.HisPrescription{}).
10
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
11
+			return db.Where("status = 1 AND user_org_id = ?", user_org_id).Preload("Drug", "status=1")
12
+		}).
13
+		Where("patient_id in (?) AND user_org_id = ? AND record_date = ? AND type = 1 ", ids, user_org_id, record_time).Find(&advices)
14
+	return
15
+}
16
+
17
+func GetBatchProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (advices models.HisPrescription, err error) {
18
+	readDb.Model(&models.HisPrescription{}).
19
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
20
+			return db.Where("status = 1 ").Preload("HisProject").Preload("GoodInfo", "status=1")
21
+		}).
22
+		Where("patient_id in (?) AND user_org_id = ? AND record_date = ? AND type <> 1", ids, user_org_id, record_time).Find(&advices)
23
+	return
24
+}
25
+
26
+func GetBatchInspectionProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (advices models.HisPrescription, err error) {
27
+	readDb.Model(&models.HisPrescription{}).
28
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
29
+			return db.Where("status = 1 ").Preload("HisProject").Preload("GoodInfo", "status=1")
30
+		}).
31
+		Where("patient_id in (?) AND user_org_id = ? AND record_date = ? AND type = 3", ids, user_org_id, record_time).Find(&advices)
32
+	return
33
+}

+ 26 - 5
service/his_service.go View File

@@ -884,12 +884,23 @@ func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int6
884 884
 	db = db.Preload("HisFundSettleListResult", "status = 1")
885 885
 	db = db.Count(&total)
886 886
 	db = db.Limit(limit).Offset(offset)
887
-	if sort_type == 1 {
888
-		err = db.Order("settle_accounts_date desc,ctime desc").Find(&order).Error
889
-	}
890
-	if sort_type == 2 {
891
-		err = db.Order("setl_time desc,ctime desc").Find(&order).Error
887
+	if user_org_id == 10215 {
888
+		if sort_type == 1 {
889
+			err = db.Order("settle_accounts_date asc,ctime asc").Find(&order).Error
890
+		}
891
+		if sort_type == 2 {
892
+			err = db.Order("setl_time asc,ctime asc").Find(&order).Error
893
+		}
894
+
895
+	} else {
896
+		if sort_type == 1 {
897
+			err = db.Order("settle_accounts_date desc,ctime desc").Find(&order).Error
898
+		}
899
+		if sort_type == 2 {
900
+			err = db.Order("setl_time desc,ctime desc").Find(&order).Error
901
+		}
892 902
 	}
903
+
893 904
 	return
894 905
 }
895 906
 
@@ -2254,3 +2265,13 @@ func GetHisDoctorAdviceInfo(id int64) (models.HisDoctorAdviceInfo, error) {
2254 2265
 	err := readDb.Model(&info).Where("id = ? and status = 1", id).Preload("Drug", "status = 1").Find(&info).Error
2255 2266
 	return info, err
2256 2267
 }
2268
+
2269
+func UpdateBatchHisPrescriptionMedType(ids []string, med_type string, start_time int64, end_time int64, user_org_id int64, old_med_type string) (err error) {
2270
+	tx := writeDb.Begin()
2271
+	if err = tx.Model(&models.HisPrescription{}).Where("id in (?) AND status = 1 AND user_org_id=? AND med_type = ? AND record_date >= ? AND record_date <= ?", ids, user_org_id, old_med_type, start_time, end_time).Updates(map[string]interface{}{"med_type": med_type}).Error; err != nil {
2272
+		tx.Rollback()
2273
+		return
2274
+	}
2275
+	tx.Commit()
2276
+	return
2277
+}

+ 2 - 5
service/patient_service.go View File

@@ -2612,10 +2612,7 @@ func GetAllPrescriptionByListOne(orgID int64, scheduleDate int64) (prescriptions
2612 2612
 	}
2613 2613
 }
2614 2614
 
2615
-func GetAllHisProjectPrescription(orgid int64, recorddate int64) (project []*models.HisPrescriptionProject, err error) {
2616
-
2617
-	err = XTReadDB().Where("user_org_id = ? and record_date = ? and status = 1", orgid, recorddate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
2618
-		return db.Preload("GoodsType", "status = 1").Where("status = 1 ")
2619
-	}).Find(&project).Error
2615
+func GetAllHisProjectPrescription(orgid int64, recorddate int64) (project []*models.HisPrescriptionProjectTwo, err error) {
2616
+	err = XTReadDB().Where("user_org_id = ? and record_date = ? and status = 1", orgid, recorddate).Find(&project).Error
2620 2617
 	return project, err
2621 2618
 }