Bläddra i källkod

11月8日库存管理

XMLWAN 2 år sedan
förälder
incheckning
34498f78de

+ 11 - 5
controllers/his_summary_controller.go Visa fil

49
 	his_patient, _ := service.GetHisSummaryPatientInfo(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
49
 	his_patient, _ := service.GetHisSummaryPatientInfo(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
50
 
50
 
51
 	order, _ := service.GetHisLastOrder(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
51
 	order, _ := service.GetHisLastOrder(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
52
+
53
+	his_record_patient, _ := service.GetHisSummaryPatientInfoSix(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime)
54
+
52
 	//获取所有的科室
55
 	//获取所有的科室
53
 	hisDepatment, _ := service.GetHisDepatment(adminUser.CurrentOrgId)
56
 	hisDepatment, _ := service.GetHisDepatment(adminUser.CurrentOrgId)
54
 	if err == nil {
57
 	if err == nil {
55
 		this.ServeSuccessJSON(map[string]interface{}{
58
 		this.ServeSuccessJSON(map[string]interface{}{
56
-			"list":         list,
57
-			"patient":      patient,
58
-			"his_patient":  his_patient,
59
-			"hisDepatment": hisDepatment,
60
-			"order":        order,
59
+			"list":               list,
60
+			"patient":            patient,
61
+			"his_patient":        his_patient,
62
+			"hisDepatment":       hisDepatment,
63
+			"order":              order,
64
+			"his_record_patient": his_record_patient,
61
 		})
65
 		})
62
 		return
66
 		return
63
 	} else {
67
 	} else {
156
 	//统计
160
 	//统计
157
 	prescription, _ := service.GetHisPrescriptionTenty(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, keyword, item_type)
161
 	prescription, _ := service.GetHisPrescriptionTenty(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, keyword, item_type)
158
 
162
 
163
+	//orderlist, _ := service.GetHisChargeOrder(adminUser.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, keyword, item_type)
164
+
159
 	var medicalInsuranceLevel = "医保等级"
165
 	var medicalInsuranceLevel = "医保等级"
160
 	medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
166
 	medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
161
 	medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, adminUser.CurrentOrgId)
167
 	medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, adminUser.CurrentOrgId)

+ 45 - 20
controllers/mobile_api_controllers/patient_api_controller.go Visa fil

724
 								prescribing_number_total = count
724
 								prescribing_number_total = count
725
 							}
725
 							}
726
 
726
 
727
-							fmt.Println("开医嘱数量", prescribing_number_total)
728
-							fmt.Println("剩余库存", total)
729
-
730
 							if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
727
 							if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
731
 								c.ServeSuccessJSON(map[string]interface{}{
728
 								c.ServeSuccessJSON(map[string]interface{}{
732
 									"msg":    "3",
729
 									"msg":    "3",
744
 								return
741
 								return
745
 							}
742
 							}
746
 							if prescribing_number_total <= total {
743
 							if prescribing_number_total <= total {
747
-								if medical.IsUse == 2 {
748
-									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
749
-									//查询默认仓库
750
-									houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
751
-									//查询默认仓库剩余多少库存
752
-									list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
753
-									var sum_count int64
754
-									var sum_in_count int64
755
-									for _, it := range list {
756
-										baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
757
-										if it.MaxUnit == baseDrug.MaxUnit {
758
-											it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
759
-											it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
744
+
745
+								//查询是否出库按钮开启
746
+								adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
747
+								if adviceSetting.IsAdviceOpen == 1 {
748
+									//查询是否出库按钮开启
749
+									prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
750
+									if prescriptionConfig.IsOpen == 1 {
751
+										if medical.IsUse == 2 {
752
+											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
753
+											//查询默认仓库
754
+											houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
755
+											//查询默认仓库剩余多少库存
756
+											list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
757
+											var sum_count int64
758
+											var sum_in_count int64
759
+											for _, it := range list {
760
+												baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
761
+												if it.MaxUnit == baseDrug.MaxUnit {
762
+													it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
763
+													it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
764
+												}
765
+												sum_count += it.StockMaxNumber + it.StockMinNumber
766
+												sum_in_count += it.WarehousingCount
767
+											}
768
+											service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
760
 										}
769
 										}
761
-										sum_count += it.StockMaxNumber + it.StockMinNumber
762
-										sum_in_count += it.WarehousingCount
763
 									}
770
 									}
764
-									service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
771
+								} else {
772
+									if medical.IsUse == 2 {
773
+										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
774
+										//查询默认仓库
775
+										houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
776
+										//查询默认仓库剩余多少库存
777
+										list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
778
+										var sum_count int64
779
+										var sum_in_count int64
780
+										for _, it := range list {
781
+											baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
782
+											if it.MaxUnit == baseDrug.MaxUnit {
783
+												it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
784
+												it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
785
+											}
786
+											sum_count += it.StockMaxNumber + it.StockMinNumber
787
+											sum_in_count += it.WarehousingCount
788
+										}
789
+										service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
790
+									}
765
 								}
791
 								}
766
 							}
792
 							}
767
-
768
 						}
793
 						}
769
 					}
794
 					}
