123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- package service
-
- import (
- "XT_New/models"
- "github.com/jinzhu/gorm"
- )
-
- func GetBatchDrugHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
- readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
- Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type = 1 AND p_type = 2", user_org_id, record_time).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", user_org_id).Preload("Drug", "status=1")
- })
- }).
- Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
- Where("id in (?) AND user_org_id = ?", ids, user_org_id).Find(&patients)
- return
- }
-
- type HisPrintPrescriptionProject struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
- Price float64 `gorm:"column:price" json:"price" form:"price"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
- Count string `gorm:"column:count" json:"count" form:"count"`
- FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
- MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
- SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
- Day string `gorm:"column:day" json:"day" form:"day"`
- HisProject HisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
- GoodInfo GoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
- Unit string `gorm:"column:unit" json:"unit" form:"unit"`
- Type int64 `gorm:"column:type" json:"type" form:"type"`
- Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
- ExecutionTime int64 `gborm:"column:execution_time" json:"execution_time" form:"execution_time"`
- ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
- ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
- CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
- CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
- Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
- StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
- TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
-
- FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
- DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
- WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
- IsCheckTeam int64 `gorm:"-" json:"is_check_team" form:"is_check_team"`
- ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
- }
-
- type HisProject struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
- Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
- Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
- Price float64 `gorm:"column:price" json:"price" form:"price"`
- Unit string `gorm:"column:unit" json:"unit" form:"unit"`
- CostClassify int64 `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
- ExecutiveSection int64 `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
- MedicalCoverage int64 `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
- StatisticalClassification int64 `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
- DiseaseDirectory int64 `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
- IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
- MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
- TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
- MedicalStatus int64 `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
- Sign int64 `gorm:"column:sign" json:"sign" form:"sign"`
- DefaultNumber string `gorm:"column:default_number" json:"default_number" form:"default_number"`
- IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
- IsCharge int64 `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
- IsEstimate int64 `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
- IsWorkload int64 `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
- Sort string `gorm:"column:sort" json:"sort" form:"sort"`
- DoctorAdvice int64 `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
- UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
- NumberDays string `gorm:"column:number_days" json:"number_days" form:"number_days"`
- Total string `gorm:"column:total" json:"total" form:"total"`
- Category int64 `gorm:"column:category" json:"category" form:"category"`
- IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
- SpecailProject int64 `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
- SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
- }
-
- func (HisProject) TableName() string {
- return "xt_his_project"
- }
-
- func (HisPrintPrescriptionProject) TableName() string {
- return "his_prescription_project"
- }
-
- func GetBatchProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
- readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
- Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1 AND p_type = 2", user_org_id, record_time).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("his_prescription_project.status = 1 AND his_prescription_project.user_org_id = ?", user_org_id).Where("his_prescription_project.status = 1 ").Preload("HisProject", "status = 1").Preload("GoodInfo", "status=1")
- })
- }).
- Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
- Where("id in (?) AND user_org_id = ? ", ids, user_org_id).Find(&patients)
-
- return
- }
-
- func GetBatchInspectionProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
- readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
- Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1 AND p_type = 2", user_org_id, record_time).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Joins("Join xt_his_project p On p.id = his_prescription_project.project_id AND p.cost_classify = 3").Where("his_prescription_project.status = 1 AND his_prescription_project.type = 2").Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1")
- })
- }).
- Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
- Where("id in (?) AND user_org_id = ? ", ids, user_org_id).Find(&patients)
- return
-
- }
-
- func GetBatchInspectionProjectHisPrescriptionTwo(ids []string, record_time int64, user_org_id int64) (patients []*models.CheckPrintPatient, err error) {
- readDb.Model(&models.CheckPrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
- Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1 AND p_type = 2", user_org_id, record_time).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Joins("Join xt_his_project p On p.id = his_prescription_project.project_id AND p.cost_classify = 3").Where("his_prescription_project.status = 1 ").Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1")
- })
- }).
- Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
- Where("id in (?) AND user_org_id = ? ", ids, user_org_id).Find(&patients)
- return
-
- }
-
- func GetUnChargeHisPrescriptionTen(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
- }).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3 AND order_status <> 2 ", org_id)
- }).
- Where("(user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 AND p_type = ?)", org_id, record_date, patient_id, p_type).
- Find(&prescription).Error
- return
- }
-
- func CreateLabelPrint(label *models.HisLabelPrintStatusInfo) (err error) {
- err = writeDb.Save(&label).Error
- return
- }
-
- func GetLabelPrint(ids string, org_id int64, record_date string, patient_id int64) (label models.HisLabelPrintStatusInfo, err error) {
- err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Where("ids = ? and user_org_id = ? and record_date = ? and patient_id = ?", ids, org_id, record_date, patient_id).First(&label).Error
- return
- }
-
- func GetLabelPrintByID(id int64) (label models.HisLabelPrintStatusInfo, err error) {
- err = readDb.Model(&models.HisLabelPrintStatusInfo{}).Preload("Patient", "status = 1").Where("id = ?", id).First(&label).Error
- return
- }
|