app_version.go 101KB

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