770
 				}
795
 				}

+ 82 - 31
controllers/patient_api_controller.go Visa fil

1791
 					return
1791
 					return
1792
 				}
1792
 				}
1793
 				if prescribing_number_total <= total {
1793
 				if prescribing_number_total <= total {
1794
-					if medical.IsUse == 2 {
1795
-						service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1796
-						//查询默认仓库
1797
-						houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
1798
-						//查询默认仓库剩余多少库存
1799
-						list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1800
-						var sum_count int64
1801
-						var sum_in_count int64
1802
-						for _, it := range list {
1803
-							baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1804
-							if it.MaxUnit == baseDrug.MaxUnit {
1805
-								it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1806
-								it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1794
+
1795
+					//查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
1796
+
1797
+					adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
1798
+					if adviceSetting.IsAdviceOpen == 1 {
1799
+
1800
+						//查询是否出库按钮开启
1801
+						prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
1802
+						if prescriptionConfig.IsOpen == 1 {
1803
+							if medical.IsUse == 2 {
1804
+								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1805
+								//查询默认仓库
1806
+								houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
1807
+								//查询默认仓库剩余多少库存
1808
+								list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1809
+								var sum_count int64
1810
+								var sum_in_count int64
1811
+								for _, it := range list {
1812
+									baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1813
+									if it.MaxUnit == baseDrug.MaxUnit {
1814
+										it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1815
+										it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1816
+									}
1817
+									sum_count += it.StockMaxNumber + it.StockMinNumber
1818
+									sum_in_count += it.WarehousingCount
1819
+								}
1820
+								service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1821
+								break
1822
+								c.ServeSuccessJSON(map[string]interface{}{
1823
+									"msg":    "1",
1824
+									"advice": advice,
1825
+								})
1826
+								return
1827
+							}
1828
+							if medical.IsUse == 1 {
1829
+								c.ServeSuccessJSON(map[string]interface{}{
1830
+									"msg":    "1",
1831
+									"advice": advice,
1832
+								})
1833
+								return
1834
+							}
1835
+						} else {
1836
+							if medical.IsUse == 1 {
1837
+								c.ServeSuccessJSON(map[string]interface{}{
1838
+									"msg":    "1",
1839
+									"advice": advice,
1840
+								})
1841
+								return
1807
 							}
1842
 							}
1808
-							sum_count += it.StockMaxNumber + it.StockMinNumber
1809
-							sum_in_count += it.WarehousingCount
1810
 						}
1843
 						}
1811
-						service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1812
-						break
1813
-						c.ServeSuccessJSON(map[string]interface{}{
1814
-							"msg":    "1",
1815
-							"advice": advice,
1816
-						})
1817
-						return
1818
-					}
1819
-					if medical.IsUse == 1 {
1820
-						c.ServeSuccessJSON(map[string]interface{}{
1821
-							"msg":    "1",
1822
-							"advice": advice,
1823
-						})
1824
-						return
1825
-					}
1826
 
1844
 
1845
+					} else {
1846
+						if medical.IsUse == 2 {
1847
+							service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1848
+							//查询默认仓库
1849
+							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
1850
+							//查询默认仓库剩余多少库存
1851
+							list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1852
+							var sum_count int64
1853
+							var sum_in_count int64
1854
+							for _, it := range list {
1855
+								baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1856
+								if it.MaxUnit == baseDrug.MaxUnit {
1857
+									it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1858
+									it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1859
+								}
1860
+								sum_count += it.StockMaxNumber + it.StockMinNumber
1861
+								sum_in_count += it.WarehousingCount
1862
+							}
1863
+							service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1864
+							break
1865
+							c.ServeSuccessJSON(map[string]interface{}{
1866
+								"msg":    "1",
1867
+								"advice": advice,
1868
+							})
1869
+							return
1870
+						}
1871
+						if medical.IsUse == 1 {
1872
+							c.ServeSuccessJSON(map[string]interface{}{
1873
+								"msg":    "1",
1874
+								"advice": advice,
1875
+							})
1876
+							return
1877
+						}
1878
+					}
1827
 				}
1879
 				}
