app_version.go 83KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285
  1. package service
  2. import (
  3. "XT_New/models"
  4. "fmt"
  5. "github.com/jinzhu/gorm"
  6. "time"
  7. )
  8. func GetAppVersionByAppType(apptype int64) (*models.AppVersion, error) {
  9. var version models.AppVersion
  10. err := readDb.Model(&models.AppVersion{}).Where("app_type=?", apptype).First(&version).Error
  11. if err == gorm.ErrRecordNotFound {
  12. return nil, nil
  13. }
  14. if err != nil {
  15. return nil, err
  16. }
  17. return &version, nil
  18. }
  19. func GetAllAppOrg() ([]*models.OrgApp, error) {
  20. var app []*models.OrgApp
  21. err := readUserDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
  22. if err == gorm.ErrRecordNotFound {
  23. return nil, nil
  24. }
  25. if err != nil {
  26. return nil, err
  27. }
  28. return app, nil
  29. }
  30. func GetSystemApp() ([]*models.OrgApp, error) {
  31. var app []*models.OrgApp
  32. err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0 ").Find(&app).Error
  33. if err == gorm.ErrRecordNotFound {
  34. return nil, nil
  35. }
  36. if err != nil {
  37. return nil, err
  38. }
  39. return app, nil
  40. }
  41. func GetApp() ([]*models.OrgApp, error) {
  42. var app []*models.OrgApp
  43. err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0").Find(&app).Error
  44. if err == gorm.ErrRecordNotFound {
  45. return nil, nil
  46. }
  47. if err != nil {
  48. return nil, err
  49. }
  50. return app, nil
  51. }
  52. func GetAppByType(orgID int64, app_type int) (*models.OrgApp, error) {
  53. var apps models.OrgApp
  54. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  55. if err != nil {
  56. return nil, err
  57. }
  58. return &apps, nil
  59. }
  60. func CreateOrgApp(app *models.OrgApp) {
  61. writeUserDb.Create(&app)
  62. }
  63. func GetAllUserRole(org_id int64) (appRole []*models.App_Role) {
  64. if org_id == 0 {
  65. readUserDb.Model(&models.App_Role{}).Where("status = 1").Find(&appRole)
  66. } else {
  67. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? ", org_id).Find(&appRole)
  68. }
  69. return
  70. }
  71. func GetAllUserRoleByUserTypeOne(org_id int) (appRole []*models.App_Role) {
  72. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type = 1").Find(&appRole)
  73. return
  74. }
  75. func GetAllUserRoleByUserTypeOther() (appRole []*models.App_Role) {
  76. //app, _ := GetOrgApp(int64(org_id), 3)
  77. //if org_id == 0 {
  78. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type > 1").Find(&appRole)
  79. //
  80. //} else {
  81. // readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? AND user_type > 1 AND app_id = ? ", org_id, app.Id).Find(&appRole)
  82. //
  83. //}
  84. return
  85. }
  86. func FindRoleByUserTypeOne(org_id int64) (role models.Role) {
  87. readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 2 AND role_name = '医生'", org_id).First(&role)
  88. return
  89. }
  90. func FindRoleByUserTypeTwo(org_id int64) (role models.Role) {
  91. readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 3 AND role_name = '护士'", org_id).First(&role)
  92. return
  93. }
  94. func GetAllRole() ([]*models.Role, error) {
  95. var app []*models.Role
  96. err := readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
  97. if err == gorm.ErrRecordNotFound {
  98. return nil, nil
  99. }
  100. if err != nil {
  101. return nil, err
  102. }
  103. return app, nil
  104. }
  105. func UpdateRoleIds(id int64, ids string) {
  106. writeUserDb.Model(&models.App_Role{}).Where("status = 1 AND id = ?", id).Updates(map[string]interface{}{"role_ids": ids, "mtime": time.Now().Unix()})
  107. }
  108. func GetOrgAppA(orgID int64, app_type int) (*models.OrgApp, error) {
  109. var apps models.OrgApp
  110. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  111. if err != nil {
  112. return nil, err
  113. }
  114. return &apps, nil
  115. }
  116. func GetOrgByIdB(orgID int64) (*models.Org, error) {
  117. var org models.Org
  118. err := readUserDb.Model(&models.Org{}).Where("id = ?", orgID).First(&org).Error
  119. if err != nil {
  120. if err == gorm.ErrRecordNotFound {
  121. return nil, nil
  122. } else {
  123. return nil, err
  124. }
  125. }
  126. return &org, nil
  127. }
  128. func GetOrgAppB(orgID int64, app_type int) (*models.OrgApp, error) {
  129. var apps models.OrgApp
  130. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  131. if err != nil {
  132. return nil, err
  133. }
  134. return &apps, nil
  135. }
  136. func CreateOrgRoleB(role *models.Role) (err error) {
  137. err = writeUserDb.Create(&role).Error
  138. return
  139. }
  140. func CreateRolePurviewB(purview *models.RolePurview) (err error) {
  141. err = writeUserDb.Create(&purview).Error
  142. return
  143. }
  144. func CreateFuncRolePurviewB(purview *models.SgjUserRoleFuncPurview) (err error) {
  145. err = writeUserDb.Create(&purview).Error
  146. return
  147. }
  148. func GetSystemRole(orgID int64) ([]*models.Role, error) {
  149. var roles []*models.Role
  150. err := readUserDb.Where(" org_id = ? AND status = 1 AND is_system > 1", orgID).First(&roles).Error
  151. if err != nil {
  152. return nil, err
  153. }
  154. return roles, nil
  155. }
  156. func HandleData() {
  157. var pe []*models.PredialysisEvaluation
  158. //readDb.Model(&models.DialysisPrescription{}).Where("user_org_id = 12 AND record_date <= 1587571200").Find(&prescription)
  159. //for _, item := range prescription {
  160. // writeDb.Model(&models.AssessmentAfterDislysis{}).Where("user_org_id =12 AND assessment_date = ?", item.RecordDate).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "actual_ultrafiltration": item.Ultrafiltration})
  161. //}
  162. readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = 9538 AND dialysis_order_id > 0").Find(&pe)
  163. for _, item := range pe {
  164. var sch models.Schedule
  165. err := readDb.Model(&models.Schedule{}).Where("status = 1 AND schedule_date = ? AND patient_id = ? AND user_org_id = 9538", item.AssessmentDate, item.PatientId).First(&sch).Error
  166. if err == nil {
  167. if sch.ID > 0 {
  168. order := &models.DialysisOrder{
  169. DialysisDate: sch.ScheduleDate,
  170. UserOrgId: 9538,
  171. PatientId: sch.PatientId,
  172. Stage: 2,
  173. BedID: sch.BedId,
  174. StartNurse: 554,
  175. FinishNurse: 554,
  176. Status: 1,
  177. CreatedTime: sch.ScheduleDate,
  178. UpdatedTime: sch.ScheduleDate,
  179. StartTime: sch.ScheduleDate,
  180. EndTime: sch.ScheduleDate,
  181. PunctureNurse: 554,
  182. Creator: 554,
  183. Modifier: 554,
  184. FinishCreator: 554,
  185. FinishModifier: 554,
  186. SchedualType: sch.ScheduleType,
  187. }
  188. writeDb.Create(&order)
  189. }
  190. }
  191. }
  192. }
  193. func FindAllOrgByImportType() (org []*models.Org, err error) {
  194. err = readUserDb.Model(&models.Org{}).Where("status =1 AND import = 0").Find(&org).Error
  195. return
  196. }
  197. func FindAllPrescription(org_id int64) (prescription []*models.DialysisPrescription, err error) {
  198. err = readDb.Model(&models.DialysisPrescription{}).Where("user_org_id=? AND status= 1 AND record_date >= 1593446400", org_id).Find(&prescription).Error
  199. return
  200. }
  201. func AddSigleDialysisBeforePre(before *models.DialysisBeforePrepare) {
  202. writeDb.Create(&before)
  203. }
  204. func GetAllHisDoctorInfo(org_id int64) (his []*models.HisDoctorAdviceInfo, err error) {
  205. err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  206. return
  207. }
  208. func GetAllHisInfo(org_id int64) (his []*models.HisPrescriptionProject, err error) {
  209. err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  210. return
  211. }
  212. func UpDateHis(his *models.HisDoctorAdviceInfo) {
  213. writeDb.Save(&his)
  214. }
  215. func UpDateHis2(his *models.HisPrescriptionProject) {
  216. writeDb.Save(&his)
  217. }
  218. func GetAllHisOrder(org_id int64) (his []*models.HisOrder, err error) {
  219. 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).Find(&his).Error
  220. return
  221. }
  222. func GetAllHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
  223. 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
  224. return
  225. }
  226. func GetLastHisOrder() (his models.HisOrder, err error) {
  227. err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106 AND status = 1 AND order_status = 2").Last(&his).Error
  228. return
  229. }
  230. type HisPrescriptionAdviceTemplate struct {
  231. ID int64 `gorm:"column:id" json:"id" form:"id"`
  232. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  233. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  234. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  235. AdviceType int64 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
  236. AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
  237. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  238. AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
  239. AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
  240. ReminderDate int64 `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
  241. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  242. SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
  243. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  244. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  245. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  246. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  247. AdviceDoctor int64 `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
  248. Status int64 `gorm:"column:status" json:"status" form:"status"`
  249. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  250. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  251. AdviceAffirm string `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
  252. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  253. StopTime int64 `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
  254. StopReason string `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
  255. StopDoctor int64 `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
  256. StopState int64 `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
  257. ParentId int64 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
  258. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  259. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  260. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  261. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  262. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  263. DialysisOrderId int64 `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
  264. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  265. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  266. DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  267. DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
  268. Groupno int64 `gorm:"column:groupno" json:"groupno" form:"groupno"`
  269. RemindType int64 `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
  270. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  271. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  272. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  273. TemplateId string `gorm:"column:template_id" json:"template_id" form:"template_id"`
  274. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  275. DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
  276. Price float64 `gorm:"column:price" json:"price" form:"price"`
  277. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  278. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  279. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  280. Day int64 `gorm:"column:day" json:"day" form:"day"`
  281. Diagnosis int64 `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  282. HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
  283. LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  284. }
  285. func (HisPrescriptionAdviceTemplate) TableName() string {
  286. return "his_prescription_advice_template"
  287. }
  288. type HisPrescriptionInfoTemplateTwo struct {
  289. ID int64 `gorm:"column:id" json:"id" form:"id"`
  290. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  291. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  292. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  293. Status int64 `gorm:"column:status" json:"status" form:"status"`
  294. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  295. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  296. Type int64 `gorm:"column:type" json:"type" form:"type"`
  297. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  298. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  299. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  300. PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
  301. HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  302. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  303. }
  304. func (HisPrescriptionInfoTemplateTwo) TableName() string {
  305. return "his_prescription_info_template"
  306. }
  307. func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
  308. err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
  309. Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
  310. return db.Where("status = 1")
  311. }).
  312. Where("status = 1 ").
  313. Find(&prescription).Error
  314. return
  315. }
  316. func SaveAdviceTemplate(advice HisPrescriptionAdviceTemplate) {
  317. writeDb.Save(&advice)
  318. }
  319. func GetAllPT(org_id int64) (his []*models.HisPrescriptionTemplate, err error) {
  320. err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  321. return
  322. }
  323. type HisPrescriptionProjectTemplate struct {
  324. ID int64 `gorm:"column:id" json:"id" form:"id"`
  325. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  326. Price float64 `gorm:"column:price" json:"price" form:"price"`
  327. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  328. Status int64 `gorm:"column:status" json:"status" form:"status"`
  329. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  330. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  331. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  332. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  333. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  334. Count string `gorm:"column:count" json:"count" form:"count"`
  335. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  336. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  337. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  338. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  339. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  340. Day string `gorm:"column:day" json:"day" form:"day"`
  341. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  342. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  343. Type int64 `gorm:"column:type" json:"type" form:"type"`
  344. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  345. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  346. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  347. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  348. }
  349. func (HisPrescriptionProjectTemplate) TableName() string {
  350. return "his_prescription_project_template"
  351. }
  352. type HisPrescriptionInfoTemplateTHree struct {
  353. ID int64 `gorm:"column:id" json:"id" form:"id"`
  354. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  355. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  356. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  357. Status int64 `gorm:"column:status" json:"status" form:"status"`
  358. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  359. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  360. Type int64 `gorm:"column:type" json:"type" form:"type"`
  361. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  362. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  363. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  364. PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
  365. HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  366. HisPrescriptionProjectTemplate []HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
  367. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  368. }
  369. func (HisPrescriptionInfoTemplateTHree) TableName() string {
  370. return "his_prescription_info_template"
  371. }
  372. func GetAllPTInfo(org_id int64, p_template_id int64) (his []*HisPrescriptionInfoTemplateTHree, err error) {
  373. err = readDb.Model(&HisPrescriptionInfoTemplateTHree{}).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
  374. return db.Where("status = 1")
  375. }).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
  376. return db.Where("status = 1")
  377. }).Where("user_org_id = ? AND status = 1 AND p_template_id = ?", org_id, p_template_id).Find(&his).Error
  378. return
  379. }
  380. func GetAllInfo(org_id int64, project_id int64) (his []*HisPrescriptionProjectTemplate, err error) {
  381. err = readDb.Model(&HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND status = 1 AND project_id = ? ", org_id, project_id).Find(&his).Error
  382. return
  383. }
  384. func UpdateStatus(project_id int64, p_id int64) {
  385. writeDb.Model(&HisPrescriptionProjectTemplate{}).Where("id = ?", project_id).Updates(map[string]interface{}{"status": 0})
  386. writeDb.Model(&HisPrescriptionInfoTemplateTwo{}).Where("id = ?", p_id).Updates(map[string]interface{}{"status": 0})
  387. }
  388. func SaveOrder(order *models.HisOrder) {
  389. writeDb.Save(&order)
  390. }
  391. func GetAllPrivateHis(org_id int64) (his []*models.HisPatient) {
  392. readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND balance_accounts_type = 2 AND status = 1", org_id).Find(&his)
  393. return
  394. }
  395. func SaveHis(his *models.HisPatient) {
  396. writeDb.Save(his)
  397. return
  398. }
  399. func GetAllProjectPrescription() (pre []*models.HisPrescription) {
  400. readDb.Model(&models.HisPrescription{}).Where("user_org_id = 10215 AND status = 1 AND type = 2 AND order_status = 1 AND record_date >= 1659283200").Find(&pre)
  401. return
  402. }
  403. func GetAllProject(id int64) (pre []*models.HisPrescriptionProject) {
  404. readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = 10215 AND status = 1 AND project_id = 1735 AND prescription_id = ?", id).Find(&pre)
  405. return
  406. }
  407. //func GetHisOrderDetailByNumberTwo(order_number string, org_id int64) (order []*HisOrderInfo, err error) {
  408. // readDb.Model(&models.Patients{})
  409. //
  410. // err = readDb.Model(&HisOrderInfo{}).Where("order_number = ? AND status = 1", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  411. // 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)
  412. // }).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  413. // 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)
  414. // }).Find(&order).Error
  415. // return
  416. //}
  417. type HisOrderTen struct {
  418. ID int64 `gorm:"column:id" json:"id" form:"id"`
  419. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  420. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  421. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  422. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  423. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  424. Status int64 `gorm:"column:status" json:"status" form:"status"`
  425. Number string `gorm:"column:number" json:"number" form:"number"`
  426. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  427. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  428. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  429. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  430. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  431. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  432. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  433. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  434. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  435. SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
  436. PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
  437. PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
  438. PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
  439. Certno string `gorm:"column:certno" json:"certno" form:"certno"`
  440. Gend string `gorm:"column:gend" json:"gend" form:"gend"`
  441. Naty string `gorm:"column:naty" json:"naty" form:"naty"`
  442. Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
  443. Age float64 `gorm:"column:age" json:"age" form:"age"`
  444. Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
  445. PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
  446. CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
  447. SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
  448. MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
  449. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  450. MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
  451. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  452. OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
  453. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  454. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  455. ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
  456. HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
  457. CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
  458. PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
  459. HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
  460. HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
  461. HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
  462. MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
  463. OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
  464. FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
  465. PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
  466. AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
  467. PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
  468. HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
  469. Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
  470. AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
  471. MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
  472. ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
  473. ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
  474. ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
  475. SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
  476. IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
  477. PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
  478. PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
  479. PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
  480. DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
  481. PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
  482. RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
  483. FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
  484. MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
  485. PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
  486. DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
  487. DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
  488. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  489. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  490. Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
  491. HisPrescriptionTen []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
  492. //VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"order_info"`
  493. VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"order_info"`
  494. OthDesc string `gorm:"oth_desc" json:"oth_desc" form:"oth_desc"`
  495. PayWays string `gorm:"pay_ways" json:"pay_ways" form:"pay_ways"`
  496. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  497. }
  498. func (HisOrderTen) TableName() string {
  499. return "his_order"
  500. }
  501. type HisPrescriptionInfoOne struct {
  502. ID int64 `gorm:"column:id" json:"id" form:"id"`
  503. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  504. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  505. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  506. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  507. Status int64 `gorm:"column:status" json:"status" form:"status"`
  508. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  509. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  510. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  511. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  512. Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  513. RegisterType int64 `gorm:"column:register_type" json:"register_type" form:"register_type"`
  514. Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
  515. Departments int64 `gorm:"column:departments" json:"departments" form:"departments"`
  516. SickHistory string `gorm:"column:sick_history" json:"sick_history" form:"sick_history"`
  517. PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
  518. PrescriptionStatus int64 `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
  519. BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
  520. DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
  521. SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
  522. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  523. }
  524. func (HisPrescriptionInfoOne) TableName() string {
  525. return "his_prescription_info"
  526. }
  527. type HisPrescriptionTen struct {
  528. ID int64 `gorm:"column:id" json:"id" form:"id"`
  529. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  530. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  531. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  532. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  533. Status int64 `gorm:"column:status" json:"status" form:"status"`
  534. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  535. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  536. Number string `gorm:"column:number" json:"number" form:"number"`
  537. Type int64 `gorm:"column:type" json:"type" form:"type"`
  538. Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
  539. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  540. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  541. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  542. PreTime int64 `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
  543. BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
  544. PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
  545. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  546. HisDoctorAdviceInfoTen []*HisDoctorAdviceInfoTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  547. HisPrescriptionProjectTen []*HisPrescriptionProjectTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
  548. HisPrescriptionInfoOne HisPrescriptionInfoOne `gorm:"ForeignKey:PrescriptionNumber;AssociationForeignKey:PrescriptionNumber" json:"p_info"`
  549. Total string `gorm:"-" json:"total" form:"total"`
  550. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  551. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  552. IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
  553. }
  554. func (HisPrescriptionTen) TableName() string {
  555. return "his_prescription"
  556. }
  557. func GetHisOrderDetailThree() (order []*HisOrderTen, err error) {
  558. err = readDb.Model(&HisOrderTen{}).Preload("VmHisOrderInfo9504", "status = 1").Preload("Patients", "status = 1").Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
  559. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  560. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  561. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  562. return db.Where("status = 1").Preload("Drug", "status = 1")
  563. })
  564. }).Where("settle_accounts_date >= 1675180800 AND settle_accounts_date <= 1677513600 AND status = 1 AND order_status =2 and p_type = 1 AND user_org_id = 10215").Find(&order).Order("patient_id").Error
  565. return
  566. }
  567. type VmHisOrderInfo9504Two struct {
  568. ID int64 `gorm:"column:id" json:"id" form:"id"`
  569. OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
  570. UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
  571. AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
  572. DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  573. Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
  574. Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
  575. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  576. PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  577. SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
  578. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  579. OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
  580. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  581. BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
  582. MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
  583. HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  584. Status int64 `gorm:"column:status" json:"status" form:"status"`
  585. Memo string `gorm:"column:memo" json:"memo" form:"memo"`
  586. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  587. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  588. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  589. DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
  590. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  591. ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
  592. ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
  593. LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  594. ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
  595. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  596. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  597. OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
  598. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  599. Type int64 `gorm:"column:type" json:"type" form:"type"`
  600. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  601. SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
  602. }
  603. func (VmHisOrderInfo9504Two) TableName() string {
  604. return "his_order_info"
  605. }
  606. type HisDoctorAdviceInfoTen struct {
  607. ID int64 `gorm:"column:id" json:"id" form:"id"`
  608. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  609. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  610. AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
  611. AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
  612. AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
  613. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  614. SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
  615. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  616. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  617. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  618. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  619. Status int64 `gorm:"column:status" json:"status" form:"status"`
  620. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  621. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  622. DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  623. DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
  624. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  625. VmHisOrderInfo9504Two VmHisOrderInfo9504Two `gorm:"ForeignKey:AdviceId;AssociationForeignKey:ID" json:"order_info"`
  626. Price float64 `gorm:"column:price" json:"price" form:"price"`
  627. DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
  628. Drug Drug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
  629. IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
  630. ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
  631. }
  632. func (HisDoctorAdviceInfoTen) TableName() string {
  633. return "his_doctor_advice_info"
  634. }
  635. type HisPrescriptionProjectTen struct {
  636. ID int64 `gorm:"column:id" json:"id" form:"id"`
  637. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  638. Price float64 `gorm:"column:price" json:"price" form:"price"`
  639. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  640. Status int64 `gorm:"column:status" json:"status" form:"status"`
  641. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  642. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  643. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  644. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  645. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  646. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  647. Count string `gorm:"column:count" json:"count" form:"count"`
  648. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  649. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  650. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  651. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  652. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  653. Day string `gorm:"column:day" json:"day" form:"day"`
  654. VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
  655. VMGoodInfo VMGoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
  656. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  657. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  658. Type int64 `gorm:"column:type" json:"type" form:"type"`
  659. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  660. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  661. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  662. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  663. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  664. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  665. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  666. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  667. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  668. VmHisOrderInfo9504Two VmHisOrderInfo9504Two `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
  669. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  670. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  671. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  672. ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
  673. }
  674. func (HisPrescriptionProjectTen) TableName() string {
  675. return "his_prescription_project"
  676. }
  677. func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
  678. err = XTReadDB().Model(&paitent).Where("user_org_id = ? and status = 1 AND in_hosptial_time >= '2023-02-01 00:00:00' AND in_hosptial_time <= '2023-02-28 23:59:59'", orgid).Find(&paitent).Error
  679. return paitent, err
  680. }
  681. func GetHisPatient2222(orgid int64) (paitent []*models.HisPatient, err error) {
  682. err = XTReadDB().Model(&models.HisPatient{}).Where("user_org_id = ? and status = 1 AND record_date >= 1654012800 AND record_date <= 1659196800 ", orgid).Find(&paitent).Error
  683. return paitent, err
  684. }
  685. func SaveHP(paitent *models.HisHospitalCheckRecord) {
  686. writeDb.Save(&paitent)
  687. }
  688. func SaveHPtWO(paitent *models.HisPatient) {
  689. writeDb.Save(&paitent)
  690. }
  691. type HisOrder9504 struct {
  692. ID int64 `gorm:"column:id" json:"id" form:"id"`
  693. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  694. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  695. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  696. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  697. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  698. Status int64 `gorm:"column:status" json:"status" form:"status"`
  699. Number string `gorm:"column:number" json:"number" form:"number"`
  700. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  701. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  702. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  703. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  704. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  705. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  706. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  707. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  708. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  709. SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
  710. PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
  711. PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
  712. PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
  713. Certno string `gorm:"column:certno" json:"certno" form:"certno"`
  714. Gend string `gorm:"column:gend" json:"gend" form:"gend"`
  715. Naty string `gorm:"column:naty" json:"naty" form:"naty"`
  716. Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
  717. Age float64 `gorm:"column:age" json:"age" form:"age"`
  718. Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
  719. PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
  720. CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
  721. SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
  722. MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
  723. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  724. MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
  725. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  726. OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
  727. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  728. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  729. ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
  730. HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
  731. CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
  732. PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
  733. HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
  734. HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
  735. HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
  736. MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
  737. OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
  738. FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
  739. PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
  740. AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
  741. PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
  742. HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
  743. Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
  744. AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
  745. MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
  746. ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
  747. ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
  748. ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
  749. SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
  750. IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
  751. PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
  752. PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
  753. PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
  754. DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
  755. PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
  756. RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
  757. FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
  758. MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
  759. PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
  760. DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
  761. DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
  762. SettleStartTime int64 `gorm:"settle_start_time" json:"settle_start_time" form:"settle_start_time"`
  763. OthDesc string `gorm:"oth_desc" json:"oth_desc" form:"oth_desc"`
  764. PayWays string `gorm:"pay_ways" json:"pay_ways" form:"pay_ways"`
  765. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  766. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  767. Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
  768. VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
  769. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  770. }
  771. func (HisOrder9504) TableName() string {
  772. return "his_order"
  773. }
  774. type VmHisOrderInfo9504 struct {
  775. ID int64 `gorm:"column:id" json:"id" form:"id"`
  776. OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
  777. UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
  778. AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
  779. DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  780. Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
  781. Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
  782. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  783. PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  784. SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
  785. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  786. OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
  787. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  788. BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
  789. MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
  790. HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  791. Status int64 `gorm:"column:status" json:"status" form:"status"`
  792. Memo string `gorm:"column:memo" json:"memo" form:"memo"`
  793. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  794. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  795. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  796. DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
  797. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  798. ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
  799. ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
  800. LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  801. ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
  802. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  803. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  804. OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
  805. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  806. Type int64 `gorm:"column:type" json:"type" form:"type"`
  807. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  808. SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
  809. HisPrescriptionProjectTen HisPrescriptionProjectTen `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
  810. HisDoctorAdviceInfoTen HisDoctorAdviceInfoTen `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advices"`
  811. }
  812. func (VmHisOrderInfo9504) TableName() string {
  813. return "his_order_info"
  814. }
  815. type VmHisOrderInfo95042 struct {
  816. ID int64 `gorm:"column:id" json:"id" form:"id"`
  817. OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
  818. UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
  819. AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
  820. DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  821. Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
  822. Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
  823. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  824. PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  825. SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
  826. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  827. OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
  828. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  829. BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
  830. MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
  831. HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  832. Status int64 `gorm:"column:status" json:"status" form:"status"`
  833. Memo string `gorm:"column:memo" json:"memo" form:"memo"`
  834. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  835. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  836. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  837. DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
  838. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  839. ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
  840. ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
  841. LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  842. ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
  843. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  844. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  845. OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
  846. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  847. Type int64 `gorm:"column:type" json:"type" form:"type"`
  848. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  849. SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
  850. }
  851. func (VmHisOrderInfo95042) TableName() string {
  852. return "his_order_info"
  853. }
  854. func GetHisOrderDetail9504() (order []*HisOrder9504, err error) {
  855. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  856. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  857. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  858. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  859. return db.Where("status = 1").Preload("Drug", "status = 1")
  860. })
  861. }).Where("settle_accounts_date >= 1640966400 AND settle_accounts_date <= 1661875200 AND status = 1 AND order_status =2 AND user_org_id = 9504").Find(&order).Order("setl_time").Error
  862. return
  863. }
  864. func GetHisOrderDetail10188() (order []*HisOrder9504, err error) {
  865. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  866. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  867. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  868. })
  869. }).Where("settle_accounts_date >= 1654012800 AND settle_accounts_date <= 1661875200 AND status = 1 AND order_status =2 AND user_org_id = 10188").Find(&order).Order("setl_time").Error
  870. return
  871. }
  872. //func GetHisOrderDetail10138() (order []*HisOrder9504, err error) {
  873. // err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  874. // return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  875. // return db.Where("status = 1").Preload("VMHisProject", "status = 1")
  876. // })
  877. // }).Where("settle_accounts_date >= 1640966400 AND settle_accounts_date <= 1648656000 AND status = 1 AND order_status =2 AND user_org_id = 10138").Find(&order).Order("setl_time").Error
  878. // return
  879. //}
  880. func GetHisOrderDetail10138() (order []*HisOrderTen, err error) {
  881. err = readDb.Model(&HisOrderTen{}).Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
  882. return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  883. return db.Where("status = 1").Preload("VMHisProject")
  884. })
  885. }).Where("settle_accounts_date >= 1672502400 AND settle_accounts_date <= 1676822400 AND status = 1 AND order_status =2 AND user_org_id = 10278").Find(&order).Error
  886. return
  887. }
  888. func GetHisOrderDetail10265() (order_infos []*VmHisOrderInfo9504, err error) {
  889. err = readDb.Model(&VmHisOrderInfo9504{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  890. return db.Preload("VMHisProject").Preload("VMGoodInfo", "status = 1")
  891. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  892. return db.Where("status = 1").Preload("Drug", "status = 1")
  893. }).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2022090814370516482'").Find(&order_infos).Error
  894. return
  895. }
  896. func GetHisOrder10265() (order_infos []*VmHisOrderInfo9504, err error) {
  897. err = readDb.Model(&VmHisOrderInfo95042{}).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2022092912130116192' AND project_id > 0").Find(&order_infos).Error
  898. return
  899. }
  900. func SaveOrderInfo(info *VmHisOrderInfo9504) {
  901. writeDb.Save(&info)
  902. }
  903. func GetHisOrderDetail10106(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
  904. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  905. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  906. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  907. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  908. return db.Where("status = 1").Preload("Drug")
  909. })
  910. }).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2 AND user_org_id = 10106", start_time, end_time).Find(&order).Order("setl_time").Error
  911. return
  912. }
  913. func GetHisOrderDetail10318(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
  914. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  915. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  916. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  917. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  918. return db.Where("status = 1").Preload("Drug")
  919. })
  920. }).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2 AND user_org_id = 10318", start_time, end_time).Find(&order).Order("setl_time").Error
  921. return
  922. }
  923. func GetLongSolution() {
  924. records, _ := GetAllSchedules()
  925. fmt.Println(records)
  926. for _, item := range records {
  927. var DialysisMachineName string
  928. //1.透析器 2.灌流器 3.透析器/灌流器
  929. so, _ := GetDialysisSolutionTwo(item.UserOrgId, item.PatientId, item.ModeId)
  930. filedRecordOne, _ := FindFiledBy(item.UserOrgId, "透析器")
  931. filedRecordTwo, _ := FindFiledBy(item.UserOrgId, "灌流器")
  932. filedRecordThree, _ := FindFiledBy(item.UserOrgId, "透析器/灌流器")
  933. if filedRecordOne.IsShow == 1 {
  934. DialysisMachineName = so.DialysisDialyszers
  935. }
  936. if filedRecordThree.IsShow == 1 {
  937. if len(DialysisMachineName) > 0 {
  938. DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
  939. } else {
  940. DialysisMachineName = so.DialyzerPerfusionApparatus
  941. }
  942. }
  943. if filedRecordTwo.IsShow == 1 {
  944. if len(DialysisMachineName) > 0 {
  945. DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
  946. } else {
  947. DialysisMachineName = so.DialysisIrrigation
  948. }
  949. }
  950. item.DialysisMachineName = DialysisMachineName
  951. UpdateSch(item)
  952. }
  953. }
  954. func GetAllSchMode() (modes []*models.PatientScheduleTemplateMode, getModesErr error) {
  955. getModesErr = readDb.Model(&models.PatientScheduleTemplateMode{}).Where("mode <> 0 AND status = 1 ").Find(&modes).Error
  956. return
  957. }
  958. type DialysisSolutionTwo struct {
  959. ID int64 `gorm:"column:id" json:"id" form:"id"`
  960. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  961. }
  962. func (DialysisSolutionTwo) TableName() string {
  963. return "xt_dialysis_solution"
  964. }
  965. type Schedule struct {
  966. ID int64 `gorm:"column:id" json:"id" form:"id"`
  967. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  968. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  969. Status int64 `gorm:"column:status" json:"status" form:"status"`
  970. ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
  971. ModeId int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
  972. DialysisMachineName string `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
  973. }
  974. func (Schedule) TableName() string {
  975. return "xt_schedule"
  976. }
  977. func GetAllSchedules() ([]Schedule, error) {
  978. var record []Schedule
  979. err := readDb.Model(&Schedule{}).Where("user_org_id = 10290 AND status = 1 AND schedule_date > 1672934400").Find(&record).Error
  980. if err != nil {
  981. if err == gorm.ErrRecordNotFound {
  982. return nil, nil
  983. } else {
  984. return nil, err
  985. }
  986. }
  987. return record, nil
  988. }
  989. func FindFiledBy(org_id int64, name string) (filedConfig models.FiledConfig, err error) {
  990. err = readDb.Model(&models.FiledConfig{}).Where("org_id =? AND module = 1 AND filed_name_cn= ?", org_id, name).First(&filedConfig).Error
  991. return
  992. }
  993. // 透析方案
  994. func GetDialysisSolutionTwo(orgID int64, patientID int64, mode_id int64) (models.DialysisSolution, error) {
  995. var record models.DialysisSolution
  996. err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
  997. return record, err
  998. }
  999. func UpdateSch(sch Schedule) (err error) {
  1000. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"dialysis_machine_name": sch.DialysisMachineName}).Error
  1001. return
  1002. }
  1003. func SaveSch(sch models.Schedule) (err error) {
  1004. err = writeDb.Save(&sch).Error
  1005. return
  1006. }
  1007. func SaveSchTwo(sch models.Schedule, sch_two models.Schedule) (err error) {
  1008. utx := writeDb.Begin()
  1009. if err = utx.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"status": 0}).Error; err != nil {
  1010. utx.Rollback()
  1011. return err
  1012. }
  1013. if err = utx.Model(&Schedule{}).Where("status=1 AND id = ?", sch_two.ID).Updates(map[string]interface{}{"status": 0}).Error; err != nil {
  1014. utx.Rollback()
  1015. return err
  1016. }
  1017. utx.Commit()
  1018. return err
  1019. }
  1020. func GetHisOrderInfoDetail() (order []*VmHisOrderInfo9504, err error) {
  1021. err = readDb.Model(&VmHisOrderInfo9504{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  1022. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  1023. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  1024. return db.Where("status = 1").Preload("Drug")
  1025. }).Where("status = 1 AND order_number = '202302201702258124538'").Find(&order).Error
  1026. return
  1027. }
  1028. func GetHisPrescriptionInfoDetail() (order []*HisPrescriptionProjectTen, err error) {
  1029. err = readDb.Model(&HisPrescriptionProjectTen{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  1030. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  1031. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  1032. return db.Where("status = 1").Preload("Drug")
  1033. }).Where("status = 1 AND order_number = '202302201702258124538'").Find(&order).Error
  1034. return
  1035. }
  1036. type HisOrder10138 struct {
  1037. ID int64 `gorm:"column:id" json:"id" form:"id"`
  1038. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  1039. Status int64 `gorm:"column:status" json:"status" form:"status"`
  1040. Number string `gorm:"column:number" json:"number" form:"number"`
  1041. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  1042. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  1043. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  1044. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  1045. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  1046. VmHisOrderInfo9504 []*VmHisOrderInfo9504 `json:"infos" form:"infos"`
  1047. }
  1048. func (HisOrder10138) TableName() string {
  1049. return "his_order"
  1050. }
  1051. type PatientVM10138 struct {
  1052. ID int64 `gorm:"column:id" json:"id" form:"id"`
  1053. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  1054. Name string `gorm:"column:name" json:"name" form:"name"`
  1055. HisOrder10138 []*HisOrder10138 `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"order"`
  1056. }
  1057. func (PatientVM10138) TableName() string {
  1058. return "xt_patients"
  1059. }
  1060. func GetHisAllPatientOrder(start_time int64, end_time int64) (order []*PatientVM10138, err error) {
  1061. err = readDb.Model(&PatientVM10138{}).Preload("HisOrder10138", " ctime >= ? AND ctime <= ? AND status = 1 AND order_status = 2", start_time, end_time).Where("user_org_id = 10138 AND status = 1").Find(&order).Error
  1062. return
  1063. }
  1064. func GetHisOrderInfoDetail10138(order_number string) (order []*VmHisOrderInfo9504, err error) {
  1065. err = readDb.Model(&VmHisOrderInfo9504{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  1066. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  1067. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  1068. return db.Where("status = 1").Preload("Drug")
  1069. }).Where("status = 1 AND order_number = ?", order_number).Find(&order).Error
  1070. return
  1071. }
  1072. //func GetHisOrderDetailOne(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
  1073. // err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  1074. // return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  1075. // return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  1076. // }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  1077. // return db.Where("status = 1").Preload("Drug")
  1078. // })
  1079. // }).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2 AND user_org_id = 9919", start_time, end_time).Find(&order).Order("setl_time").Error
  1080. // return
  1081. //}
  1082. //
  1083. type HisOrderTenOne struct {
  1084. ID int64 `gorm:"column:id" json:"id" form:"id"`
  1085. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  1086. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  1087. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  1088. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  1089. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  1090. Status int64 `gorm:"column:status" json:"status" form:"status"`
  1091. Number string `gorm:"column:number" json:"number" form:"number"`
  1092. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  1093. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  1094. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  1095. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  1096. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  1097. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  1098. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  1099. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  1100. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  1101. SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
  1102. PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
  1103. PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
  1104. PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
  1105. Certno string `gorm:"column:certno" json:"certno" form:"certno"`
  1106. Gend string `gorm:"column:gend" json:"gend" form:"gend"`
  1107. Naty string `gorm:"column:naty" json:"naty" form:"naty"`
  1108. Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
  1109. Age float64 `gorm:"column:age" json:"age" form:"age"`
  1110. Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
  1111. PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
  1112. CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
  1113. SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
  1114. MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
  1115. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  1116. MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
  1117. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  1118. OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
  1119. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  1120. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  1121. ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
  1122. HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
  1123. CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
  1124. PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
  1125. HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
  1126. HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
  1127. HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
  1128. MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
  1129. OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
  1130. FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
  1131. PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
  1132. AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
  1133. PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
  1134. HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
  1135. Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
  1136. AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
  1137. MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
  1138. ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
  1139. ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
  1140. ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
  1141. SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
  1142. IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
  1143. PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
  1144. PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
  1145. PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
  1146. DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
  1147. PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
  1148. RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
  1149. FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
  1150. MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
  1151. PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
  1152. DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
  1153. DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
  1154. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  1155. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  1156. Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
  1157. HisPrescriptionTen []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
  1158. OthDesc string `gorm:"oth_desc" json:"oth_desc" form:"oth_desc"`
  1159. PayWays string `gorm:"pay_ways" json:"pay_ways" form:"pay_ways"`
  1160. }
  1161. func (HisOrderTenOne) TableName() string {
  1162. return "his_order"
  1163. }
  1164. func GetHisOrderDetailOne(start_time int64, end_time int64) (order []*HisOrderTen, err error) {
  1165. err = readDb.Model(&HisOrderTen{}).Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
  1166. return db.Where("status = 1").Preload("HisPrescriptionInfoOne", "status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  1167. return db.Where("status = 1").Preload("VmHisOrderInfo9504Two", "status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  1168. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  1169. return db.Where("status = 1").Preload("VmHisOrderInfo9504Two", "status = 1").Preload("Drug", "status = 1")
  1170. })
  1171. }).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2 AND user_org_id = 9919 AND setl_id <> ''", start_time, end_time).Find(&order).Error
  1172. return
  1173. }