app_version.go 63KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  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. //VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
  492. HisPrescriptionTen []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
  493. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  494. }
  495. func (HisOrderTen) TableName() string {
  496. return "his_order"
  497. }
  498. type HisPrescriptionTen struct {
  499. ID int64 `gorm:"column:id" json:"id" form:"id"`
  500. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  501. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  502. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  503. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  504. Status int64 `gorm:"column:status" json:"status" form:"status"`
  505. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  506. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  507. Number string `gorm:"column:number" json:"number" form:"number"`
  508. Type int64 `gorm:"column:type" json:"type" form:"type"`
  509. Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
  510. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  511. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  512. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  513. PreTime int64 `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
  514. BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
  515. PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
  516. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  517. HisDoctorAdviceInfoTen []*HisDoctorAdviceInfoTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  518. HisPrescriptionProjectTen []*HisPrescriptionProjectTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
  519. Total string `gorm:"-" json:"total" form:"total"`
  520. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  521. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  522. IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
  523. }
  524. func (HisPrescriptionTen) TableName() string {
  525. return "his_prescription"
  526. }
  527. func GetHisOrderDetailThree() (order []*HisOrderTen, err error) {
  528. err = readDb.Model(&HisOrderTen{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  529. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  530. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  531. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  532. return db.Where("status = 1").Preload("Drug", "status = 1")
  533. })
  534. }).Where("setl_time >= '2023-07-01 00:00:00' AND setl_time <= '2023-07-31 23:59:59' AND status = 1 AND order_status =2 AND user_org_id = 10215").Find(&order).Order("patient_id").Error
  535. return
  536. }
  537. type HisDoctorAdviceInfoTen struct {
  538. ID int64 `gorm:"column:id" json:"id" form:"id"`
  539. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  540. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  541. AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
  542. AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
  543. AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
  544. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  545. SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
  546. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  547. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  548. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  549. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  550. Status int64 `gorm:"column:status" json:"status" form:"status"`
  551. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  552. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  553. DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  554. DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
  555. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  556. Price float64 `gorm:"column:price" json:"price" form:"price"`
  557. DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
  558. Drug Drug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
  559. IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
  560. ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
  561. }
  562. func (HisDoctorAdviceInfoTen) TableName() string {
  563. return "his_doctor_advice_info"
  564. }
  565. type HisPrescriptionProjectTen struct {
  566. ID int64 `gorm:"column:id" json:"id" form:"id"`
  567. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  568. Price float64 `gorm:"column:price" json:"price" form:"price"`
  569. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  570. Status int64 `gorm:"column:status" json:"status" form:"status"`
  571. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  572. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  573. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  574. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  575. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  576. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  577. Count string `gorm:"column:count" json:"count" form:"count"`
  578. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  579. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  580. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  581. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  582. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  583. Day string `gorm:"column:day" json:"day" form:"day"`
  584. VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
  585. VMGoodInfo VMGoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
  586. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  587. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  588. Type int64 `gorm:"column:type" json:"type" form:"type"`
  589. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  590. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  591. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  592. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  593. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  594. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  595. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  596. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  597. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  598. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  599. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  600. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  601. ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
  602. }
  603. func (HisPrescriptionProjectTen) TableName() string {
  604. return "his_prescription_project"
  605. }
  606. func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
  607. err = XTReadDB().Model(&paitent).Where("user_org_id = ? and status = 1 AND in_hosptial_time >= '2023-07-01 00:00:00' AND in_hosptial_time <= '2023-07-31 23:59:59'", orgid).Find(&paitent).Error
  608. return paitent, err
  609. }
  610. func SaveHP(paitent *models.HisHospitalCheckRecord) {
  611. writeDb.Save(&paitent)
  612. }
  613. type HisOrder9504 struct {
  614. ID int64 `gorm:"column:id" json:"id" form:"id"`
  615. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  616. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  617. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  618. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  619. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  620. Status int64 `gorm:"column:status" json:"status" form:"status"`
  621. Number string `gorm:"column:number" json:"number" form:"number"`
  622. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  623. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  624. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  625. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  626. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  627. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  628. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  629. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  630. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  631. SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
  632. PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
  633. PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
  634. PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
  635. Certno string `gorm:"column:certno" json:"certno" form:"certno"`
  636. Gend string `gorm:"column:gend" json:"gend" form:"gend"`
  637. Naty string `gorm:"column:naty" json:"naty" form:"naty"`
  638. Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
  639. Age float64 `gorm:"column:age" json:"age" form:"age"`
  640. Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
  641. PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
  642. CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
  643. SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
  644. MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
  645. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  646. MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
  647. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  648. OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
  649. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  650. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  651. ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
  652. HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
  653. CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
  654. PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
  655. HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
  656. HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
  657. HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
  658. MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
  659. OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
  660. FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
  661. PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
  662. AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
  663. PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
  664. HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
  665. Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
  666. AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
  667. MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
  668. ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
  669. ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
  670. ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
  671. SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
  672. IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
  673. PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
  674. PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
  675. PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
  676. DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
  677. PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
  678. RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
  679. FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
  680. MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
  681. PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
  682. DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
  683. DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
  684. SettleStartTime int64 `gorm:"settle_start_time" json:"settle_start_time" form:"settle_start_time"`
  685. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  686. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  687. Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
  688. VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
  689. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  690. }
  691. func (HisOrder9504) TableName() string {
  692. return "his_order"
  693. }
  694. type VmHisOrderInfo9504 struct {
  695. ID int64 `gorm:"column:id" json:"id" form:"id"`
  696. OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
  697. UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
  698. AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
  699. DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  700. Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
  701. Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
  702. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  703. PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  704. SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
  705. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  706. OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
  707. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  708. BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
  709. MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
  710. HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  711. Status int64 `gorm:"column:status" json:"status" form:"status"`
  712. Memo string `gorm:"column:memo" json:"memo" form:"memo"`
  713. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  714. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  715. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  716. DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
  717. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  718. ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
  719. ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
  720. LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  721. ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
  722. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  723. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  724. OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
  725. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  726. Type int64 `gorm:"column:type" json:"type" form:"type"`
  727. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  728. SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
  729. HisPrescriptionProjectTen HisPrescriptionProjectTen `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
  730. HisDoctorAdviceInfoTen HisDoctorAdviceInfoTen `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advices"`
  731. }
  732. func (VmHisOrderInfo9504) TableName() string {
  733. return "his_order_info"
  734. }
  735. type VmHisOrderInfo95042 struct {
  736. ID int64 `gorm:"column:id" json:"id" form:"id"`
  737. OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
  738. UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
  739. AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
  740. DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  741. Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
  742. Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
  743. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  744. PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  745. SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
  746. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  747. OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
  748. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  749. BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
  750. MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
  751. HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  752. Status int64 `gorm:"column:status" json:"status" form:"status"`
  753. Memo string `gorm:"column:memo" json:"memo" form:"memo"`
  754. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  755. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  756. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  757. DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
  758. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  759. ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
  760. ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
  761. LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  762. ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
  763. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  764. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  765. OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
  766. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  767. Type int64 `gorm:"column:type" json:"type" form:"type"`
  768. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  769. SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
  770. }
  771. func (VmHisOrderInfo95042) TableName() string {
  772. return "his_order_info"
  773. }
  774. func GetHisOrderDetail9504() (order []*HisOrder9504, err error) {
  775. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  776. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  777. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  778. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  779. return db.Where("status = 1").Preload("Drug", "status = 1")
  780. })
  781. }).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
  782. return
  783. }
  784. func GetHisOrderDetail10188() (order []*HisOrder9504, err error) {
  785. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  786. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  787. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  788. })
  789. }).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
  790. return
  791. }
  792. //func GetHisOrderDetail10138() (order []*HisOrder9504, err error) {
  793. // err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  794. // return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  795. // return db.Where("status = 1").Preload("VMHisProject", "status = 1")
  796. // })
  797. // }).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
  798. // return
  799. //}
  800. func GetHisOrderDetail10138() (order []*HisOrderTen, err error) {
  801. err = readDb.Model(&HisOrderTen{}).Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
  802. return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  803. return db.Where("status = 1").Preload("VMHisProject")
  804. })
  805. }).Where("setl_time >= '2022-04-01 00:00:00' AND setl_time <= '2022-06-30 23:00:00' AND status = 1 AND order_status =2 AND user_org_id = 10278").Find(&order).Error
  806. return
  807. }
  808. func GetHisOrderDetail10265() (order_infos []*VmHisOrderInfo9504, err error) {
  809. err = readDb.Model(&VmHisOrderInfo9504{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  810. return db.Preload("VMHisProject").Preload("VMGoodInfo", "status = 1")
  811. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  812. return db.Where("status = 1").Preload("Drug", "status = 1")
  813. }).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2022090814370516482'").Find(&order_infos).Error
  814. return
  815. }
  816. func GetHisOrder10265() (order_infos []*VmHisOrderInfo9504, err error) {
  817. err = readDb.Model(&VmHisOrderInfo95042{}).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2023031016334716192' AND project_id > 0").Find(&order_infos).Error
  818. return
  819. }
  820. func GetHisOrder10265two() (order_infos []*VmHisOrderInfo9504, err error) {
  821. err = readDb.Model(&VmHisOrderInfo95042{}).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2023031016334716192'").Find(&order_infos).Error
  822. return
  823. }
  824. func SaveOrderInfo(info *VmHisOrderInfo9504) {
  825. writeDb.Save(&info)
  826. }
  827. func GetHisOrderDetail10106(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
  828. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  829. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  830. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  831. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  832. return db.Where("status = 1").Preload("Drug")
  833. })
  834. }).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
  835. return
  836. }
  837. func GetHisOrderDetail10318(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
  838. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  839. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  840. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  841. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  842. return db.Where("status = 1").Preload("Drug")
  843. })
  844. }).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
  845. return
  846. }
  847. func GetLongSolution() {
  848. records, _ := GetAllSchedules()
  849. fmt.Println(records)
  850. for _, item := range records {
  851. var DialysisMachineName string
  852. //1.透析器 2.灌流器 3.透析器/灌流器
  853. so, _ := GetDialysisSolutionTwo(item.UserOrgId, item.PatientId, item.ModeId)
  854. filedRecordOne, _ := FindFiledBy(item.UserOrgId, "透析器")
  855. filedRecordTwo, _ := FindFiledBy(item.UserOrgId, "灌流器")
  856. filedRecordThree, _ := FindFiledBy(item.UserOrgId, "透析器/灌流器")
  857. if filedRecordOne.IsShow == 1 {
  858. DialysisMachineName = so.DialysisDialyszers
  859. }
  860. if filedRecordThree.IsShow == 1 {
  861. if len(DialysisMachineName) > 0 {
  862. DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
  863. } else {
  864. DialysisMachineName = so.DialyzerPerfusionApparatus
  865. }
  866. }
  867. if filedRecordTwo.IsShow == 1 {
  868. if len(DialysisMachineName) > 0 {
  869. DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
  870. } else {
  871. DialysisMachineName = so.DialysisIrrigation
  872. }
  873. }
  874. item.DialysisMachineName = DialysisMachineName
  875. UpdateSch(item)
  876. }
  877. }
  878. func GetAllSchMode() (modes []*models.PatientScheduleTemplateMode, getModesErr error) {
  879. getModesErr = readDb.Model(&models.PatientScheduleTemplateMode{}).Where("mode <> 0 AND status = 1 ").Find(&modes).Error
  880. return
  881. }
  882. type DialysisSolutionTwo struct {
  883. ID int64 `gorm:"column:id" json:"id" form:"id"`
  884. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  885. }
  886. func (DialysisSolutionTwo) TableName() string {
  887. return "xt_dialysis_solution"
  888. }
  889. type Schedule struct {
  890. ID int64 `gorm:"column:id" json:"id" form:"id"`
  891. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  892. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  893. Status int64 `gorm:"column:status" json:"status" form:"status"`
  894. ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
  895. ModeId int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
  896. DialysisMachineName string `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
  897. }
  898. func (Schedule) TableName() string {
  899. return "xt_schedule"
  900. }
  901. func GetAllSchedules() ([]Schedule, error) {
  902. var record []Schedule
  903. err := readDb.Model(&Schedule{}).Where("user_org_id = 10290 AND status = 1 AND schedule_date > 1672934400").Find(&record).Error
  904. if err != nil {
  905. if err == gorm.ErrRecordNotFound {
  906. return nil, nil
  907. } else {
  908. return nil, err
  909. }
  910. }
  911. return record, nil
  912. }
  913. func FindFiledBy(org_id int64, name string) (filedConfig models.FiledConfig, err error) {
  914. err = readDb.Model(&models.FiledConfig{}).Where("org_id =? AND module = 1 AND filed_name_cn= ?", org_id, name).First(&filedConfig).Error
  915. return
  916. }
  917. // 透析方案
  918. func GetDialysisSolutionTwo(orgID int64, patientID int64, mode_id int64) (models.DialysisSolution, error) {
  919. var record models.DialysisSolution
  920. 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
  921. return record, err
  922. }
  923. func UpdateSch(sch Schedule) (err error) {
  924. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"dialysis_machine_name": sch.DialysisMachineName}).Error
  925. return
  926. }
  927. func SaveSch(sch *models.Schedule) (err error) {
  928. err = writeDb.Save(&sch).Error
  929. return
  930. }
  931. func SaveSchTwo(sch models.Schedule, sch_two models.Schedule) (err error) {
  932. //err = writeDb.Save(&sch).Error
  933. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"status": 0}).Error
  934. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch_two.ID).Updates(map[string]interface{}{"status": 0}).Error
  935. return
  936. }