Sfoglia il codice sorgente

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

28169 7 mesi fa
parent
commit
4bb8d06ecd

+ 45 - 0
controllers/his_api_controller.go Vedi File

@@ -10279,6 +10279,51 @@ func (this *HisApiController) GetCallHisPrescription() {
10279 10279
 	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
10280 10280
 	adminUserInfo := this.GetAdminUserInfo()
10281 10281
 	prescriptions, err := service.GetCallHisPrescriptions(startime.Unix(), endtime.Unix(), adminUserInfo.CurrentOrgId, patient_id, p_type)
10282
+
10283
+	//if
10284
+	//storeConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
10285
+	//
10286
+	//lastWarehouse, _ := service.FindLastDrugWarehousingInfoByID(s.DrugId, storeConfig.DrugStorehouseOut)
10287
+
10288
+	if adminUserInfo.CurrentOrgId == 10265 {
10289
+		_, config := service.FindHisStockPriceRecordByOrgId(adminUserInfo.CurrentOrgId)
10290
+		if config.ID > 0 && config.IsOpen == 1 {
10291
+			for _, subitems := range prescriptions {
10292
+				for _, item := range subitems.VMHisPrescription {
10293
+					for _, subItem := range item.HisDoctorAdviceInfo {
10294
+						drug, _ := service.GetDrugByGoodId(subItem.DrugId)
10295
+						info, _ := service.GetWarehoseInfoByDrugId(subItem.DrugId, adminUserInfo.CurrentOrgId)
10296
+						if info.RetailPrice > 0 {
10297
+							if subItem.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
10298
+								subItem.Drug.RetailPrice = info.RetailPrice * float64(drug.MinNumber)
10299
+							}
10300
+							if subItem.PrescribingNumberUnit == drug.MinUnit {
10301
+								subItem.Drug.MinPrice = info.RetailPrice
10302
+								subItem.Drug.RetailPrice = info.RetailPrice
10303
+							}
10304
+
10305
+						}
10306
+					}
10307
+				}
10308
+			}
10309
+		}
10310
+
10311
+		if config.ID > 0 && config.IsOpen == 1 {
10312
+			for _, subitems := range prescriptions {
10313
+				for _, item := range subitems.VMHisPrescription {
10314
+					for _, subItem := range item.HisPrescriptionProject {
10315
+						if subItem.Type == 3 {
10316
+							info, _ := service.GetGoodWarehoseInfoByGoodId(subItem.ProjectId, adminUserInfo.CurrentOrgId)
10317
+							if info.Price > 0 {
10318
+								subItem.GoodInfo.PackingPrice = info.Price
10319
+							}
10320
+						}
10321
+					}
10322
+				}
10323
+			}
10324
+		}
10325
+	}
10326
+
10282 10327
 	if err == nil {
10283 10328
 		this.ServeSuccessJSON(map[string]interface{}{
10284 10329
 			"prescriptions": prescriptions,

+ 1 - 0
models/his_charge_models.go Vedi File

@@ -387,6 +387,7 @@ type NewChargeDetail struct {
387 387
 	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
388 388
 	ItemId            int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
389 389
 	Pdate             string  `gorm:"column:pdate" json:"pdate" form:"pdate"`
390
+	CostClassify      int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
390 391
 }
391 392
 
392 393
 type NewHisChargeOrder struct {

+ 4 - 0
models/his_hospital_models.go Vedi File

@@ -85,6 +85,8 @@ type HisHospitalCheckRecord struct {
85 85
 	HisHospitalOrder     HisHospitalOrder `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"order"`
86 86
 	BalanceAccountsType  int64            `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
87 87
 	InsuplcAdmdvs        string           `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
88
+	ReturnOpter          string           `gorm:"column:return_opter" json:"return_opter" form:"return_opter"`
89
+	ReturnOpterTime      string           `gorm:"column:return_opter_time" json:"return_opter_time" form:"return_opter_time"`
88 90
 }
89 91
 
90 92
 func (HisHospitalCheckRecord) TableName() string {
@@ -133,6 +135,8 @@ type HisHospitalCheckRecordTwo struct {
133 135
 	BalanceAccountsType  int64  `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
134 136
 	PsnType              int64  `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
135 137
 	InsuplcAdmdvs        string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
138
+	ReturnOpter          string `gorm:"column:return_opter" json:"return_opter" form:"return_opter"`
139
+	ReturnOpterTime      string `gorm:"column:return_opter_time" json:"return_opter_time" form:"return_opter_time"`
136 140
 }
137 141
 
138 142
 func (HisHospitalCheckRecordTwo) TableName() string {

+ 4 - 0
models/his_models.go Vedi File

@@ -2405,6 +2405,8 @@ type NewHisHospitalCheckRecord struct {
2405 2405
 	MdtrtCertType   string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
2406 2406
 	InHosptialTime  string `gorm:"column:in_hosptial_time" json:"in_hosptial_time" form:"in_hosptial_time"`
2407 2407
 	OutHosptialTime string `gorm:"column:out_hosptial_time" json:"out_hosptial_time" form:"out_hosptial_time"`
2408
+	ReturnOpter     string `gorm:"column:return_opter" json:"return_opter" form:"return_opter"`
2409
+	ReturnOpterTime string `gorm:"column:return_opter_time" json:"return_opter_time" form:"return_opter_time"`
2408 2410
 }
2409 2411
 
2410 2412
 func (NewHisHospitalCheckRecord) TableName() string {
@@ -2609,6 +2611,8 @@ type HisHospitalCheckRecordTwenty struct {
2609 2611
 	BalanceAccountsType  int64  `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
2610 2612
 	PsnType              int64  `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
2611 2613
 	InsuplcAdmdvs        string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
2614
+	ReturnOpter          string `gorm:"column:return_opter" json:"return_opter" form:"return_opter"`
2615
+	ReturnOpterTime      string `gorm:"column:return_opter_time" json:"return_opter_time" form:"return_opter_time"`
2612 2616
 }
2613 2617
 
2614 2618
 func (HisHospitalCheckRecordTwenty) TableName() string {

+ 36 - 36
service/his_charge_service.go Vedi File

@@ -158,7 +158,7 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
158 158
 		switch item_type {
159 159
 		case 0:
160 160
 			if time_type == "0" {
161
-				err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
161
+				err = readDb.Table("his_order_info as oi").Select("-1000 as cost_classify, oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
162 162
 					Joins("JOIN his_order o ON oi.order_number = o.number  and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
163 163
 					Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
164 164
 					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
@@ -167,7 +167,7 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
167 167
 
168 168
 			} else {
169 169
 
170
-				err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
170
+				err = readDb.Table("his_order_info as oi").Select("-1000 as cost_classify,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
171 171
 					Joins("JOIN his_order o ON oi.order_number = o.number  and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
172 172
 					Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
173 173
 					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
@@ -180,7 +180,7 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
180 180
 		case 1:
181 181
 			if time_type == "0" {
182 182
 
183
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
183
+				err = readDb.Table("his_order_info as oi").Select("-1000 as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
184 184
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
185 185
 					Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
186 186
 					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
@@ -188,7 +188,7 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
188 188
 					Where("oi.advice_id > 0 and oi.user_org_id = ? and  o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?    and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
189 189
 
190 190
 			} else {
191
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
191
+				err = readDb.Table("his_order_info as oi").Select("-1000 as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
192 192
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
193 193
 					Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
194 194
 					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
@@ -207,7 +207,7 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
207 207
 		case 0:
208 208
 			if time_type == "0" {
209 209
 
210
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
210
+				err = readDb.Table("his_order_info as oi").Select("-1000 as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
211 211
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
212 212
 					Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
213 213
 					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
@@ -216,7 +216,7 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
216 216
 
217 217
 			} else {
218 218
 
219
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
219
+				err = readDb.Table("his_order_info as oi").Select("-1000 as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
220 220
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
221 221
 					Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
222 222
 					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
@@ -228,7 +228,7 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
228 228
 			break
229 229
 		case 1:
230 230
 			if time_type == "0" {
231
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
231
+				err = readDb.Table("his_order_info as oi").Select("-1000 as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
232 232
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
233 233
 					Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
234 234
 					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
@@ -237,7 +237,7 @@ func GetNewAllPatientDrugChargeDetails(org_id int64, start_time_str string, end_
237 237
 
238 238
 			} else {
239 239
 
240
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
240
+				err = readDb.Table("his_order_info as oi").Select("-1000 as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
241 241
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
242 242
 					Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
243 243
 					Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
@@ -259,7 +259,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
259 259
 		switch item_type {
260 260
 		case 0:
261 261
 			if time_type == "0" {
262
-				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
262
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
263 263
 					Joins("JOIN his_order o ON oi.order_number = o.number  and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
264 264
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
265 265
 					Joins(" left join xt_his_project project on  p.project_id = project.id").
@@ -269,7 +269,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
269 269
 
270 270
 			} else {
271 271
 
272
-				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
272
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
273 273
 					Joins("JOIN his_order o ON oi.order_number = o.number  and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
274 274
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
275 275
 					Joins(" left join xt_his_project project on  p.project_id = project.id").
@@ -298,7 +298,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
298 298
 			break
299 299
 		case 2:
300 300
 			if time_type == "0" {
301
-				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
301
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
302 302
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
303 303
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
304 304
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -307,7 +307,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
307 307
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
308 308
 
309 309
 			} else {
310
-				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
310
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
311 311
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
312 312
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
313 313
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -320,7 +320,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
320 320
 			break
321 321
 		case 3:
322 322
 			if time_type == "0" {
323
-				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
323
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
324 324
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
325 325
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
326 326
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -329,7 +329,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
329 329
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
330 330
 
331 331
 			} else {
332
-				err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
332
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
333 333
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
334 334
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
335 335
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -342,7 +342,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
342 342
 			break
343 343
 		case 4:
344 344
 			if time_type == "0" {
345
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
345
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
346 346
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
347 347
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
348 348
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -351,7 +351,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
351 351
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 and project.cost_classify = 3", org_id, start_time, end_time).Scan(&patients).Error
352 352
 
353 353
 			} else {
354
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
354
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
355 355
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
356 356
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
357 357
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -364,7 +364,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
364 364
 			break
365 365
 		case 5:
366 366
 			if time_type == "0" {
367
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
367
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
368 368
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
369 369
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
370 370
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -373,7 +373,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
373 373
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1  and project.cost_classify = 2", org_id, start_time, end_time).Scan(&patients).Error
374 374
 
375 375
 			} else {
376
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
376
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
377 377
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
378 378
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
379 379
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -386,7 +386,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
386 386
 			break
387 387
 		case 6:
388 388
 			if time_type == "0" {
389
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
389
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
390 390
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
391 391
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
392 392
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -395,7 +395,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
395 395
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 and project.cost_classify = 6", org_id, start_time, end_time).Scan(&patients).Error
396 396
 
397 397
 			} else {
398
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
398
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
399 399
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
400 400
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
401 401
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -406,7 +406,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
406 406
 			break
407 407
 		case 7:
408 408
 			if time_type == "0" {
409
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
409
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
410 410
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
411 411
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
412 412
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -415,7 +415,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
415 415
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 and project.cost_classify = 11", org_id, start_time, end_time).Scan(&patients).Error
416 416
 
417 417
 			} else {
418
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
418
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
419 419
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
420 420
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
421 421
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -431,7 +431,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
431 431
 		switch item_type {
432 432
 		case 0:
433 433
 			if time_type == "0" {
434
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
434
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
435 435
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
436 436
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
437 437
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -441,7 +441,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
441 441
 
442 442
 			} else {
443 443
 
444
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
444
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
445 445
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
446 446
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
447 447
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -456,7 +456,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
456 456
 		case 2:
457 457
 			if time_type == "0" {
458 458
 
459
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
459
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
460 460
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
461 461
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
462 462
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -465,7 +465,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
465 465
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
466 466
 
467 467
 			} else {
468
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
468
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
469 469
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
470 470
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
471 471
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -479,7 +479,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
479 479
 		case 3:
480 480
 			if time_type == "0" {
481 481
 
482
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
482
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
483 483
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S')  BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
484 484
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
485 485
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -489,7 +489,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
489 489
 
490 490
 			} else {
491 491
 
492
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
492
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
493 493
 					Joins("JOIN his_order o ON oi.order_number = o.number   and  o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
494 494
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
495 495
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -501,7 +501,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
501 501
 		case 4:
502 502
 			if time_type == "0" {
503 503
 
504
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
504
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
505 505
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
506 506
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
507 507
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -510,7 +510,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
510 510
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 and project.cost_classify = 3 ", org_id, start_time, end_time).Scan(&patients).Error
511 511
 
512 512
 			} else {
513
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
513
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
514 514
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
515 515
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
516 516
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -522,7 +522,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
522 522
 		case 5:
523 523
 			if time_type == "0" {
524 524
 
525
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
525
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
526 526
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
527 527
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
528 528
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -531,7 +531,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
531 531
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1  and project.cost_classify = 2", org_id, start_time, end_time).Scan(&patients).Error
532 532
 
533 533
 			} else {
534
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
534
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
535 535
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
536 536
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
537 537
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -543,7 +543,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
543 543
 		case 6:
544 544
 			if time_type == "0" {
545 545
 
546
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
546
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
547 547
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
548 548
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
549 549
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -552,7 +552,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
552 552
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1  and project.cost_classify = 10", org_id, start_time, end_time).Scan(&patients).Error
553 553
 
554 554
 			} else {
555
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
555
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
556 556
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
557 557
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
558 558
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -564,7 +564,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
564 564
 		case 7:
565 565
 			if time_type == "0" {
566 566
 
567
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
567
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
568 568
 					Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
569 569
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
570 570
 					Joins("left join xt_his_project project on  p.project_id = project.id").
@@ -573,7 +573,7 @@ func GetNewAllPatientProjectAndGoodChargeDetails(org_id int64, start_time_str st
573 573
 					Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1   and project.cost_classify = 11", org_id, start_time, end_time).Scan(&patients).Error
574 574
 
575 575
 			} else {
576
-				err = readDb.Table("his_order_info as oi").Select("FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
576
+				err = readDb.Table("his_order_info as oi").Select("(case p.type  when 2 then project.cost_classify  when 3 then -100  END) as cost_classify,FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d %H:%i:%S') as pdate,0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
577 577
 					Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
578 578
 					Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
579 579
 					Joins("left join xt_his_project project on  p.project_id = project.id").