1828
-
1829
 			}
1880
 			}
1830
 		}
1881
 		}
1831
 
1882
 

+ 29 - 1
service/his_summary_service.go Visa fil

13
 			Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
13
 			Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
14
 				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
14
 				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
15
 					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
15
 					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
16
-						return db.Preload("Drug", "status = 1").Where("status = 1")
16
+						return db.Preload("Drug", "status = 1").Where("status = 1 ")
17
 					}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
17
 					}).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
18
 					return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type,unit,remark").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
18
 					return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type,unit,remark").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
19
 						return db.Select("id,project_name,unit").Where("status = 1 ")
19
 						return db.Select("id,project_name,unit").Where("status = 1 ")
231
 	return
231
 	return
232
 }
232
 }
233
 
233
 
234
+func GetHisSummaryPatientInfoSix(org_id int64, patient_id int64, start_time int64, end_time int64) (info models.HisHospitalCheckRecord, err error) {
235
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("user_org_id = ? AND status = 1 AND record_date >= ? AND  record_date <= ? AND patient_id = ?", org_id, start_time, end_time, patient_id).Last(&info).Error
236
+	return
237
+}
238
+
234
 func GetDetailPatients(keywords string, org_id int64) (patients []*models.ChargePatientTwo, err error) {
239
 func GetDetailPatients(keywords string, org_id int64) (patients []*models.ChargePatientTwo, err error) {
235
 	if len(keywords) == 0 {
240
 	if len(keywords) == 0 {
236
 		err = readDb.Model(&models.ChargePatientTwo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&patients).Error
241
 		err = readDb.Model(&models.ChargePatientTwo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&patients).Error
301
 	err = XTReadDB().Where("patient_id = ? and user_org_id = ? and schedule_date >=? and schedule_date<=? and status = 1", patient_id, org_id, start_time, end_time).Find(&schedule).Error
306
 	err = XTReadDB().Where("patient_id = ? and user_org_id = ? and schedule_date >=? and schedule_date<=? and status = 1", patient_id, org_id, start_time, end_time).Find(&schedule).Error
302
 	return schedule, err
307
 	return schedule, err
303
 }
308
 }
309
+
310
+func GetHisChargeOrder(org_id int64, patient_id int64, start_time int64, end_time int64, keyword string, item_type int64) (order []*models.HisChargeOrder, err error) {
311
+
312
+	db := XTReadDB().Model(&order).Where("status = 1")
313
+
314
+	if org_id > 0 {
315
+		db = db.Where("user_org_id = ?", org_id)
316
+	}
317
+	if patient_id > 0 {
318
+		db = db.Where("patient_id = ?", patient_id)
319
+	}
320
+
321
+	if start_time > 0 {
322
+		db = db.Where("settle_accounts_date>=?", start_time)
323
+	}
324
+	if end_time > 0 {
325
+		db = db.Where("settle_accounts_date<=?", end_time)
326
+	}
327
+	err = db.Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
328
+		return db.Where("status = 1").Preload("HisChargePrescriptionProject", "status=1").Preload("HisChargeDoctorAdviceInfo", "status=1")
329
+	}).Error
330
+	return order, err
331
+}