1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188 |
- package service
-
- import (
- "fmt"
- "gdyb/models"
- "github.com/jinzhu/gorm"
- "strconv"
- "time"
- )
-
- type HisPatient struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- Name string `gorm:"column:name" json:"name" form:"name"`
- Gender int64 `gorm:"column:gender" json:"gender" form:"gender"`
- Total float64 `gorm:"column:total" json:"total" form:"total"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"prescription"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- PatientInfo string `gorm:"column:patient_info" json:"patient_info" form:"patient_info"`
- Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
- }
-
- func (HisPatient) TableName() string {
- return "his_patient"
- }
-
- type Schedule struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
- Patients Patients `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patients"`
- HisPatient HisPatient `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"his_patient"`
- HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"prescription"`
- VMHisPrescriptionInfo VMHisPrescriptionInfo `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"info"`
- }
-
- func (Schedule) TableName() string {
- return "xt_schedule"
- }
-
- type VMHisPrescriptionInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- 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"`
- 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"`
- Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
- Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
- Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
- RegisterType int64 `gorm:"column:register_type" json:"register_type" form:"register_type"`
- Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
- Departments string `gorm:"column:departments" json:"departments" form:"departments"`
- SickHistory string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
- PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
- BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
- PrescriptionStatus int64 `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
- DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
- DepartmentId int64 `gorm:"column:department_id" json:"department_id" form:"department_id"`
- SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
- }
-
- func (VMHisPrescriptionInfo) TableName() string {
- return "his_prescription_info"
- }
-
- type Patients struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- UserId int64 `gorm:"column:user_id" json:"user_id" form:"user_id"`
- Avatar string `gorm:"column:avatar" json:"avatar" form:"avatar"`
- PatientType int64 `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
- DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
- AdmissionNumber string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
- Source int64 `gorm:"column:source" json:"source" form:"source"`
- Lapseto int64 `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
- PartitionId int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
- BedId int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
- Name string `gorm:"column:name" json:"name" form:"name"`
- Alias string `gorm:"column:alias" json:"alias" form:"alias"`
- Gender int64 `gorm:"column:gender" json:"gender" form:"gender"`
- MaritalStatus int64 `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
- IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
- Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
- ReimbursementWayId int64 `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
- HealthCareType int64 `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
- HealthCareNo string `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
- HealthCareDueDate int64 `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
- Height int64 `gorm:"column:height" json:"height" form:"height"`
- BloodType int64 `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
- Rh int64 `gorm:"column:rh" json:"rh" form:"rh"`
- HealthCareDueAlertDate int64 `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
- EducationLevel int64 `gorm:"column:education_level" json:"education_level" form:"education_level"`
- Profession int64 `gorm:"column:profession" json:"profession" form:"profession"`
- Phone string `gorm:"column:phone" json:"phone" form:"phone"`
- HomeTelephone string `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
- RelativePhone string `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
- RelativeRelations string `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
- HomeAddress string `gorm:"column:home_address" json:"home_address" form:"home_address"`
- WorkUnit string `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
- UnitAddress string `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
- Children int64 `gorm:"column:children" json:"children" form:"children"`
- ReceivingDate int64 `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
- IsHospitalFirstDialysis int64 `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
- FirstDialysisDate int64 `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
- FirstDialysisHospital string `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
- PredialysisCondition string `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
- PreHospitalDialysisFrequency string `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
- PreHospitalDialysisTimes int64 `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
- HospitalFirstDialysisDate int64 `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
- InductionPeriod int64 `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
- InitialDialysis int64 `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
- TotalDialysis int64 `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
- AttendingDoctorId int64 `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
- HeadNurseId int64 `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
- Evaluate string `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
- Diagnose string `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
- Remark string `gorm:"column:remark" json:"remark" form:"remark"`
- RegistrarsId int64 `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
- Registrars string `gorm:"column:registrars" json:"registrars" form:"registrars"`
- QrCode string `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
- BindingState int64 `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
- PatientComplains string `gorm:"column:patient_complains" json:"patient_complains" form:"patient_complains"`
- PresentHistory string `gorm:"column:present_history" json:"present_history" form:"present_history"`
- PastHistory string `gorm:"column:past_history" json:"past_history" form:"past_history"`
- Temperature float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
- Pulse int64 `gorm:"column:pulse" json:"pulse" form:"pulse"`
- Respiratory int64 `gorm:"column:respiratory" json:"respiratory" form:"respiratory"`
- Sbp int64 `gorm:"column:sbp" json:"sbp" form:"sbp"`
- Dbp int64 `gorm:"column:dbp" json:"dbp" form:"dbp"`
- 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"`
- Nation string `gorm:"column:nation" json:"nation" form:"nation"`
- NativePlace string `gorm:"column:native_place" json:"native_place" form:"native_place"`
- Age int64 `gorm:"column:age" json:"age" form:"age"`
- InfectiousNextRecordTime int64 `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time" form:"infectious_next_record_time"`
- IsInfectious int64 `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
- IsOpenRemind int64 `gorm:"column:is_open_remind" json:"is_open_remind" form:"is_open_remind"`
- RemindCycle int64 `gorm:"column:remind_cycle" json:"remind_cycle" form:"remind_cycle"`
- ResponseResult string `gorm:"column:response_result" json:"response_result" form:"response_result"`
- FirstTreatmentDate int64 `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
- DialysisAge int64 `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
- ExpenseKind int64 `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
- TellPhone string `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
- ContactName string `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
- UserSysBeforeCount int64 `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
- IsExcelExport int64 `gorm:"column:is_excel_export" json:"is_excel_export" form:"is_excel_export"`
- SchRemark string `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
- OutReason string `gorm:"column:out_reason" json:"out_reason" form:"out_reason"`
- InsuplcAdmdvs string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
- }
-
- func (Patients) TableName() string {
- return "xt_patients"
- }
-
- type HisPrescription struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- 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"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- }
-
- func (HisPrescription) TableName() string {
- return "his_prescription"
- }
-
- func GetHisPatientList(org_id int64, keywords string, record_date int64) (patients []*Schedule, err error) {
- db := readDb.Model(&Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date = ?", org_id, record_date)
- db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
- db = db.Preload("HisPatient", "user_org_id = ? AND status = 1", org_id)
- err = db.Preload("HisPrescription", "user_org_id = ? AND status = 1", org_id).Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1", org_id).Find(&patients).Error
- return
- }
-
- func GetAllBaseDrugStockList(org_id int64) (drugs []*models.BaseDrugLib, err error) {
- err = readDb.Model(&models.BaseDrugLib{}).Where("user_org_id = ? AND status = 1", org_id).Find(&drugs).Error
- return
- }
-
- func GetHisPatientInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPatient, err error) {
- err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
- return
- }
-
- func GetNewHisPatientInfo(org_id int64, id int64, record_date int64) (info models.HisPatient, err error) {
- err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND id = ?", org_id, record_date, id).First(&info).Error
- return
- }
-
- func GetXTPatientInfo(org_id int64, patient_id int64) (info models.Patients, err error) {
- err = readDb.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1 AND id = ?", org_id, patient_id).First(&info).Error
- return
- }
-
- func GetHisPatientCaseHistoryInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPatientCaseHistory, err error) {
- err = readDb.Model(&models.HisPatientCaseHistory{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
- return
- }
-
- func GetHisPatientCaseHistoryList(org_id int64, patient_id int64) (caseHistorys []*models.HisPatientCaseHistory, err error) {
- db := readDb.Model(&models.HisPatientCaseHistory{}).Where("user_org_id = ? AND status = 1 AND his_patient_id = ?", org_id, patient_id)
- err = db.Find(&caseHistorys).Error
- return
- }
-
- func GetHisPatientCaseHistoryTemplate(org_id int64, startime int64, endtime int64, keyword string) (caseHistorys []*models.HisCaseHistoryTemplate, err error) {
- likekey := "%" + keyword + "%"
- db := readDb.Model(&models.HisCaseHistoryTemplate{}).Where("user_org_id = ? AND status = 1", org_id)
- if startime > 0 {
- db = db.Where("record_date>=?", startime)
- }
- if endtime > 0 {
- db = db.Where("record_date<=?", endtime)
- }
- if len(keyword) > 0 {
- db = db.Where("template_name like ? ", likekey)
- }
- err = db.Find(&caseHistorys).Error
- return
- }
-
- func GetHisPatientCaseHistory(org_id int64) (caseHistory []*models.HisPatientCaseHistory, err error) {
-
- err = readDb.Model(&models.HisPatientCaseHistory{}).Where("user_org_id = ? and status = 1", org_id).Find(&caseHistory).Error
- return caseHistory, err
- }
-
- func SaveHisPatientCaseHistoryTemplate(template models.HisCaseHistoryTemplate) (err error) {
- err = writeDb.Create(&template).Error
- return
- }
-
- func GetHisPatientCaseHistoryById(hispatientid int64) (*models.HisPatientCaseHistory, error) {
- history := models.HisPatientCaseHistory{}
- err := XTReadDB().Model(&history).Where("his_patient_id = ? and status = 1", hispatientid).Find(&history).Error
- if err != nil {
- if err == gorm.ErrRecordNotFound {
- return nil, err
- } else {
- return nil, err
- }
- }
- return &history, nil
- }
-
- func SaveHisPatientCaseHistory(caseHistory *models.HisPatientCaseHistory) error {
- err := writeDb.Create(&caseHistory).Error
- return err
- }
-
- func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
- err = writeDb.Save(&prescription).Error
- return
- }
-
- func DelelteHisPrescription(id int64, user_org_id int64) (err error) {
- err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
- err = writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
- err = writeDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
- return
- }
-
- func DelelteDoctorAdvice(id int64, user_org_id int64) (err error) {
- err = writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
-
- return
- }
-
- func DelelteProject(id int64, user_org_id int64) (err error) {
- err = writeDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
-
- return
- }
-
- func GetHisPrescription(org_id int64, patient_id int64, record_date 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("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1", org_id, record_date, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetNewHisPrescription(org_id int64, his_patient_id int64, record_date int64, reg_type string) (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("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status=1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND his_patient_id = ? AND order_status <> 2 AND p_type <> 1 AND med_type = ?", org_id, record_date, his_patient_id, reg_type).
- Find(&prescription).Error
- return
- }
-
- type OtherDrugWarehouseInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
- WarehousingCount int64 `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
- DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
- }
-
- func (OtherDrugWarehouseInfo) TableName() string {
- return "xt_drug_warehouse_info"
- }
-
- type VMDrugSalesReturnInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
- Count int64 `gorm:"column:count" json:"count" form:"count"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
- }
-
- func (VMDrugSalesReturnInfo) TableName() string {
- return "xt_drug_sales_return_info"
- }
-
- type VMDrugWarehouseOutInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
- Count int64 `gorm:"column:count" json:"count" form:"count"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
- }
-
- func (VMDrugWarehouseOutInfo) TableName() string {
- return "xt_drug_warehouse_out_info"
- }
-
- type VMDrugCancelStockInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
- Count int64 `gorm:"column:count" json:"count" form:"count"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
- }
-
- func (VMDrugCancelStockInfo) TableName() string {
- return "xt_drug_cancel_stock_info"
- }
-
- type BaseDrugLib struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
- Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
- Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
- DrugAlias string `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
- DrugAliasPinyin string `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
- DrugAliasWubi string `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
- DrugCategory int64 `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
- DrugSpec string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
- DrugType int64 `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
- DrugStockLimit string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
- DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
- DrugDosageForm int64 `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
- MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
- MaxUnit string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
- MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
- UnitMatrixing string `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
- RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
- LastPrice float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
- DrugControl int64 `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- DrugClassify string `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
- DrugDose float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
- DrugDoseUnit int64 `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
- MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
- ProvincesCode string `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
-
- Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
- PharmacologyCategory int64 `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
- StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
- Code string `gorm:"column:code" json:"code" form:"code"`
- IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
- IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
- Agent string `gorm:"column:agent" json:"agent" form:"agent"`
- DrugStatus string `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
- LimitRemark string `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
- SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
- PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
- Label int64 `gorm:"column:label" json:"label" form:"label"`
- Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
- IsUseDoctorAdvice int64 `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
- IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
- IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
- IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
- IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
- 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"`
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
- DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
- HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
- LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
- IsUser int64 `gorm:"column:is_user" json:"is_user" form:"is_user"`
-
- //MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
- OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
- VMDrugSalesReturnInfo []*VMDrugSalesReturnInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"sales_return"`
- VMDrugWarehouseOutInfo []*VMDrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_out"`
- VMDrugCancelStockInfo []*VMDrugCancelStockInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"cancel_stock"`
- }
-
- func (BaseDrugLib) TableName() string {
- return "xt_base_drug"
- }
-
- func GetAllDrugLibList(org_id int64) (list []*BaseDrugLib, err error) {
- err = readDb.Model(&BaseDrugLib{}).Preload("OtherDrugWarehouseInfo", "status = 1 AND org_id = ?", org_id).
- Preload("VMDrugSalesReturnInfo", "status = 1 AND org_id = ?", org_id).
- Preload("VMDrugWarehouseOutInfo", "status = 1 AND org_id = ?", org_id).
- Preload("VMDrugCancelStockInfo", "status = 1 AND org_id = ?", org_id).
- Where("org_id = ? AND status = 1", org_id).Find(&list).Error
- return
- }
-
- func CreateAddtionalCharge(charge *models.HisAdditionalCharge) (err error) {
- err = writeDb.Create(&charge).Error
- return
- }
-
- func FindAllHisAdviceTemplate(org_id int64) (temps []*models.HisDoctorAdviceParentTemplate, err error) {
- err = readDb.Model(&models.HisDoctorAdviceParentTemplate{}).Preload("HisDoctorAdviceTemplate", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,advice_name,advice_desc,single_dose,single_dose_unit,prescribing_number,prescribing_number_unit,delivery_way,execution_frequency,status,created_time,updated_time,parent_id,template_id,drug_spec,drug_spec_unit,advice_type,day_count,week_days,frequency_type,way,drug_id,drug_name_id, IF(parent_id>0, parent_id, id) as advice_order").Where("status = 1").Order("advice_order desc, id")
- }).Where("org_id = ? AND status=1 ", org_id).Find(&temps).Error
- return
- }
-
- func GetHisAdminUserDoctors(org_id int64) (doctors []*models.UserAdminRole, err error) {
- err = readUserDb.Model(&models.UserAdminRole{}).Preload("XtHisDepartment", func(db *gorm.DB) *gorm.DB {
- return readDb.Model(&models.XtHisDepartment{}).Where("status = 1 AND user_org_id = ?", org_id)
- }).Where("org_id = ? AND status = 1 AND (user_type = 1 OR user_type = 2)", org_id).Find(&doctors).Error
- return
- }
-
- func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
- err = writeDb.Save(s).Error
- return
- }
-
- func CreateHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
- err = writeDb.Save(project).Error
- return
- }
-
- func SaveHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
- err = writeDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
- return
- }
-
- func CreateHisPatientTwo(patient *models.VMHisPatient) error {
- err := writeDb.Create(&patient).Error
- return err
- }
-
- func GetVMHisPatientInfo(org_id int64, patient_id int64, record_date int64) (info models.VMHisPatient, err error) {
- err = readDb.Model(&models.VMHisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
- return
- }
-
- func GetNewVMHisPatientInfo(org_id int64, his_patient_id int64, record_date int64) (info models.VMHisPatient, err error) {
- err = readDb.Model(&models.VMHisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND id = ?", org_id, record_date, his_patient_id).First(&info).Error
- return
- }
-
- func GetNewHisPatientRecord(org_id int64, id int64) (info models.VMHisPatient, err error) {
- err = readDb.Model(&models.VMHisPatient{}).Where("user_org_id = ? AND status = 1 AND patient_id = ?", org_id, id).First(&info).Error
- return
- }
-
- func GetHisPatientRecord(org_id int64, id int64) (info models.VMHisPatient, err error) {
- err = readDb.Model(&models.VMHisPatient{}).Where("user_org_id = ? AND status = 1 AND id = ?", org_id, id).First(&info).Error
- return
- }
-
- func CreateOrder(order *models.HisOrder) (err error) {
- err = writeDb.Create(&order).Error
- return
- }
-
- func CreateOrderInfo(order *models.HisOrderInfo) (err error) {
- err = writeDb.Create(&order).Error
- return
- }
- func FindPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
- return
- }
- func FindHisPatientPrescriptionInfo(org_id int64, his_patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND his_patient_id = ?", org_id, record_date, his_patient_id).First(&info).Error
- return
- }
-
- func FindLastPatientPrescriptionInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date <= ? AND patient_id = ?", org_id, record_date, patient_id).Order("record_date desc").First(&info).Error
- return
- }
-
- func FindLastPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64) (info models.HisPrescriptionInfo, err error) {
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ?", org_id, patient_id).Last(&info).Error
- return
- }
-
- func FindLastPatientPrescriptionInfoTwo1(org_id int64, patient_id int64) (info models.HisPrescriptionInfo, err error) {
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? and p_type = 1", org_id, patient_id).Last(&info).Error
- return
- }
-
- func FindLastPatientPrescriptionInfoTwo2(org_id int64, patient_id int64, start_time string, end_time string) (info []models.HisPrescriptionInfo, err error) {
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? and p_type = 1 and FROM_UNIXTIME(record_date) >= ? and FROM_UNIXTIME(record_date) <= ?", org_id, patient_id, start_time, end_time).Find(&info).Error
- return
- }
-
- func SavePatientPrescriptionInfo(info models.HisPrescriptionInfo) (err error) {
- err = writeDb.Save(&info).Error
- return
- }
-
- 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) {
- offset := (page - 1) * limit
- db := readDb.Model(&models.HisOrder{})
-
- if doctor_id > 0 {
- 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)
- }
-
- if len(keywords) > 0 {
- keywords = "%" + keywords + "%"
- 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)
-
- }
-
- if start_time != 0 {
- db = db.Where("his_order.settle_accounts_date>=?", start_time)
- }
- if end_time != 0 {
- db = db.Where("his_order.settle_accounts_date<=?", end_time)
- }
-
- db = db.Where("his_order.status = 1 AND his_order.user_org_id = ?", user_org_id)
-
- db = db.Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
- Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
- Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
- Preload("HisPrescriptionInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", user_org_id).Preload("XtHisDepartment", "status = 1")
- })
- db = db.Count(&total)
- err = db.Limit(limit).Offset(offset).Order("ctime desc").Find(&order).Error
- return
- }
-
- func UpDatePrescriptionNumber(user_org_id int64, ids []int64, number string) (err error) {
- err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
- return
- }
-
- func UpDatePrescriptionOrderStatus(user_org_id int64, ids []int64) (err error) {
- err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"order_status": 4, "mtime": time.Now().Unix()}).Error
- return
- }
-
- func UpDatePrescriptionInfoNumber(user_org_id int64, id int64, number string, record_time int64) (err error) {
- err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? AND record_date = ?", user_org_id, id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 2, "mtime": time.Now().Unix()}).Error
- return
- }
-
- func UpDateHisPrescriptionInfoNumber(user_org_id int64, his_patient_id int64, number string, record_time int64) (err error) {
- err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND his_patient_id = ? AND record_date = ?", user_org_id, his_patient_id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 2, "mtime": time.Now().Unix()}).Error
- return
- }
-
- type HisOrder struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
- SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
- OrderStatus float64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
- PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
- PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
- PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
- Certno string `gorm:"column:certno" json:"certno" form:"certno"`
- PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
-
- DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
- PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
- RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
- FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
- MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
- PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
- Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
- Modify int64 `gorm:"column:modify" json:"modify" form:"modify"`
- MedType int64 `gorm:"column:med_type" json:"med_type" form:"med_type"`
- IsPre int64 `gorm:"column:is_pre" json:"is_pre" form:"is_pre"`
- SzChargeInfo string `gorm:"column:sz_charge_info" json:"sz_charge_info" form:"sz_charge_info"`
- SzProjectInfo string `gorm:"column:sz_project_info" json:"sz_project_info" form:"sz_project_info"`
- SzMedicineInsuranceInfo string `gorm:"column:sz_medicine_insurance_info" json:"sz_medicine_insurance_info" form:"sz_medicine_insurance_info"`
- MzNumber string `gorm:"column:mz_number" json:"mz_number" form:"mz_number"`
- OrgSetlNumber string `gorm:"column:org_setl_number" json:"org_setl_number" form:"org_setl_number"`
- PayWays string `gorm:"column:pay_ways" json:"pay_way" form:"pay_ways"`
- OthDesc string `gorm:"column:oth_desc" json:"oth_desc" form:"oth_desc"`
- SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
- FaPiaoSn string `gorm:"column:fa_piao_sn" json:"fa_piao_sn" form:"fa_piao_sn"`
- //FaPiaoSn string `gorm:"column:fa_piao_sn" json:"fa_piao_sn" form:"fa_piao_sn"`
-
- HisOrderInfo models.HisOrderInfo `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
- Patients models.Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
- HisPatient models.HisPatient `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
- HisPrescriptionInfo models.HisPrescriptionInfo `gorm:"ForeignKey:PatientId,SettleAccountsDate;AssociationForeignKey:PatientId,RecordDate" json:"p_info"`
- HisPrescription []*models.HisPrescription `gorm:"ForeignKey:SettleAccountsDate;AssociationForeignKey:RecordDate" json:"prescriptions"`
-
- IsUploadDiagnose int64 `gorm:"column:is_upload_diagnose" json:"is_upload_diagnose" form:"is_upload_diagnose"`
- IsUploadOrderInfo int64 `gorm:"column:is_upload_order_info" json:"is_upload_order_info" form:"is_upload_order_info"`
- IsUploadSuccess int64 `gorm:"column:is_upload_success" json:"is_upload_success" form:"is_upload_success"`
- }
-
- func (HisOrder) TableName() string {
- return "his_order"
- }
-
- func GetHisOrder(user_org_id int64, number string, patient_id int64) (order HisOrder, err error) {
- err = readDb.Model(&HisOrder{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND number=?", user_org_id, patient_id, number).
- Preload("HisOrderInfo", "status = 1 AND user_org_id = ?", user_org_id).
- Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
- Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
- Preload("HisPrescriptionInfo", "status = 1 AND user_org_id = ?", user_org_id).
- Order("ctime desc").
- Find(&order).Error
- return
- }
-
- func GetHisPrescriptionThree(org_id int64, patient_id int64, record_date int64, number string) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
- }).
- Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND batch_number=?", org_id, record_date, patient_id, number).
- Find(&prescription).Error
- return
- }
-
- type HisPrescriptionInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- 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"`
- 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"`
- Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
- Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
- Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
- RegisterType int64 `gorm:"column:register_type" json:"register_type" form:"register_type"`
- Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
- Departments int64 `gorm:"column:departments" json:"departments" form:"departments"`
- SickHistory string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
- Patients models.Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
- HisPatient models.HisPatient `gorm:"ForeignKey:HisPatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"his_patient"`
- HisPatientCaseHistory models.HisPatientCaseHistory `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,RecordDate" json:"case_history"`
- PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
- BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
- PrescriptionStatus int64 `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
- DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
- DepartmentId int64 `gorm:"column:department_id" json:"department_id" form:"department_id"`
- SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
- }
-
- func (HisPrescriptionInfo) TableName() string {
- return "his_prescription_info"
- }
-
- func GetHisPrescriptionOrderList(org_id int64) (prescriptionOrder []*HisPrescriptionInfo, err error) {
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ?", org_id).
- Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
- Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).
- Preload("HisPatientCaseHistory", "status = 1 AND user_org_id = ?", org_id).
- Order("ctime desc").Find(&prescriptionOrder).Error
- return
-
- }
-
- func GetHisPrescriptionOrderInfo(id int64, org_id int64) (prescriptionOrder HisPrescriptionInfo, err error) {
- err = readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND id = ? AND user_org_id = ? ", id, org_id).
- Preload("Patients", "status = 1 AND user_org_id = ?", org_id).
- Preload("HisPatient", "status = 1 AND user_org_id = ?", org_id).
- Preload("HisPatientCaseHistory", "status = 1 AND user_org_id = ?", org_id).First(&prescriptionOrder).Error
- return
-
- }
-
- func GetHisPrescriptionFour(org_id int64, patient_id int64, record_date int64, number string) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND prescription_number=?", org_id, record_date, patient_id, number).
- Find(&prescription).Error
- return
- }
-
- func GetMedicalInsuranceConfig(org_id int64) (medicalInsuranceConfig models.MedicalInsuranceConfig, err error) {
- err = readDb.Model(&models.MedicalInsuranceConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&medicalInsuranceConfig).Error
- return
-
- }
-
- func UpdataOrderStatus(id int64, number string, user_org_id int64, log string, result string) (err error) {
- err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "refund_request_log": log, "refund_log": result, "status": 0}).Error
- err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
- err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
- return
-
- }
-
- func UpdataOrderStatusThree(id int64, number string, user_org_id int64, log string, result string) (err error) {
- err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "refund_request_log": log, "refund_log": result, "status": 0}).Error
- err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 4, "mtime": time.Now().Unix()}).Error
- err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
- return
-
- }
-
- func UpdataRegStatus(patient_id int64, record_time int64, org_id int64) {
- writeDb.Model(&models.HisPatient{}).Where("patient_id = ? AND status = 1 AND record_date =? AND user_org_id = ?", patient_id, record_time, org_id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()})
- //writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
- //writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
- }
-
- func UpdataRegStatusTwo(his_patient_id int64, record_time int64, org_id int64) {
- writeDb.Model(&models.HisPatient{}).Where("status = 1 AND record_date =? AND user_org_id = ? AND id = ?", record_time, org_id, his_patient_id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()})
- writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND user_org_id = ? AND his_patient_id = ?", org_id, his_patient_id).Updates(map[string]interface{}{"his_patient_id": 0, "mtime": time.Now().Unix()})
- writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ? AND his_patient_id = ?", org_id, his_patient_id).Updates(map[string]interface{}{"his_patient_id": 0, "mtime": time.Now().Unix()})
-
- }
-
- func UpdataRegStatus2(id int64) error {
- err := writeDb.Model(&models.HisPatient{}).Where("id = ?", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
- return err
- }
- func GetAdminUserInfoByID(org_id int64, admin_user_id int64) (role models.UserAdminRole, err error) {
- err = readUserDb.Model(&models.UserAdminRole{}).Where("org_id = ? AND admin_user_id = ?", org_id, admin_user_id).First(&role).Error
- return
- }
-
- func GetAdminUserInfo(org_id int64) (role models.UserAdminRole, err error) {
- err = readUserDb.Model(&models.UserAdminRole{}).Where("org_id = ? AND status = 1", org_id).First(&role).Error
- return
- }
-
- func GetHisOrderTwo(user_org_id int64, number string, patient_id int64) (order models.HisOrder, err error) {
- err = readDb.Model(&HisOrder{}).Where("user_org_id = ? AND patient_id = ? AND number=?", user_org_id, patient_id, number).
- First(&order).Error
- return
- }
-
- func UpDateOrder(order models.HisOrder) (err error) {
- err = writeDb.Save(&order).Error
- return
- }
-
- func UpDateOrderTwo(order *models.HisOrder) (err error) {
- err = writeDb.Save(&order).Error
- return
- }
-
- func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
- err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 2, "mtime": time.Now().Unix()}).Error
- err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 3, "mtime": time.Now().Unix()}).Error
- return
- }
-
- func CreateErrMsgLog(log *models.HisOrderError) {
- writeDb.Model(&models.HisOrderError{}).Create(&log)
-
- }
-
- func FindHisRegisterRecord(record_time int64, patient_id int64, org_id int64) (total int64, err error) {
-
- err = readDb.Model(&models.VMHisPatient{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND record_date = ?", org_id, patient_id, record_time).Count(&total).Error
-
- return
- }
-
- func FindMedicalInsuranceInfo(org_id int64) (config models.MedicalInsuranceOrgConfig, err error) {
- err = readDb.Model(&models.MedicalInsuranceOrgConfig{}).Where("status = 1 AND user_org_id = ?", org_id).First(&config).Error
- return
- }
-
- func FindAllSick(orgId int64) (list []*models.OutpatientServiceSick, err error) {
- db := readDb.Model(&models.OutpatientServiceSick{})
- db = db.Where("user_org_id = ? AND status = 1", orgId)
- err = db.Order("ctime desc").Find(&list).Error
- return
-
- }
-
- func FindAllDiagnose(orgId int64) (list []*models.HisXtDiagnoseConfig, err error) {
- db := readDb.Model(&models.HisXtDiagnoseConfig{})
- db = db.Where("user_org_id = ? AND status = 1", orgId)
- err = db.Order("ctime desc").Find(&list).Error
- return
- }
-
- func FindAllAddition(orgId int64) (list []*models.XtHisAddtionConfig, err error) {
- db := readDb.Model(&models.XtHisAddtionConfig{})
- db = db.Where("user_org_id = ? AND status = 1", orgId)
- err = db.Order("ctime desc").Find(&list).Error
- return
-
- }
-
- type XtHisOrder struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
- SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
- Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
- Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
- Modify int64 `gorm:"column:modify" json:"modify" form:"modify"`
- PayWays string `gorm:"column:pay_ways" json:"pay_way" form:"pay_ways"`
- OthDesc string `gorm:"column:oth_desc" json:"oth_desc" form:"oth_desc"`
-
- FaPiaoCode string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
- FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
-
- HisOrderInfo models.HisOrderInfo `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
- Patients models.Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
- HisPatient models.HisPatient `gorm:"ForeignKey:HisPatientId;AssociationForeignKey:ID" json:"his_patient"`
- HisPrescriptionInfo models.HisPrescriptionInfo `gorm:"ForeignKey:PatientId,SettleAccountsDate;AssociationForeignKey:PatientId,RecordDate" json:"p_info"`
- HisPrescription []*models.HisPrescription `gorm:"ForeignKey:SettleAccountsDate;AssociationForeignKey:RecordDate" json:"prescriptions"`
-
- IsUploadDiagnose int64 `gorm:"column:is_upload_diagnose" json:"is_upload_diagnose" form:"is_upload_diagnose"`
- IsUploadOrderInfo int64 `gorm:"column:is_upload_order_info" json:"is_upload_order_info" form:"is_upload_order_info"`
- IsUploadSuccess int64 `gorm:"column:is_upload_success" json:"is_upload_success" form:"is_upload_success"`
- }
-
- func (XtHisOrder) TableName() string {
- return "his_order"
- }
-
- func GetHisPrescriptionNight(org_id int64, patient_id int64, record_date int64, prescription_id int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? and prescription_id =?", org_id, prescription_id).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
- }).
- Preload("HisAdditionalCharge", "status = 1 AND user_org_id = ?", org_id).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetAllAdditionCharge(org_id int64, patient_id int64, record_time int64) (addition []*models.HisAdditionalCharge, err error) {
- err = readDb.Model(&models.HisAdditionalCharge{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND record_date = ?", org_id, patient_id, record_time).Find(&addition).Error
- return
-
- }
-
- func DelelteAddition(id int64, user_org_id int64) (err error) {
- 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
- return
- }
-
- func GetHisPatientPrescriptionList(org_id int64, keywords string, record_date int64, page int64, limit int64) (patients []*Schedule, err error, total int64) {
- offset := (page - 1) * limit
- db := readDb.Model(&Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date = ?", org_id, record_date)
- if len(keywords) > 0 {
- keywords = "%" + keywords + "%"
- 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)
- 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)
- }
- db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
- db = db.Preload("HisPatient", "user_org_id = ? AND status = 1", org_id)
- db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1", org_id).
- Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1", org_id)
- db = db.Count(&total)
- err = db.Limit(limit).Offset(offset).Find(&patients).Error
- return
- }
-
- func UpdateHisPatientIsReturn(patientid int64, recorddate int64, orgid int64) (models.VMHisPatient, error) {
-
- patient := models.VMHisPatient{}
- err := XTWriteDB().Model(&patient).Where("patient_id = ? and record_date = ? and user_org_id = ? and status = 1", patientid, recorddate, orgid).Updates(map[string]interface{}{"is_return": 3}).Error
- return patient, err
- }
-
- type VMOtherHisPrescriptionInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- CheckGroup []int64 `gorm:"-" json:"check_group" form:"check_group"`
- VMHisPrescription []*VMHisPrescription `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId" json:"prescriptions"`
- }
-
- func (VMOtherHisPrescriptionInfo) TableName() string {
- return "his_prescription_info"
- }
-
- type VMHisPrescription struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
- BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
- PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
- Type int64 `gorm:"column:type" json:"type" form:"type"`
- HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"doctor_advice"`
- HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
- }
-
- func (VMHisPrescription) TableName() string {
- return "his_prescription"
- }
-
- func GetCallHisPrescriptions(start_time int64, end_time int64, org_id int64, patient_id int64) (advice []*VMOtherHisPrescriptionInfo, err error) {
- err = readDb.Model(&VMOtherHisPrescriptionInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date >= ? AND record_date <= ?", patient_id, org_id, start_time, end_time).
- Preload("VMHisPrescription", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).
- Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
- })
- }).Find(&advice).Error
-
- return
- }
-
- func GetHisOrderByID(order_id int64) (order models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
- return
- }
-
- func GetFaPiaoHisOrderByID(order_id int64) (order models.HisFaPiaoOrder, err error) {
- str := strconv.FormatInt(order_id, 10)
- key := "%" + str + "%"
- err = readDb.Model(&models.HisFaPiaoOrder{}).Where("order_ids like ? and status = 1", key).First(&order).Error
- return
- }
-
- func GetHisOrderByIDTwo(order_id int64) (order models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Preload("HisOrderInfo", "status = 1").Preload("HisPatient", "status = 1").Where("id = ? AND status = 1", order_id).First(&order).Error
- return
- }
-
- func GetHisOrderInfoByNumber(order_number string) (order []*models.HisOrderInfo, err error) {
- db := readDb.Model(&models.HisOrderInfo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("BaseDrugLib", "status = 1").Where("status = 1")
- })
- err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
- return
- }
-
- func GetHisOrderInfoByNumberTwo(order_number string) (order []*models.HisOrderInfo, err error) {
- db := readDb.Model(&models.HisOrderInfo{})
- //db = db.Joins("Join his_prescription_project as p On p.id = his_order_info.project_id")
- db = db.Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("status = 1")
- })
- err = db.Where("order_number = ? AND status = 1 AND project_id > 0", order_number).Find(&order).Error
- return
- }
-
- func GetHisOrderInfoByNumberThree(order_number string) (order []*models.HisOrderInfo, err error) {
- db := readDb.Model(&models.HisOrderInfo{})
- //db = db.Joins("Join his_prescription_project as p On p.id = his_order_info.project_id AND p.team_id > 0")
-
- db = db.Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("status = 1")
- })
- err = db.Where("order_number = ? AND status = 1 AND project_id > 0", order_number).Find(&order).Error
- return
- }
-
- func GetOrderByTime(start_time int64, end_time int64, org_id int64, insutype string, clr_org string, clr_type string, mdtrtareaAdmvs string) (orders []*models.HisOrder, err error) {
- db := readDb.Model(&models.HisOrder{})
- db = db.Where("user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ? AND insutype = ?", org_id, end_time, start_time, insutype)
- if len(clr_org) > 0 {
- db = db.Where("clr_optins = ?", clr_org)
- }
- if len(clr_type) > 0 {
- if mdtrtareaAdmvs == "150499" {
- if clr_type == "11" {
- db = db.Where("clr_type = ?", clr_type)
- }
-
- } else {
-
- db = db.Where("clr_type = ?", clr_type)
- }
- } else {
- if len(clr_type) == 0 {
- db = db.Where("clr_type = ?", "")
-
- } else {
- db = db.Where("clr_type = ?", "9903")
-
- }
-
- }
- err = db.Find(&orders).Error
- return
- }
-
- func GetOrderByTimeFive(start_time int64, end_time int64, org_id int64, insutype string, clr_org string, clr_type string, mdtrtareaAdmvs string) (orders []*models.HisOrder, err error) {
- db := readDb.Model(&models.HisOrder{})
- db = db.Where("user_org_id = ? AND order_status = 3 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ? AND insutype = ?", org_id, end_time, start_time, insutype)
- if len(clr_org) > 0 {
- db = db.Where("clr_optins = ?", clr_org)
- }
- if len(clr_type) > 0 {
- if mdtrtareaAdmvs == "150499" {
- if clr_type == "11" {
- db = db.Where("clr_type = ?", clr_type)
- }
-
- } else {
- db = db.Where("clr_type = ?", clr_type)
-
- }
- }
- err = db.Find(&orders).Error
- return
- }
-
- func GetOrderByTimeFour(start_time int64, end_time int64, org_id int64) (orders []*models.HisOrder, err error) {
- db := readDb.Model(&models.HisOrder{})
- db = db.Where("user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ? ", org_id, end_time, start_time)
- err = db.Find(&orders).Error
- return
- }
-
- func GetOrderByTimeTenaaa(start_time int64, end_time int64, org_id int64, org string) (orders []*models.HisOrder, err error) {
- db := readDb.Model(&models.HisOrder{})
- db = db.Where("clr_options = ? and user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ? ", org, org_id, end_time, start_time)
- err = db.Find(&orders).Error
- return
- }
-
- func GetOrderByTime11222(start_time int64, end_time int64, org_id int64) (orders []*models.HisOrder, err error) {
- db := readDb.Model(&models.HisOrder{})
- db = db.Where("psn_name = '付云芳' and user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ?", org_id, end_time, start_time)
- err = db.Find(&orders).Error
- return
- }
-
- func GetOrderByTimeFourfor11(start_time int64, end_time int64, org_id int64) (orders []*models.HisOrder, err error) {
- db := readDb.Model(&models.HisOrder{})
- db = db.Where("user_org_id = ? AND status = 1 AND order_status = 2 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ? and med_type = 11", org_id, end_time, start_time)
- err = db.Find(&orders).Error
- return
- }
-
- func GetOrderByTimeThree(start_time int64, end_time int64, org_id int64, insutype string, clr_type string) (orders []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ? AND insutype = ?", org_id, end_time, start_time, insutype).Find(&orders).Error
- return
- }
-
- func GetOrderByTimeTwo(start_time int64, end_time int64, org_id int64) (orders []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND is_medicine_insurance = 1 AND UNIX_TIMESTAMP(setl_time) <= ? AND UNIX_TIMESTAMP(setl_time) >= ?", org_id, end_time, start_time).Find(&orders).Error
- return
- }
-
- func GetPatientByID(orgID int64, patientID int64) (*models.Patients, error) {
- var patient models.Patients
- err := readDb.Model(&models.Patients{}).Where("id = ? and user_org_id=? and status=1", patientID, orgID).First(&patient).Error
- if err != nil {
- if err == gorm.ErrRecordNotFound {
- return nil, nil
- } else {
- return nil, err
- }
- }
- return &patient, nil
- }
-
- func FindDiagnoseById(id int64) (models.HisXtDiagnoseConfig, error) {
- dealer := models.HisXtDiagnoseConfig{}
- err := readDb.Model(&models.HisXtDiagnoseConfig{}).Where("id = ? and status = 1", id).First(&dealer).Error
- return dealer, err
- }
-
- func FindDiagnoseByIdtwo(id string) (models.HisXtDiagnoseConfig, error) {
- dealer := models.HisXtDiagnoseConfig{}
- err := readDb.Model(&models.HisXtDiagnoseConfig{}).Where("id = ? and status = 1", id).First(&dealer).Error
- return dealer, err
- }
-
- func FindDiagnoseByIds(ids []string) ([]*models.HisXtDiagnoseConfig, error) {
- dealer := []*models.HisXtDiagnoseConfig{}
- err := readDb.Model(&models.HisXtDiagnoseConfig{}).Where("id IN (?) AND status = 1", ids).Find(&dealer).Error
- return dealer, err
- }
-
- func FindSickById(id int64) (*models.OutpatientServiceSick, error) {
- outPatient := &models.OutpatientServiceSick{}
- err := readDb.Model(&models.OutpatientServiceSick{}).Where("id = ? AND status = 1", id).First(&outPatient).Error
- return outPatient, err
- }
-
- //
- //type MonthHisPrescription struct {
- // ID int64 `gorm:"column:id" json:"id" form:"id"`
- // UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- // RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- // 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"`
- // 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"`
- // Number string `gorm:"column:number" json:"number" form:"number"`
- // Type int64 `gorm:"column:type" json:"type" form:"type"`
- // Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
- // Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
- // Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
- // OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
- // BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
- // PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
- // Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
- // HisPatient models.VMHisPatient `gorm:"ForeignKey:PatientId;AssociationForeignKey:patient_id" json:"hisPatient"`
- // HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
- // HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
- // HisAdditionalCharge []*models.HisAdditionalCharge `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
- // VMHisPrescriptionInfo models.HisPrescriptionInfo `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"info"`
- //}
- //
- //func (MonthHisPrescription) TableName() string {
- // return "his_prescription"
- //}
-
- func GetMonthHisPrescription(org_id int64, patient_id int64, start_time int64, end_time int64, reg_type string) (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("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status=1")
- }).
- Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND status = 1 AND p_type <> 1 AND med_type = ?", org_id, start_time, end_time, patient_id, reg_type).
- Find(&prescription).Error
- return
- }
-
- func GetPatientByNumber(number string, user_org_id int64) (patient Patients, err error) {
- err = readDb.Model(&Patients{}).Where("(health_care_no = ? OR id_card_no = ?) AND user_org_id = ?", number, number, user_org_id).First(&patient).Error
- return
- }
-
- func GetPatientByIDCard(id_card_no string, user_org_id int64) (patient Patients, err error) {
- err = readDb.Model(&Patients{}).Where("(health_care_no = ? or id_card_no = ?) AND user_org_id = ?", id_card_no, id_card_no, user_org_id).First(&patient).Error
- return
- }
-
- func GetHisOrderThree(record_time int64, patient_id int64, user_org_id int64) (order models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("patient_id = ? AND user_org_id = ? AND settle_accounts_date = ? AND status = 1", patient_id, user_org_id, record_time).First(&order).Error
- return
- }
-
- func GetAppRole(orgID int64) (models.App_Role, error) {
- var appRole models.App_Role
- err := readUserDb.Model(models.App_Role{}).Where("org_id = ? AND user_type = 2", orgID).First(&appRole).Error
- return appRole, err
- }
-
- func GetPatientByIDTwo(orgID int64, patientID int64) (Patients, error) {
- var patient Patients
- err := readDb.Model(&Patients{}).Where("id = ? and user_org_id=? and status=1", patientID, orgID).First(&patient).Error
- return patient, err
- }
-
- func GetDrugList(orgID int64) (drug []*models.BaseDrugList, err error) {
-
- db := XTReadDB().Table("xt_base_drug as x").Where("x.status = 1")
- table := XTReadDB().Table("xt_manufacturer as m")
- fmt.Print(table)
- if orgID > 0 {
- db = db.Where("x.org_id = ? and x.id = 397", orgID)
- }
- err = db.Select("x.id,x.medical_insurance_number,x.code,x.drug_name,x.drug_spec,x.drug_type,x.min_unit,x.last_price,x.retail_price,x.limit_remark,x.drug_dosage_form,m.manufacturer_name").Joins("left join xt_manufacturer as m on m.id = x.manufacturer").Scan(&drug).Error
-
- return drug, err
- }
-
- func GetDrugDosageForm(orgid int64) (dataconfig []*models.XtDrugDataConfig, err error) {
-
- err = XTReadDB().Where("(org_id = ? or org_id = 0) and parent_id = 4 and status = 1", orgid).Find(&dataconfig).Error
- return dataconfig, err
- }
-
- func GetDoctorList(orgid int64) (role []*models.SgjUserAdminRole, err error) {
-
- //err = UserReadDB().Model(&role).Where("org_id = ? and status = 1 and user_type = 2", orgid).Find(&role).Error
- //return role, err
-
- db := UserReadDB().Table("sgj_user_admin_role as x").Where("x.status =1")
- table := UserReadDB().Table("sgj_user_admin as a")
- fmt.Println(table)
- err = db.Select("x.id,x.admin_user_id,x.org_id,x.app_id,x.role_id,x.user_name,x.avatar,x.user_type,x.user_title,x.intro,x.user_title_name,x.role_ids,x.message,x.sex,x.birthday,x.sort,x.is_sort,x.department,x.department_id,x.age,x.nation,x.card_type,x.id_card,x.education,x.study_major_name,x.work_major_name,x.role_type,x.medical_code,x.doctor_code,x.licensing,x.job_number,x.prescription_qualification_identification,x.identification_outpatients,x.start_time,x.medical_range_code,x.medical_level,x.medical_type_job,x.pharmacist_registration_number,x.doctor_range_code,x.doctor_level,x.doctor_type_job,x.doctor_number,x.outpatient_illness_category,x.is_active,x.active_status,a.mobile").Joins("left join sgj_user_admin as a on a.id = x.admin_user_id").Scan(&role).Error
- return role, err
- }
-
- func GetPrescriptionByIds(ids []string, org_id 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("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
- }).
- Where("id in (?) AND user_org_id = ? AND status = 1", ids, org_id).
- Find(&prescription).Error
-
- return
- }
-
- func GetDoctorListTwo(orgid int64) (role []*models.SgjUserAdminRole, err error) {
-
- db := UserReadDB().Table("sgj_user_admin_role as x").Where("x.status =1 AND x.user_type = 2 AND x.org_id = ?", orgid)
- //table := UserReadDB().Table("sgj_user_admin as a")
- //fmt.Println(table)
- err = db.Select("x.id,x.admin_user_id,x.org_id,x.app_id,x.role_id,x.user_name,x.avatar,x.user_type,x.user_title,x.intro,x.user_title_name,x.role_ids,x.message,x.sex,x.birthday,x.sort,x.is_sort,x.department,x.department_id,x.age,x.nation,x.card_type,x.id_card,x.education,x.study_major_name,x.work_major_name,x.role_type,x.medical_code,x.doctor_code,x.licensing,x.job_number,x.prescription_qualification_identification,x.identification_outpatients,x.start_time,x.medical_range_code,x.medical_level,x.medical_type_job,x.pharmacist_registration_number,x.doctor_range_code,x.doctor_level,x.doctor_type_job,x.doctor_number,x.outpatient_illness_category,x.is_active,x.active_status,a.mobile").Joins("left join sgj_user_admin as a on a.id = x.admin_user_id").Scan(&role).Error
- return role, err
- }
-
- func GetRoleList(orgid int64) (role []*models.SgjUserRole, err error) {
-
- err = UserReadDB().Model(&role).Where("org_id = ? and status =1", orgid).Find(&role).Error
- return role, err
- }
-
- func GetDrugListByDetail(orgID int64, id int64) (drug []*models.BaseDrugList, err error) {
-
- db := XTReadDB().Table("xt_base_drug as x").Where("x.status = 1")
- table := XTReadDB().Table("xt_manufacturer as m")
- fmt.Print(table)
- if orgID > 0 {
- db = db.Where("x.org_id = ? and x.id = ?", orgID, id)
- }
- err = db.Select("x.id,x.medical_insurance_number,x.code,x.drug_name,x.drug_spec,x.drug_type,x.min_unit,x.last_price,x.retail_price,x.limit_remark,x.drug_dosage_form,m.manufacturer_name").Joins("left join xt_manufacturer as m on m.id = x.manufacturer").Scan(&drug).Error
-
- return drug, err
- }
-
- func GetGoodInformationList(orgid int64) (good []*models.GoodInformation, err error) {
-
- db := XTReadDB().Table("xt_good_information as x").Where("x.status=1")
- table := XTReadDB().Table("xt_manufacturer as m")
- fmt.Println(table)
- if orgid > 0 {
- db = db.Where("x.org_id = ?", orgid)
- }
- err = db.Select("x.id,x.social_security_directory_code,x.good_name,x.specification_name,x.production_type,x.special_medical,x.good_unit,x.buy_price,x.sell_price,x.remark,m.manufacturer_name").Joins("left join xt_manufacturer as m on m.id = x.manufacturer").Scan(&good).Error
- return good, err
- }
-
- func GetGoodListByDetail(orgid int64, id int64) (good []*models.GoodInformation, err error) {
- db := XTReadDB().Table("xt_good_information as x").Where("x.status=1")
- table := XTReadDB().Table("xt_manufacturer as m")
- fmt.Println(table)
- if orgid > 0 {
- db = db.Where("x.org_id = ? and x.id= ?", orgid, id)
- }
- err = db.Select("x.id,x.social_security_directory_code,x.good_name,x.specification_name,x.production_type,x.special_medical,x.good_unit,x.buy_price,x.sell_price,x.remark,m.manufacturer_name").Joins("left join xt_manufacturer as m on m.id = x.manufacturer").Scan(&good).Error
- return good, err
- }
-
- func GetDoctorListByDetail(orgid int64, id int64) (role []*models.SgjUserAdminRole, err error) {
-
- db := UserReadDB().Table("sgj_user_admin_role as x").Where("x.status =1")
- table := UserReadDB().Table("sgj_user_admin as a")
- fmt.Println(table)
- if id > 0 {
- db = db.Where("x.status = 1 and x.admin_user_id = ? and x.org_id = ?", id, orgid)
- }
- err = db.Select("x.age,x.id,x.admin_user_id,x.org_id,x.app_id,x.role_id,x.user_name,x.avatar,x.user_type,x.user_title,x.intro,x.user_title_name,x.role_ids,x.message,x.sex,x.birthday,x.sort,x.is_sort,x.department,x.department_id,x.nation,x.card_type,x.id_card,x.education,x.study_major_name,x.work_major_name,x.role_type,x.medical_code,x.doctor_code,x.licensing,x.job_number,x.prescription_qualification_identification,x.identification_outpatients,x.start_time,x.medical_range_code,x.medical_level,x.medical_type_job,x.pharmacist_registration_number,x.doctor_range_code,x.doctor_level,x.doctor_type_job,x.doctor_number,x.outpatient_illness_category,x.is_active,x.active_status,a.mobile").Joins("left join sgj_user_admin as a on a.id = x.admin_user_id").Scan(&role).Error
- return role, err
- }
-
- func GetMyPorjecgList(orgid int64) (project []*models.MyHisProject, err error) {
-
- err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
- return project, err
- }
-
- func GetMyPorjecgListDetail(orgid int64, id int64) (project []*models.MyHisProject, err error) {
- err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1 and id = ?", orgid, id).Find(&project).Error
- return project, err
- }
-
- func GetBathchMyPorjecgList(idss []int64) (project []*models.MyHisProject, err error) {
- db := XTReadDB().Table("xt_his_project")
- if len(idss) == 1 {
- err = db.Where("status = 1 and id = ?", idss[0]).Find(&project).Error
- } else {
- err = db.Where("status = 1 and id IN(?)", idss).Find(&project).Error
- }
-
- return project, err
- }
- func GetBathchMyPorjecgListtwo(org_id int64) (project []*models.MyHisProject, err error) {
- db := XTReadDB().Table("xt_his_project")
-
- err = db.Where("status = 1 and user_org_id = ?", org_id).Find(&project).Error
-
- return project, err
- }
- func GetBatchDoctorList(idss []int64) (role []*models.SgjUserAdminRole, err error) {
-
- db := UserReadDB().Table("sgj_user_admin_role as x").Where("x.status =1")
- table := UserReadDB().Table("sgj_user_admin as a")
- fmt.Println(table)
- if len(idss) == 1 {
- db = db.Where("x.status = 1 and x.admin_user_id = ?", idss[0])
- } else {
- db = db.Where("x.status = 1 and x.admin_user_id IN(?)", idss)
- }
- err = db.Select("x.age,x.id,x.admin_user_id,x.org_id,x.app_id,x.role_id,x.user_name,x.avatar,x.user_type,x.user_title,x.intro,x.user_title_name,x.role_ids,x.message,x.sex,x.birthday,x.sort,x.is_sort,x.department,x.department_id,x.nation,x.card_type,x.id_card,x.education,x.study_major_name,x.work_major_name,x.role_type,x.medical_code,x.doctor_code,x.licensing,x.job_number,x.prescription_qualification_identification,x.identification_outpatients,x.start_time,x.medical_range_code,x.medical_level,x.medical_type_job,x.pharmacist_registration_number,x.doctor_range_code,x.doctor_level,x.doctor_type_job,x.doctor_number,x.outpatient_illness_category,x.is_active,x.active_status,a.mobile").Joins("left join sgj_user_admin as a on a.id = x.admin_user_id").Scan(&role).Error
- return role, err
-
- }
-
- func GetAllPatient(org_id int64) (patients []*models.Patients, err error) {
- err = readDb.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1 AND lapseto = 1", org_id).Find(&patients).Error
- return
- }
-
- func UpdateHisPrescriptionHisID(his_patient_id int64, patient_id int64, record_time int64, org_id int64) {
- XTWriteDB().Model(&models.HisPrescription{}).Where("record_date = ? AND user_org_id = ? AND patient_id = ? AND his_patient_id = 0", record_time, org_id, patient_id).Updates(map[string]interface{}{"his_patient_id": his_patient_id})
- XTWriteDB().Model(&models.HisPrescriptionInfo{}).Where("record_date = ? AND user_org_id = ? AND patient_id = ? AND his_patient_id = 0", record_time, org_id, patient_id).Updates(map[string]interface{}{"his_patient_id": his_patient_id})
- return
- }
-
- func UpdateHisPrescriptionHisIDTwo(his_patient_id int64, patient_id int64, record_time int64, org_id int64, start_time int64) {
- XTWriteDB().Model(&models.HisPrescription{}).Where("record_date <= ? AND record_date >= ? AND user_org_id = ? AND patient_id = ? AND his_patient_id = 0 AND order_status <> 2", record_time, start_time, org_id, patient_id).Updates(map[string]interface{}{"his_patient_id": his_patient_id})
- XTWriteDB().Model(&models.HisPrescriptionInfo{}).Where("record_date = ? AND user_org_id = ? AND patient_id = ? AND his_patient_id = 0 AND order_status <> 2", record_time, start_time, org_id, patient_id).Updates(map[string]interface{}{"his_patient_id": his_patient_id})
- return
- }
- func UpdateHisPrescriptionHisID1111(his_patient_id int64, patient_id int64, record_time int64, org_id int64) {
- //XTWriteDB().Model(&models.HisPrescription{}).Where("record_date = ? AND user_org_id = ? AND patient_id = ? AND his_patient_id = 0", record_time, org_id, patient_id).Updates(map[string]interface{}{"his_patient_id": his_patient_id})
- //XTWriteDB().Model(&models.HisPrescriptionInfo{}).Where("record_date = ? AND user_org_id = ? AND patient_id = ? AND his_patient_id = 0", record_time, org_id, patient_id).Updates(map[string]interface{}{"his_patient_id": his_patient_id})
- return
- }
-
- func GetHisPatientInfoList(org_id int64, patient_id int64, record_date int64) (info []*models.HisPatient, err error) {
- err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Find(&info).Error
- return
- }
-
- func GetHisPatientByNumber(number string) (his models.HisPatient, err error) {
- err = readDb.Model(&models.HisPatient{}).Where("number = ? AND status = 1", number).First(&his).Error
- return
- }
- func GetNewHisPrescriptionByNumber(number string) (pre models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).Where("batch_number = ? AND status = 1", number).First(&pre).Error
- return
-
- }
-
- func CreateUploadRecord(result *models.HisFundSettleListResult) (err error) {
- err = writeDb.Create(&result).Error
- return
- }
-
- func GetUploadRecord(order_id int64) (result models.HisFundSettleListResult, err error) {
- err = readDb.Model(&models.HisFundSettleListResult{}).Where("order_id = ? AND status = 1", order_id).First(&result).Error
- return
- }
- func UpdateRecord(result *models.HisFundSettleListResult) (err error) {
- err = writeDb.Save(&result).Error
- return
- }
-
- func GetDeviceNumberByID(bed_id int64, org_id int64) (device_number models.DeviceNumber, err error) {
- err = readDb.Model(&models.DeviceNumber{}).Where("id = ? AND org_id = ?", bed_id, org_id).First(&device_number).Error
- return
- }
-
- func UpdateHisPatientStatus(his *models.VMHisPatient) {
- writeDb.Save(&his)
- }
-
- func UpdateHisPatient123(his *Patients) {
- writeDb.Save(&his)
- }
-
- func GetLastHisOrder(org_id int64) (his models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND order_status = 2 AND fa_piao_code <> '' AND fa_piao_number <> ''", org_id).Last(&his).Error
- return
- }
-
- func GetLastHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Select("max(convert(fa_piao_number,signed)) as fa_piao_number").Where("user_org_id = ? AND status = 1 AND order_status = 2 ", org_id).Find(&his).Error
- return
- }
-
- func GetHisPatientInfoTwo(org_id int64, patient_id int64, record_date int64) (info []*models.HisPatient, err error) {
- err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Find(&info).Error
- return
- }
-
- func GetNewHisOrderTwo(user_org_id int64, mdtrt_id string, patient_id int64, record_time int64) (order HisOrder, err error) {
- err = readDb.Model(&HisOrder{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND mdtrt_id=? AND settle_accounts_date = ? ", user_org_id, patient_id, mdtrt_id, record_time).
- Order("ctime desc").
- Find(&order).Error
- return
- }
-
- func GetNewHisOrderThree(mdtrt_id string) (order HisOrder, err error) {
- err = readDb.Model(&HisOrder{}).Where("status = 1 AND mdtrt_id=? ", mdtrt_id).First(&order).Error
- return
- }
-
- func UpdateHisPatientThree(his *models.HisPatient) {
- writeDb.Save(&his)
- }
-
- func GetNewHisPrescriptionTwo(org_id int64, his_patient_id int64, record_date int64, med_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("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status=1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND his_patient_id = ? AND order_status <> 2 AND p_type <> 1 AND med_type = ?", org_id, record_date, his_patient_id, med_type).
- Find(&prescription).Error
- return
- }
-
- func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_time int64, end_time int64, med_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("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status=1")
- }).
- Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND status = 1 AND p_type <> 1 AND med_type = ?", org_id, start_time, end_time, patient_id, med_type).
- Find(&prescription).Error
- return
- }
-
- func GetNewHisPatientInfoFour(org_id int64, id int64) (info models.HisPatient, err error) {
- err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND id = ?", org_id, id).First(&info).Error
- return
- }
-
- func GetTodayHisOrder(org_id int64, patient_id int64, record_time int64, number string) (order models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? AND settle_accounts_date = ? AND order_status = 1 AND mdtrt_id = ?", org_id, patient_id, record_time, number).First(&order).Error
- return
- }
-
- func GetLastFundList(org_id int64) (order models.HisFundSettleListResult, err error) {
- err = readDb.Model(&models.HisFundSettleListResult{}).Where("user_org_id = ? AND status = 1 ", org_id).Last(&order).Error
- return
- }
-
- func GetOrderError(org_id int64) (order []*models.HisOrderError, err error) {
- err = readDb.Model(&models.HisOrderError{}).Where("user_org_id = ? AND status = 1 AND stage = 10106 ", org_id).Find(&order).Error
- return
- }
-
- func GetOrderCountByNumber(org_id int64, patient_id int64, record_time int64, number string) (count int64, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? AND settle_accounts_date = ? AND order_status = 2 AND mdtrt_id = ?", org_id, patient_id, record_time, number).Count(&count).Error
-
- return
- }
-
- func CreateHisPsn(psn *models.HisPsn) {
- writeDb.Save(&psn)
- }
-
- func GetPsnByPatientId(patient_id int64) (psn models.HisPsn, err error) {
- err = readDb.Model(&models.HisPsn{}).Where("patient_id = ?", patient_id).Last(&psn).Error
- return
- }
- func GetPsnByPatientIdtWO(patient_id int64, record_date int64) (psn models.HisPsn, err error) {
- err = readDb.Model(&models.HisPsn{}).Where("patient_id = ? AND record_date = ?", patient_id, record_date).Last(&psn).Error
- return
- }
-
- func GetHisPatientByPatientId(patient_id int64) (psn models.HisPatient, err error) {
- err = readDb.Model(&models.HisPatient{}).Where("patient_id = ?", patient_id).Last(&psn).Error
- return
- }
-
- //func GetPsnByPatientIdTwo(patient_id int64, record_date int64) (psn models.HisPsn, err error) {
- // err = readDb.Model(&models.HisPsn{}).Where("patient_id = ? AND record_date = ? AND stage = 1", patient_id, record_date).Last(&psn).Error
- // return
- //}
-
- func GetPsnByPatientIdTwo(patient_id int64) (psn models.HisPsn, err error) {
- err = readDb.Model(&models.HisPsn{}).Where("patient_id = ?", patient_id).Last(&psn).Error
- return
- }
-
- func GetAllHisOrder(org_id int64) (his []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND order_status = 2 AND setl_id <> '' AND med_type = '14' AND setl_time >= '2022-12-15 00:00:00'", org_id).Order("setl_time asc").Find(&his).Error
- fmt.Println(err)
- return
- }
-
- func GetAllHisOrderTwo(org_id int64) (his []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND order_status = 2 AND setl_id <> '' AND med_type = '14' AND id >= 247903", org_id).Order("setl_time asc").Find(&his).Error
- fmt.Println(err)
- return
- }
-
- func GetAllHisOrder10106(org_id int64) (his []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106 AND status = 1 AND order_status = 2 AND setl_id <> '' AND med_type = '14' AND setl_time >= '2023-08-01 00:00:00' AND setl_time <= '2023-08-31 23:59:00'").Order("setl_time asc").Find(&his).Error
- fmt.Println(err)
- return
- }
- func GetAllHisOrder10138() (his []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10028 AND status = 1 AND order_status = 2 AND setl_id <> '' AND setl_time >= '2024-01-01 00:00:00' and mdtrt_id not like '%out%'").Order("setl_time asc").Find(&his).Error
- fmt.Println(err)
- return
- }
- func GetOrderError10138() (order []*models.HisOrderError, err error) {
- err = readDb.Model(&models.HisOrderError{}).Where("status = 1 AND stage = 10138500").Find(&order).Error
- return
- }
-
- func GetAllHisOrder10278() (his []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where(" user_org_id = 10537 AND status = 1 AND order_status = 2 AND setl_id <> '' AND setl_time >= '2024-09-01 00:00:00' AND setl_time <= '2024-10-31 23:00:00' and mdtrt_id not like '%out%'").Order("setl_time asc").Find(&his).Error
- fmt.Println(err)
- return
- }
-
- func GetAllHisOrder10265() (his []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where(" user_org_id = 10265 AND status = 1 AND order_status = 2 AND setl_id <> '' AND setl_time >= '2024-09-01 00:00:00' AND setl_time <= '2024-09-30 23:59:00'").Order("setl_time asc").Find(&his).Error
- fmt.Println(err)
- return
- }
-
- //func GetAllHisOrder10265() (his []*models.HisOrder, err error) {
- // err = readDb.Model(&models.HisOrder{}).Where(" user_org_id = 10265 AND status = 1 AND order_status = 2 AND setl_id <> '' AND setl_time >= '2023-09-01 00:00:00'").Order("setl_time asc").Find(&his).Error
- // fmt.Println(err)
- // return
- //}
-
- // func GetAllHisOrder2(org_id int64) (his []models.HisOrder, err error) {
- // err = readDb.Model(&models.HisOrder{}).Where("id = 180753").Order("setl_time asc").First(&his).Error
- // return
- // }
- func GetAllHisOrderErr10278() (his []*models.HisOrderError, err error) {
- err = readDb.Model(&models.HisOrderError{}).Where("user_org_id = 10278 AND status = 1 AND stage = 10276").Find(&his).Error
- return
- }
-
- func GetHisOrderInfoByNumberFour(order_number string) (order []*models.HisOrderInfo, err error) {
- db := readDb.Model(&models.HisOrderInfo{})
- err = db.Where("order_number = ? AND status = 1", order_number).Find(&order).Error
- return
- }
-
- func UpdataOrderStatusByNumber(number string) (err error) {
- err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND number = ?", number).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0}).Error
- return
-
- }
-
- func UpdataHospitalOrderStatus(number string, user_org_id int64) (err error) {
- err = writeDb.Model(&models.HisOrderInfo{}).Where("status = 1 AND order_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
- err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
- err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
- return
-
- }
-
- func GetHisFundSettleListResult(order_id int64) (result models.HisFundSettleListResult, err error) {
- db := readDb.Model(&models.HisFundSettleListResult{})
- err = db.Where("order_id = ? AND status = 1", order_id).First(&result).Error
- return
- }
-
- func SaveClearRecord(record *models.HisYidiClearRecord) {
- writeDb.Save(&record)
- }
-
- func GetClearRecordById(id int64) (record models.HisYidiClearRecord, err error) {
- err = readDb.Model(&models.HisYidiClearRecord{}).Where("id = ? AND status = 1").First(&record).Error
- return
- }
-
- func UpdateOrder(order models.HisOrder) (err error) {
- err = writeDb.Save(&order).Error
- return
- }
- func UpdateOrderTwo(order models.NewHisOrder111) (err error) {
- err = writeDb.Save(&order).Error
- return
- }
- func GetNewHisPrescriptionTen(org_id int64, his_patient_id int64, record_date int64) (prescription []*models.HisPrescriptionTen, err error) {
- err = readDb.Model(&models.HisPrescriptionTen{}).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("BaseDrugLib", "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", "status=1").Preload("GoodInfo", "status=1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND his_patient_id = ? AND p_type <> 1 ", org_id, record_date, his_patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetHisOrderByIDTwo1111(order_id int64) (order models.NewHisOrder111, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("id = ? AND status = 1", order_id).First(&order).Error
- return
- }
-
- func GetHisPrescriptionForMedType(org_id int64, patient_id int64, record_date 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("BaseDrugLib", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
- }).
- Where("(user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 and med_type = 148801) or (user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 and med_type = 118801)", org_id, record_date, patient_id, org_id, record_date, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetOrderByTimeTen(start_time string, end_time string, org_id int64) (orders []*models.FixMonRecDetailFileIn, err error) {
- err = readDb.Raw("select CASE WHEN p.`insuplc_admdvs` LIKE '%3209%' THEN CONCAT(his_order.insutype, '99', his_order.med_type, '555555') ELSE CONCAT(his_order.insutype, '99', his_order.med_type, '888888') END AS fund_key, his_order.insutype, '99' as `psn_type` , his_order.`med_type`, COUNT(DISTINCT his_order.`certno`) AS psn_cnt, count(*) as psn_time, sum(his_order.medfee_sumamt) as sumamt, sum(his_order.inscp_scp_amt) as amt, sum(his_order.fund_pay_sumamt) + sum(his_order.acct_pay) as fund FROM his_order join his_patient p on p.number = his_order.mdtrt_id where his_order.user_org_id = ? and his_order.status = 1 and his_order.order_status = 2 and his_order.setl_time >= ? and his_order.setl_time <= ? and his_order.setl_id <> '' GROUP BY fund_key", org_id, start_time+" 00:00:00", end_time+" 23:00:00").Scan(&orders).Error
- return
- }
-
- func GetOrderByTimeTentwo(start_time string, end_time string, org_id int64) (orders []*models.FixMonRecDetailFileIn, err error) {
- err = readDb.Raw("select CASE WHEN p.`insuplc_admdvs` LIKE '%3209%' THEN CONCAT(his_order.insutype, '99', his_order.med_type, '555555') ELSE CONCAT(his_order.insutype, '99', his_order.med_type, '888888') END AS fund_key, his_order.insutype, '99' as `psn_type` , his_order.`med_type`, COUNT(DISTINCT his_order.`certno`) AS psn_cnt, count(*) as psn_time, sum(his_order.medfee_sumamt) as sumamt, sum(his_order.inscp_scp_amt) as amt, sum(his_order.fund_pay_sumamt) + sum(his_order.acct_pay) as fund FROM his_order join his_patient p on p.number = his_order.mdtrt_id where his_order.user_org_id = ? and his_order.status = 0 and his_order.order_status = 3 and his_order.setl_time >= ? and his_order.setl_time <= ? and his_order.setl_id <> '' GROUP BY fund_key", org_id, start_time+" 00:00:00", end_time+" 23:00:00").Scan(&orders).Error
- return
- }
-
- func GetOrderDetailByTimeTen(start_time string, end_time string, org_id int64, fund_key string) (fund []models.FundDetail, err error) {
- err = readDb.Raw("SELECT CASE WHEN p.`insuplc_admdvs` LIKE '%3209%' THEN CONCAT(his_order.insutype, '99', his_order.med_type, '555555') ELSE CONCAT(his_order.insutype, '99', his_order.med_type, '888888') end AS fund_key, his_order.`setl_detail` FROM his_order join his_patient p on p.number = his_order.mdtrt_id where his_order.user_org_id = ? and his_order.status = 1 and his_order.order_status = 2 and his_order.setl_time >= ? and his_order.setl_time <= ? and CONCAT(his_order.insutype, '99', his_order.med_type, '555555') = ?", org_id, start_time+" 00:00:00", end_time+" 23:59:00", fund_key).Scan(&fund).Error
- return
- }
-
- func Saveflow(flow models.HisPrescriptionFlow) {
- writeDb.Save(&flow)
- }
-
- func Createflow(flow *models.HisPrescriptionFlow) {
- writeDb.Create(&flow)
- }
-
- func GetNewHisPrescriptionTenone(org_id int64, number string) (prescription []*models.HisPrescriptionTen, err error) {
- err = readDb.Model(&models.HisPrescriptionTen{}).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("BaseDrugLib", "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", "status=1").Preload("GoodInfo", "status=1")
- }).
- Where("user_org_id = ? AND status = 1 AND batch_number = ? and order_status = 4 ", org_id, number).
- Find(&prescription).Error
- return
- }
-
- func GetHisOrderByIDThree(start_time string) (his []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where(" user_org_id = 10265 AND status = 1 AND order_status = 2 AND setl_id <> '' AND setl_time >= ?", start_time).Order("setl_time asc").Find(&his).Error
- fmt.Println(err)
- return
- }
-
- func UpDatePrescriptionNumber111(user_org_id int64, start_time int64, end_time int64, number string, patient_id int64) (err error) {
- err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND record_date >= ? and record_date <= ? and patient_id = ? and order_status = 1", user_org_id, start_time, end_time, patient_id).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
- return
- }
- func UpDatePrescriptionNumber222(user_org_id int64, id int64, number string, patient_id int64) (err error) {
- err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id = ? and patient_id = ?", user_org_id, id, patient_id).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix()}).Error
- return
- }
-
- func GetAllHisOrderTwo10485() (his []*models.HisOrder, err error) {
- err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10485 AND status = 1 AND order_status = 2 AND setl_id <> '' AND setl_time >= '2024-01-01 00:00:00' ").Order("setl_time asc").Find(&his).Error
- fmt.Println(err)
- return
- }
-
- func GetNewDrugWarehouseInfo(org_id int64, id_arr []string) (newDrugWarehouse []*models.NewDrugWarehouseInfo, err error) {
- readDb.Model(&models.NewDrugWarehouseInfo{}).Where("org_id = ? and status = 1 and id in (?) ", org_id, id_arr).Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&newDrugWarehouse)
- return
- }
-
- func GetNewDrugWarehouseInfobytime(org_id int64, s_time int64, e_time int64) (newDrugWarehouse []*models.NewDrugWarehouseInfo, err error) {
- readDb.Model(&models.NewDrugWarehouseInfo{}).Where("org_id = ? and status = 1 and ctime > ? and ctime < ? and drug_code <> '' ", org_id, s_time, e_time).Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&newDrugWarehouse)
- return
- }
-
- func GetNewDrugFlowInfo(org_id int64, id_arr []string) (flows []*models.DrugFlow, err error) {
- err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = ? and status = 1 and id in (?)", org_id, id_arr).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
- }).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
- return
- }
-
- func GetNewDrugFlowInfoByPatient(patient_id int64, drug_id int64, time int64, org_id int64) (flows []*models.DrugFlow, err error) {
- err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = ? and status = 1 and patient_id = ? and drug_id = ? and system_time = ?", org_id, patient_id, drug_id, time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
- }).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
- return
- }
-
- func GetNewUploadDrugFlowInfoByPatientTwo(patient_id int64, advice_id int64, time int64, org_id int64) (flows []*models.DrugFlow, err error) {
- err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = ? and status = 1 and patient_id = ? and drug_id = ? and system_time = ? and is_sale = 1", org_id, patient_id, advice_id, time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
- }).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
- return
- }
-
- func GetNewDrugFlowInfotwo() (flows []*models.DrugFlow, err error) {
- err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = 10188 and status = 1 and id >= ? and consumable_type = 3 and is_sale = 0", 2394762).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
- }).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
- return
- }
-
- func GetNewDrugFlowInfothree() (flows []*models.DrugFlow, err error) {
- err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = 10217 and status = 1 and id >= ? and consumable_type = 3 and is_sale = 0", 2328112).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
- }).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
- return
- }
-
- func GetNewDrugFlowInfothree123() (flows []*models.DrugFlow, err error) {
- err = readDb.Model(&models.DrugFlow{}).Where("user_org_id = 10217 and status = 1 and length(drug_code) > 0 and consumable_type = 3 and is_sale = 0 and id > 2739716").Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
- }).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
- return
- }
-
- func GetNewDrugFlowInforTen(system_time int64, org_id int64) (flows []*models.DrugFlow, err error) {
- err = readDb.Model(&models.DrugFlow{}).Joins("join his_doctor_advice_info info on info.patient_id = xt_drug_flow.patient_id and info.drug_id = xt_drug_flow.drug_id and info.record_date = xt_drug_flow.system_time").Where("xt_drug_flow.user_org_id = ? and xt_drug_flow.status = 1 and xt_drug_flow.consumable_type = 3 and xt_drug_flow.is_sale = 0 and xt_drug_flow.system_time = ?", org_id, system_time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 and drug_code <> ''").Preload("BaseDrugLib", "status=1")
- }).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
- return
- }
-
- func GetNewDrugFlowInforTenone(start_system_time int64, end_system_time int64, org_id int64) (flows []*models.DrugFlow, err error) {
- err = readDb.Model(&models.DrugFlow{}).Joins("join his_doctor_advice_info info on info.patient_id = xt_drug_flow.patient_id and info.drug_id = xt_drug_flow.drug_id and info.record_date = xt_drug_flow.system_time").Where("xt_drug_flow.user_org_id = ? and xt_drug_flow.status = 1 and xt_drug_flow.consumable_type = 3 and xt_drug_flow.is_sale = 0 and xt_drug_flow.system_time >= ? and xt_drug_flow.system_time <= ?", org_id, start_system_time, end_system_time).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 and drug_code <> ''").Preload("BaseDrugLib", "status=1")
- }).Preload("NewDrugWarehouseInfo", "status = 1").Find(&flows).Error
- return
- }
-
- func GetHisPrescriptionByID(id int64) (pre models.HisPrescription) {
- err = readDb.Model(&models.HisPrescription{}).Where("id = ? and status = 1", id).Find(&pre).Error
- return
- }
-
- func GetHisOrderByNumber(number string) (order models.HisOrder) {
- err = readDb.Model(&models.HisOrder{}).Where("number = ? and status = 1", number).First(&order).Error
- return
- }
-
- func SaveDF(df *models.DrugFlow) (err error) {
- //err = writeDb.(&df).Error
- err = XTWriteDB().Model(&models.DrugFlow{}).Where("id = ? ", df.ID).Updates(map[string]interface{}{
- "is_sale": df.IsSale,
- "sale_date": df.SaleDate,
- "bchno": df.Bchno,
- //"is_change"
- }).Error
- return
- }
-
- func SaveDF2(df *models.DrugFlow) (err error) {
- //err = writeDb.(&df).Error
- err = XTWriteDB().Model(&models.DrugFlow{}).Where("id = ? ", df.ID).Updates(map[string]interface{}{
- "is_change": df.IsChange,
- "bg_bchno": df.BgBchno,
- //"is_change"
- }).Error
- return
- }
- func GetDrugByID(drug_id int64) (drug models.BaseDrugLib, err error) {
- err = readDb.Model(&models.BaseDrugLib{}).Where("id = ?", drug_id).First(&drug).Error
- return
- }
-
- func GetBbx01ByTeamID(team_id int64) (team models.XtHisProjectTeam) {
- err = readDb.Model(&models.XtHisProjectTeam{}).Where("id = ?", team_id).First(&team).Error
- return
- }
- func GetHisOrderDetailByNumber(order_number string, org_id int64) (order []*HisOrderInfo, err error) {
- err = readDb.Model(&HisOrderInfo{}).Where("order_number = ? AND status = 1", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("VMHisProject", "status = 1 AND user_org_id = ?", org_id).Preload("VMGoodInfo", "status = 1 AND org_id = ?", org_id)
- }).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status = 1 AND org_id = ?", org_id)
- }).Find(&order).Error
- return
- }
-
- type HisOrderInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
- UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
- AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
- DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
- Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
- Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
- ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
- ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
- SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
- ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
- FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
- HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
- HisDoctorAdviceInfo HisDoctorAdviceInfo `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
- }
-
- func (HisOrderInfo) TableName() string {
- return "his_order_info"
- }
-
- type HisDoctorAdviceInfo struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
- AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
- AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
- AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
- SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
- SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
- PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
- PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
- DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
- PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
-
- Price float64 `gorm:"column:price" json:"price" form:"price"`
- DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
- Drug Drug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
-
- IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
- ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
- IsSelfDrug int64 `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
- IsUpload int64 `gorm:"column:is_upload" json:"is_upload" form:"is_upload"`
- }
-
- type Drug struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
- Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
- Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
- DrugAlias string `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
- DrugAliasPinyin string `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
- DrugAliasWubi string `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
- DrugCategory int64 `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
- DrugSpec string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
- DrugType int64 `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
- DrugStockLimit string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
- DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
- DrugDosageForm int64 `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
- MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
- MaxUnit string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
- MinNumber int64 `gorm:"column:min_number" json:"min_number" form:"min_number"`
- MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
- Dose string `gorm:"column:dose" json:"dose" form:"dose"`
- DoseUnit string `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
- UnitMatrixing string `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
- RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
- MinPrice float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
- LastPrice float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
- DrugControl int64 `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- DrugClassify string `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
- DrugDose float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
- DrugDoseUnit int64 `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
- MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
- ProvincesCode string `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
- Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
- PharmacologyCategory int64 `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
- StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
- Code string `gorm:"column:code" json:"code" form:"code"`
- IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
- IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
- Agent string `gorm:"column:agent" json:"agent" form:"agent"`
- DrugStatus string `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
- LimitRemark string `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
- SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
- PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
- Label int64 `gorm:"column:label" json:"label" form:"label"`
- Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
- IsUseDoctorAdvice int64 `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
- IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
- IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
- IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
- IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
- 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"`
- OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
- DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
- Dealer int64 `gorm:"column:dealer" json:"dealer" form:"dealer"`
- PrescriptionMark int64 `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- DrugRemark string `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
- SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
- DoseCode string `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
- IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
- HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
- LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
- Dosage string `gorm:"column:dosage" json:"dosage" form:"dosage"`
- Unval string `gorm:"column:unval" json:"unval" form:"unval"`
- PackingUnit string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
- PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
- DrugDay string `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
- Total float64 `gorm:"column:total" json:"total" form:"total"`
- PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
- IsUser int64 `gorm:"column:is_user" json:"is_user" form:"is_user"`
- Bck01b string `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
- Bby01 string `gorm:"column:bby01" json:"bby01" form:"bby01"`
- Bbx01 string `gorm:"column:bbx01" json:"bbx01" form:"bbx01"`
- }
-
- func (Drug) TableName() string {
- return "xt_base_drug"
- }
-
- type VMHisProject struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
- 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"`
- StatisticalClassification int64 `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
- UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
- Status int64 `gorm:"column:status" json:"status" form:"status"`
- SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
- ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
- DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
- NumberDays string `gorm:"column:number_days" json:"number_days" form:"number_days"`
- MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
- }
-
- func (VMHisProject) TableName() string {
- return "xt_his_project"
- }
-
- type VMGoodInfo struct {
- ID int64 `gorm:"column:id" json:"id"`
- SpecificationName string `gorm:"column:specification_name" json:"specification_name"`
- GoodTypeId int64 `gorm:"column:good_type_id" json:"good_type_id"`
- OrgId int64 `gorm:"column:org_id" json:"org_id"`
- GoodName string `gorm:"column:good_name" json:"good_name" form:"good_name"`
- GoodUnit int64 `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
- Total float64 `gorm:"column:total" json:"total" form:"total"`
- PackingUnit string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
- MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
- }
-
- func (VMGoodInfo) TableName() string {
- return "xt_good_information"
- }
-
- func (HisDoctorAdviceInfo) TableName() string {
- return "his_doctor_advice_info"
- }
-
- type VMHisPatient struct {
- ID int64 `gorm:"column:id" json:"id" form:"id"`
- BalanceAccountsType int64 `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
- MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
- Name string `gorm:"column:name" json:"name" form:"name"`
- Gender int64 `gorm:"column:gender" json:"gender" form:"gender"`
- IdType int64 `gorm:"column:id_type" json:"id_type" form:"id_type"`
- MedicalTreatmentType int64 `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
- Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
- RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
- Age float64 `gorm:"column:age" json:"age" form:"age"`
- PhoneNumber string `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
- IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
- RegisterType int64 `gorm:"column:register_type" json:"register_type" form:"register_type"`
- AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
- Departments int64 `gorm:"column:departments" json:"departments" form:"departments"`
- IsNeedCostOfProduction int64 `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
- RegisterCost float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
- TreatmentCost float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
- CostOfProduction float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
- Total float64 `gorm:"column:total" json:"total" form:"total"`
- 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"`
- Number string `gorm:"column:number" json:"number" form:"number"`
- Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
- IsReturn int64 `gorm:"column:is_return" json:"is_return" form:"is_return"`
- PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
- PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
- Certno string `gorm:"column:certno" json:"certno" form:"certno"`
- PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
- Gend string `gorm:"column:gend" json:"gend" form:"gend"`
- Naty string `gorm:"column:naty" json:"naty" form:"naty"`
- Brdy string `gorm:"column:brdy" json:"brdy" form:"brdy"`
- Iinfo string `gorm:"column:iinfo" json:"iinfo" form:"iinfo"`
- Idetinfo string `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
- IptOtpNo string `gorm:"column:ipt_otp_no" json:"ipt_otp_no" form:"ipt_otp_no"`
- PType string `gorm:"column:p_type" json:"p_type" form:"p_type"`
- Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
- SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
- PatientInfo string `gorm:"column:patient_info" json:"patient_info" form:"patient_info"`
- }
-
- func (VMHisPatient) TableName() string {
- return "his_patient"
- }
-
- type HisPrescriptionProject 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"`
- VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
- VMGoodInfo VMGoodInfo `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 `gorm:"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"`
- ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
- }
-
- func (HisPrescriptionProject) TableName() string {
- return "his_prescription_project"
- }
-
- func FindeHisAdviceDocAdvice(orgid int64, patient_id int64, stime int64, etime int64) (advice []*models.HisDoctorAdviceInfo, err error) {
-
- db := XTReadDB().Model(&advice).Where("status= 1 and drug_code <> ''")
-
- if orgid > 0 {
- db = db.Where("user_org_id = ?", orgid)
- }
- if patient_id > 0 {
- db = db.Where("patient_id = ?", patient_id)
- }
- if stime > 0 {
- db = db.Where("advice_date >=?", stime)
- }
- if etime > 0 {
- db = db.Where("advice_date<=?", etime)
- }
- err = db.Find(&advice).Error
-
- return advice, err
- }
-
- func FindUploadHisAdviceDocAdvice(orgid int64, patient_id int64, stime int64, etime int64) (advice []*models.HisDoctorAdviceInfo, err error) {
-
- db := XTReadDB().Model(&advice).Where("status= 1")
-
- if orgid > 0 {
- db = db.Where("user_org_id = ?", orgid)
- }
- if patient_id > 0 {
- db = db.Where("patient_id = ?", patient_id)
- }
- if stime > 0 {
- db = db.Where("advice_date >=?", stime)
- }
- if etime > 0 {
- db = db.Where("advice_date<=?", etime)
- }
- db = db.Where("is_upload = 1")
- err = db.Find(&advice).Error
- return advice, err
- }
-
- func SaveDoctoradviceStatus(id int64) {
- writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("id = ?", id).Updates(map[string]interface{}{"is_upload": 1})
-
- }
-
- func SaveDoctoradviceStatusTwo(id int64) {
- writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("id = ?", id).Updates(map[string]interface{}{"is_upload": 0})
-
- }
-
- func FindHisAdviceDocAdvice(id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
- db := XTReadDB().Model(&advice).Where("status= 1 and id = ?", id)
- err = db.Find(&advice).Error
- return advice, err
- }
|