city_data_uoload_service.go 78KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909
  1. // 统计后台的 service
  2. package service
  3. import (
  4. "Data_Upload_Api/models"
  5. "Data_Upload_Api/models/sz"
  6. "github.com/jinzhu/gorm"
  7. "strings"
  8. "time"
  9. )
  10. func GetSyncTimeByOrgId(org_id int64, sync_type int64) (sync_info models.XTSyncInfo, err error) {
  11. err = readDb.Model(&models.XTSyncInfo{}).Where("org_id = ? and sync_type = ? ", org_id, sync_type).Last(&sync_info).Error
  12. return
  13. }
  14. func FindAllDataUploadConfigOrgInfo(province_id int64, city_id int64, config_type int64) (data []*sz.DataUploadConfig, err error) {
  15. err = readDb.Model(&sz.DataUploadConfig{}).Where("status = 1 AND province_id = ? AND city_id = ? AND config_type = ?", province_id, city_id, config_type).Find(&data).Error
  16. return
  17. }
  18. func FindDataUploadOrgInfo(org_id int64, module_type int64) (data sz.DataUpload, err error) {
  19. err = readDb.Model(&sz.DataUpload{}).Where(" org_id = ? AND module_type = ?", org_id, module_type).Last(&data).Error
  20. return
  21. }
  22. func FindOrgData(org_id int64, sync_time int64) (org models.UserOrg, err error) {
  23. err = readUserDb.Model(&models.UserOrg{}).Where("status = 1 AND id = ? AND ctime > ?", org_id, sync_time).Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
  24. return readDb.Where("status = 1")
  25. }).Find(&org).Error
  26. return
  27. }
  28. func FindOrgRolesData(org_id int64, lastUploadTime int64, nowTime int64) (role []*models.UserAdminRole, err error) {
  29. db := readUserDb.Model(&models.UserAdminRole{}).Where("status = 1 AND org_id = ? ", org_id)
  30. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  31. err = db.Find(&role).Error
  32. return
  33. }
  34. func FindOrgDeviceZone(org_id int64, lastUploadTime int64, nowTime int64) (role []*models.DeviceZone, err error) {
  35. db := readDb.Model(&models.DeviceZone{}).Where("status = 1 AND org_id = ? ", org_id)
  36. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  37. err = db.Find(&role).Error
  38. return
  39. }
  40. func FindDrugList(org_id int64, lastUploadTime int64, nowTime int64) (drugs []*models.BaseDrugLib, err error) {
  41. db := readDb.Model(&models.BaseDrugLib{}).Where("status = 1 AND org_id = ? ", org_id)
  42. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  43. err = db.Find(&drugs).Error
  44. return
  45. }
  46. func FindProjectList(org_id int64, lastUploadTime int64, nowTime int64) (projects []*models.XtHisProject, err error) {
  47. db := readDb.Model(&models.XtHisProject{}).Where("status = 1 AND user_org_id = ? ", org_id)
  48. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  49. err = db.Find(&projects).Error
  50. return
  51. }
  52. func FindOrgRolesDataNew(org_id int64, lastUploadTime int64, nowTime int64) (role []*models.App_Role, err error) {
  53. db := readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? ", org_id)
  54. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  55. err = db.Find(&role).Error
  56. return
  57. }
  58. func FindOrgPatientData(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
  59. db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ?", org_id)
  60. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  61. err = db.Find(&patient).Error
  62. return
  63. }
  64. func FindHisPatientData(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPatient, err error) {
  65. db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND total_dialysis > 0", org_id)
  66. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  67. err = db.Find(&patient).Error
  68. return
  69. }
  70. func FindOrgPatientInfoById(id int64) (*models.Patients, error) {
  71. var patient models.Patients
  72. db := readDb.Model(&models.Patients{}).Where("status = 1 AND id = ?", id)
  73. err = db.First(&patient).Error
  74. return &patient, err
  75. }
  76. func FindOrgHisPatient(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPatient, err error) {
  77. db := readDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ?", org_id)
  78. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  79. err = db.Find(&patient).Error
  80. return
  81. }
  82. func FindOrgHisPatientCnt(org_id int64, sync_date int64) (total int64, err error) {
  83. err = readDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ?", org_id).Where("record_date = ? ", sync_date).Count(&total).Error
  84. return total, err
  85. }
  86. func FindOrgHisPatientCntOne(orgid int64, startime int64) (models.ResultOne, error) {
  87. info := models.ResultOne{}
  88. db := XTReadDB().Table("his_order as x").Where("x.status = 1").Where("x.order_status = 2").Where("x.user_org_id = ?", orgid).Where("x.settle_accounts_date = ?", startime)
  89. err = db.Select("sum(p.det_item_fee_sumamt) as sumamt,sum(p.inscp_scp_amt) as amt").Joins("left join his_order_info as p on p.order_id = x.id").Scan(&info).Error
  90. return info, err
  91. }
  92. func FindOrgHisPatientCntTwo(orgid int64, startime int64) (models.ResultOne, error) {
  93. result := models.ResultOne{}
  94. db := XTReadDB().Table("his_order as x").Where("x.status = 1").Where("x.order_status = 2").Where("x.user_org_id = ?", orgid).Where("x.settle_accounts_date = ?", startime)
  95. err = db.Select("sum(p.det_item_fee_sumamt) as sumamt,sum(p.inscp_scp_amt) as amt").Joins("left join his_order_info as p on p.order_id = x.id and p.advice_id > 0").Scan(&result).Error
  96. return result, err
  97. }
  98. func FindOrgHisPrescriptionInfo(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPrescriptionInfo, err error) {
  99. db := readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ?", org_id)
  100. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  101. err = db.Find(&patient).Error
  102. return
  103. }
  104. func FindOrgHisPrescription(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPrescription, err error) {
  105. db := readDb.Model(&models.HisPrescription{}).Where("status = 1 AND user_org_id = ?", org_id)
  106. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  107. err = db.Find(&patient).Error
  108. return
  109. }
  110. func FindOrgHisDoctorAdviceInfo(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisDoctorAdviceInfo, err error) {
  111. db := readDb.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ?", org_id)
  112. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  113. err = db.Find(&patient).Error
  114. return
  115. }
  116. func FindOrgHisDoctorAdviceInfoByPid(org_id int64, pid int64) (patient []*models.HisDoctorAdviceInfo, err error) {
  117. db := readDb.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ? and prescription_id = ?", org_id)
  118. err = db.Find(&patient).Error
  119. return
  120. }
  121. func FindOrgHisOrder(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisOrder, err error) {
  122. db := readDb.Model(&models.HisOrder{}).Where("status = 1 AND user_org_id = ?", org_id)
  123. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  124. err = db.Find(&patient).Error
  125. return
  126. }
  127. func FindOrgHisOrderInfo(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisOrderInfo, err error) {
  128. db := readDb.Model(&models.HisOrderInfo{}).Where("status = 1 AND user_org_id = ?", org_id)
  129. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  130. err = db.Find(&patient).Error
  131. return
  132. }
  133. func GetHisOrderByNumber(order_number string) (*models.HisOrder, error) {
  134. var order models.HisOrder
  135. db := readDb.Model(&models.HisOrder{}).Where("number = ? AND status = 1 ", order_number)
  136. err = db.First(&order).Error
  137. return &order, err
  138. }
  139. func GetHisDoctorAdviceInfo(id int64) (*models.HisDoctorAdviceInfo, error) {
  140. var order models.HisDoctorAdviceInfo
  141. db := readDb.Model(&models.HisDoctorAdviceInfo{}).Where("id = ? AND status = 1 ", id)
  142. err = db.Find(&order).Error
  143. return &order, err
  144. }
  145. func GetHisPrescriptionProjectInfo(id int64) (*models.HisPrescriptionProject, error) {
  146. var order models.HisPrescriptionProject
  147. db := readDb.Model(&models.HisPrescriptionProject{}).Where("id = ? AND status = 1 ", id)
  148. err = db.Find(&order).Error
  149. return &order, err
  150. }
  151. func GetHisProjectInfo(id int64) (*models.HisProject, error) {
  152. var order models.HisProject
  153. db := readDb.Model(&models.HisProject{}).Where("id = ? AND status = 1 ", id)
  154. err = db.Find(&order).Error
  155. return &order, err
  156. }
  157. func GetGoodInfo(id int64) (*models.GoodInfo, error) {
  158. var order models.GoodInfo
  159. db := readDb.Model(&models.GoodInfo{}).Where("id = ? AND status = 1 ", id)
  160. err = db.Find(&order).Error
  161. return &order, err
  162. }
  163. func GetHisOrderInfoByNumber(order_number string) (order []*models.HisOrderInfo, err error) {
  164. db := readDb.Model(&models.HisOrderInfo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  165. return db.Preload("BaseDrugLib", "status = 1").Where("status = 1")
  166. })
  167. err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
  168. return
  169. }
  170. func FindOrgHisPrescriptionById(id int64) (*models.HisPrescription, error) {
  171. var HisPrescription models.HisPrescription
  172. db := readDb.Model(&models.HisPrescription{}).Where("status = 1 and id =? ", id)
  173. err = db.First(&HisPrescription).Error
  174. return &HisPrescription, err
  175. }
  176. func FindBaseDrugLibById(id int64) (*models.BaseDrugLib, error) {
  177. var BaseDrugLib models.BaseDrugLib
  178. db := readDb.Model(&models.BaseDrugLib{}).Where("status = 1 and id =? ", id)
  179. err = db.First(&BaseDrugLib).Error
  180. return &BaseDrugLib, err
  181. }
  182. func FindOrgHisPrescriptionInfoByNumber(org_id int64, prescription_number string) (*models.HisPrescriptionInfo, error) {
  183. var HisPrescriptionInfo models.HisPrescriptionInfo
  184. db := readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ? and prescription_number =? ", org_id, prescription_number)
  185. err = db.First(&HisPrescriptionInfo).Error
  186. return &HisPrescriptionInfo, err
  187. }
  188. func FindOrgHisPatientInfo(org_id int64, record_date int64, patient_id int64) (*models.HisPatient, error) {
  189. var HisPatient models.HisPatient
  190. db := readDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ? and record_date =? and patient_id = ?", org_id, record_date, patient_id)
  191. err = db.First(&HisPatient).Error
  192. return &HisPatient, err
  193. }
  194. func FindOrgPatientDataOne(org_id int64) (patient []*models.Patients, err error) {
  195. db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ?", org_id)
  196. err = db.Find(&patient).Error
  197. return
  198. }
  199. func FindOrgPatientInfectious(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
  200. db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND lapseto = 2 ", org_id)
  201. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  202. err = db.Find(&patient).Error
  203. return
  204. }
  205. func FindOrgDeviceNumber(org_id int64, lastUploadTime int64, nowTime int64) (devices []*models.DeviceNumber, err error) {
  206. db := readDb.Model(&models.DeviceNumber{}).Where("status = 1 AND org_id = ?", org_id)
  207. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  208. err = db.Find(&devices).Error
  209. return
  210. }
  211. func FindOrgPatientOutData(lastUploadTime int64, nowTime int64) (patient []*models.PatientLapseto, err error) {
  212. db := readDb.Model(&models.PatientLapseto{}).Where("status = 1 AND lapseto_type >= 2 ")
  213. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  214. err = db.Find(&patient).Error
  215. return
  216. }
  217. func FindOrgPatientOutDataTwo(lastUploadTime int64, nowTime int64) (patient []*models.XtPatientAllergic, err error) {
  218. db := readDb.Model(&models.XtPatientAllergic{}).Where("status = 1 AND patient_source >= 2 ")
  219. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  220. err = db.Find(&patient).Error
  221. return
  222. }
  223. func FindOrgPatientOutDataByID(patient_id int64) (*models.PatientLapseto, error) {
  224. var patient models.PatientLapseto
  225. db := readDb.Model(&models.PatientLapseto{}).Where("status = 1 AND lapseto_type >= 2 AND patient_id =? ", patient_id)
  226. err = db.First(&patient).Error
  227. return &patient, err
  228. }
  229. func FindOrgScheduleData(org_id int64, lastUploadTime int64, nowTime int64) (sch []*models.Schedule, err error) {
  230. db := readDb.Model(&models.Schedule{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DeviceNumber", "status = 1")
  231. if lastUploadTime != 0 && nowTime != 0 {
  232. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  233. }
  234. err = db.Find(&sch).Error
  235. return
  236. }
  237. func FindOrgDialysisPrescriptionData(org_id int64, lastUploadTime int64, nowTime int64) (ps []*models.DialysisPrescription, err error) {
  238. db := readDb.Model(&models.DialysisPrescription{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DialysisOrder", "status = 1")
  239. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  240. err = db.Find(&ps).Error
  241. return
  242. }
  243. func FindOrgDoctorAdviceTemplateData(org_id int64, lastUploadTime int64, nowTime int64) (advice []*models.DoctorAdviceTemplate, err error) {
  244. db := readDb.Model(&models.DoctorAdviceTemplate{}).Where("status = 1 AND org_id = ? and advice_type = 0 ", org_id)
  245. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  246. err = db.Find(&advice).Error
  247. return
  248. }
  249. func FindOrgDoctorAdvice(org_id int64, lastUploadTime int64, nowTime int64) (advice []*models.DoctorAdvice, err error) {
  250. db := readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND org_id = ? ", org_id)
  251. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  252. err = db.Find(&advice).Error
  253. return
  254. }
  255. func FindAssessmentBeforeDislysis(org_id int64, patient_id int64) (before models.AssessmentBeforeDislysis, err error) {
  256. db := readDb.Model(&models.AssessmentBeforeDislysis{}).Where("status = 1 AND user_org_id = ? and patient_id = ? ", org_id, patient_id)
  257. err = db.Last(&before).Error
  258. return
  259. }
  260. func FindOrgMonitorRecordData(org_id int64, lastUploadTime int64, nowTime int64) (monitor []*models.MonitoringRecord, err error) {
  261. db := readDb.Model(&models.MonitoringRecord{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DialysisOrder", "status = 1")
  262. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  263. err = db.Find(&monitor).Error
  264. return
  265. }
  266. func FindOrgMonitorRecordByLike(org_id int64, keyword string, lastUploadTime int64, nowTime int64) (monitor []*models.MonitoringRecord, err error) {
  267. db := readDb.Model(&models.MonitoringRecord{}).Where("status = 1 AND user_org_id = ? AND symptom like ?", org_id, keyword)
  268. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  269. err = db.Find(&monitor).Error
  270. return
  271. }
  272. func FindOrgInspection(org_id int64, lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
  273. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("Patients", "status = 1")
  274. db = db.Where("inspect_date >= ? AND inspect_date <= ?", lastUploadTime, nowTime).Group("inspect_date,project_id,patient_id")
  275. err = db.Find(&inspection).Error
  276. return
  277. }
  278. func FindLisReportByLAB(rdb *gorm.DB, lab_sno string) (lisreport []*sz.TempHdLisReport, err error) {
  279. db := rdb.Model(&sz.TempHdLisReport{}).Where("LAB_SNO = ? ", lab_sno)
  280. err = db.Find(&lisreport).Error
  281. return
  282. }
  283. func FindLisINDICATORSByNo(rdb *gorm.DB, lab_sno string, inspected_result_no string) (lisreport []*sz.TempHdLisIndicators, err error) {
  284. db := rdb.Model(&sz.TempHdLisIndicators{}).Where("LAB_SNO = ? AND INSPECTED_RESULT_NO = ?", lab_sno, inspected_result_no)
  285. err = db.Find(&lisreport).Error
  286. return
  287. }
  288. func FindLisINDICATORSByNoUpdate(rdb *gorm.DB, lab_sno string, inspected_result_no string, inspected_result_desc string, inspected_result_unit string, create_time time.Time) (err error) {
  289. err = rdb.Exec("update t_hd_lis_indicators set inspected_result_desc = ?,inspected_result_value = ?,inspected_result_unit = ?,create_time = ? "+
  290. "WHERE LAB_SNO = ? and INSPECTED_RESULT_NO = ? ", inspected_result_desc, inspected_result_desc, inspected_result_unit, create_time, lab_sno, inspected_result_no).Error
  291. return
  292. }
  293. func FindOrgInspectionTwo(org_id int64, lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
  294. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("XtInspectionReference", "status = 1")
  295. db = db.Where("inspect_date >= ? AND inspect_date <= ?", lastUploadTime, nowTime)
  296. err = db.Find(&inspection).Error
  297. return
  298. }
  299. func FindOrgInspectionThree(org_id int64, lastUploadTime int64, nowTime int64, itemid string) (inspection []*models.XtInspection, err error) {
  300. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("XtInspectionReference", "status = 1")
  301. db = db.Where("inspect_date >= ? AND inspect_date <= ? AND item_id = ?", lastUploadTime, nowTime, itemid)
  302. err = db.Find(&inspection).Error
  303. return
  304. }
  305. // 传染病查询
  306. func FindOrgInspectionGroupOne(org_id int64, lastUploadTime int64, nowTime int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  307. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id = 14 and patient_id = ?", org_id, patient_id)
  308. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
  309. err = db.Find(&inspection).Error
  310. return
  311. }
  312. // 传染病查询 龙岗二院
  313. func FindOrgInspectionGroupLgey(org_id int64, lastUploadTime int64, nowTime int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  314. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id in(14,18006,18008,18044,18051,18065,18076,18078,18114,18130,18131,18141,18142,18143,18167,18169,18175,18176,18178,18230,18241,18245,18246,14) and patient_id = ?", org_id, patient_id)
  315. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
  316. err = db.Find(&inspection).Error
  317. return
  318. }
  319. // 传染病查询
  320. func FindOrgInspectionGroupLgeyTwo(org_id int64, inspect_date int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  321. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id in(18006,18008,18044,18051,18065,18076,18078,18114,18130,18131,18141,18142,18143,18167,18169,18175,18176,18178,18230,18241,18245,18246,14) and patient_id = ? and inspect_date = ?", org_id, patient_id, inspect_date)
  322. err = db.Find(&inspection).Error
  323. return
  324. }
  325. // 传染病查询 深圳百霖
  326. func FindOrgInspectionGroupSzbl(org_id int64, lastUploadTime int64, nowTime int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  327. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id in (1013800,1013870) and patient_id = ?", org_id, patient_id)
  328. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
  329. err = db.Find(&inspection).Error
  330. return
  331. }
  332. // 传染病查询 深圳百霖贝尔
  333. func FindOrgInspectionGroupSzblbr(org_id int64, lastUploadTime int64, nowTime int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  334. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id in (1013803,1013856) and patient_id = ?", org_id, patient_id)
  335. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
  336. err = db.Find(&inspection).Error
  337. return
  338. }
  339. // 传染病查询
  340. func FindOrgInspectionGroupSzblTwo(org_id int64, inspect_date int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  341. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id in (1013800,1013870) and patient_id = ? and inspect_date = ?", org_id, patient_id, inspect_date)
  342. err = db.Find(&inspection).Error
  343. return
  344. }
  345. // 传染病查询
  346. func FindOrgInspectionGroupSzblbrTwo(org_id int64, inspect_date int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  347. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id in (1013803,1013856) and patient_id = ? and inspect_date = ?", org_id, patient_id, inspect_date)
  348. err = db.Find(&inspection).Error
  349. return
  350. }
  351. // 传染病查询
  352. func FindOrgInspectionGroupTwo(org_id int64, inspect_date int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  353. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id = 14 and patient_id = ? and inspect_date = ?", org_id, patient_id, inspect_date)
  354. err = db.Find(&inspection).Error
  355. return
  356. }
  357. func FindOrgInspectionReference(org_id int64, lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
  358. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("XtInspectionReference", "status = 1")
  359. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  360. err = db.Find(&inspection).Error
  361. return
  362. }
  363. func CreateOrgRecord(rdb *gorm.DB, hospital *sz.TempHdHospital) (err error) {
  364. err = rdb.Model(&sz.TempHdHospital{}).Create(&hospital).Error
  365. return
  366. }
  367. func CreateUploadRecord(upload *sz.DataUpload) (err error) {
  368. err = writeDb.Model(&sz.DataUpload{}).Create(&upload).Error
  369. return
  370. }
  371. func FindOrgDialysisData(org_id int64, lastUploadTime int64, nowTime int64) (ps []*models.VMDialysisOrder, err error) {
  372. db := readDb.Model(&models.VMDialysisOrder{}).Where("status = 1 AND user_org_id = ? AND stage = 2 ", org_id).
  373. Preload("DeviceNumber", "status = 1").
  374. Preload("VMDialysisPrescription", "status = 1").
  375. Preload("AssessmentBeforeDislysis", "status = 1").
  376. Preload("AssessmentAfterDislysis", "status = 1").
  377. Preload("Schedule", "status = 1").
  378. Preload("MonitoringRecord", "status = 1")
  379. if lastUploadTime != 0 && nowTime != 0 {
  380. db = db.Where("updated_time >= ? AND updated_time <= ?", lastUploadTime, nowTime)
  381. }
  382. err = db.Find(&ps).Error
  383. return
  384. }
  385. func FindOrgDeviceZoneRecordData(org_id int64, lastUploadTime int64, nowTime int64) (zone []*models.DeviceZone, err error) {
  386. db := readDb.Model(&models.DeviceZone{}).Where("status = 1 AND org_id = ?", org_id)
  387. if lastUploadTime != 0 && nowTime != 0 {
  388. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  389. }
  390. err = db.Find(&zone).Error
  391. return
  392. }
  393. func FindOrgWaterMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
  394. db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ? AND device_type = 2", org_id)
  395. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  396. err = db.Find(&waterMachine).Error
  397. return
  398. }
  399. func FindSyncPatientAllData(rdb *gorm.DB) (hdPatients []*sz.TempHdPatient, err error) {
  400. err = rdb.Model(&sz.TempHdPatient{}).Find(&hdPatients).Error
  401. return
  402. }
  403. func UpdateSyncPatient(patientId int64, ylyl1 string, rdb *gorm.DB) (err error) {
  404. err = rdb.Model(&sz.TempHdPatient{}).Where("patient_nk = ?", patientId).Update("ylyl1", ylyl1).Error
  405. return
  406. }
  407. func FindSyncPatient(patientId int64, rdb *gorm.DB) (hdPatients []*sz.TempHdPatient, err error) {
  408. err = rdb.Model(&sz.TempHdPatient{}).Where("patient_nk = ?", patientId).Find(&hdPatients).Error
  409. return
  410. }
  411. func FindSyncPatientOut(patientId int64, rdb *gorm.DB) (hdPatients []*sz.TempHdPatientOut, err error) {
  412. err = rdb.Model(&sz.TempHdPatientOut{}).Where("patient_nk = ?", patientId).Find(&hdPatients).Error
  413. return
  414. }
  415. func FindPatientInfoByIdno(idno string) (patient models.Patients, err error) {
  416. err = readDb.Model(&models.Patients{}).Where("id_card_no = ?", idno).First(&patient).Error
  417. return
  418. }
  419. func BatchCreateWMsRecord(wms []*sz.TempHdWm, rdb *gorm.DB) (err error) {
  420. if len(wms) > 0 {
  421. utx := rdb
  422. if len(wms) > 0 {
  423. thisSQL := "INSERT INTO t_hd_wm (hospital_id, equipment_id, equipment_brand, enable_time,equipment_type,xgbz,create_time,update_time,sjscsj) VALUES "
  424. insertParams := make([]string, 0)
  425. insertData := make([]interface{}, 0)
  426. for _, wm := range wms {
  427. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
  428. insertData = append(insertData, wm.HospitalId)
  429. insertData = append(insertData, wm.EquipmentId)
  430. insertData = append(insertData, wm.EquipmentBrand)
  431. insertData = append(insertData, wm.EnableTime)
  432. insertData = append(insertData, wm.EquipmentType)
  433. insertData = append(insertData, wm.Xgbz)
  434. insertData = append(insertData, wm.CreateTime)
  435. insertData = append(insertData, wm.UpdateTime)
  436. insertData = append(insertData, wm.Sjscsj)
  437. }
  438. thisSQL += strings.Join(insertParams, ", ")
  439. // err = utx.Exec(thisSQL, insertData...).Error
  440. // if err != nil {
  441. // utx.Rollback()
  442. // return
  443. // }
  444. utx.Exec(thisSQL, insertData...)
  445. }
  446. // utx.Commit()
  447. }
  448. return
  449. }
  450. func BatchCreateStaffRecord(staffs []*sz.TempHdStaff, rdb *gorm.DB) (err error) {
  451. if len(staffs) > 0 {
  452. utx := rdb
  453. if len(staffs) > 0 {
  454. var id_no int64
  455. id_no = 429001198701091670
  456. for _, info := range staffs {
  457. thisSQL := "INSERT INTO t_hd_staff (hospital_id,staff_id, id_no,id_type,staff_name, position, staff_status, staff_no, permanent_type, in_date ,create_time, sjscsj, xgbz) VALUES "
  458. insertParams := make([]string, 0)
  459. insertData := make([]interface{}, 0)
  460. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
  461. insertData = append(insertData, info.HospitalId)
  462. insertData = append(insertData, info.StaffId)
  463. insertData = append(insertData, id_no)
  464. insertData = append(insertData, "01")
  465. insertData = append(insertData, info.StaffName)
  466. insertData = append(insertData, info.Position)
  467. insertData = append(insertData, "0")
  468. insertData = append(insertData, info.StaffId)
  469. insertData = append(insertData, info.PermanentType)
  470. insertData = append(insertData, "2019-09-01")
  471. insertData = append(insertData, info.CreateTime)
  472. insertData = append(insertData, info.Sjscsj)
  473. insertData = append(insertData, info.Xgbz)
  474. thisSQL += strings.Join(insertParams, ", ")
  475. utx.Exec(thisSQL, insertData...)
  476. id_no++
  477. }
  478. }
  479. // utx.Commit()
  480. }
  481. return
  482. }
  483. func BatchCreateLayoutRecord(layouts []*sz.TempHdLayout, rdb *gorm.DB) (err error) {
  484. if len(layouts) > 0 {
  485. utx := rdb
  486. if len(layouts) > 0 {
  487. for _, info := range layouts {
  488. thisSQL := "INSERT INTO t_hd_layout (hospital_id,partition_name,create_time, sjscsj, xgbz) VALUES "
  489. insertParams := make([]string, 0)
  490. insertData := make([]interface{}, 0)
  491. insertParams = append(insertParams, "(?,?,?,?,?)")
  492. insertData = append(insertData, info.HospitalId)
  493. insertData = append(insertData, info.PartitionName)
  494. insertData = append(insertData, info.CreateTime)
  495. insertData = append(insertData, info.Sjscsj)
  496. insertData = append(insertData, info.Xgbz)
  497. thisSQL += strings.Join(insertParams, ", ")
  498. utx.Exec(thisSQL, insertData...)
  499. }
  500. }
  501. // utx.Commit()
  502. }
  503. return
  504. }
  505. func BatchCreatePatinet(patients []*sz.TempHdPatient, rdb *gorm.DB) (err error) {
  506. if len(patients) > 0 {
  507. utx := rdb
  508. if len(patients) > 0 {
  509. for _, info := range patients {
  510. thisSQL := "INSERT INTO t_hd_patient ( hospital_id, patient_nk, card_no, card_type, id_no, id_type, patient_name, gender, born_date, diagnosis_summary, is_crf, pay_method, local_insurance, dialysis_start_time, local_start_time, outpatient_no, hospitalized_no, xgbz, create_time, update_time, sjscsj,ylyl1) VALUES "
  511. insertParams := make([]string, 0)
  512. insertData := make([]interface{}, 0)
  513. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  514. insertData = append(insertData, info.HospitalId)
  515. insertData = append(insertData, info.PatientNk)
  516. insertData = append(insertData, info.CardNo)
  517. insertData = append(insertData, info.CardType)
  518. insertData = append(insertData, info.IdNo)
  519. insertData = append(insertData, info.IdType)
  520. insertData = append(insertData, info.PatientName)
  521. insertData = append(insertData, info.Gender)
  522. insertData = append(insertData, info.BornDate)
  523. insertData = append(insertData, info.DiagnosisSummary)
  524. insertData = append(insertData, info.IsCrf)
  525. insertData = append(insertData, "02")
  526. insertData = append(insertData, "1")
  527. insertData = append(insertData, info.DialysisStartTime)
  528. insertData = append(insertData, info.LocalStartTime)
  529. insertData = append(insertData, info.OutpatientNo)
  530. insertData = append(insertData, info.HospitalizedNo)
  531. insertData = append(insertData, info.Xgbz)
  532. insertData = append(insertData, info.CreateTime)
  533. insertData = append(insertData, info.UpdateTime)
  534. insertData = append(insertData, info.Sjscsj)
  535. insertData = append(insertData, info.Ylyl1)
  536. thisSQL += strings.Join(insertParams, ", ")
  537. utx.Exec(thisSQL, insertData...)
  538. }
  539. }
  540. // utx.Commit()
  541. }
  542. return
  543. }
  544. func BatchCreateSchedual(patients []*sz.TempHdShift, rdb *gorm.DB) (err error) {
  545. if len(patients) > 0 {
  546. utx := rdb
  547. if len(patients) > 0 {
  548. for _, info := range patients {
  549. thisSQL := "INSERT INTO t_hd_shift (ps_id, hospital_id, patient_nk, schedule_date, shift_type,sickbed_no,schedule_status,create_time,sjscsj,xgbz) VALUES "
  550. insertParams := make([]string, 0)
  551. insertData := make([]interface{}, 0)
  552. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  553. insertData = append(insertData, info.PsId)
  554. insertData = append(insertData, info.HospitalId)
  555. insertData = append(insertData, info.PatientNk)
  556. insertData = append(insertData, info.ScheduleDate)
  557. insertData = append(insertData, info.ShiftType)
  558. insertData = append(insertData, info.SickbedNo)
  559. insertData = append(insertData, info.ScheduleStatus)
  560. insertData = append(insertData, info.CreateTime)
  561. insertData = append(insertData, info.Sjscsj)
  562. insertData = append(insertData, info.Xgbz)
  563. thisSQL += strings.Join(insertParams, ", ")
  564. utx.Exec(thisSQL, insertData...)
  565. }
  566. }
  567. // utx.Commit()
  568. }
  569. return
  570. }
  571. func BatchCreatePs(patients []*sz.TempHdPs, rdb *gorm.DB) (err error) {
  572. if len(patients) > 0 {
  573. utx := rdb
  574. if len(patients) > 0 {
  575. thisSQL := "INSERT INTO t_hd_ps (prescribe_id,hospital_id,patient_nk,rrt_type,rrt_type_name,dialysis_frequency,frequency_unit,prescribe_time,create_time,sjscsj,xgbz) VALUES "
  576. insertParams := make([]string, 0)
  577. insertData := make([]interface{}, 0)
  578. for _, info := range patients {
  579. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  580. insertData = append(insertData, info.PrescribeId)
  581. insertData = append(insertData, info.HospitalId)
  582. insertData = append(insertData, info.PatientNk)
  583. insertData = append(insertData, info.RrtType)
  584. insertData = append(insertData, info.RrtTypeName)
  585. insertData = append(insertData, info.DialysisFrequency)
  586. insertData = append(insertData, info.FrequencyUnit)
  587. insertData = append(insertData, info.PrescribeTime)
  588. insertData = append(insertData, info.CreateTime)
  589. insertData = append(insertData, info.Sjscsj)
  590. insertData = append(insertData, info.Xgbz)
  591. }
  592. thisSQL += strings.Join(insertParams, ", ")
  593. // err = utx.Exec(thisSQL, insertData...).Error
  594. // if err != nil {
  595. // utx.Rollback()
  596. // return
  597. // }
  598. utx.Exec(thisSQL, insertData...)
  599. }
  600. // utx.Commit()
  601. }
  602. return
  603. }
  604. func BatchCreatePsOther(ps *sz.TempHdPs, rdb *gorm.DB) (err error) {
  605. err = rdb.Create(&ps).Error
  606. return err
  607. }
  608. func BatchCreatePsm(psms []*sz.TempHdPsMedicine, rdb *gorm.DB) (err error) {
  609. if len(psms) > 0 {
  610. utx := rdb
  611. if len(psms) > 0 {
  612. for _, psm := range psms {
  613. thisSQL := "INSERT INTO t_hd_ps_medicine (sn,hospital_id, medicine_type_id,medicine_id,create_time,sjscsj,xgbz) VALUES "
  614. insertParams := make([]string, 0)
  615. insertData := make([]interface{}, 0)
  616. insertParams = append(insertParams, "(?,?,?,?,?,?,?)")
  617. insertData = append(insertData, psm.Sn)
  618. insertData = append(insertData, psm.HospitalId)
  619. insertData = append(insertData, psm.MedicineTypeId)
  620. insertData = append(insertData, psm.MedicineId)
  621. insertData = append(insertData, psm.CreateTime)
  622. insertData = append(insertData, psm.Sjscsj)
  623. insertData = append(insertData, psm.Xgbz)
  624. thisSQL += strings.Join(insertParams, ", ")
  625. // err = utx.Exec(thisSQL, insertData...).Error
  626. utx.Exec(thisSQL, insertData...)
  627. }
  628. // if err != nil {
  629. // utx.Rollback()
  630. // return
  631. // }
  632. }
  633. // utx.Commit()
  634. }
  635. return
  636. }
  637. func BatchCreateDialysis(psms []*sz.TempHdDialysis, rdb *gorm.DB) (err error) {
  638. if len(psms) > 0 {
  639. utx := rdb
  640. if len(psms) > 0 {
  641. for _, psm := range psms {
  642. thisSQL := "INSERT INTO t_hd_dialysis (dialysis_id,hospital_id,patient_nk,ps_id,dialysis_date,sickbed_no,division_id,equipment_id,mix_dialysis,ufv,total_treat_duration,is_hospitalization,is_emergency,is_perioperative_period,before_sbp,before_dbp,after_sbp,after_dbp,before_weight,after_weight,ktv,urr,up_nurse_id,down_nurse_id,check_nurse_id,puncture_nurse_id,start_time,end_time,create_time,sjscsj,xgbz,charge_doctor_id,charge_nurse_id) VALUES "
  643. insertParams := make([]string, 0)
  644. insertData := make([]interface{}, 0)
  645. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  646. insertData = append(insertData, psm.DialysisId)
  647. insertData = append(insertData, psm.HospitalId)
  648. insertData = append(insertData, psm.PatientNk)
  649. insertData = append(insertData, psm.PsId)
  650. insertData = append(insertData, psm.DialysisDate)
  651. insertData = append(insertData, psm.SickbedNo)
  652. insertData = append(insertData, psm.DivisionId)
  653. insertData = append(insertData, psm.EquipmentId)
  654. insertData = append(insertData, psm.MixDialysis)
  655. insertData = append(insertData, psm.Ufv)
  656. insertData = append(insertData, psm.TotalTreatDuration)
  657. insertData = append(insertData, psm.IsHospitalization)
  658. insertData = append(insertData, psm.IsEmergency)
  659. insertData = append(insertData, psm.IsPerioperativePeriod)
  660. insertData = append(insertData, psm.BeforeSbp)
  661. insertData = append(insertData, psm.BeforeDbp)
  662. insertData = append(insertData, psm.AfterSbp)
  663. insertData = append(insertData, psm.AfterDbp)
  664. insertData = append(insertData, psm.BeforeWeight)
  665. insertData = append(insertData, psm.AfterWeight)
  666. insertData = append(insertData, psm.Ktv)
  667. insertData = append(insertData, psm.Urr)
  668. insertData = append(insertData, psm.UpNurseId)
  669. insertData = append(insertData, psm.DownNurseId)
  670. insertData = append(insertData, psm.CheckNurseId)
  671. insertData = append(insertData, psm.PunctureNurseId)
  672. insertData = append(insertData, psm.StartTime)
  673. insertData = append(insertData, psm.EndTime)
  674. insertData = append(insertData, psm.CreateTime)
  675. insertData = append(insertData, psm.Sjscsj)
  676. insertData = append(insertData, psm.Xgbz)
  677. insertData = append(insertData, psm.ChargeDoctorId)
  678. insertData = append(insertData, psm.ChargeNurseId)
  679. thisSQL += strings.Join(insertParams, ", ")
  680. utx.Exec(thisSQL, insertData...)
  681. }
  682. // if err != nil {
  683. // utx.Rollback()
  684. // return
  685. // }
  686. }
  687. // utx.Commit()
  688. }
  689. return
  690. }
  691. func BatchCreatePatientOut(patientOuts []*sz.TempHdPatientOut, rdb *gorm.DB) (err error) {
  692. if len(patientOuts) > 0 {
  693. utx := rdb
  694. if len(patientOuts) > 0 {
  695. thisSQL := "INSERT INTO t_hd_patient_quit (sn,hospital_id,patient_nk,sequelae_date,sequelae_type,create_time,death_reason,ext_reason,sjscsj,xgbz) VALUES "
  696. insertParams := make([]string, 0)
  697. insertData := make([]interface{}, 0)
  698. for _, out := range patientOuts {
  699. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  700. insertData = append(insertData, out.Sn)
  701. insertData = append(insertData, out.HospitalId)
  702. insertData = append(insertData, out.PatientNk)
  703. insertData = append(insertData, out.SequelaeDate)
  704. insertData = append(insertData, out.SequelaeType)
  705. insertData = append(insertData, out.CreateTime)
  706. insertData = append(insertData, out.DeathReason)
  707. insertData = append(insertData, out.ExtReason)
  708. insertData = append(insertData, out.Sjscsj)
  709. insertData = append(insertData, out.Xgbz)
  710. }
  711. thisSQL += strings.Join(insertParams, ", ")
  712. utx.Exec(thisSQL, insertData...)
  713. // if err != nil {
  714. // utx.Rollback()
  715. // return
  716. // }
  717. }
  718. // utx.Commit()
  719. }
  720. return
  721. }
  722. func BatchCreateDoctorsAdvice(advices []*sz.TempHdDoctorsAdvice, rdb *gorm.DB) (err error) {
  723. if len(advices) > 0 {
  724. utx := rdb
  725. if len(advices) > 0 {
  726. for _, advice := range advices {
  727. thisSQL := "INSERT INTO t_hd_doctors_advice (medical_order_id, hospital_id,dialysis_id,order_type,patient_nk,dialysis_duration,blood_vol,anticoagulant,create_time,sjscsj,xgbz,rrt_type,rrt_type_name,dry_weight) VALUES "
  728. insertParams := make([]string, 0)
  729. insertData := make([]interface{}, 0)
  730. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  731. insertData = append(insertData, advice.MedicalOrderId)
  732. insertData = append(insertData, advice.HospitalId)
  733. insertData = append(insertData, advice.DialysisId)
  734. insertData = append(insertData, advice.OrderType)
  735. insertData = append(insertData, advice.PatientNk)
  736. insertData = append(insertData, advice.DialysisDuration)
  737. insertData = append(insertData, advice.BloodVol)
  738. insertData = append(insertData, advice.Anticoagulant)
  739. insertData = append(insertData, advice.CreateTime)
  740. insertData = append(insertData, advice.Sjscsj)
  741. insertData = append(insertData, advice.Xgbz)
  742. insertData = append(insertData, advice.RrtType)
  743. insertData = append(insertData, advice.RrtTypeName)
  744. insertData = append(insertData, advice.DryWeight)
  745. thisSQL += strings.Join(insertParams, ", ")
  746. utx.Exec(thisSQL, insertData...)
  747. }
  748. // if err != nil {
  749. // utx.Rollback()
  750. // return
  751. // }
  752. }
  753. // utx.Commit()
  754. }
  755. return
  756. }
  757. func BatchCreateMonitor(advices []*sz.TempHdMiddle, rdb *gorm.DB) (err error) {
  758. if len(advices) > 0 {
  759. utx := rdb
  760. if len(advices) > 0 {
  761. for _, advice := range advices {
  762. thisSQL := "INSERT INTO t_hd_middle (sn,hospital_id, patient_nk,dialysis_id,monitor_time,sbp,dbp,create_time,sjscsj,xgbz) VALUES "
  763. insertParams := make([]string, 0)
  764. insertData := make([]interface{}, 0)
  765. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  766. insertData = append(insertData, advice.Sn)
  767. insertData = append(insertData, advice.HospitalId)
  768. insertData = append(insertData, advice.PatientNk)
  769. insertData = append(insertData, advice.DialysisId)
  770. insertData = append(insertData, advice.MonitorTime)
  771. insertData = append(insertData, advice.Sbp)
  772. insertData = append(insertData, advice.Dbp)
  773. insertData = append(insertData, advice.CreateTime)
  774. insertData = append(insertData, advice.Sjscsj)
  775. insertData = append(insertData, advice.Xgbz)
  776. thisSQL += strings.Join(insertParams, ", ")
  777. utx.Exec(thisSQL, insertData...)
  778. }
  779. // if err != nil {
  780. // utx.Rollback()
  781. // return
  782. // }
  783. }
  784. // utx.Commit()
  785. }
  786. return
  787. }
  788. func FindOrgOtherMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
  789. db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ? AND device_type = 3", org_id)
  790. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  791. err = db.Find(&waterMachine).Error
  792. return
  793. }
  794. func FindOrgDeviceInformationData(org_id int64, lastUploadTime int64, nowTime int64) (deviceInformation []*models.DeviceInformation, err error) {
  795. db := readUserDb.Model(&models.DeviceInformation{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("VMDeviceAddmacher", "status = 1")
  796. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  797. err = db.Find(&deviceInformation).Error
  798. return
  799. }
  800. func FindOrgMachineRepairData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.DeviceRepair, err error) {
  801. db := readUserDb.Model(&models.DeviceRepair{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("VMDeviceAddmacher", "status = 1")
  802. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  803. err = db.Find(&waterMachine).Error
  804. return
  805. }
  806. func FindOrgDevicePlan(org_id int64, lastUploadTime int64, nowTime int64) (deviceplan []*models.DevicePlan, err error) {
  807. db := readUserDb.Model(&models.DevicePlan{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("VMDeviceAddmacher", "status = 1")
  808. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  809. err = db.Find(&deviceplan).Error
  810. return
  811. }
  812. func BatchCreateOtherMachineRecord(wms []*sz.TempHdOtherMachine, rdb *gorm.DB) (err error) {
  813. if len(wms) > 0 {
  814. utx := rdb
  815. if len(wms) > 0 {
  816. for _, wm := range wms {
  817. thisSQL := "INSERT INTO t_hd_other_machine (hospital_id, equipment_id, equipment_brand, enable_time,status,equipment_type,xgbz,create_time,update_time,sjscsj) VALUES "
  818. insertParams := make([]string, 0)
  819. insertData := make([]interface{}, 0)
  820. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  821. insertData = append(insertData, wm.HospitalId)
  822. insertData = append(insertData, wm.EquipmentId)
  823. insertData = append(insertData, wm.EquipmentBrand)
  824. insertData = append(insertData, wm.EnableTime)
  825. insertData = append(insertData, wm.Status)
  826. insertData = append(insertData, wm.EquipmentType)
  827. insertData = append(insertData, wm.Xgbz)
  828. insertData = append(insertData, wm.CreateTime)
  829. insertData = append(insertData, wm.UpdateTime)
  830. insertData = append(insertData, wm.Sjscsj)
  831. thisSQL += strings.Join(insertParams, ", ")
  832. utx.Exec(thisSQL, insertData...)
  833. }
  834. }
  835. // utx.Commit()
  836. }
  837. return
  838. }
  839. func BatchCreateDmDisinfect(dfs []*sz.TempHdDmDisinfect, rdb *gorm.DB) (err error) {
  840. if len(dfs) > 0 {
  841. utx := rdb
  842. if len(dfs) > 0 {
  843. for _, df := range dfs {
  844. thisSQL := "INSERT INTO t_hd_dm_disinfect (sn,hospital_id, equipment_id, sickbed_no, inspection_time,is_qualified,case_order,xgbz,create_time,sjscsj) VALUES "
  845. insertParams := make([]string, 0)
  846. insertData := make([]interface{}, 0)
  847. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  848. insertData = append(insertData, df.Sn)
  849. insertData = append(insertData, df.HospitalId)
  850. insertData = append(insertData, df.EquipmentId)
  851. insertData = append(insertData, df.SickbedNo)
  852. insertData = append(insertData, df.InspectionTime)
  853. insertData = append(insertData, df.IsQualified)
  854. insertData = append(insertData, df.CaseOrder)
  855. insertData = append(insertData, df.Xgbz)
  856. insertData = append(insertData, df.CreateTime)
  857. insertData = append(insertData, df.Sjscsj)
  858. thisSQL += strings.Join(insertParams, ", ")
  859. utx.Exec(thisSQL, insertData...)
  860. }
  861. }
  862. // utx.Commit()
  863. }
  864. return
  865. }
  866. func BatchCreateWmDisinfect(dfs []*sz.TempWdDmDisinfect, rdb *gorm.DB) (err error) {
  867. if len(dfs) > 0 {
  868. utx := rdb
  869. if len(dfs) > 0 {
  870. for _, df := range dfs {
  871. thisSQL := "INSERT INTO t_hd_wm_disinfect (sn,hospital_id, equipment_id, inspection_time,is_qualified,case_order,xgbz,create_time,sjscsj) VALUES "
  872. insertParams := make([]string, 0)
  873. insertData := make([]interface{}, 0)
  874. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
  875. insertData = append(insertData, df.Sn)
  876. insertData = append(insertData, df.HospitalId)
  877. insertData = append(insertData, df.EquipmentId)
  878. insertData = append(insertData, df.InspectionTime)
  879. insertData = append(insertData, df.IsQualified)
  880. insertData = append(insertData, df.CaseOrder)
  881. insertData = append(insertData, df.Xgbz)
  882. insertData = append(insertData, df.CreateTime)
  883. insertData = append(insertData, df.Sjscsj)
  884. thisSQL += strings.Join(insertParams, ", ")
  885. utx.Exec(thisSQL, insertData...)
  886. }
  887. }
  888. // utx.Commit()
  889. }
  890. return
  891. }
  892. func BatchCreateMainTain(maintain []*sz.TempHdMaintain, rdb *gorm.DB) (err error) {
  893. if len(maintain) > 0 {
  894. utx := rdb
  895. if len(maintain) > 0 {
  896. thisSQL := "INSERT INTO t_hd_maintain (sn,hospital_id, equipment_id, equipment_type, repair_time, xgbz,create_time,sjscsj) VALUES "
  897. insertParams := make([]string, 0)
  898. insertData := make([]interface{}, 0)
  899. for _, wm := range maintain {
  900. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?)")
  901. insertData = append(insertData, wm.Sn)
  902. insertData = append(insertData, wm.HospitalId)
  903. insertData = append(insertData, wm.EquipmentId)
  904. insertData = append(insertData, wm.EquipmentType)
  905. insertData = append(insertData, wm.RepairTime)
  906. insertData = append(insertData, wm.Xgbz)
  907. insertData = append(insertData, wm.CreateTime)
  908. insertData = append(insertData, wm.Sjscsj)
  909. }
  910. thisSQL += strings.Join(insertParams, ", ")
  911. utx.Exec(thisSQL, insertData...)
  912. // if err != nil {
  913. // utx.Rollback()
  914. // return
  915. // }
  916. }
  917. // utx.Commit()
  918. }
  919. return
  920. }
  921. func BatchCreateDisinfectMethod(disinfects []*sz.TempHdDisinfectMethod, rdb *gorm.DB) (err error) {
  922. if len(disinfects) > 0 {
  923. utx := rdb
  924. if len(disinfects) > 0 {
  925. thisSQL := "INSERT INTO t_hd_disinfect_method (hospital_id, equipment_id, equipment_type, disinfect_method,disinfector,concentration, xgbz,create_time,update_time,sjscsj) VALUES "
  926. insertParams := make([]string, 0)
  927. insertData := make([]interface{}, 0)
  928. for _, wm := range disinfects {
  929. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  930. insertData = append(insertData, wm.HospitalId)
  931. insertData = append(insertData, wm.EquipmentId)
  932. insertData = append(insertData, wm.EquipmentType)
  933. insertData = append(insertData, wm.DisinfectMethod)
  934. insertData = append(insertData, wm.Disinfector)
  935. insertData = append(insertData, wm.Concentration)
  936. insertData = append(insertData, wm.Xgbz)
  937. insertData = append(insertData, wm.CreateTime)
  938. insertData = append(insertData, wm.UpdateTime)
  939. insertData = append(insertData, wm.Sjscsj)
  940. }
  941. thisSQL += strings.Join(insertParams, ", ")
  942. utx.Exec(thisSQL, insertData...)
  943. // if err != nil {
  944. // utx.Rollback()
  945. // return
  946. // }
  947. }
  948. // utx.Commit()
  949. }
  950. return
  951. }
  952. func FindOrgMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
  953. db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND device_type = 1 and user_org_id = ?", org_id).Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
  954. return readDb.Model(&models.DeviceNumber{}).Where("status = 1")
  955. })
  956. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  957. err = db.Find(&waterMachine).Error
  958. return
  959. }
  960. func BatchCreateHDMRecord(wms []*sz.TempHdDm, rdb *gorm.DB) (err error) {
  961. if len(wms) > 0 {
  962. utx := rdb
  963. if len(wms) > 0 {
  964. for _, wm := range wms {
  965. thisSQL := "INSERT INTO t_hd_dm (hospital_id, equipment_id,sickbed_no,sickbed_type ,equipment_brand, enable_time,status,equipment_type, xgbz,bbp,create_time,update_time,sjscsj) VALUES "
  966. insertParams := make([]string, 0)
  967. insertData := make([]interface{}, 0)
  968. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
  969. insertData = append(insertData, wm.HospitalId)
  970. insertData = append(insertData, wm.EquipmentId)
  971. insertData = append(insertData, wm.SickbedNo)
  972. insertData = append(insertData, wm.SickbedType)
  973. insertData = append(insertData, wm.EquipmentBrand)
  974. insertData = append(insertData, wm.EnableTime)
  975. insertData = append(insertData, wm.Status)
  976. insertData = append(insertData, wm.EquipmentType)
  977. insertData = append(insertData, wm.Xgbz)
  978. insertData = append(insertData, wm.Bbp)
  979. insertData = append(insertData, wm.CreateTime)
  980. insertData = append(insertData, wm.UpdateTime)
  981. insertData = append(insertData, wm.Sjscsj)
  982. thisSQL += strings.Join(insertParams, ", ")
  983. utx.Exec(thisSQL, insertData...)
  984. }
  985. // if err != nil {
  986. // utx.Rollback()
  987. // return
  988. // }
  989. }
  990. // utx.Commit()
  991. }
  992. return
  993. }
  994. func CreateHDDivision(wms []*sz.TempHdDivision, rdb *gorm.DB) (err error) {
  995. if len(wms) > 0 {
  996. utx := rdb
  997. if len(wms) > 0 {
  998. for _, wm := range wms {
  999. thisSQL := "INSERT INTO t_hd_division (division_id,hospital_id, division_name,division_type, xgbz,create_time,update_time,sjscsj) VALUES "
  1000. insertParams := make([]string, 0)
  1001. insertData := make([]interface{}, 0)
  1002. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?)")
  1003. insertData = append(insertData, wm.DivisionId)
  1004. insertData = append(insertData, wm.HospitalId)
  1005. insertData = append(insertData, wm.DivisionName)
  1006. insertData = append(insertData, wm.DivisionType)
  1007. insertData = append(insertData, wm.Xgbz)
  1008. insertData = append(insertData, wm.CreateTime)
  1009. insertData = append(insertData, wm.UpdateTime)
  1010. insertData = append(insertData, wm.Sjscsj)
  1011. thisSQL += strings.Join(insertParams, ", ")
  1012. utx.Exec(thisSQL, insertData...)
  1013. }
  1014. }
  1015. }
  1016. return
  1017. }
  1018. func CreateAccess(wms []*sz.TempHdAccess, rdb *gorm.DB) (err error) {
  1019. if len(wms) > 0 {
  1020. utx := rdb
  1021. if len(wms) > 0 {
  1022. for _, wm := range wms {
  1023. thisSQL := "INSERT INTO t_hd_access (access_id,hospital_id,patient_nk,access_type,access_type_name,access_status,setup_date,first_use_time,xgbz,create_time,update_time,sjscsj) VALUES "
  1024. insertParams := make([]string, 0)
  1025. insertData := make([]interface{}, 0)
  1026. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
  1027. insertData = append(insertData, wm.AccessId)
  1028. insertData = append(insertData, wm.HospitalId)
  1029. insertData = append(insertData, wm.PatientNk)
  1030. insertData = append(insertData, wm.AccessType)
  1031. insertData = append(insertData, wm.AccessTypeName)
  1032. insertData = append(insertData, wm.AccessStatus)
  1033. insertData = append(insertData, wm.SetupDate)
  1034. insertData = append(insertData, wm.FirstUseTime)
  1035. insertData = append(insertData, wm.Xgbz)
  1036. insertData = append(insertData, wm.CreateTime)
  1037. insertData = append(insertData, wm.UpdateTime)
  1038. insertData = append(insertData, wm.Sjscsj)
  1039. thisSQL += strings.Join(insertParams, ", ")
  1040. utx.Exec(thisSQL, insertData...)
  1041. }
  1042. }
  1043. }
  1044. return
  1045. }
  1046. func CreateSickbed(wms []*sz.TempHdSickbed, rdb *gorm.DB) (err error) {
  1047. if len(wms) > 0 {
  1048. utx := rdb
  1049. if len(wms) > 0 {
  1050. for _, wm := range wms {
  1051. thisSQL := "INSERT INTO t_hd_sickbed (sickbed_no,hospital_id,division_id,sickbed_code,sickbed_type,xgbz,create_time,update_time,sjscsj) VALUES "
  1052. insertParams := make([]string, 0)
  1053. insertData := make([]interface{}, 0)
  1054. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
  1055. insertData = append(insertData, wm.SickbedNo)
  1056. insertData = append(insertData, wm.HospitalId)
  1057. insertData = append(insertData, wm.DivisionId)
  1058. insertData = append(insertData, wm.SickbedCode)
  1059. insertData = append(insertData, wm.SickbedType)
  1060. insertData = append(insertData, wm.Xgbz)
  1061. insertData = append(insertData, wm.CreateTime)
  1062. insertData = append(insertData, wm.UpdateTime)
  1063. insertData = append(insertData, wm.Sjscsj)
  1064. thisSQL += strings.Join(insertParams, ", ")
  1065. utx.Exec(thisSQL, insertData...)
  1066. }
  1067. }
  1068. }
  1069. return
  1070. }
  1071. func CreateDiagnosis(wms []*sz.TempHdDiagnosis, rdb *gorm.DB) (err error) {
  1072. if len(wms) > 0 {
  1073. utx := rdb
  1074. if len(wms) > 0 {
  1075. for _, wm := range wms {
  1076. thisSQL := "INSERT INTO t_hd_diagnosis (diagnosis_id,hospital_id,patient_nk,diagnosis_time,diagnosis_type,diagnosis_type_item,diagnosis_type_detail,xgbz,create_time,sjscsj) VALUES "
  1077. insertParams := make([]string, 0)
  1078. insertData := make([]interface{}, 0)
  1079. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  1080. insertData = append(insertData, wm.DiagnosisId)
  1081. insertData = append(insertData, wm.HospitalId)
  1082. insertData = append(insertData, wm.PatientNk)
  1083. insertData = append(insertData, wm.DiagnosisTime)
  1084. insertData = append(insertData, wm.DiagnosisType)
  1085. insertData = append(insertData, wm.DiagnosisTypeItem)
  1086. insertData = append(insertData, wm.DiagnosisTypeDetail)
  1087. insertData = append(insertData, wm.Xgbz)
  1088. insertData = append(insertData, wm.CreateTime)
  1089. insertData = append(insertData, wm.Sjscsj)
  1090. thisSQL += strings.Join(insertParams, ", ")
  1091. utx.Exec(thisSQL, insertData...)
  1092. }
  1093. }
  1094. }
  1095. return
  1096. }
  1097. func CreateInfection(wms []*sz.TempHdInfection, rdb *gorm.DB) (err error) {
  1098. if len(wms) > 0 {
  1099. utx := rdb
  1100. if len(wms) > 0 {
  1101. for _, wm := range wms {
  1102. thisSQL := "INSERT INTO t_hd_infection (sn,hospital_id,patient_nk,hbv,hcv,rpr,hiv,hbsag,hbsab,hbeag,hbeab,hbcab,check_date,doctor_id,xgbz,create_time,sjscsj) VALUES "
  1103. insertParams := make([]string, 0)
  1104. insertData := make([]interface{}, 0)
  1105. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  1106. insertData = append(insertData, wm.Sn)
  1107. insertData = append(insertData, wm.HospitalId)
  1108. insertData = append(insertData, wm.PatientNk)
  1109. insertData = append(insertData, wm.Hbv)
  1110. insertData = append(insertData, wm.Hcv)
  1111. insertData = append(insertData, wm.Rpr)
  1112. insertData = append(insertData, wm.Hiv)
  1113. insertData = append(insertData, wm.Hbsag)
  1114. insertData = append(insertData, wm.Hbsab)
  1115. insertData = append(insertData, wm.Hbeag)
  1116. insertData = append(insertData, wm.Hbeab)
  1117. insertData = append(insertData, wm.Hbcab)
  1118. insertData = append(insertData, wm.CheckDate)
  1119. insertData = append(insertData, wm.DoctorId)
  1120. insertData = append(insertData, wm.Xgbz)
  1121. insertData = append(insertData, wm.CreateTime)
  1122. insertData = append(insertData, wm.Sjscsj)
  1123. thisSQL += strings.Join(insertParams, ", ")
  1124. utx.Exec(thisSQL, insertData...)
  1125. }
  1126. }
  1127. }
  1128. return
  1129. }
  1130. func CreateComplication(wms []*sz.TempHdComplication, rdb *gorm.DB) (err error) {
  1131. if len(wms) > 0 {
  1132. utx := rdb
  1133. if len(wms) > 0 {
  1134. for _, wm := range wms {
  1135. thisSQL := "INSERT INTO t_hd_complication (sn,hospital_id,patient_nk,dialysis_id,monitor_id,neopathy_time,neopathy_type,neopathy_desc,xgbz,create_time,sjscsj) VALUES "
  1136. insertParams := make([]string, 0)
  1137. insertData := make([]interface{}, 0)
  1138. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  1139. insertData = append(insertData, wm.Sn)
  1140. insertData = append(insertData, wm.HospitalId)
  1141. insertData = append(insertData, wm.PatientNk)
  1142. insertData = append(insertData, wm.DialysisId)
  1143. insertData = append(insertData, wm.MonitorId)
  1144. insertData = append(insertData, wm.NeopathyTime)
  1145. insertData = append(insertData, wm.NeopathyType)
  1146. insertData = append(insertData, wm.NeopathyDesc)
  1147. insertData = append(insertData, wm.Xgbz)
  1148. insertData = append(insertData, wm.CreateTime)
  1149. insertData = append(insertData, wm.Sjscsj)
  1150. thisSQL += strings.Join(insertParams, ", ")
  1151. utx.Exec(thisSQL, insertData...)
  1152. }
  1153. }
  1154. }
  1155. return
  1156. }
  1157. func CreateLisReport(wms []*sz.TempHdLisReport, rdb *gorm.DB) (err error) {
  1158. if len(wms) > 0 {
  1159. utx := rdb
  1160. if len(wms) > 0 {
  1161. for _, wm := range wms {
  1162. thisSQL := "INSERT INTO t_hd_lis_report (lab_sno,hospital_id,patient_nk,report_date,check_date,jz_no,mz_flag,zy_no,mz_no,department_code,department_name,card_no,card_type,patient_name,dep_code,dep_name,inspected_type,report_categry,application_name,application_type,check_name,check_item_name,check_item_code,record_ccount,check_result,diagnose_name,xgbz,create_time,sjscsj) VALUES "
  1163. insertParams := make([]string, 0)
  1164. insertData := make([]interface{}, 0)
  1165. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  1166. insertData = append(insertData, wm.LabSno)
  1167. insertData = append(insertData, wm.HospitalId)
  1168. insertData = append(insertData, wm.PatientNk)
  1169. insertData = append(insertData, wm.ReportDate)
  1170. insertData = append(insertData, wm.CheckDate)
  1171. insertData = append(insertData, wm.JzNo)
  1172. insertData = append(insertData, wm.MzFlag)
  1173. insertData = append(insertData, wm.ZyNo)
  1174. insertData = append(insertData, wm.MzNo)
  1175. insertData = append(insertData, wm.DepartmentCode)
  1176. insertData = append(insertData, wm.DepartmentName)
  1177. insertData = append(insertData, wm.CardNo)
  1178. insertData = append(insertData, wm.CardType)
  1179. insertData = append(insertData, wm.PatientName)
  1180. insertData = append(insertData, wm.DepCode)
  1181. insertData = append(insertData, wm.DepName)
  1182. insertData = append(insertData, wm.InspectedType)
  1183. insertData = append(insertData, wm.ReportCategry)
  1184. insertData = append(insertData, wm.ApplicationName)
  1185. insertData = append(insertData, wm.ApplicationType)
  1186. insertData = append(insertData, wm.CheckName)
  1187. insertData = append(insertData, wm.CheckItemName)
  1188. insertData = append(insertData, wm.CheckItemCode)
  1189. insertData = append(insertData, wm.RecordCcount)
  1190. insertData = append(insertData, wm.CheckResult)
  1191. insertData = append(insertData, wm.DiagnoseName)
  1192. insertData = append(insertData, wm.Xgbz)
  1193. insertData = append(insertData, wm.CreateTime)
  1194. insertData = append(insertData, wm.Sjscsj)
  1195. thisSQL += strings.Join(insertParams, ", ")
  1196. utx.Exec(thisSQL, insertData...)
  1197. }
  1198. }
  1199. }
  1200. return
  1201. }
  1202. func CreateLisIndicators(wms []*sz.TempHdLisIndicators, rdb *gorm.DB) (err error) {
  1203. if len(wms) > 0 {
  1204. utx := rdb
  1205. if len(wms) > 0 {
  1206. for _, wm := range wms {
  1207. thisSQL := "INSERT INTO t_hd_lis_indicators (inspected_result_no,hospital_id,lab_sno,report_date,check_date,inspected_indicate,inspected_item_en_name,inspected_item_cn_name,inspected_result_desc,inspected_result_value,inspected_result_unit,ref_range,unit_type,inspected_result,create_time) VALUES "
  1208. insertParams := make([]string, 0)
  1209. insertData := make([]interface{}, 0)
  1210. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  1211. insertData = append(insertData, wm.InspectedResultNo)
  1212. insertData = append(insertData, wm.HospitalId)
  1213. insertData = append(insertData, wm.LabSno)
  1214. insertData = append(insertData, wm.ReportDate)
  1215. insertData = append(insertData, wm.CheckDate)
  1216. insertData = append(insertData, wm.InspectedIndicate)
  1217. insertData = append(insertData, wm.InspectedItemEnName)
  1218. insertData = append(insertData, wm.InspectedItemCnName)
  1219. insertData = append(insertData, wm.InspectedResultDesc)
  1220. insertData = append(insertData, wm.InspectedResultValue)
  1221. insertData = append(insertData, wm.InspectedResultUnit)
  1222. insertData = append(insertData, wm.RefRange)
  1223. insertData = append(insertData, wm.UnitType)
  1224. insertData = append(insertData, wm.InspectedResult)
  1225. insertData = append(insertData, wm.CreateTime)
  1226. thisSQL += strings.Join(insertParams, ", ")
  1227. utx.Exec(thisSQL, insertData...)
  1228. }
  1229. }
  1230. }
  1231. return
  1232. }
  1233. func FindOrgCulture(org_id int64, lastUploadTime int64, nowTime int64) (culture []*models.XtDeviceCulture, err error) {
  1234. err = UserReadDB().Model(&culture).Where("status = 1 and user_org_id = ? and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&culture).Error
  1235. return culture, err
  1236. }
  1237. func CreateLisCulture(wms []*sz.TempHdLisCulture, rdb *gorm.DB) (err error) {
  1238. if len(wms) > 0 {
  1239. utx := rdb
  1240. if len(wms) > 0 {
  1241. for _, wm := range wms {
  1242. thisSQL := "INSERT INTO t_hd_dm_dialysate_bc (sn,hospital_id,equipment_id,inspection_time,is_qualified,inspected_value,is_substitution_qualified,case_order,create_time,sjscsj,xgbz) VALUES "
  1243. insertParams := make([]string, 0)
  1244. insertData := make([]interface{}, 0)
  1245. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  1246. insertData = append(insertData, wm.Sn)
  1247. insertData = append(insertData, wm.HospitalId)
  1248. insertData = append(insertData, wm.EquitmentId)
  1249. insertData = append(insertData, wm.InspectionTime)
  1250. insertData = append(insertData, wm.IsQualified)
  1251. insertData = append(insertData, wm.InspectedValue)
  1252. insertData = append(insertData, wm.IsSubstitutionQualified)
  1253. insertData = append(insertData, wm.CaseOrder)
  1254. insertData = append(insertData, wm.CreateTime)
  1255. insertData = append(insertData, wm.Sjscsj)
  1256. insertData = append(insertData, wm.Xgbz)
  1257. thisSQL += strings.Join(insertParams, ", ")
  1258. utx.Exec(thisSQL, insertData...)
  1259. }
  1260. }
  1261. }
  1262. return
  1263. }
  1264. func FindOrgDialysate(org_id int64, lastUploadTime int64, nowTime int64) (dialysate []*models.XtDeviceDialysate, err error) {
  1265. err = UserReadDB().Model(&dialysate).Where("status = 1 and user_org_id = ? and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&dialysate).Error
  1266. return dialysate, err
  1267. }
  1268. func CreateLisDialysate(wms []*sz.TempHdLisDialysate, rdb *gorm.DB) (err error) {
  1269. if len(wms) > 0 {
  1270. utx := rdb
  1271. if len(wms) > 0 {
  1272. for _, wm := range wms {
  1273. thisSQL := "INSERT INTO t_hd_dm_dialysate_en (sn,hospital_id,equipment_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
  1274. insertParams := make([]string, 0)
  1275. insertData := make([]interface{}, 0)
  1276. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  1277. insertData = append(insertData, wm.Sn)
  1278. insertData = append(insertData, wm.HospitalId)
  1279. insertData = append(insertData, wm.EquitmentId)
  1280. insertData = append(insertData, wm.InspectionTime)
  1281. insertData = append(insertData, wm.IsQualified)
  1282. insertData = append(insertData, wm.InspectedValue)
  1283. insertData = append(insertData, wm.CaseOrder)
  1284. insertData = append(insertData, wm.CreateTime)
  1285. insertData = append(insertData, wm.Sjscsj)
  1286. insertData = append(insertData, wm.Xgbz)
  1287. thisSQL += strings.Join(insertParams, ", ")
  1288. utx.Exec(thisSQL, insertData...)
  1289. }
  1290. }
  1291. }
  1292. return
  1293. }
  1294. func FindOrgArialDetection(org_id int64, lastUploadTime int64, nowTime int64) (airdetection []*models.XtAerialDetection, err error) {
  1295. err = XTReadDB().Model(&airdetection).Where("user_org_id = ? and status=1 and created_time>=? and created_time<=?", org_id, lastUploadTime, nowTime).Find(&airdetection).Error
  1296. return airdetection, err
  1297. }
  1298. func CreateAirDisinfect(wms []*sz.TempHdLisAirDisinfect, rdb *gorm.DB) (err error) {
  1299. if len(wms) > 0 {
  1300. utx := rdb
  1301. if len(wms) > 0 {
  1302. for _, wm := range wms {
  1303. thisSQL := "INSERT INTO t_hd_air_disinfect (sn,hospital_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
  1304. insertParams := make([]string, 0)
  1305. insertData := make([]interface{}, 0)
  1306. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
  1307. insertData = append(insertData, wm.Sn)
  1308. insertData = append(insertData, wm.HospitalId)
  1309. insertData = append(insertData, wm.InspectionTime)
  1310. insertData = append(insertData, wm.IsQualified)
  1311. insertData = append(insertData, wm.InspectedValue)
  1312. insertData = append(insertData, wm.CaseOrder)
  1313. insertData = append(insertData, wm.CreateTime)
  1314. insertData = append(insertData, wm.Sjscsj)
  1315. insertData = append(insertData, wm.Xgbz)
  1316. thisSQL += strings.Join(insertParams, ", ")
  1317. utx.Exec(thisSQL, insertData...)
  1318. }
  1319. }
  1320. }
  1321. return
  1322. }
  1323. func FindOrgBodyDetection(org_id int64, lastUploadTime int64, nowTime int64) (body []*models.XtBodyDetection, err error) {
  1324. err = XTReadDB().Model(&body).Where("user_org_id = ? and status=1 and created_time>=? and created_time<=?", org_id, lastUploadTime, nowTime).Find(&body).Error
  1325. return body, err
  1326. }
  1327. func CreateBodyDisinfect(wms []*sz.TempHdLisBodyDisinfect, rdb *gorm.DB) (err error) {
  1328. if len(wms) > 0 {
  1329. utx := rdb
  1330. if len(wms) > 0 {
  1331. for _, wm := range wms {
  1332. thisSQL := "INSERT INTO t_hd_surface_disinfect (sn,hospital_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
  1333. insertParams := make([]string, 0)
  1334. insertData := make([]interface{}, 0)
  1335. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
  1336. insertData = append(insertData, wm.Sn)
  1337. insertData = append(insertData, wm.HospitalId)
  1338. insertData = append(insertData, wm.InspectionTime)
  1339. insertData = append(insertData, wm.IsQualified)
  1340. insertData = append(insertData, wm.InspectedValue)
  1341. insertData = append(insertData, wm.CaseOrder)
  1342. insertData = append(insertData, wm.CreateTime)
  1343. insertData = append(insertData, wm.Sjscsj)
  1344. insertData = append(insertData, wm.Xgbz)
  1345. thisSQL += strings.Join(insertParams, ", ")
  1346. utx.Exec(thisSQL, insertData...)
  1347. }
  1348. }
  1349. }
  1350. return
  1351. }
  1352. func FindOrgWaterFc(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDeviceWater, err error) {
  1353. err = UserReadDB().Model(&water).Where("user_org_id = ? and status = 1 and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
  1354. return water, err
  1355. }
  1356. func CreateWaterFc(wms []*sz.TempHdLisWaterFc, rdb *gorm.DB) (err error) {
  1357. if len(wms) > 0 {
  1358. utx := rdb
  1359. if len(wms) > 0 {
  1360. for _, wm := range wms {
  1361. thisSQL := "INSERT INTO t_hd_water_fc(sn,hospital_id,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
  1362. insertParams := make([]string, 0)
  1363. insertData := make([]interface{}, 0)
  1364. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
  1365. insertData = append(insertData, wm.Sn)
  1366. insertData = append(insertData, wm.HospitalId)
  1367. insertData = append(insertData, wm.EquitmentId)
  1368. insertData = append(insertData, wm.WaterType)
  1369. insertData = append(insertData, wm.InspectionOrgId)
  1370. insertData = append(insertData, wm.InspectionTime)
  1371. insertData = append(insertData, wm.IsQualified)
  1372. insertData = append(insertData, wm.InspectedValue)
  1373. insertData = append(insertData, wm.CaseOrder)
  1374. insertData = append(insertData, wm.CreateTime)
  1375. insertData = append(insertData, wm.Sjscsj)
  1376. insertData = append(insertData, wm.Xgbz)
  1377. thisSQL += strings.Join(insertParams, ", ")
  1378. utx.Exec(thisSQL, insertData...)
  1379. }
  1380. }
  1381. }
  1382. return
  1383. }
  1384. func FindOrgWaterEl(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.DeviceIon, err error) {
  1385. err = UserReadDB().Model(&water).Where("user_org_id = ? and status = 1 and sampling_date>=? and sampling_date<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
  1386. return water, err
  1387. }
  1388. func CreateWaterEl(wms []*sz.TempHdLisWaterEl, rdb *gorm.DB) (err error) {
  1389. if len(wms) > 0 {
  1390. utx := rdb
  1391. if len(wms) > 0 {
  1392. for _, wm := range wms {
  1393. thisSQL := "INSERT INTO t_hd_water_el(sn,hospital_id,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
  1394. insertParams := make([]string, 0)
  1395. insertData := make([]interface{}, 0)
  1396. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
  1397. insertData = append(insertData, wm.Sn)
  1398. insertData = append(insertData, wm.HospitalId)
  1399. insertData = append(insertData, wm.EquitmentId)
  1400. insertData = append(insertData, wm.WaterType)
  1401. insertData = append(insertData, wm.InspectionOrgId)
  1402. insertData = append(insertData, wm.InspectionTime)
  1403. insertData = append(insertData, wm.IsQualified)
  1404. insertData = append(insertData, wm.InspectedValue)
  1405. insertData = append(insertData, wm.CaseOrder)
  1406. insertData = append(insertData, wm.CreateTime)
  1407. insertData = append(insertData, wm.Sjscsj)
  1408. insertData = append(insertData, wm.Xgbz)
  1409. thisSQL += strings.Join(insertParams, ", ")
  1410. utx.Exec(thisSQL, insertData...)
  1411. }
  1412. }
  1413. }
  1414. return
  1415. }
  1416. func CreateWaterTe(wms []*sz.TempHdLisWaterTe, rdb *gorm.DB) (err error) {
  1417. if len(wms) > 0 {
  1418. utx := rdb
  1419. if len(wms) > 0 {
  1420. for _, wm := range wms {
  1421. thisSQL := "INSERT INTO t_hd_water_te(sn,hospital_id,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,case_order,create_time,sjscsj,xgbz) VALUES "
  1422. insertParams := make([]string, 0)
  1423. insertData := make([]interface{}, 0)
  1424. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  1425. insertData = append(insertData, wm.Sn)
  1426. insertData = append(insertData, wm.HospitalId)
  1427. insertData = append(insertData, wm.EquitmentId)
  1428. insertData = append(insertData, wm.WaterType)
  1429. insertData = append(insertData, wm.InspectionOrgId)
  1430. insertData = append(insertData, wm.InspectionTime)
  1431. insertData = append(insertData, wm.IsQualified)
  1432. insertData = append(insertData, wm.CaseOrder)
  1433. insertData = append(insertData, wm.CreateTime)
  1434. insertData = append(insertData, wm.Sjscsj)
  1435. insertData = append(insertData, wm.Xgbz)
  1436. thisSQL += strings.Join(insertParams, ", ")
  1437. utx.Exec(thisSQL, insertData...)
  1438. }
  1439. }
  1440. }
  1441. return
  1442. }
  1443. func FindOrgWaterNc(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDeviceOxygenates, err error) {
  1444. err = UserReadDB().Model(&water).Where("user_org_id = ? and status = 1 and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
  1445. return water, err
  1446. }
  1447. func CreateWaterNc(wms []*sz.TempHdLisWaterNc, rdb *gorm.DB) (err error) {
  1448. if len(wms) > 0 {
  1449. utx := rdb
  1450. if len(wms) > 0 {
  1451. for _, wm := range wms {
  1452. thisSQL := "INSERT INTO t_hd_water_nc(sn,hospital_id,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
  1453. insertParams := make([]string, 0)
  1454. insertData := make([]interface{}, 0)
  1455. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
  1456. insertData = append(insertData, wm.Sn)
  1457. insertData = append(insertData, wm.HospitalId)
  1458. insertData = append(insertData, wm.EquitmentId)
  1459. insertData = append(insertData, wm.WaterType)
  1460. insertData = append(insertData, wm.InspectionOrgId)
  1461. insertData = append(insertData, wm.InspectionTime)
  1462. insertData = append(insertData, wm.IsQualified)
  1463. insertData = append(insertData, wm.InspectedValue)
  1464. insertData = append(insertData, wm.CaseOrder)
  1465. insertData = append(insertData, wm.CreateTime)
  1466. insertData = append(insertData, wm.Sjscsj)
  1467. insertData = append(insertData, wm.Xgbz)
  1468. thisSQL += strings.Join(insertParams, ", ")
  1469. utx.Exec(thisSQL, insertData...)
  1470. }
  1471. }
  1472. }
  1473. return
  1474. }
  1475. func FindOrgWaterPh(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDevicePh, err error) {
  1476. err = UserReadDB().Model(&water).Where("user_org_id = ? and ctime>? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
  1477. return water, err
  1478. }
  1479. func CreateWaterPh(wms []*sz.TempHdLisWaterPh, rdb *gorm.DB) (err error) {
  1480. if len(wms) > 0 {
  1481. utx := rdb
  1482. if len(wms) > 0 {
  1483. for _, wm := range wms {
  1484. thisSQL := "INSERT INTO t_hd_water_ph(sn,hospital_id,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,case_order,create_time,sjscsj,xgbz) VALUES "
  1485. insertParams := make([]string, 0)
  1486. insertData := make([]interface{}, 0)
  1487. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  1488. insertData = append(insertData, wm.Sn)
  1489. insertData = append(insertData, wm.HospitalId)
  1490. insertData = append(insertData, wm.EquitmentId)
  1491. insertData = append(insertData, wm.WaterType)
  1492. insertData = append(insertData, wm.InspectionOrgId)
  1493. insertData = append(insertData, wm.InspectionTime)
  1494. insertData = append(insertData, wm.IsQualified)
  1495. insertData = append(insertData, wm.CaseOrder)
  1496. insertData = append(insertData, wm.CreateTime)
  1497. insertData = append(insertData, wm.Sjscsj)
  1498. insertData = append(insertData, wm.Xgbz)
  1499. thisSQL += strings.Join(insertParams, ", ")
  1500. utx.Exec(thisSQL, insertData...)
  1501. }
  1502. }
  1503. }
  1504. return
  1505. }
  1506. func FindOrgWaterWh(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDeviceHadwater, err error) {
  1507. err = UserReadDB().Model(&water).Where("user_org_id = ? and ctime>=? and ctime<=? and status =1", org_id, lastUploadTime, nowTime).Find(&water).Error
  1508. return water, err
  1509. }
  1510. func CreateWaterWh(wms []*sz.TempHdLisWaterWh, rdb *gorm.DB) (err error) {
  1511. if len(wms) > 0 {
  1512. utx := rdb
  1513. if len(wms) > 0 {
  1514. for _, wm := range wms {
  1515. thisSQL := "INSERT INTO t_hd_water_wh(sn,hospital_id,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
  1516. insertParams := make([]string, 0)
  1517. insertData := make([]interface{}, 0)
  1518. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
  1519. insertData = append(insertData, wm.Sn)
  1520. insertData = append(insertData, wm.HospitalId)
  1521. insertData = append(insertData, wm.EquitmentId)
  1522. insertData = append(insertData, wm.WaterType)
  1523. insertData = append(insertData, wm.InspectionOrgId)
  1524. insertData = append(insertData, wm.InspectionTime)
  1525. insertData = append(insertData, wm.IsQualified)
  1526. insertData = append(insertData, wm.InspectedValue)
  1527. insertData = append(insertData, wm.CaseOrder)
  1528. insertData = append(insertData, wm.CreateTime)
  1529. insertData = append(insertData, wm.Sjscsj)
  1530. insertData = append(insertData, wm.Xgbz)
  1531. thisSQL += strings.Join(insertParams, ", ")
  1532. utx.Exec(thisSQL, insertData...)
  1533. }
  1534. }
  1535. }
  1536. return
  1537. }
  1538. func FindOrgAccess(org_id int64, lastUploadTime int64, nowTime int64) (access []*models.XtPatientVascularAccess, err error) {
  1539. err = XTReadDB().Model(&access).Where("user_org_id = ? and start_time>=? and start_time<=? and status =1", org_id, lastUploadTime, nowTime).Find(&access).Error
  1540. return access, err
  1541. }
  1542. func FindOrgHdCi(org_id int64, lastUploadTime int64, nowTime int64) (access []*models.XtPatientVascularAccess, err error) {
  1543. err = XTReadDB().Model(&access).Where("user_org_id = ? and start_time>=? and start_time<=? and access_project = 2 and sequelae_type > 0 and status =1", org_id, lastUploadTime, nowTime).Find(&access).Error
  1544. return access, err
  1545. }
  1546. func CreateHdCi(wms []*sz.TempHdCi, rdb *gorm.DB) (err error) {
  1547. if len(wms) > 0 {
  1548. utx := rdb
  1549. if len(wms) > 0 {
  1550. for _, wm := range wms {
  1551. thisSQL := "INSERT INTO t_hd_ci(infect_sn,hospital_id,patient_nk,access_id,ci_type,blood_culture,infection_date,create_time,sjscsj,xgbz) VALUES "
  1552. insertParams := make([]string, 0)
  1553. insertData := make([]interface{}, 0)
  1554. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  1555. insertData = append(insertData, wm.InfectSn)
  1556. insertData = append(insertData, wm.HospitalId)
  1557. insertData = append(insertData, wm.PatientNk)
  1558. insertData = append(insertData, wm.AccessId)
  1559. insertData = append(insertData, wm.CiType)
  1560. insertData = append(insertData, wm.BloodCulture)
  1561. insertData = append(insertData, wm.InfectionDate)
  1562. insertData = append(insertData, wm.CreateTime)
  1563. insertData = append(insertData, wm.Sjscsj)
  1564. insertData = append(insertData, wm.Xgbz)
  1565. thisSQL += strings.Join(insertParams, ", ")
  1566. utx.Exec(thisSQL, insertData...)
  1567. }
  1568. }
  1569. }
  1570. return
  1571. }
  1572. func FindOrgHdCiOutCome(org_id int64, lastUploadTime int64, nowTime int64) (access []*models.XtPatientVascularAccess, err error) {
  1573. err = XTReadDB().Model(&access).Where("user_org_id = ? and start_time>=? and start_time<=? and access_project = 2 and ci_type > 0 and status =1", org_id, lastUploadTime, nowTime).Find(&access).Error
  1574. return access, err
  1575. }
  1576. func CreateHdCiOutCome(wms []*sz.TempHdCiOutCome, rdb *gorm.DB) (err error) {
  1577. if len(wms) > 0 {
  1578. utx := rdb
  1579. if len(wms) > 0 {
  1580. for _, wm := range wms {
  1581. thisSQL := "INSERT INTO t_hd_ci_outcome(hospital_id,sn,infect_sn,patient_nk,sequelae_type,sjscsj,xgbz,create_time) VALUES "
  1582. insertParams := make([]string, 0)
  1583. insertData := make([]interface{}, 0)
  1584. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?)")
  1585. insertData = append(insertData, wm.HospitalId)
  1586. insertData = append(insertData, wm.Sn)
  1587. insertData = append(insertData, wm.InfectSn)
  1588. insertData = append(insertData, wm.PatientNk)
  1589. insertData = append(insertData, wm.SequelaeType)
  1590. insertData = append(insertData, wm.Sjscsj)
  1591. insertData = append(insertData, wm.Xgbz)
  1592. insertData = append(insertData, wm.CreateTime)
  1593. thisSQL += strings.Join(insertParams, ", ")
  1594. utx.Exec(thisSQL, insertData...)
  1595. }
  1596. }
  1597. }
  1598. return
  1599. }
  1600. func CreateLisWaterBc(wms []*sz.TempHdLisWaterBc, rdb *gorm.DB) (err error) {
  1601. if len(wms) > 0 {
  1602. utx := rdb
  1603. if len(wms) > 0 {
  1604. for _, wm := range wms {
  1605. thisSQL := "INSERT INTO t_hd_water_bc (sn,hospital_id,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,sjscsj,xgbz,create_time) VALUES "
  1606. insertParams := make([]string, 0)
  1607. insertData := make([]interface{}, 0)
  1608. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
  1609. insertData = append(insertData, wm.Sn)
  1610. insertData = append(insertData, wm.HospitalId)
  1611. insertData = append(insertData, wm.EquitmentId)
  1612. insertData = append(insertData, wm.WaterType)
  1613. insertData = append(insertData, wm.InspectionOrgId)
  1614. insertData = append(insertData, wm.InspectionTime)
  1615. insertData = append(insertData, wm.IsQualified)
  1616. insertData = append(insertData, wm.InspectedValue)
  1617. insertData = append(insertData, wm.CaseOrder)
  1618. insertData = append(insertData, wm.Sjscsj)
  1619. insertData = append(insertData, wm.Xgbz)
  1620. insertData = append(insertData, wm.CreateTime)
  1621. thisSQL += strings.Join(insertParams, ", ")
  1622. utx.Exec(thisSQL, insertData...)
  1623. }
  1624. }
  1625. }
  1626. return
  1627. }
  1628. func CreateLisWaterEn(wms []*sz.TempHdLisWaterEn, rdb *gorm.DB) (err error) {
  1629. if len(wms) > 0 {
  1630. utx := rdb
  1631. if len(wms) > 0 {
  1632. for _, wm := range wms {
  1633. thisSQL := "INSERT INTO t_hd_water_en (sn,hospital_id,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,sjscsj,xgbz,create_time) VALUES "
  1634. insertParams := make([]string, 0)
  1635. insertData := make([]interface{}, 0)
  1636. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
  1637. insertData = append(insertData, wm.Sn)
  1638. insertData = append(insertData, wm.HospitalId)
  1639. insertData = append(insertData, wm.EquitmentId)
  1640. insertData = append(insertData, wm.WaterType)
  1641. insertData = append(insertData, wm.InspectionOrgId)
  1642. insertData = append(insertData, wm.InspectionTime)
  1643. insertData = append(insertData, wm.IsQualified)
  1644. insertData = append(insertData, wm.InspectedValue)
  1645. insertData = append(insertData, wm.CaseOrder)
  1646. insertData = append(insertData, wm.Sjscsj)
  1647. insertData = append(insertData, wm.Xgbz)
  1648. insertData = append(insertData, wm.CreateTime)
  1649. thisSQL += strings.Join(insertParams, ", ")
  1650. utx.Exec(thisSQL, insertData...)
  1651. }
  1652. }
  1653. }
  1654. return
  1655. }
  1656. func BatchCreateTBDICPractitioner(ps *sz.TBDICPractitioner, rdb *gorm.DB) (err error) {
  1657. err = rdb.Create(&ps).Error
  1658. return err
  1659. }
  1660. func BatchCreateTBDICMedicines(ps *sz.TBDICMedicines, rdb *gorm.DB) (err error) {
  1661. err = rdb.Create(&ps).Error
  1662. return err
  1663. }
  1664. func BatchCreateTBDICZlxmdzzd(ps *sz.TBDICZlxmdzzd, rdb *gorm.DB) (err error) {
  1665. err = rdb.Create(&ps).Error
  1666. return err
  1667. }
  1668. func BatchCreateTBDICYpdzzd(ps *sz.TBDICYpdzzd, rdb *gorm.DB) (err error) {
  1669. err = rdb.Create(&ps).Error
  1670. return err
  1671. }
  1672. func BatchCreateTBDICZlxmml(ps *sz.TBDICZlxmml, rdb *gorm.DB) (err error) {
  1673. err = rdb.Create(&ps).Error
  1674. return err
  1675. }
  1676. func BatchCreateTMDICTBED(ps *sz.TM_DICT_BED, rdb *gorm.DB) (err error) {
  1677. err = rdb.Create(&ps).Error
  1678. return err
  1679. }
  1680. func BatchCreateTB_MZ_Patient_Information(ps *sz.TB_MZ_Patient_Information, rdb *gorm.DB) (err error) {
  1681. err = rdb.Create(&ps).Error
  1682. return err
  1683. }
  1684. func BatchCreateTB_HIS_MZ_Reg(ps *sz.TB_HIS_MZ_Reg, rdb *gorm.DB) (err error) {
  1685. err = rdb.Create(&ps).Error
  1686. return err
  1687. }
  1688. func BatchCreateTB_YL_MZ_Medical_Record(ps *sz.TB_YL_MZ_Medical_Record, rdb *gorm.DB) (err error) {
  1689. err = rdb.Create(&ps).Error
  1690. return err
  1691. }
  1692. func BatchCreateTB_Diagnosis_Detail(ps *sz.TB_Diagnosis_Detail, rdb *gorm.DB) (err error) {
  1693. err = rdb.Create(&ps).Error
  1694. return err
  1695. }
  1696. func BatchCreateTB_CIS_Prescription(ps *sz.TB_CIS_Prescription, rdb *gorm.DB) (err error) {
  1697. err = rdb.Create(&ps).Error
  1698. return err
  1699. }
  1700. func BatchCreateTB_CIS_Prescription_Detail(ps *sz.TB_CIS_Prescription_Detail, rdb *gorm.DB) (err error) {
  1701. err = rdb.Create(&ps).Error
  1702. return err
  1703. }
  1704. func BatchCreateTB_HIS_MZ_Charge(ps *sz.TB_HIS_MZ_Charge, rdb *gorm.DB) (err error) {
  1705. err = rdb.Create(&ps).Error
  1706. return err
  1707. }
  1708. func BatchCreateTB_HIS_MZ_Fee_Detail(ps *sz.TB_HIS_MZ_Fee_Detail, rdb *gorm.DB) (err error) {
  1709. err = rdb.Create(&ps).Error
  1710. return err
  1711. }
  1712. func BatchCreateTB_STAT_YWL_Report(ps *sz.TB_STAT_YWL_Report, rdb *gorm.DB) (err error) {
  1713. err = rdb.Create(&ps).Error
  1714. return err
  1715. }