Browse Source

医保对接

csx 3 years ago
parent
commit
1089b78569

+ 38 - 20
controllers/his_api_controller.go View File

@@ -60,9 +60,9 @@ func HisManagerApiRegistRouters() {
60 60
 	beego.Router("/api/presettle/get", &HisApiController{}, "get:PreSettle")
61 61
 
62 62
 	beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
63
+	beego.Router("/api/refundnumber/post", &HisApiController{}, "post:RefundNumber")
63 64
 
64 65
 	beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
65
-
66 66
 	beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
67 67
 
68 68
 	//beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
@@ -3027,24 +3027,31 @@ func (c *HisApiController) GetUploadInfo() {
3027 3027
 //退款
3028 3028
 func (c *HisApiController) Refund() {
3029 3029
 	order_id, _ := c.GetInt64("order_id")
3030
-	//number := c.GetString("number")
3031
-
3032 3030
 	order, _ := service.GetHisOrderByID(order_id)
3033 3031
 	adminUser := c.GetAdminUserInfo()
3034
-	config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
3035
-	if config.IsOpen == 1 { //对接了医保,走医保流程
3036
-
3032
+	err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId)
3033
+	if err == nil {
3034
+		c.ServeSuccessJSON(map[string]interface{}{
3035
+			"msg": "退费成功",
3036
+		})
3037 3037
 	} else {
3038
-		err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId)
3039
-		if err == nil {
3040
-			c.ServeSuccessJSON(map[string]interface{}{
3041
-				"msg": "退费成功",
3042
-			})
3043
-		} else {
3044
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3045
-			return
3046
-		}
3038
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3039
+		return
3040
+	}
3041
+}
3047 3042
 
3043
+func (c *HisApiController) RefundNumber() {
3044
+	his_patient_id, _ := c.GetInt64("id")
3045
+	info, _ := service.GetNewHisPatientInfo(his_patient_id)
3046
+	info.Status = 0
3047
+	err := service.SaveHisPatient(info)
3048
+	if err == nil {
3049
+		c.ServeSuccessJSON(map[string]interface{}{
3050
+			"msg": "退号成功",
3051
+		})
3052
+	} else {
3053
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3054
+		return
3048 3055
 	}
3049 3056
 
3050 3057
 }
@@ -4307,6 +4314,14 @@ func (c *HisApiController) CreateHisPrescriptionTemplate() {
4307 4314
 					return
4308 4315
 				}
4309 4316
 				types := int64(items["type"].(float64))
4317
+
4318
+				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
4319
+					utils.ErrorLog("med_type")
4320
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4321
+					return
4322
+				}
4323
+				med_type := strconv.Itoa(int(items["med_type"].(float64)))
4324
+
4310 4325
 				ctime := time.Now().Unix()
4311 4326
 				prescription := &models.HisPrescriptionInfoTemplate{
4312 4327
 					PatientId:   patient_id,
@@ -4318,6 +4333,7 @@ func (c *HisApiController) CreateHisPrescriptionTemplate() {
4318 4333
 					Creator:     adminInfo.AdminUser.Id,
4319 4334
 					Status:      1,
4320 4335
 					PTemplateId: template.ID,
4336
+					MedType:     med_type,
4321 4337
 				}
4322 4338
 				service.CreateHisPrescriptionInfoTemplate(prescription)
4323 4339
 
@@ -4610,6 +4626,7 @@ func (c *HisApiController) GetPrivateExpensesInfo() {
4610 4626
 	order_id, _ := c.GetInt64("id", 0)
4611 4627
 	his_patient_id, _ := c.GetInt64("his_patient_id", 0)
4612 4628
 	order, _ := service.GetHisOrderByID(order_id)
4629
+	role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, c.GetAdminUserInfo().AdminUser.Id)
4613 4630
 	if order.ID == 0 {
4614 4631
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
4615 4632
 		return
@@ -4620,11 +4637,12 @@ func (c *HisApiController) GetPrivateExpensesInfo() {
4620 4637
 	order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
4621 4638
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
4622 4639
 	c.ServeSuccessJSON(map[string]interface{}{
4623
-		"order":      order,
4624
-		"order_info": order_info,
4625
-		"patient":    patient,
4626
-		"admin_info": adminInfo,
4627
-		"his":        his,
4640
+		"order":         order,
4641
+		"order_info":    order_info,
4642
+		"patient":       patient,
4643
+		"admin_info":    adminInfo,
4644
+		"his":           his,
4645
+		"current_admin": role,
4628 4646
 	})
4629 4647
 
4630 4648
 }

+ 8 - 0
controllers/his_config_api_controller.go View File

@@ -130,6 +130,13 @@ func (c *HisConfigApiController) CreatePrescriptionTemplate() {
130 130
 				}
131 131
 				types := int64(items["type"].(float64))
132 132
 
133
+				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
134
+					utils.ErrorLog("med_type")
135
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
136
+					return
137
+				}
138
+				med_type := strconv.Itoa(int(items["med_type"].(float64)))
139
+
133 140
 				ctime := time.Now().Unix()
134 141
 				prescription := &models.HisPrescriptionInfoTemplate{
135 142
 					ID:          id,
@@ -142,6 +149,7 @@ func (c *HisConfigApiController) CreatePrescriptionTemplate() {
142 149
 					Creator:     adminInfo.AdminUser.Id,
143 150
 					Status:      1,
144 151
 					PTemplateId: src_template.ID,
152
+					MedType:     med_type,
145 153
 				}
146 154
 				service.CreateHisPrescriptionInfoTemplate(prescription)
147 155
 

+ 2 - 0
controllers/his_project_api_controller.go View File

@@ -1189,6 +1189,7 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1189 1189
 	adminUserInfo := this.GetAdminUserInfo()
1190 1190
 	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId)
1191 1191
 	projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId, "")
