app_version.go 63KB

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