|
@@ -204,8 +204,122 @@ func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (pres
|
204
|
204
|
return
|
205
|
205
|
}
|
206
|
206
|
|
207
|
|
-func GetAllDrugLibList(org_id int64) (list []*models.BaseDrugLib, err error) {
|
208
|
|
- err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? AND status = 1", org_id).Find(&list).Error
|
|
207
|
+type OtherDrugWarehouseInfo struct {
|
|
208
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
209
|
+ DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
|
|
210
|
+ WarehousingCount int64 `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
|
|
211
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
212
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
213
|
+}
|
|
214
|
+
|
|
215
|
+func (OtherDrugWarehouseInfo) TableName() string {
|
|
216
|
+ return "xt_drug_warehouse_info"
|
|
217
|
+}
|
|
218
|
+
|
|
219
|
+type VMDrugSalesReturnInfo struct {
|
|
220
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
221
|
+ DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
|
|
222
|
+ Count int64 `gorm:"column:count" json:"count" form:"count"`
|
|
223
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
224
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
225
|
+}
|
|
226
|
+
|
|
227
|
+func (VMDrugSalesReturnInfo) TableName() string {
|
|
228
|
+ return "xt_drug_sales_return_info"
|
|
229
|
+}
|
|
230
|
+
|
|
231
|
+type VMDrugWarehouseOutInfo struct {
|
|
232
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
233
|
+ DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
|
|
234
|
+ Count int64 `gorm:"column:count" json:"count" form:"count"`
|
|
235
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
236
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
237
|
+}
|
|
238
|
+
|
|
239
|
+func (VMDrugWarehouseOutInfo) TableName() string {
|
|
240
|
+ return "xt_drug_warehouse_out_info"
|
|
241
|
+}
|
|
242
|
+
|
|
243
|
+type VMDrugCancelStockInfo struct {
|
|
244
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
245
|
+ DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
|
|
246
|
+ Count int64 `gorm:"column:count" json:"count" form:"count"`
|
|
247
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
248
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
249
|
+}
|
|
250
|
+
|
|
251
|
+func (VMDrugCancelStockInfo) TableName() string {
|
|
252
|
+ return "xt_drug_cancel_stock_info"
|
|
253
|
+}
|
|
254
|
+
|
|
255
|
+type BaseDrugLib struct {
|
|
256
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
257
|
+ DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
|
|
258
|
+ Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
|
|
259
|
+ Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
|
|
260
|
+ DrugAlias string `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
|
|
261
|
+ DrugAliasPinyin string `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
|
|
262
|
+ DrugAliasWubi string `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
|
|
263
|
+ DrugCategory int64 `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
|
|
264
|
+ DrugSpec string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
|
|
265
|
+ DrugType int64 `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
|
|
266
|
+ DrugStockLimit string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
|
|
267
|
+ DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
|
|
268
|
+ DrugDosageForm int64 `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
|
|
269
|
+ MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
|
|
270
|
+ MaxUnit string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
|
|
271
|
+ MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
|
|
272
|
+ UnitMatrixing string `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
|
|
273
|
+ RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
|
|
274
|
+ LastPrice float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
|
|
275
|
+ DrugControl int64 `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
|
|
276
|
+ Number string `gorm:"column:number" json:"number" form:"number"`
|
|
277
|
+ DrugClassify string `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
|
|
278
|
+ DrugDose float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
|
|
279
|
+ DrugDoseUnit int64 `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
|
|
280
|
+ MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
|
|
281
|
+ Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
|
|
282
|
+ PharmacologyCategory int64 `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
|
|
283
|
+ StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
|
|
284
|
+ Code string `gorm:"column:code" json:"code" form:"code"`
|
|
285
|
+ IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
|
|
286
|
+ IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
|
|
287
|
+ Agent string `gorm:"column:agent" json:"agent" form:"agent"`
|
|
288
|
+ DrugStatus string `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
|
|
289
|
+ LimitRemark string `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
|
|
290
|
+ DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
|
|
291
|
+ ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
|
|
292
|
+ SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
|
|
293
|
+ PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
|
|
294
|
+ Label int64 `gorm:"column:label" json:"label" form:"label"`
|
|
295
|
+ Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
|
|
296
|
+ IsUseDoctorAdvice int64 `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
|
|
297
|
+ IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
|
|
298
|
+ IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
|
|
299
|
+ IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
|
|
300
|
+ IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
|
|
301
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
302
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
303
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
304
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
305
|
+ DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
|
|
306
|
+ //MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
|
|
307
|
+ OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
|
|
308
|
+ VMDrugSalesReturnInfo []*VMDrugSalesReturnInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`
|
|
309
|
+ VMDrugWarehouseOutInfo []*VMDrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_out"`
|
|
310
|
+ VMDrugCancelStockInfo []*VMDrugCancelStockInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"cancel_stock"`
|
|
311
|
+}
|
|
312
|
+
|
|
313
|
+func (BaseDrugLib) TableName() string {
|
|
314
|
+ return "xt_base_drug"
|
|
315
|
+}
|
|
316
|
+
|
|
317
|
+func GetAllDrugLibList(org_id int64) (list []*BaseDrugLib, err error) {
|
|
318
|
+ err = readDb.Model(&BaseDrugLib{}).Preload("OtherDrugWarehouseInfo", "status = 1 AND org_id = ?", org_id).
|
|
319
|
+ Preload("VMDrugSalesReturnInfo", "status = 1 AND org_id = ?", org_id).
|
|
320
|
+ Preload("VMDrugWarehouseOutInfo", "status = 1 AND org_id = ?", org_id).
|
|
321
|
+ Preload("VMDrugCancelStockInfo", "status = 1 AND org_id = ?", org_id).
|
|
322
|
+ Where("org_id = ? AND status = 1", org_id).Find(&list).Error
|
209
|
323
|
return
|
210
|
324
|
}
|
211
|
325
|
|
|
@@ -285,13 +399,37 @@ func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
|
285
|
399
|
|
286
|
400
|
}
|
287
|
401
|
|
288
|
|
-func GetHisOrderList(user_org_id int64) (order []*models.HisOrder, err error) {
|
289
|
|
- err = readDb.Model(&models.HisOrder{}).Where("status = 1 AND user_org_id = ?", user_org_id).
|
290
|
|
- Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
|
|
402
|
+func GetHisOrderList(user_org_id int64, page int64, limit int64, start_time int64, end_time int64, doctor_id int64, keywords string) (order []*models.HisOrder, err error, total int64) {
|
|
403
|
+ offset := (page - 1) * limit
|
|
404
|
+ db := readDb.Model(&models.HisOrder{})
|
|
405
|
+
|
|
406
|
+ if doctor_id > 0 {
|
|
407
|
+ db = db.Joins("join his_prescription_info as info on info.patient_id = his_order.patient_id AND info.record_date = his_order.settle_accounts_date AND info.doctor_id = ? AND info.user_org_id = ?", doctor_id, user_org_id)
|
|
408
|
+ }
|
|
409
|
+
|
|
410
|
+ if len(keywords) > 0 {
|
|
411
|
+ keywords = "%" + keywords + "%"
|
|
412
|
+ db = db.Joins("join xt_patients as patient on patient.id = his_order.patient_id AND patient.name like ? AND patient.user_org_id = ?", keywords, user_org_id)
|
|
413
|
+
|
|
414
|
+ }
|
|
415
|
+
|
|
416
|
+ if start_time != 0 {
|
|
417
|
+ db = db.Where("his_order.settle_accounts_date>=?", start_time)
|
|
418
|
+ }
|
|
419
|
+ if end_time != 0 {
|
|
420
|
+ db = db.Where("his_order.settle_accounts_date<=?", end_time)
|
|
421
|
+ }
|
|
422
|
+
|
|
423
|
+ db = db.Where("his_order.status = 1 AND his_order.user_org_id = ?", user_org_id)
|
|
424
|
+
|
|
425
|
+ db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
|
291
|
426
|
Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
|
292
|
427
|
Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
|
293
|
|
- Preload("HisPrescriptionInfo", "status = 1 AND user_org_id = ?", user_org_id).Order("ctime desc").
|
294
|
|
- Find(&order).Error
|
|
428
|
+ Preload("HisPrescriptionInfo", func(db *gorm.DB) *gorm.DB {
|
|
429
|
+ return db.Where("status = 1 AND user_org_id = ?", user_org_id).Preload("XtHisDepartment", "status = 1")
|
|
430
|
+ })
|
|
431
|
+ db = db.Count(&total)
|
|
432
|
+ err = db.Limit(limit).Offset(offset).Order("ctime desc").Find(&order).Error
|
295
|
433
|
return
|
296
|
434
|
}
|
297
|
435
|
|
|
@@ -352,6 +490,7 @@ func GetHisPrescriptionThree(org_id int64, patient_id int64, record_date int64,
|
352
|
490
|
Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
|
353
|
491
|
return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
|
354
|
492
|
}).
|
|
493
|
+ Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).
|
355
|
494
|
Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND batch_number=?", org_id, record_date, patient_id, number).
|
356
|
495
|
Find(&prescription).Error
|
357
|
496
|
return
|
|
@@ -530,3 +669,20 @@ func DelelteAddition(id int64, user_org_id int64) (err error) {
|
530
|
669
|
err = writeDb.Model(&models.HisAdditionalCharge{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
|
531
|
670
|
return
|
532
|
671
|
}
|
|
672
|
+
|
|
673
|
+func GetHisPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*Schedule, err error, total int64) {
|
|
674
|
+ offset := (page - 1) * limit
|
|
675
|
+ db := readDb.Model(&Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date = ?", org_id, record_date)
|
|
676
|
+ if len(keywords) > 0 {
|
|
677
|
+ keywords = "%" + keywords + "%"
|
|
678
|
+ db = db.Joins("JOIN xt_patients as p On xt_schedule.patient_id = p.id AND p.user_org_id = ? AND p.name like ?", org_id, keywords)
|
|
679
|
+ db = db.Joins("JOIN his_prescription_info as info On xt_schedule.patient_id = info.patient_id AND info.user_org_id = ? AND info.record_date = ? AND info.prescription_number like ?", org_id, record_date, keywords)
|
|
680
|
+ }
|
|
681
|
+ db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
|
|
682
|
+ db = db.Preload("HisPatient", "user_org_id = ? AND status = 1", org_id)
|
|
683
|
+ db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1", org_id).
|
|
684
|
+ Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1", org_id)
|
|
685
|
+ db = db.Count(&total)
|
|
686
|
+ err = db.Limit(limit).Offset(offset).Find(&patients).Error
|
|
687
|
+ return
|
|
688
|
+}
|