1192
+	his, _ := service.GetLastHisPatient(patient_id, adminUserInfo.CurrentOrgId)
1192 1193
 	//prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1193 1194
 	hisPatient, _ := service.GetHisPatientById(patient_id)
1194 1195
 	if err != nil {
@@ -1199,6 +1200,7 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1199 1200
 		"advicePrint": advicePrint,
1200 1201
 		"projectlist": projectlist,
1201 1202
 		"hisPatient":  hisPatient,
1203
+		"his":         his,
1202 1204
 	})
1203 1205
 }
1204 1206
 

+ 5 - 5
controllers/new_mobile_api_controllers/mobile_his_api_controller.go View File

@@ -470,11 +470,11 @@ func (c *MobileHisApiController) CreateHisPrescription() {
470 470
 				}
471 471
 				types := int64(items["type"].(float64))
472 472
 
473
-				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
474
-					utils.ErrorLog("med_type")
475
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
476
-					return
477
-				}
473
+				//if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
474
+				//	utils.ErrorLog("med_type")
475
+				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
476
+				//	return
477
+				//}
478 478
 				//med_type := int64(items["med_type"].(float64))
479 479
 				//med_type := strconv.Itoa(int(items["med_type"].(float64)))
480 480
 				//med_type := strconv.Itoa(int(items["med_type"].(float64)))

+ 2 - 0
models/his_models.go View File

@@ -129,6 +129,7 @@ type HisPatient struct {
129 129
 	PType                  int64   `gorm:"column:p_type" json:"p_type" form:"p_type"`
130 130
 	Diagnosis              int64   `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
131 131
 	SickType               int64   `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
132
+	PatientInfo            int64   `gorm:"column:patient_info" json:"patient_info" form:"patient_info"`
132 133
 }
133 134
 
134 135
 func (HisPatient) TableName() string {
@@ -1404,6 +1405,7 @@ type HisPrescriptionInfoTemplate struct {
1404 1405
 	PTemplateId                    int64                             `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
1405 1406
 	HisPrescriptionAdviceTemplate  []*HisPrescriptionAdviceTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
1406 1407
 	HisPrescriptionProjectTemplate []*HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
1408
+	MedType                        string                            `gorm:"column:med_type" json:"med_type" form:"med_type"`
1407 1409
 }
1408 1410
 
1409 1411
 func (HisPrescriptionInfoTemplate) TableName() string {

+ 5 - 0
service/his_project_service.go View File

@@ -719,3 +719,8 @@ func GetHisPatientByIdThree(id int64) (models.HisPatient, error) {
719 719
 	err := XTReadDB().Model(&patient).Where("id = ? and status = 1", id).First(&patient).Error
720 720
 	return patient, err
721 721
 }
722
+
723
+func GetLastHisPatient(patient_id int64, org_id int64) (his models.HisPatient, err error) {
724
+	err = XTReadDB().Model(&models.HisPatient{}).Where("user_org_id = ? AND patient_id = ? and status = 1 AND patient_info <> ''", org_id, patient_id).First(&his).Error
725
+	return
726
+}

+ 12 - 1
service/his_service.go View File

@@ -1018,6 +1018,11 @@ func UpdataOrderStatus(id int64, number string, user_org_id int64) (err error) {
1018 1018
 
1019 1019
 }
1020 1020
 
1021
+func SaveHisPatient(his models.HisPatient) (err error) {
1022
+	err = writeDb.Save(&his).Error
1023
+	return
1024
+}
1025
+
1021 1026
 func UpdataRegStatus(patient_id int64, record_time int64, org_id int64) {
1022 1027
 	writeDb.Model(&models.HisPatient{}).Where("patient_id = ? AND status = 1 AND record_date =? AND user_org_id = ?", patient_id, record_time, org_id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()})
1023 1028
 
@@ -1663,10 +1668,16 @@ type CustomAccountFormData struct {
1663 1668
 	DiagnosisId        int64   `gorm:"column:diagnosis_id" json:"diagnosis_id" form:"diagnosis_id"`
1664 1669
 	DialysisCount      int64   `gorm:"-"`
1665 1670
 	PatientId          int64   `gorm:"column:patient_id" json:"dialysis_count" form:"dialysis_count"`
1671
+	HifmiPay           float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
1672
+	HifobPay           float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
1673
+	CvlservPay         float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
1674
+	HifesPay           float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
1675
+	MayPay             float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
1676
+	SetlDetail         string  `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
1666 1677
 }
1667 1678
 
1668 1679
 func GetCheckAccountFormData(start_time int64, end_time int64, org_id int64, insutype string) (cus []*CustomAccountFormData, err error) {
1669
-	err = readDb.Raw("select o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND insutype = ? Group by o.id", org_id, start_time, end_time, insutype).Scan(&cus).Error
1680
+	err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND insutype = ? Group by o.id", org_id, start_time, end_time, insutype).Scan(&cus).Error
1670 1681
 
1671 1682
 	for _, item := range cus {
1672 1683
 		var total int64