app_version.go 98KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614
  1. package service
  2. import (
  3. "XT_New/models"
  4. "fmt"
  5. "github.com/jinzhu/gorm"
  6. "math"
  7. "strconv"
  8. "time"
  9. )
  10. func GetAppVersionByAppType(apptype int64) (*models.AppVersion, error) {
  11. var version models.AppVersion
  12. err := readDb.Model(&models.AppVersion{}).Where("app_type=?", apptype).First(&version).Error
  13. if err == gorm.ErrRecordNotFound {
  14. return nil, nil
  15. }
  16. if err != nil {
  17. return nil, err
  18. }
  19. return &version, nil
  20. }
  21. func GetAllAppOrg() ([]*models.OrgApp, error) {
  22. var app []*models.OrgApp
  23. err := readUserDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
  24. if err == gorm.ErrRecordNotFound {
  25. return nil, nil
  26. }
  27. if err != nil {
  28. return nil, err
  29. }
  30. return app, nil
  31. }
  32. func GetSystemApp() ([]*models.OrgApp, error) {
  33. var app []*models.OrgApp
  34. err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0 ").Find(&app).Error
  35. if err == gorm.ErrRecordNotFound {
  36. return nil, nil
  37. }
  38. if err != nil {
  39. return nil, err
  40. }
  41. return app, nil
  42. }
  43. func GetApp() ([]*models.OrgApp, error) {
  44. var app []*models.OrgApp
  45. err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0").Find(&app).Error
  46. if err == gorm.ErrRecordNotFound {
  47. return nil, nil
  48. }
  49. if err != nil {
  50. return nil, err
  51. }
  52. return app, nil
  53. }
  54. func GetAppByType(orgID int64, app_type int) (*models.OrgApp, error) {
  55. var apps models.OrgApp
  56. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  57. if err != nil {
  58. return nil, err
  59. }
  60. return &apps, nil
  61. }
  62. func CreateOrgApp(app *models.OrgApp) {
  63. writeUserDb.Create(&app)
  64. }
  65. func GetAllUserRole(org_id int64) (appRole []*models.App_Role) {
  66. if org_id == 0 {
  67. readUserDb.Model(&models.App_Role{}).Where("status = 1").Find(&appRole)
  68. } else {
  69. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? ", org_id).Find(&appRole)
  70. }
  71. return
  72. }
  73. func GetAllUserRoleByUserTypeOne(org_id int) (appRole []*models.App_Role) {
  74. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type = 1").Find(&appRole)
  75. return
  76. }
  77. func GetAllUserRoleByUserTypeOther() (appRole []*models.App_Role) {
  78. //app, _ := GetOrgApp(int64(org_id), 3)
  79. //if org_id == 0 {
  80. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type > 1").Find(&appRole)
  81. //
  82. //} else {
  83. // readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? AND user_type > 1 AND app_id = ? ", org_id, app.Id).Find(&appRole)
  84. //
  85. //}
  86. return
  87. }
  88. func FindRoleByUserTypeOne(org_id int64) (role models.Role) {
  89. readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 2 AND role_name = '医生'", org_id).First(&role)
  90. return
  91. }
  92. func FindRoleByUserTypeTwo(org_id int64) (role models.Role) {
  93. readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 3 AND role_name = '护士'", org_id).First(&role)
  94. return
  95. }
  96. func GetAllRole() ([]*models.Role, error) {
  97. var app []*models.Role
  98. err := readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
  99. if err == gorm.ErrRecordNotFound {
  100. return nil, nil
  101. }
  102. if err != nil {
  103. return nil, err
  104. }
  105. return app, nil
  106. }
  107. func UpdateRoleIds(id int64, ids string) {
  108. writeUserDb.Model(&models.App_Role{}).Where("status = 1 AND id = ?", id).Updates(map[string]interface{}{"role_ids": ids, "mtime": time.Now().Unix()})
  109. }
  110. func GetOrgAppA(orgID int64, app_type int) (*models.OrgApp, error) {
  111. var apps models.OrgApp
  112. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  113. if err != nil {
  114. return nil, err
  115. }
  116. return &apps, nil
  117. }
  118. func GetOrgByIdB(orgID int64) (*models.Org, error) {
  119. var org models.Org
  120. err := readUserDb.Model(&models.Org{}).Where("id = ?", orgID).First(&org).Error
  121. if err != nil {
  122. if err == gorm.ErrRecordNotFound {
  123. return nil, nil
  124. } else {
  125. return nil, err
  126. }
  127. }
  128. return &org, nil
  129. }
  130. func GetOrgAppB(orgID int64, app_type int) (*models.OrgApp, error) {
  131. var apps models.OrgApp
  132. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  133. if err != nil {
  134. return nil, err
  135. }
  136. return &apps, nil
  137. }
  138. func CreateOrgRoleB(role *models.Role) (err error) {
  139. err = writeUserDb.Create(&role).Error
  140. return
  141. }
  142. func CreateRolePurviewB(purview *models.RolePurview) (err error) {
  143. err = writeUserDb.Create(&purview).Error
  144. return
  145. }
  146. func CreateFuncRolePurviewB(purview *models.SgjUserRoleFuncPurview) (err error) {
  147. err = writeUserDb.Create(&purview).Error
  148. return
  149. }
  150. func GetSystemRole(orgID int64) ([]*models.Role, error) {
  151. var roles []*models.Role
  152. err := readUserDb.Where(" org_id = ? AND status = 1 AND is_system > 1", orgID).First(&roles).Error
  153. if err != nil {
  154. return nil, err
  155. }
  156. return roles, nil
  157. }
  158. func HandleData() {
  159. var pe []*models.PredialysisEvaluation
  160. //readDb.Model(&models.DialysisPrescription{}).Where("user_org_id = 12 AND record_date <= 1587571200").Find(&prescription)
  161. //for _, item := range prescription {
  162. // 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})
  163. //}
  164. readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = 9538 AND dialysis_order_id > 0").Find(&pe)
  165. for _, item := range pe {
  166. var sch models.Schedule
  167. 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
  168. if err == nil {
  169. if sch.ID > 0 {
  170. order := &models.DialysisOrder{
  171. DialysisDate: sch.ScheduleDate,
  172. UserOrgId: 9538,
  173. PatientId: sch.PatientId,
  174. Stage: 2,
  175. BedID: sch.BedId,
  176. StartNurse: 554,
  177. FinishNurse: 554,
  178. Status: 1,
  179. CreatedTime: sch.ScheduleDate,
  180. UpdatedTime: sch.ScheduleDate,
  181. StartTime: sch.ScheduleDate,
  182. EndTime: sch.ScheduleDate,
  183. PunctureNurse: 554,
  184. Creator: 554,
  185. Modifier: 554,
  186. FinishCreator: 554,
  187. FinishModifier: 554,
  188. SchedualType: sch.ScheduleType,
  189. }
  190. writeDb.Create(&order)
  191. }
  192. }
  193. }
  194. }
  195. func FindAllOrgByImportType() (org []*models.Org, err error) {
  196. err = readUserDb.Model(&models.Org{}).Where("status =1 AND import = 0").Find(&org).Error
  197. return
  198. }
  199. func FindAllPrescription(org_id int64) (prescription []*models.DialysisPrescription, err error) {
  200. err = readDb.Model(&models.DialysisPrescription{}).Where("user_org_id=? AND status= 1 AND record_date >= 1593446400", org_id).Find(&prescription).Error
  201. return
  202. }
  203. func AddSigleDialysisBeforePre(before *models.DialysisBeforePrepare) {
  204. writeDb.Create(&before)
  205. }
  206. func GetAllHisDoctorInfo(org_id int64) (his []*models.HisDoctorAdviceInfo, err error) {
  207. err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  208. return
  209. }
  210. func GetAllHisInfo(org_id int64) (his []*models.HisPrescriptionProject, err error) {
  211. err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  212. return
  213. }
  214. func UpDateHis(his *models.HisDoctorAdviceInfo) {
  215. writeDb.Save(&his)
  216. }
  217. func UpDateHis2(his *models.HisPrescriptionProject) {
  218. writeDb.Save(&his)
  219. }
  220. func GetAllHisOrder(org_id int64) (his []*models.HisOrder, err error) {
  221. 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
  222. return
  223. }
  224. func GetAllHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
  225. 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
  226. return
  227. }
  228. func GetLastHisOrder() (his models.HisOrder, err error) {
  229. err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106 AND status = 1 AND order_status = 2").Last(&his).Error
  230. return
  231. }
  232. type HisPrescriptionAdviceTemplate struct {
  233. ID int64 `gorm:"column:id" json:"id" form:"id"`
  234. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  235. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  236. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  237. AdviceType int64 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
  238. AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
  239. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  240. AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
  241. AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
  242. ReminderDate int64 `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
  243. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  244. SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
  245. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  246. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  247. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  248. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  249. AdviceDoctor int64 `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
  250. Status int64 `gorm:"column:status" json:"status" form:"status"`
  251. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  252. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  253. AdviceAffirm string `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
  254. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  255. StopTime int64 `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
  256. StopReason string `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
  257. StopDoctor int64 `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
  258. StopState int64 `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
  259. ParentId int64 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
  260. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  261. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  262. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  263. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  264. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  265. DialysisOrderId int64 `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
  266. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  267. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  268. DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  269. DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
  270. Groupno int64 `gorm:"column:groupno" json:"groupno" form:"groupno"`
  271. RemindType int64 `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
  272. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  273. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  274. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  275. TemplateId string `gorm:"column:template_id" json:"template_id" form:"template_id"`
  276. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  277. DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
  278. Price float64 `gorm:"column:price" json:"price" form:"price"`
  279. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  280. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  281. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  282. Day int64 `gorm:"column:day" json:"day" form:"day"`
  283. Diagnosis int64 `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  284. HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
  285. LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  286. }
  287. func (HisPrescriptionAdviceTemplate) TableName() string {
  288. return "his_prescription_advice_template"
  289. }
  290. type HisPrescriptionInfoTemplateTwo struct {
  291. ID int64 `gorm:"column:id" json:"id" form:"id"`
  292. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  293. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  294. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  295. Status int64 `gorm:"column:status" json:"status" form:"status"`
  296. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  297. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  298. Type int64 `gorm:"column:type" json:"type" form:"type"`
  299. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  300. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  301. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  302. PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
  303. HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  304. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  305. }
  306. func (HisPrescriptionInfoTemplateTwo) TableName() string {
  307. return "his_prescription_info_template"
  308. }
  309. func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
  310. err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
  311. Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
  312. return db.Where("status = 1")
  313. }).
  314. Where("status = 1 ").
  315. Find(&prescription).Error
  316. return
  317. }
  318. func SaveAdviceTemplate(advice HisPrescriptionAdviceTemplate) {
  319. writeDb.Save(&advice)
  320. }
  321. func GetAllPT(org_id int64) (his []*models.HisPrescriptionTemplate, err error) {
  322. err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  323. return
  324. }
  325. type HisPrescriptionProjectTemplate struct {
  326. ID int64 `gorm:"column:id" json:"id" form:"id"`
  327. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  328. Price float64 `gorm:"column:price" json:"price" form:"price"`
  329. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  330. Status int64 `gorm:"column:status" json:"status" form:"status"`
  331. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  332. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  333. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  334. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  335. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  336. Count string `gorm:"column:count" json:"count" form:"count"`
  337. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  338. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  339. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  340. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  341. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  342. Day string `gorm:"column:day" json:"day" form:"day"`
  343. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  344. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  345. Type int64 `gorm:"column:type" json:"type" form:"type"`
  346. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  347. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  348. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  349. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  350. }
  351. func (HisPrescriptionProjectTemplate) TableName() string {
  352. return "his_prescription_project_template"
  353. }
  354. type HisPrescriptionInfoTemplateTHree struct {
  355. ID int64 `gorm:"column:id" json:"id" form:"id"`
  356. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  357. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  358. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  359. Status int64 `gorm:"column:status" json:"status" form:"status"`
  360. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  361. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  362. Type int64 `gorm:"column:type" json:"type" form:"type"`
  363. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  364. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  365. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  366. PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
  367. HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  368. HisPrescriptionProjectTemplate []HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
  369. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  370. }
  371. func (HisPrescriptionInfoTemplateTHree) TableName() string {
  372. return "his_prescription_info_template"
  373. }
  374. func GetAllPTInfo(org_id int64, p_template_id int64) (his []*HisPrescriptionInfoTemplateTHree, err error) {
  375. err = readDb.Model(&HisPrescriptionInfoTemplateTHree{}).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
  376. return db.Where("status = 1")
  377. }).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
  378. return db.Where("status = 1")
  379. }).Where("user_org_id = ? AND status = 1 AND p_template_id = ?", org_id, p_template_id).Find(&his).Error
  380. return
  381. }
  382. func GetAllInfo(org_id int64, project_id int64) (his []*HisPrescriptionProjectTemplate, err error) {
  383. err = readDb.Model(&HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND status = 1 AND project_id = ? ", org_id, project_id).Find(&his).Error
  384. return
  385. }
  386. func UpdateStatus(project_id int64, p_id int64) {
  387. writeDb.Model(&HisPrescriptionProjectTemplate{}).Where("id = ?", project_id).Updates(map[string]interface{}{"status": 0})
  388. writeDb.Model(&HisPrescriptionInfoTemplateTwo{}).Where("id = ?", p_id).Updates(map[string]interface{}{"status": 0})
  389. }
  390. func SaveOrder(order *models.HisOrder) {
  391. writeDb.Save(&order)
  392. }
  393. func SaveOrderTwo(order *models.HisOrder) error {
  394. err := writeDb.Save(&order).Error
  395. return err
  396. }
  397. func GetAllPrivateHis(org_id int64) (his []*models.HisPatient) {
  398. readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND balance_accounts_type = 2 AND status = 1", org_id).Find(&his)
  399. return
  400. }
  401. func SaveHis(his *models.HisPatient) {
  402. writeDb.Save(his)
  403. return
  404. }
  405. func GetAllProjectPrescription() (pre []*models.HisPrescription) {
  406. 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)
  407. return
  408. }
  409. func GetAllProject(id int64) (pre []*models.HisPrescriptionProject) {
  410. readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = 10215 AND status = 1 AND project_id = 1735 AND prescription_id = ?", id).Find(&pre)
  411. return
  412. }
  413. //func GetHisOrderDetailByNumberTwo(order_number string, org_id int64) (order []*HisOrderInfo, err error) {
  414. // readDb.Model(&models.Patients{})
  415. //
  416. // err = readDb.Model(&HisOrderInfo{}).Where("order_number = ? AND status = 1", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  417. // 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)
  418. // }).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  419. // 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)
  420. // }).Find(&order).Error
  421. // return
  422. //}
  423. type HisOrderTen struct {
  424. ID int64 `gorm:"column:id" json:"id" form:"id"`
  425. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  426. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  427. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  428. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  429. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  430. Status int64 `gorm:"column:status" json:"status" form:"status"`
  431. Number string `gorm:"column:number" json:"number" form:"number"`
  432. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  433. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  434. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  435. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  436. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  437. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  438. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  439. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  440. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  441. SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
  442. PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
  443. PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
  444. PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
  445. Certno string `gorm:"column:certno" json:"certno" form:"certno"`
  446. Gend string `gorm:"column:gend" json:"gend" form:"gend"`
  447. Naty string `gorm:"column:naty" json:"naty" form:"naty"`
  448. Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
  449. Age float64 `gorm:"column:age" json:"age" form:"age"`
  450. Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
  451. PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
  452. CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
  453. SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
  454. MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
  455. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  456. MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
  457. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  458. OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
  459. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  460. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  461. ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
  462. HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
  463. CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
  464. PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
  465. HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
  466. HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
  467. HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
  468. MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
  469. OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
  470. FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
  471. PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
  472. AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
  473. PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
  474. HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
  475. Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
  476. AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
  477. MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
  478. ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
  479. ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
  480. ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
  481. SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
  482. IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
  483. PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
  484. PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
  485. PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
  486. DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
  487. PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
  488. RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
  489. FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
  490. MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
  491. PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
  492. DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
  493. DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
  494. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  495. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  496. Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
  497. //VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
  498. HisPrescriptionTen []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
  499. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  500. }
  501. func (HisOrderTen) TableName() string {
  502. return "his_order"
  503. }
  504. type HisPrescriptionTen struct {
  505. ID int64 `gorm:"column:id" json:"id" form:"id"`
  506. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  507. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  508. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  509. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  510. Status int64 `gorm:"column:status" json:"status" form:"status"`
  511. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  512. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  513. Number string `gorm:"column:number" json:"number" form:"number"`
  514. Type int64 `gorm:"column:type" json:"type" form:"type"`
  515. Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
  516. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  517. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  518. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  519. PreTime int64 `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
  520. BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
  521. PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
  522. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  523. HisDoctorAdviceInfoTen []*HisDoctorAdviceInfoTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  524. HisPrescriptionProjectTen []*HisPrescriptionProjectTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
  525. Total string `gorm:"-" json:"total" form:"total"`
  526. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  527. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  528. IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
  529. }
  530. func (HisPrescriptionTen) TableName() string {
  531. return "his_prescription"
  532. }
  533. func GetHisOrderDetailThree(start_time string, end_time string, org_id int64) (order []*HisOrderTen, err error) {
  534. start_time = start_time + " 00:00:00"
  535. end_time = end_time + " 23:59:00"
  536. err = readDb.Model(&HisOrderTen{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  537. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  538. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  539. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  540. return db.Where("status = 1").Preload("Drug", "status = 1")
  541. })
  542. }).Where("setl_time >= ? AND setl_time <= ? AND status = 1 AND order_status =2 AND user_org_id = ?", start_time, end_time, org_id).Find(&order).Order("patient_id").Error
  543. return
  544. }
  545. type HisDoctorAdviceInfoTen struct {
  546. ID int64 `gorm:"column:id" json:"id" form:"id"`
  547. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  548. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  549. AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
  550. AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
  551. AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
  552. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  553. SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
  554. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  555. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  556. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  557. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  558. Status int64 `gorm:"column:status" json:"status" form:"status"`
  559. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  560. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  561. DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  562. DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
  563. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  564. Price float64 `gorm:"column:price" json:"price" form:"price"`
  565. DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
  566. Drug Drug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
  567. IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
  568. ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
  569. IsSelfDrug int64 `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
  570. }
  571. func (HisDoctorAdviceInfoTen) TableName() string {
  572. return "his_doctor_advice_info"
  573. }
  574. type HisPrescriptionProjectTen struct {
  575. ID int64 `gorm:"column:id" json:"id" form:"id"`
  576. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  577. Price float64 `gorm:"column:price" json:"price" form:"price"`
  578. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  579. Status int64 `gorm:"column:status" json:"status" form:"status"`
  580. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  581. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  582. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  583. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  584. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  585. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  586. Count string `gorm:"column:count" json:"count" form:"count"`
  587. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  588. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  589. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  590. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  591. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  592. Day string `gorm:"column:day" json:"day" form:"day"`
  593. VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
  594. VMGoodInfo VMGoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
  595. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  596. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  597. Type int64 `gorm:"column:type" json:"type" form:"type"`
  598. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  599. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  600. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  601. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  602. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  603. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  604. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  605. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  606. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  607. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  608. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  609. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  610. ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
  611. }
  612. func (HisPrescriptionProjectTen) TableName() string {
  613. return "his_prescription_project"
  614. }
  615. func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
  616. err = XTReadDB().Model(&paitent).Where("user_org_id = ? and status = 1 AND in_hosptial_time >= '2024-06-01 00:00:00' AND in_hosptial_time <= '2024-06-30 23:59:59'", orgid).Find(&paitent).Error
  617. return paitent, err
  618. }
  619. func SaveHP(paitent *models.HisHospitalCheckRecord) {
  620. writeDb.Save(&paitent)
  621. }
  622. func Savehis(paitent *models.HisPatient) {
  623. writeDb.Save(&paitent)
  624. }
  625. type HisOrder9504 struct {
  626. ID int64 `gorm:"column:id" json:"id" form:"id"`
  627. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  628. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  629. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  630. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  631. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  632. Status int64 `gorm:"column:status" json:"status" form:"status"`
  633. Number string `gorm:"column:number" json:"number" form:"number"`
  634. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  635. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  636. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  637. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  638. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  639. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  640. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  641. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  642. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  643. SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
  644. PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
  645. PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
  646. PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
  647. Certno string `gorm:"column:certno" json:"certno" form:"certno"`
  648. Gend string `gorm:"column:gend" json:"gend" form:"gend"`
  649. Naty string `gorm:"column:naty" json:"naty" form:"naty"`
  650. Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
  651. Age float64 `gorm:"column:age" json:"age" form:"age"`
  652. Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
  653. PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
  654. CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
  655. SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
  656. MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
  657. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  658. MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
  659. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  660. OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
  661. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  662. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  663. ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
  664. HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
  665. CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
  666. PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
  667. HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
  668. HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
  669. HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
  670. MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
  671. OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
  672. FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
  673. PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
  674. AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
  675. PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
  676. HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
  677. Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
  678. AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
  679. MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
  680. ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
  681. ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
  682. ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
  683. SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
  684. IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
  685. PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
  686. PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
  687. PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
  688. DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
  689. PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
  690. RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
  691. FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
  692. MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
  693. PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
  694. DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
  695. DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
  696. SettleStartTime int64 `gorm:"settle_start_time" json:"settle_start_time" form:"settle_start_time"`
  697. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  698. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  699. Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
  700. VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
  701. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  702. }
  703. func (HisOrder9504) TableName() string {
  704. return "his_order"
  705. }
  706. type VmHisOrderInfo9504 struct {
  707. ID int64 `gorm:"column:id" json:"id" form:"id"`
  708. OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
  709. UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
  710. AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
  711. DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  712. Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
  713. Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
  714. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  715. PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  716. SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
  717. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  718. OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
  719. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  720. BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
  721. MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
  722. HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  723. Status int64 `gorm:"column:status" json:"status" form:"status"`
  724. Memo string `gorm:"column:memo" json:"memo" form:"memo"`
  725. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  726. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  727. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  728. DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
  729. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  730. ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
  731. ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
  732. LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  733. ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
  734. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  735. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  736. OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
  737. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  738. Type int64 `gorm:"column:type" json:"type" form:"type"`
  739. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  740. SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
  741. HisPrescriptionProjectTen HisPrescriptionProjectTen `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
  742. HisDoctorAdviceInfoTen HisDoctorAdviceInfoTen `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advices"`
  743. }
  744. func (VmHisOrderInfo9504) TableName() string {
  745. return "his_order_info"
  746. }
  747. type VmHisOrderInfo95042 struct {
  748. ID int64 `gorm:"column:id" json:"id" form:"id"`
  749. OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
  750. UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
  751. AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
  752. DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  753. Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
  754. Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
  755. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  756. PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  757. SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
  758. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  759. OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
  760. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  761. BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
  762. MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
  763. HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  764. Status int64 `gorm:"column:status" json:"status" form:"status"`
  765. Memo string `gorm:"column:memo" json:"memo" form:"memo"`
  766. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  767. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  768. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  769. DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
  770. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  771. ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
  772. ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
  773. LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  774. ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
  775. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  776. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  777. OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
  778. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  779. Type int64 `gorm:"column:type" json:"type" form:"type"`
  780. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  781. SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
  782. }
  783. func (VmHisOrderInfo95042) TableName() string {
  784. return "his_order_info"
  785. }
  786. func GetHisOrderDetail9504() (order []*HisOrder9504, err error) {
  787. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  788. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  789. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  790. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  791. return db.Where("status = 1").Preload("Drug", "status = 1")
  792. })
  793. }).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
  794. return
  795. }
  796. func GetHisOrderDetail10188() (order []*HisOrder9504, err error) {
  797. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  798. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  799. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  800. })
  801. }).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
  802. return
  803. }
  804. //func GetHisOrderDetail10138() (order []*HisOrder9504, err error) {
  805. // err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  806. // return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  807. // return db.Where("status = 1").Preload("VMHisProject", "status = 1")
  808. // })
  809. // }).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
  810. // return
  811. //}
  812. func GetHisOrderDetail10138() (order []*HisOrderTen, err error) {
  813. err = readDb.Model(&HisOrderTen{}).Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
  814. return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  815. return db.Where("status = 1").Preload("VMHisProject")
  816. })
  817. }).Where("setl_time >= '2024-04-01 00:00:00' AND setl_time <= '2024-06-30 23:00:00' AND status = 1 AND order_status =2 AND user_org_id = 10278").Find(&order).Error
  818. return
  819. }
  820. func GetHisOrderDetail10265() (order_infos []*VmHisOrderInfo9504, err error) {
  821. err = readDb.Model(&VmHisOrderInfo9504{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  822. return db.Preload("VMHisProject").Preload("VMGoodInfo", "status = 1")
  823. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  824. return db.Where("status = 1").Preload("Drug", "status = 1")
  825. }).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2022090814370516482'").Find(&order_infos).Error
  826. return
  827. }
  828. func GetHisOrder10265() (order_infos []*VmHisOrderInfo9504, err error) {
  829. err = readDb.Model(&VmHisOrderInfo95042{}).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2023031016334716192' AND project_id > 0").Find(&order_infos).Error
  830. return
  831. }
  832. func GetHisOrder10265two() (order_infos []*VmHisOrderInfo9504, err error) {
  833. err = readDb.Model(&VmHisOrderInfo95042{}).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2023031016334716192'").Find(&order_infos).Error
  834. return
  835. }
  836. func SaveOrderInfo(info *VmHisOrderInfo9504) {
  837. writeDb.Save(&info)
  838. }
  839. func GetHisOrderDetail10106(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
  840. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  841. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  842. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  843. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  844. return db.Where("status = 1").Preload("Drug")
  845. })
  846. }).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
  847. return
  848. }
  849. func GetHisOrderDetail10318(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
  850. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  851. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  852. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  853. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  854. return db.Where("status = 1").Preload("Drug")
  855. })
  856. }).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
  857. return
  858. }
  859. func GetLongSolution() {
  860. records, _ := GetAllSchedules()
  861. fmt.Println(records)
  862. for _, item := range records {
  863. var DialysisMachineName string
  864. //1.透析器 2.灌流器 3.透析器/灌流器
  865. so, _ := GetDialysisSolutionTwo(item.UserOrgId, item.PatientId, item.ModeId)
  866. filedRecordOne, _ := FindFiledBy(item.UserOrgId, "透析器")
  867. filedRecordTwo, _ := FindFiledBy(item.UserOrgId, "灌流器")
  868. filedRecordThree, _ := FindFiledBy(item.UserOrgId, "透析器/灌流器")
  869. if filedRecordOne.IsShow == 1 {
  870. DialysisMachineName = so.DialysisDialyszers
  871. }
  872. if filedRecordThree.IsShow == 1 {
  873. if len(DialysisMachineName) > 0 {
  874. DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
  875. } else {
  876. DialysisMachineName = so.DialyzerPerfusionApparatus
  877. }
  878. }
  879. if filedRecordTwo.IsShow == 1 {
  880. if len(DialysisMachineName) > 0 {
  881. DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
  882. } else {
  883. DialysisMachineName = so.DialysisIrrigation
  884. }
  885. }
  886. item.DialysisMachineName = DialysisMachineName
  887. UpdateSch(item)
  888. }
  889. }
  890. func GetAllSchMode() (modes []*models.PatientScheduleTemplateMode, getModesErr error) {
  891. getModesErr = readDb.Model(&models.PatientScheduleTemplateMode{}).Where("mode <> 0 AND status = 1 ").Find(&modes).Error
  892. return
  893. }
  894. type DialysisSolutionTwo struct {
  895. ID int64 `gorm:"column:id" json:"id" form:"id"`
  896. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  897. }
  898. func (DialysisSolutionTwo) TableName() string {
  899. return "xt_dialysis_solution"
  900. }
  901. type Schedule struct {
  902. ID int64 `gorm:"column:id" json:"id" form:"id"`
  903. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  904. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  905. Status int64 `gorm:"column:status" json:"status" form:"status"`
  906. ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
  907. ModeId int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
  908. DialysisMachineName string `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
  909. }
  910. func (Schedule) TableName() string {
  911. return "xt_schedule"
  912. }
  913. func GetAllSchedules() ([]Schedule, error) {
  914. var record []Schedule
  915. err := readDb.Model(&Schedule{}).Where("user_org_id = 10290 AND status = 1 AND schedule_date > 1672934400").Find(&record).Error
  916. if err != nil {
  917. if err == gorm.ErrRecordNotFound {
  918. return nil, nil
  919. } else {
  920. return nil, err
  921. }
  922. }
  923. return record, nil
  924. }
  925. func FindFiledBy(org_id int64, name string) (filedConfig models.FiledConfig, err error) {
  926. err = readDb.Model(&models.FiledConfig{}).Where("org_id =? AND module = 1 AND filed_name_cn= ?", org_id, name).First(&filedConfig).Error
  927. return
  928. }
  929. // 透析方案
  930. func GetDialysisSolutionTwo(orgID int64, patientID int64, mode_id int64) (models.DialysisSolution, error) {
  931. var record models.DialysisSolution
  932. 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
  933. return record, err
  934. }
  935. func UpdateSch(sch Schedule) (err error) {
  936. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"dialysis_machine_name": sch.DialysisMachineName}).Error
  937. return
  938. }
  939. func SaveSch(sch *models.Schedule) (err error) {
  940. err = writeDb.Save(&sch).Error
  941. return
  942. }
  943. func SaveSchTwo(sch models.Schedule, sch_two models.Schedule) (err error) {
  944. //err = writeDb.Save(&sch).Error
  945. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"status": 0}).Error
  946. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch_two.ID).Updates(map[string]interface{}{"status": 0}).Error
  947. return
  948. }
  949. func GetDrugstwo(orgId int64) (drugs []*XtBaseDrugtwo, err error) {
  950. err = readDb.Model(&XtBaseDrugtwo{}).Where("org_id = ? AND status = 1", orgId).Find(&drugs).Error
  951. return
  952. }
  953. func GetGoodInfotwo(orgId int64) (drugs []*XtGoodInformation, err error) {
  954. err = readDb.Model(&XtGoodInformation{}).Where("org_id = ? AND status = 1", orgId).Find(&drugs).Error
  955. return
  956. }
  957. func Getprojecttwo(orgId int64) (drugs []*XtHisProject, err error) {
  958. err = readDb.Model(&XtHisProject{}).Where("user_org_id = ? AND status = 1", orgId).Find(&drugs).Error
  959. return
  960. }
  961. func SaveDrugtwo(drugs *XtBaseDrugtwo) error {
  962. err := XTWriteDB().Save(&drugs).Error
  963. return err
  964. }
  965. func SaveGoodtwo(drugs *XtGoodInformation) error {
  966. err := XTWriteDB().Save(&drugs).Error
  967. return err
  968. }
  969. func SaveProject(drugs *XtHisProject) error {
  970. err := XTWriteDB().Save(&drugs).Error
  971. return err
  972. }
  973. type XtGoodInformation struct {
  974. ID int64 `gorm:"column:id" json:"id" form:"id"`
  975. GoodCode string `gorm:"column:good_code" json:"good_code" form:"good_code"`
  976. SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
  977. GoodTypeId int64 `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
  978. GoodUnit int64 `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
  979. BuyPrice float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
  980. SellPrice float64 `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
  981. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  982. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  983. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  984. Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
  985. Dealer int64 `gorm:"column:dealer" json:"dealer" form:"dealer"`
  986. ExpiryDateWarnDayCount int64 `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
  987. StockWarnCount int64 `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
  988. IsReuse int64 `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
  989. Status int64 `gorm:"column:status" json:"status" form:"status"`
  990. FilmArea string `gorm:"column:film_area" json:"film_area" form:"film_area"`
  991. IsUse int64 `gorm:"column:is_use" json:"is_use" form:"is_use"`
  992. FilmMaterialQuality string `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
  993. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  994. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  995. Creater int64 `gorm:"column:creater" json:"creater" form:"creater"`
  996. GoodName string `gorm:"column:good_name" json:"good_name" form:"good_name"`
  997. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  998. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  999. GoodKind int64 `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
  1000. MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
  1001. RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
  1002. MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
  1003. IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
  1004. IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
  1005. StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
  1006. GoodStatus string `gorm:"column:good_status" json:"good_status" form:"good_status"`
  1007. DefaultCount int64 `gorm:"column:default_count" json:"default_count" form:"default_count"`
  1008. IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
  1009. IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
  1010. IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
  1011. IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
  1012. Sign int64 `gorm:"column:sign" json:"sign" form:"sign"`
  1013. Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
  1014. IsDoctorUse int64 `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
  1015. Agent string `gorm:"column:agent" json:"agent" form:"agent"`
  1016. GoodNumber string `gorm:"column:good_number" json:"good_number" form:"good_number"`
  1017. CommdityCode string `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
  1018. SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
  1019. ProductionType string `gorm:"column:production_type" json:"production_type" form:"production_type"`
  1020. SpecialMedical string `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
  1021. IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
  1022. Total float64 `gorm:"column:total" json:"total" form:"total"`
  1023. MinNumber int64 `gorm:"column:min_number" json:"min_number" form:"min_number"`
  1024. PackingUnit string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
  1025. PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
  1026. DefaultCountUnit string `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
  1027. MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
  1028. RegisterNumber string `gorm:"column:register_number" json:"register_number" form:"register_number"`
  1029. ProvincesCode string `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
  1030. IsUser int64 `gorm:"column:is_user" json:"is_user" form:"is_user"`
  1031. Number string `gorm:"column:number" json:"number" form:"number"`
  1032. IsWarehouse int64 `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
  1033. BatchRetaiPrice float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
  1034. SumCount int64 `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
  1035. SumInCount int64 `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
  1036. TotalCount int64 `gorm:"column:total_count" json:"total_count" form:"total_count"`
  1037. SumOutCount int64 `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
  1038. SumCancelCount int64 `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
  1039. IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
  1040. FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
  1041. ZuobiaoId string `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
  1042. Bck01b string `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
  1043. Bby01 string `gorm:"column:bby01" json:"bby01" form:"bby01"`
  1044. }
  1045. func (XtGoodInformation) TableName() string {
  1046. return "xt_good_information"
  1047. }
  1048. type XtBaseDrugtwo struct {
  1049. ID int64 `gorm:"column:id" json:"id" form:"id"`
  1050. DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
  1051. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  1052. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  1053. DrugAlias string `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
  1054. DrugAliasPinyin string `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
  1055. DrugAliasWubi string `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
  1056. DrugCategory int64 `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
  1057. DrugSpec string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  1058. DrugType int64 `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
  1059. DrugStockLimit string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
  1060. DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
  1061. DrugDosageForm int64 `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
  1062. MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
  1063. MaxUnit string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
  1064. MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
  1065. UnitMatrixing string `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
  1066. RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
  1067. LastPrice float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
  1068. DrugControl int64 `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
  1069. Number string `gorm:"column:number" json:"number" form:"number"`
  1070. DrugClassify string `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
  1071. DrugDose float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
  1072. DrugDoseUnit int64 `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
  1073. MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
  1074. Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
  1075. PharmacologyCategory int64 `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
  1076. StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
  1077. Code string `gorm:"column:code" json:"code" form:"code"`
  1078. IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
  1079. IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
  1080. Agent string `gorm:"column:agent" json:"agent" form:"agent"`
  1081. DrugStatus string `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
  1082. LimitRemark string `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
  1083. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  1084. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  1085. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  1086. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  1087. Label int64 `gorm:"column:label" json:"label" form:"label"`
  1088. Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
  1089. IsUseDoctorAdvice int64 `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
  1090. IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
  1091. IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
  1092. IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
  1093. IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
  1094. Status int64 `gorm:"column:status" json:"status" form:"status"`
  1095. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  1096. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  1097. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  1098. DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
  1099. Dealer int64 `gorm:"column:dealer" json:"dealer" form:"dealer"`
  1100. DoseCode string `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
  1101. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  1102. DrugRemark string `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
  1103. SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
  1104. IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
  1105. PrescriptionMark int64 `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
  1106. HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
  1107. LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  1108. Total float64 `gorm:"column:total" json:"total" form:"total"`
  1109. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  1110. MinNumber int64 `gorm:"column:min_number" json:"min_number" form:"min_number"`
  1111. Dose string `gorm:"column:dose" json:"dose" form:"dose"`
  1112. DoseUnit string `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
  1113. DrugDay string `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
  1114. MinPrice float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
  1115. ProvincesCode string `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
  1116. IsUser int64 `gorm:"column:is_user" json:"is_user" form:"is_user"`
  1117. SumCount int64 `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
  1118. BatchRetaiPrice float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
  1119. SumInCount int64 `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
  1120. IsPharmacy int64 `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
  1121. TotalCount int64 `gorm:"column:total_count" json:"total_count" form:"total_count"`
  1122. DrugStockLimitCount int64 `gorm:"column:drug_stock_limit_count" json:"drug_stock_limit_count" form:"drug_stock_limit_count"`
  1123. SumOutCount int64 `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
  1124. SumCancelCount int64 `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
  1125. FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
  1126. ZuobiaoId string `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
  1127. Bby01 string `gorm:"column:bby01" json:"bby01" form:"bby01"`
  1128. Bck01b string `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
  1129. }
  1130. func (XtBaseDrugtwo) TableName() string {
  1131. return "xt_base_drug"
  1132. }
  1133. type XtHisProject struct {
  1134. ID int64 `gorm:"column:id" json:"id" form:"id"`
  1135. ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
  1136. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  1137. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  1138. Price float64 `gorm:"column:price" json:"price" form:"price"`
  1139. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  1140. CostClassify int64 `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
  1141. ExecutiveSection int64 `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
  1142. MedicalCoverage int64 `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
  1143. StatisticalClassification int64 `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
  1144. DiseaseDirectory int64 `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
  1145. IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
  1146. MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
  1147. TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
  1148. MedicalStatus int64 `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
  1149. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  1150. Sign int64 `gorm:"column:sign" json:"sign" form:"sign"`
  1151. DefaultNumber string `gorm:"column:default_number" json:"default_number" form:"default_number"`
  1152. IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
  1153. IsCharge int64 `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
  1154. IsEstimate int64 `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
  1155. IsWorkload int64 `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
  1156. Sort string `gorm:"column:sort" json:"sort" form:"sort"`
  1157. DoctorAdvice int64 `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
  1158. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  1159. Status int64 `gorm:"column:status" json:"status" form:"status"`
  1160. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  1161. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  1162. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  1163. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  1164. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  1165. NumberDays string `gorm:"column:number_days" json:"number_days" form:"number_days"`
  1166. Total string `gorm:"column:total" json:"total" form:"total"`
  1167. IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
  1168. SpecailProject int64 `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
  1169. SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
  1170. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  1171. Category int64 `gorm:"column:category" json:"category" form:"category"`
  1172. IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
  1173. FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
  1174. ZuobiaoId string `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
  1175. Bck01b string `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
  1176. Bby01 string `gorm:"column:bby01" json:"bby01" form:"bby01"`
  1177. }
  1178. func (XtHisProject) TableName() string {
  1179. return "xt_his_project"
  1180. }
  1181. func Saved(drug models.BaseDrugLib) {
  1182. writeDb.Create(&drug)
  1183. }
  1184. func Savegd(good GoodInfotwo) {
  1185. writeDb.Create(&good)
  1186. }
  1187. type GoodInfotwo struct {
  1188. ID int64 `gorm:"column:id" json:"id" form:"id"`
  1189. GoodCode string `gorm:"column:good_code" json:"good_code" form:"good_code"`
  1190. SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
  1191. GoodTypeId int64 `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
  1192. GoodUnit int64 `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
  1193. BuyPrice float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
  1194. SellPrice float64 `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
  1195. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  1196. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  1197. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  1198. Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
  1199. Dealer int64 `gorm:"column:dealer" json:"dealer" form:"dealer"`
  1200. ExpiryDateWarnDayCount int64 `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
  1201. StockWarnCount int64 `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
  1202. IsReuse int64 `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
  1203. Status int64 `gorm:"column:status" json:"status" form:"status"`
  1204. FilmArea string `gorm:"column:film_area" json:"film_area" form:"film_area"`
  1205. IsUse int64 `gorm:"column:is_use" json:"is_use" form:"is_use"`
  1206. FilmMaterialQuality string `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
  1207. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  1208. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  1209. Creater int64 `gorm:"column:creater" json:"creater" form:"creater"`
  1210. GoodName string `gorm:"column:good_name" json:"good_name" form:"good_name"`
  1211. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  1212. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  1213. GoodKind int64 `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
  1214. MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
  1215. RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
  1216. MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
  1217. ProvincesCode string `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
  1218. FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
  1219. IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
  1220. IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
  1221. StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
  1222. GoodStatus string `gorm:"column:good_status" json:"good_status" form:"good_status"`
  1223. DefaultCount int64 `gorm:"column:default_count" json:"default_count" form:"default_count"`
  1224. Sign int64 `gorm:"column:sign" json:"sign" form:"sign"`
  1225. IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
  1226. IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
  1227. IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
  1228. IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
  1229. Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
  1230. IsDoctorUse int64 `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
  1231. Agent string `gorm:"column:agent" json:"agent" form:"agent"`
  1232. GoodNumber string `gorm:"column:good_number" json:"good_number" form:"good_number"`
  1233. CommdityCode string `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
  1234. SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
  1235. ProductionType string `gorm:"column:production_type" json:"production_type" form:"production_type"`
  1236. SpecialMedical string `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
  1237. IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
  1238. MinNumber int64 `gorm:"column:min_number" json:"min_number" form:"min_number"`
  1239. PackingUnit string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
  1240. PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
  1241. DefaultCountUnit string `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
  1242. MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
  1243. Total float64 `gorm:"column:total" json:"total" form:"total"`
  1244. RegisterNumber string `gorm:"column:register_number" json:"register_number" form:"register_number"`
  1245. IsUser int64 `gorm:"column:is_user" json:"is_user" form:"is_user"`
  1246. Number string `gorm:"column:number" json:"number" form:"number"`
  1247. IsWarehouse int64 `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
  1248. SumCount int64 `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
  1249. BatchRetaiPrice float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
  1250. SumInCount int64 `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
  1251. Bbx01 int64 `gorm:"column:bbx01" json:"bbx01" form:"bbx01"`
  1252. Bby01 int64 `gorm:"column:bby01" json:"bby01" form:"bby01"`
  1253. }
  1254. func (GoodInfotwo) TableName() string {
  1255. return "xt_good_information"
  1256. }
  1257. func GetHisPatient4444555() (paitent []*models.HisPatient, err error) {
  1258. err = XTReadDB().Model(&paitent).Where("user_org_id = 10485 and status = 1 AND record_date >= 1704038400").Find(&paitent).Error
  1259. return paitent, err
  1260. }
  1261. func UpDateNumber(id int64, number string) {
  1262. writeDb.Model(&models.GoodInfo{}).Where("id = ?", id).Updates(map[string]interface{}{"number": number})
  1263. }
  1264. func GetOrderinfo(org_id int64) (info []models.HisOrderInfo, err error) {
  1265. err = readDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? and advice_id = 0 and med_chrgitm_type = '09' and ctime >= 1717344000", org_id).Find(&info).Error
  1266. for _, in := range info {
  1267. var doc models.HisDoctorAdviceInfo
  1268. readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? and feedetl_sn = ? and status = 1 and advice_date = 1717344000", org_id, in.FeedetlSn).First(&doc)
  1269. writeDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? and feedetl_sn = ? and advice_id = 0 and med_chrgitm_type = '09' and ctime >= 1717344000", org_id, doc.FeedetlSn).Updates(map[string]interface{}{"advice_id": doc.ID})
  1270. }
  1271. return
  1272. }
  1273. type Result22 struct {
  1274. InspectDate string
  1275. Inspect int64
  1276. PatientID int64
  1277. ItemID1 int64
  1278. ItemID2 int64
  1279. ItemName1 string
  1280. ItemName2 string
  1281. InspectValue1 string
  1282. InspectValue2 string
  1283. WeightAfter float64
  1284. ActualUltrafiltration float64
  1285. ActualTreatmentHour int64
  1286. ActualTreatmentHours float64
  1287. WeightBefore float64
  1288. }
  1289. func Aaa() {
  1290. var inspections []Result22
  1291. readDb.Raw(`
  1292. SELECT
  1293. DATE(FROM_UNIXTIME(xts.inspect_date)) AS inspect_date,
  1294. xts.inspect,
  1295. xts.patient_id,
  1296. xts.item_id AS item_id_1,
  1297. b.item_id AS item_id_2,
  1298. xts.item_name AS item_name_1,
  1299. b.item_name AS item_name_2,
  1300. xts.inspect_value AS inspect_value1,
  1301. b.inspect_value AS inspect_value2,
  1302. b.weight_after,
  1303. b.actual_ultrafiltration,
  1304. b.actual_treatment_hour,
  1305. b.actual_treatment_minute / 60.0 AS actual_treatment_hours,
  1306. xts.weight_before
  1307. FROM
  1308. (SELECT
  1309. DATE(FROM_UNIXTIME(xts.inspect_date)) AS inspect_date,
  1310. xts.inspect_date as inspect,
  1311. xts.patient_id,
  1312. xts.item_id,
  1313. xts.item_name,
  1314. xts.inspect_value,
  1315. be.weight_before
  1316. FROM xt_inspection xts
  1317. JOIN xt_assessment_before_dislysis be
  1318. ON be.patient_id = xts.patient_id
  1319. AND DATE(FROM_UNIXTIME(xts.inspect_date)) = DATE(FROM_UNIXTIME(be.assessment_date))
  1320. WHERE xts.org_id = 10677 AND xts.item_id = 106770503) xts
  1321. JOIN
  1322. (SELECT
  1323. DATE(FROM_UNIXTIME(xt.inspect_date)) AS inspect_date,
  1324. xt.inspect_date as inspect,
  1325. xt.patient_id,
  1326. xt.item_id,
  1327. xt.item_name,
  1328. xt.inspect_value,
  1329. ad.weight_after,
  1330. ad.actual_ultrafiltration,
  1331. ad.actual_treatment_hour,
  1332. ad.actual_treatment_minute
  1333. FROM xt_inspection xt
  1334. JOIN xt_assessment_after_dislysis ad
  1335. ON DATE(FROM_UNIXTIME(xt.inspect_date)) = DATE(FROM_UNIXTIME(ad.assessment_date))
  1336. AND xt.patient_id = ad.patient_id
  1337. WHERE xt.org_id = 10677 AND xt.item_id = 106771301
  1338. AND ad.weight_after > 0
  1339. AND ad.actual_ultrafiltration > 0) b
  1340. ON xts.inspect_date = b.inspect_date
  1341. AND xts.patient_id = b.patient_id;
  1342. `).Scan(&inspections)
  1343. for _, item := range inspections {
  1344. // 定义一个日期字符串
  1345. timestamp := item.Inspect
  1346. var ins models.Inspection
  1347. ins.Status = 1
  1348. ins.PatientId = item.PatientID
  1349. ins.OrgId = 10677
  1350. ins.ItemName = "透析前尿素氮"
  1351. ins.CreatedTime = time.Now().Unix()
  1352. ins.UpdatedTime = time.Now().Unix()
  1353. ins.ProjectName = "KT/V"
  1354. ins.InspectType = 3
  1355. ins.InspectDate = timestamp
  1356. ins.InspectValue = item.InspectValue1
  1357. ins.ProjectId = 1014
  1358. ins.ItemId = 10879
  1359. writeDb.Create(&ins)
  1360. var ins2 models.Inspection
  1361. ins2.Status = 1
  1362. ins2.PatientId = item.PatientID
  1363. ins2.OrgId = 10677
  1364. ins2.ItemName = "透析后尿素氮"
  1365. ins2.CreatedTime = time.Now().Unix()
  1366. ins2.UpdatedTime = time.Now().Unix()
  1367. ins2.ProjectName = "KT/V"
  1368. ins2.InspectType = 3
  1369. ins2.InspectDate = timestamp
  1370. ins2.InspectValue = item.InspectValue2
  1371. ins2.ProjectId = 1014
  1372. ins2.ItemId = 10878
  1373. writeDb.Create(&ins2)
  1374. var ins3 models.Inspection
  1375. ins3.Status = 1
  1376. ins3.PatientId = item.PatientID
  1377. ins3.OrgId = 10677
  1378. ins3.ItemName = "透析时间"
  1379. ins3.CreatedTime = time.Now().Unix()
  1380. ins3.UpdatedTime = time.Now().Unix()
  1381. ins3.ProjectName = "KT/V"
  1382. ins3.InspectType = 3
  1383. ins3.InspectDate = timestamp
  1384. strValue := fmt.Sprintf("%f", float64(item.ActualTreatmentHour)+item.ActualTreatmentHours)
  1385. ins3.InspectValue = strValue
  1386. ins3.ProjectId = 1014
  1387. ins3.ItemId = 10877
  1388. writeDb.Create(&ins3)
  1389. var ins4 models.Inspection
  1390. ins4.Status = 1
  1391. ins4.PatientId = item.PatientID
  1392. ins4.OrgId = 10677
  1393. ins4.ItemName = "实际超滤量"
  1394. ins4.CreatedTime = time.Now().Unix()
  1395. ins4.UpdatedTime = time.Now().Unix()
  1396. ins4.ProjectName = "KT/V"
  1397. ins4.InspectType = 3
  1398. ins4.InspectDate = timestamp
  1399. strValue2 := fmt.Sprintf("%f", item.ActualUltrafiltration/1000)
  1400. ins4.InspectValue = strValue2
  1401. ins4.ProjectId = 1014
  1402. ins4.ItemId = 10876
  1403. writeDb.Create(&ins4)
  1404. var ins7 models.Inspection
  1405. ins7.Status = 1
  1406. ins7.PatientId = item.PatientID
  1407. ins7.OrgId = 10677
  1408. ins7.ItemName = "透后体重"
  1409. ins7.CreatedTime = time.Now().Unix()
  1410. ins7.UpdatedTime = time.Now().Unix()
  1411. ins7.ProjectName = "KT/V"
  1412. ins7.InspectType = 3
  1413. ins7.InspectDate = timestamp
  1414. strValue5 := fmt.Sprintf("%f", item.WeightAfter)
  1415. ins7.InspectValue = strValue5
  1416. ins7.ProjectId = 1014
  1417. ins7.ItemId = 10874
  1418. writeDb.Create(&ins7)
  1419. var ins8 models.Inspection
  1420. ins8.Status = 1
  1421. ins8.PatientId = item.PatientID
  1422. ins8.OrgId = 10677
  1423. ins8.ItemName = "KT/V"
  1424. ins8.CreatedTime = time.Now().Unix()
  1425. ins8.UpdatedTime = time.Now().Unix()
  1426. ins8.ProjectName = "KT/V"
  1427. ins8.InspectType = 3
  1428. ins8.InspectDate = timestamp
  1429. ins8.InspectValue = ""
  1430. ins8.ProjectId = 1014
  1431. ins8.ItemId = 10950
  1432. C0, _ := strconv.ParseFloat(item.InspectValue1, 64)
  1433. Ct, _ := strconv.ParseFloat(item.InspectValue2, 64)
  1434. a := math.Log((Ct/C0 - (0.008 * (float64(item.ActualTreatmentHour) + item.ActualTreatmentHours))))
  1435. b := (4 - 3.5*(Ct/C0)) * ((item.ActualUltrafiltration / 1000) / item.WeightAfter)
  1436. c := -a + b
  1437. // 格式化输出,保留5位小数
  1438. valueFormatted := fmt.Sprintf("%.5f", c)
  1439. ins8.InspectValue = valueFormatted
  1440. writeDb.Create(&ins8)
  1441. var ins9 models.Inspection
  1442. ins9.Status = 1
  1443. ins9.PatientId = item.PatientID
  1444. ins9.OrgId = 10677
  1445. ins9.ItemName = "URR(%)"
  1446. ins9.CreatedTime = time.Now().Unix()
  1447. ins9.UpdatedTime = time.Now().Unix()
  1448. ins9.ProjectName = "KT/V"
  1449. ins9.InspectType = 3
  1450. ins9.InspectDate = timestamp
  1451. before, _ := strconv.ParseFloat(item.InspectValue1, 64)
  1452. after, _ := strconv.ParseFloat(item.InspectValue2, 64)
  1453. value2 := (((before - after) / before) * 100)
  1454. rounded := math.Round(value2*100) / 100
  1455. strValue6 := fmt.Sprintf("%f", rounded)
  1456. ins9.InspectValue = strValue6
  1457. ins9.ProjectId = 1014
  1458. ins9.ItemId = 10951
  1459. writeDb.Create(&ins9)
  1460. }
  1461. }