city_data_uoload_service.go 61KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516
  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. )
  9. func GetSyncTimeByOrgId(org_id int64, sync_type int64) (sync_info models.XTSyncInfo, err error) {
  10. err = readDb.Model(&models.XTSyncInfo{}).Where("org_id = ? and sync_type = ? ", org_id, sync_type).Last(&sync_info).Error
  11. return
  12. }
  13. func FindAllDataUploadConfigOrgInfo(province_id int64, city_id int64, config_type int64) (data []*sz.DataUploadConfig, err error) {
  14. 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
  15. return
  16. }
  17. func FindDataUploadOrgInfo(org_id int64, module_type int64) (data sz.DataUpload, err error) {
  18. err = readDb.Model(&sz.DataUpload{}).Where(" org_id = ? AND module_type = ?", org_id, module_type).Last(&data).Error
  19. return
  20. }
  21. func FindOrgData(org_id int64, sync_time int64) (org models.UserOrg, err error) {
  22. err = readUserDb.Model(&models.UserOrg{}).Where("status = 1 AND id = ? AND ctime > ?", org_id, sync_time).Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
  23. return readDb.Where("status = 1")
  24. }).Find(&org).Error
  25. return
  26. }
  27. func FindOrgRolesData(org_id int64, lastUploadTime int64, nowTime int64) (role []*models.UserAdminRole, err error) {
  28. db := readUserDb.Model(&models.UserAdminRole{}).Where("status = 1 AND org_id = ? ", org_id)
  29. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  30. err = db.Find(&role).Error
  31. return
  32. }
  33. func FindOrgRolesDataNew(org_id int64, lastUploadTime int64, nowTime int64) (role []*models.App_Role, err error) {
  34. db := readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? ", org_id)
  35. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  36. err = db.Find(&role).Error
  37. return
  38. }
  39. func FindOrgPatientData(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
  40. db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ?", org_id)
  41. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  42. err = db.Find(&patient).Error
  43. return
  44. }
  45. func FindOrgPatientInfoById(id int64) (*models.Patients, error) {
  46. var patient models.Patients
  47. db := readDb.Model(&models.Patients{}).Where("status = 1 AND id = ?", id)
  48. err = db.First(&patient).Error
  49. return &patient,err
  50. }
  51. func FindOrgHisPatient(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPatient, err error) {
  52. db := readDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ?", org_id)
  53. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  54. err = db.Find(&patient).Error
  55. return
  56. }
  57. func FindOrgHisPrescriptionInfo(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPrescriptionInfo, err error) {
  58. db := readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ?", org_id)
  59. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  60. err = db.Find(&patient).Error
  61. return
  62. }
  63. func FindOrgHisPrescription(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPrescription, err error) {
  64. db := readDb.Model(&models.HisPrescription{}).Where("status = 1 AND user_org_id = ?", org_id)
  65. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  66. err = db.Find(&patient).Error
  67. return
  68. }
  69. func FindOrgHisDoctorAdviceInfo(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisDoctorAdviceInfo, err error) {
  70. db := readDb.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ?", org_id)
  71. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  72. err = db.Find(&patient).Error
  73. return
  74. }
  75. func FindOrgHisDoctorAdviceInfoByPid(org_id int64, pid int64) (patient []*models.HisDoctorAdviceInfo, err error) {
  76. db := readDb.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ? and prescription_id = ?", org_id)
  77. err = db.Find(&patient).Error
  78. return
  79. }
  80. func FindOrgHisOrder(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisOrder, err error) {
  81. db := readDb.Model(&models.HisOrder{}).Where("status = 1 AND user_org_id = ?", org_id)
  82. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  83. err = db.Find(&patient).Error
  84. return
  85. }
  86. func FindOrgHisOrderInfo(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisOrderInfo, err error) {
  87. db := readDb.Model(&models.HisOrderInfo{}).Where("status = 1 AND user_org_id = ?", org_id)
  88. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  89. err = db.Find(&patient).Error
  90. return
  91. }
  92. func GetHisOrderByNumber(order_number string) ( *models.HisOrder, error) {
  93. var order models.HisOrder
  94. db := readDb.Model(&models.HisOrder{}).Where("number = ? AND status = 1 ", order_number)
  95. err = db.First(&order).Error
  96. return &order,err
  97. }
  98. func GetHisDoctorAdviceInfo(id int64) ( *models.HisDoctorAdviceInfo, error) {
  99. var order models.HisDoctorAdviceInfo
  100. db := readDb.Model(&models.HisDoctorAdviceInfo{}).Where("id = ? AND status = 1 ", id)
  101. err = db.Find(&order).Error
  102. return &order,err
  103. }
  104. func GetHisOrderInfoByNumber(order_number string) (order []*models.HisOrderInfo, err error) {
  105. db := readDb.Model(&models.HisOrderInfo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  106. return db.Preload("BaseDrugLib", "status = 1").Where("status = 1")
  107. })
  108. err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
  109. return
  110. }
  111. func FindOrgHisPrescriptionById( id int64) (*models.HisPrescription, error) {
  112. var HisPrescription models.HisPrescription
  113. db := readDb.Model(&models.HisPrescription{}).Where("status = 1 and id =? ", id)
  114. err = db.First(&HisPrescription).Error
  115. return &HisPrescription,err
  116. }
  117. func FindBaseDrugLibById( id int64) (*models.BaseDrugLib, error) {
  118. var BaseDrugLib models.BaseDrugLib
  119. db := readDb.Model(&models.BaseDrugLib{}).Where("status = 1 and id =? ", id)
  120. err = db.First(&BaseDrugLib).Error
  121. return &BaseDrugLib,err
  122. }
  123. func FindOrgHisPrescriptionInfoByNumber(org_id int64, prescription_number string) (*models.HisPrescriptionInfo, error) {
  124. var HisPrescriptionInfo models.HisPrescriptionInfo
  125. db := readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ? and prescription_number =? ", org_id,prescription_number)
  126. err = db.First(&HisPrescriptionInfo).Error
  127. return &HisPrescriptionInfo,err
  128. }
  129. func FindOrgHisPatientInfo(org_id int64, record_date int64, patient_id int64) (*models.HisPatient, error) {
  130. var HisPatient models.HisPatient
  131. db := readDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ? and record_date =? and patient_id = ?", org_id,record_date,patient_id)
  132. err = db.First(&HisPatient).Error
  133. return &HisPatient,err
  134. }
  135. func FindOrgPatientDataOne(org_id int64) (patient []*models.Patients, err error) {
  136. db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ?", org_id)
  137. err = db.Find(&patient).Error
  138. return
  139. }
  140. func FindOrgPatientInfectious(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
  141. db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND lapseto = 2 ", org_id)
  142. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  143. err = db.Find(&patient).Error
  144. return
  145. }
  146. func FindOrgDeviceNumber(org_id int64, lastUploadTime int64, nowTime int64) (devices []*models.DeviceNumber, err error) {
  147. db := readDb.Model(&models.DeviceNumber{}).Where("status = 1 AND org_id = ?", org_id)
  148. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  149. err = db.Find(&devices).Error
  150. return
  151. }
  152. func FindOrgPatientOutData(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
  153. db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND lapseto = 2 ", org_id).Preload("PatientLapseto", "status = 1")
  154. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  155. err = db.Find(&patient).Error
  156. return
  157. }
  158. func FindOrgScheduleData(org_id int64, lastUploadTime int64, nowTime int64) (sch []*models.Schedule, err error) {
  159. db := readDb.Model(&models.Schedule{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DeviceNumber", "status = 1")
  160. if lastUploadTime != 0 && nowTime != 0 {
  161. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  162. }
  163. err = db.Find(&sch).Error
  164. return
  165. }
  166. func FindOrgDialysisPrescriptionData(org_id int64, lastUploadTime int64, nowTime int64) (ps []*models.DialysisPrescription, err error) {
  167. db := readDb.Model(&models.DialysisPrescription{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DialysisOrder", "status = 1")
  168. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  169. err = db.Find(&ps).Error
  170. return
  171. }
  172. func FindOrgDoctorAdviceTemplateData(org_id int64, lastUploadTime int64, nowTime int64) (advice []*models.DoctorAdviceTemplate, err error) {
  173. db := readDb.Model(&models.DoctorAdviceTemplate{}).Where("status = 1 AND org_id = ? and advice_type = 0 ", org_id)
  174. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  175. err = db.Find(&advice).Error
  176. return
  177. }
  178. func FindAssessmentBeforeDislysis(org_id int64, patient_id int64) (before models.AssessmentBeforeDislysis, err error) {
  179. db := readDb.Model(&models.AssessmentBeforeDislysis{}).Where("status = 1 AND user_org_id = ? and patient_id = ? ", org_id, patient_id)
  180. err = db.Last(&before).Error
  181. return
  182. }
  183. func FindOrgMonitorRecordData(org_id int64, lastUploadTime int64, nowTime int64) (monitor []*models.MonitoringRecord, err error) {
  184. db := readDb.Model(&models.MonitoringRecord{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DialysisOrder", "status = 1")
  185. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  186. err = db.Find(&monitor).Error
  187. return
  188. }
  189. func FindOrgMonitorRecordByLike(org_id int64, keyword string, lastUploadTime int64, nowTime int64) (monitor []*models.MonitoringRecord, err error) {
  190. db := readDb.Model(&models.MonitoringRecord{}).Where("status = 1 AND user_org_id = ? AND symptom like ?", org_id, keyword)
  191. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  192. err = db.Find(&monitor).Error
  193. return
  194. }
  195. func FindOrgInspection(org_id int64, lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
  196. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("Patients", "status = 1")
  197. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date,project_id,patient_id")
  198. err = db.Find(&inspection).Error
  199. return
  200. }
  201. func FindOrgInspectionTwo(org_id int64, lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
  202. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("Patients", "status = 1")
  203. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  204. err = db.Find(&inspection).Error
  205. return
  206. }
  207. // 传染病查询
  208. func FindOrgInspectionGroupOne(org_id int64, lastUploadTime int64, nowTime int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  209. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id = 14 and patient_id = ?", org_id, patient_id)
  210. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
  211. err = db.Find(&inspection).Error
  212. return
  213. }
  214. // 传染病查询
  215. func FindOrgInspectionGroupTwo(org_id int64, inspect_date int64, patient_id int64) (inspection []*models.XtInspection, err error) {
  216. 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)
  217. err = db.Find(&inspection).Error
  218. return
  219. }
  220. func FindOrgInspectionReference(org_id int64, lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
  221. db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("XtInspectionReference", "status = 1")
  222. db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
  223. err = db.Find(&inspection).Error
  224. return
  225. }
  226. func CreateOrgRecord(rdb *gorm.DB, hospital *sz.TempHdHospital) (err error) {
  227. err = rdb.Model(&sz.TempHdHospital{}).Create(&hospital).Error
  228. return
  229. }
  230. func CreateUploadRecord(upload *sz.DataUpload) (err error) {
  231. err = writeDb.Model(&sz.DataUpload{}).Create(&upload).Error
  232. return
  233. }
  234. func FindOrgDialysisData(org_id int64, lastUploadTime int64, nowTime int64) (ps []*models.VMDialysisOrder, err error) {
  235. db := readDb.Model(&models.VMDialysisOrder{}).Where("status = 1 AND user_org_id = ? AND stage = 2 ", org_id).
  236. Preload("DeviceNumber", "status = 1").
  237. Preload("VMDialysisPrescription", "status = 1").
  238. Preload("AssessmentBeforeDislysis", "status = 1").
  239. Preload("AssessmentAfterDislysis", "status = 1").
  240. Preload("Schedule", "status = 1").
  241. Preload("MonitoringRecord", "status = 1")
  242. if lastUploadTime != 0 && nowTime != 0 {
  243. db = db.Where("updated_time >= ? AND updated_time <= ?", lastUploadTime, nowTime)
  244. }
  245. err = db.Find(&ps).Error
  246. return
  247. }
  248. func FindOrgDeviceZoneRecordData(org_id int64, lastUploadTime int64, nowTime int64) (zone []*models.DeviceZone, err error) {
  249. db := readDb.Model(&models.DeviceZone{}).Where("status = 1 AND org_id = ?", org_id)
  250. if lastUploadTime != 0 && nowTime != 0 {
  251. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  252. }
  253. err = db.Find(&zone).Error
  254. return
  255. }
  256. func FindOrgWaterMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
  257. db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ? AND device_type = 2", org_id)
  258. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  259. err = db.Find(&waterMachine).Error
  260. return
  261. }
  262. func BatchCreateWMsRecord(wms []*sz.TempHdWm, rdb *gorm.DB) (err error) {
  263. if len(wms) > 0 {
  264. utx := rdb
  265. if len(wms) > 0 {
  266. thisSQL := "INSERT INTO t_hd_wm (hospital_id, equipment_id, equipment_brand, equipment_model, enable_time,discarded_time,equipment_type,xgbz,create_time,update_time,sjscsj) VALUES "
  267. insertParams := make([]string, 0)
  268. insertData := make([]interface{}, 0)
  269. for _, wm := range wms {
  270. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  271. insertData = append(insertData, wm.HospitalId)
  272. insertData = append(insertData, wm.EquipmentId)
  273. insertData = append(insertData, wm.EquipmentBrand)
  274. insertData = append(insertData, wm.EquipmentModel)
  275. insertData = append(insertData, wm.EnableTime)
  276. insertData = append(insertData, wm.DiscardedTime)
  277. insertData = append(insertData, wm.EquipmentType)
  278. insertData = append(insertData, wm.Xgbz)
  279. insertData = append(insertData, wm.CreateTime)
  280. insertData = append(insertData, wm.UpdateTime)
  281. insertData = append(insertData, wm.Sjscsj)
  282. }
  283. thisSQL += strings.Join(insertParams, ", ")
  284. // err = utx.Exec(thisSQL, insertData...).Error
  285. // if err != nil {
  286. // utx.Rollback()
  287. // return
  288. // }
  289. utx.Exec(thisSQL, insertData...)
  290. }
  291. utx.Commit()
  292. }
  293. return
  294. }
  295. func BatchCreateStaffRecord(staffs []*sz.TempHdStaff, rdb *gorm.DB) (err error) {
  296. if len(staffs) > 0 {
  297. utx := rdb
  298. if len(staffs) > 0 {
  299. var id_no int64
  300. id_no = 429001198701091670
  301. for _, info := range staffs {
  302. 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, update_time, sjscsj, xgbz) VALUES "
  303. insertParams := make([]string, 0)
  304. insertData := make([]interface{}, 0)
  305. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  306. insertData = append(insertData, info.HospitalId)
  307. insertData = append(insertData, info.StaffId)
  308. insertData = append(insertData, id_no)
  309. insertData = append(insertData, "01")
  310. insertData = append(insertData, info.StaffName)
  311. insertData = append(insertData, info.Position)
  312. insertData = append(insertData, "0")
  313. insertData = append(insertData, info.StaffId)
  314. insertData = append(insertData, info.PermanentType)
  315. insertData = append(insertData, "2019-09-01")
  316. insertData = append(insertData, info.CreateTime)
  317. insertData = append(insertData, info.UpdateTime)
  318. insertData = append(insertData, info.Sjscsj)
  319. insertData = append(insertData, info.Xgbz)
  320. thisSQL += strings.Join(insertParams, ", ")
  321. utx.Exec(thisSQL, insertData...)
  322. id_no++
  323. }
  324. }
  325. // utx.Commit()
  326. }
  327. return
  328. }
  329. func BatchCreatePatinet(patients []*sz.TempHdPatient, rdb *gorm.DB) (err error) {
  330. if len(patients) > 0 {
  331. utx := rdb
  332. if len(patients) > 0 {
  333. for _, info := range patients {
  334. 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) VALUES "
  335. insertParams := make([]string, 0)
  336. insertData := make([]interface{}, 0)
  337. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  338. insertData = append(insertData, info.HospitalId)
  339. insertData = append(insertData, info.PatientNk)
  340. insertData = append(insertData, info.CardNo)
  341. insertData = append(insertData, info.CardType)
  342. insertData = append(insertData, info.IdNo)
  343. insertData = append(insertData, info.IdType)
  344. insertData = append(insertData, info.PatientName)
  345. insertData = append(insertData, info.Gender)
  346. insertData = append(insertData, info.BornDate)
  347. insertData = append(insertData, info.DiagnosisSummary)
  348. insertData = append(insertData, info.IsCrf)
  349. insertData = append(insertData, "02")
  350. insertData = append(insertData, "1")
  351. insertData = append(insertData, info.DialysisStartTime)
  352. insertData = append(insertData, info.LocalStartTime)
  353. insertData = append(insertData, info.OutpatientNo)
  354. insertData = append(insertData, info.HospitalizedNo)
  355. insertData = append(insertData, info.Xgbz)
  356. insertData = append(insertData, info.CreateTime)
  357. insertData = append(insertData, info.UpdateTime)
  358. insertData = append(insertData, info.Sjscsj)
  359. thisSQL += strings.Join(insertParams, ", ")
  360. utx.Exec(thisSQL, insertData...)
  361. }
  362. }
  363. // utx.Commit()
  364. }
  365. return
  366. }
  367. func BatchCreateSchedual(patients []*sz.TempHdShift, rdb *gorm.DB) (err error) {
  368. if len(patients) > 0 {
  369. utx := rdb
  370. if len(patients) > 0 {
  371. for _, info := range patients {
  372. 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 "
  373. insertParams := make([]string, 0)
  374. insertData := make([]interface{}, 0)
  375. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  376. insertData = append(insertData, info.PsId)
  377. insertData = append(insertData, info.HospitalId)
  378. insertData = append(insertData, info.PatientNk)
  379. insertData = append(insertData, info.ScheduleDate)
  380. insertData = append(insertData, info.ShiftType)
  381. insertData = append(insertData, info.SickbedNo)
  382. insertData = append(insertData, info.ScheduleStatus)
  383. insertData = append(insertData, info.CreateTime)
  384. insertData = append(insertData, info.Sjscsj)
  385. insertData = append(insertData, info.Xgbz)
  386. thisSQL += strings.Join(insertParams, ", ")
  387. utx.Exec(thisSQL, insertData...)
  388. }
  389. }
  390. // utx.Commit()
  391. }
  392. return
  393. }
  394. func BatchCreatePs(patients []*sz.TempHdPs, rdb *gorm.DB) (err error) {
  395. if len(patients) > 0 {
  396. utx := rdb
  397. if len(patients) > 0 {
  398. 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 "
  399. insertParams := make([]string, 0)
  400. insertData := make([]interface{}, 0)
  401. for _, info := range patients {
  402. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  403. insertData = append(insertData, info.PrescribeId)
  404. insertData = append(insertData, info.HospitalId)
  405. insertData = append(insertData, info.PatientNk)
  406. insertData = append(insertData, info.RrtType)
  407. insertData = append(insertData, info.RrtTypeName)
  408. insertData = append(insertData, info.DialysisFrequency)
  409. insertData = append(insertData, info.FrequencyUnit)
  410. insertData = append(insertData, info.PrescribeTime)
  411. insertData = append(insertData, info.CreateTime)
  412. insertData = append(insertData, info.Sjscsj)
  413. insertData = append(insertData, info.Xgbz)
  414. }
  415. thisSQL += strings.Join(insertParams, ", ")
  416. // err = utx.Exec(thisSQL, insertData...).Error
  417. // if err != nil {
  418. // utx.Rollback()
  419. // return
  420. // }
  421. utx.Exec(thisSQL, insertData...)
  422. }
  423. // utx.Commit()
  424. }
  425. return
  426. }
  427. func BatchCreatePsOther(ps *sz.TempHdPs, rdb *gorm.DB) (err error) {
  428. err = rdb.Create(&ps).Error
  429. return err
  430. }
  431. func BatchCreatePsm(psms []*sz.TempHdPsMedicine, rdb *gorm.DB) (err error) {
  432. if len(psms) > 0 {
  433. utx := rdb
  434. if len(psms) > 0 {
  435. for _, psm := range psms {
  436. thisSQL := "INSERT INTO t_hd_ps_medicine (hospital_id, medicine_type_id,medicine_id,create_time,sjscsj,xgbz,sn) VALUES "
  437. insertParams := make([]string, 0)
  438. insertData := make([]interface{}, 0)
  439. insertParams = append(insertParams, "(?,?,?,?,?,?,?)")
  440. insertData = append(insertData, psm.HospitalId)
  441. insertData = append(insertData, psm.MedicineTypeId)
  442. insertData = append(insertData, psm.MedicineId)
  443. insertData = append(insertData, psm.CreateTime)
  444. insertData = append(insertData, psm.Sjscsj)
  445. insertData = append(insertData, psm.Xgbz)
  446. insertData = append(insertData, psm.Sn)
  447. thisSQL += strings.Join(insertParams, ", ")
  448. // err = utx.Exec(thisSQL, insertData...).Error
  449. utx.Exec(thisSQL, insertData...)
  450. }
  451. // if err != nil {
  452. // utx.Rollback()
  453. // return
  454. // }
  455. }
  456. // utx.Commit()
  457. }
  458. return
  459. }
  460. func BatchCreateDialysis(psms []*sz.TempHdDialysis, rdb *gorm.DB) (err error) {
  461. if len(psms) > 0 {
  462. utx := rdb
  463. if len(psms) > 0 {
  464. for _, psm := range psms {
  465. 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,up_nurse_id,down_nurse_id,check_nurse_id,puncture_nurse_id,start_time,end_time,create_time,sjscsj,xgbz) VALUES "
  466. insertParams := make([]string, 0)
  467. insertData := make([]interface{}, 0)
  468. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  469. insertData = append(insertData, psm.DialysisId)
  470. insertData = append(insertData, psm.HospitalId)
  471. insertData = append(insertData, psm.PatientNk)
  472. insertData = append(insertData, psm.PsId)
  473. insertData = append(insertData, psm.DialysisDate)
  474. insertData = append(insertData, psm.SickbedNo)
  475. insertData = append(insertData, psm.DivisionId)
  476. insertData = append(insertData, psm.EquipmentId)
  477. insertData = append(insertData, psm.MixDialysis)
  478. insertData = append(insertData, psm.Ufv)
  479. insertData = append(insertData, psm.TotalTreatDuration)
  480. insertData = append(insertData, psm.IsHospitalization)
  481. insertData = append(insertData, psm.IsEmergency)
  482. insertData = append(insertData, psm.IsPerioperativePeriod)
  483. insertData = append(insertData, psm.BeforeSbp)
  484. insertData = append(insertData, psm.BeforeDbp)
  485. insertData = append(insertData, psm.AfterSbp)
  486. insertData = append(insertData, psm.AfterDbp)
  487. insertData = append(insertData, psm.BeforeWeight)
  488. insertData = append(insertData, psm.AfterWeight)
  489. insertData = append(insertData, psm.UpNurseId)
  490. insertData = append(insertData, psm.DownNurseId)
  491. insertData = append(insertData, psm.CheckNurseId)
  492. insertData = append(insertData, psm.PunctureNurseId)
  493. insertData = append(insertData, psm.StartTime)
  494. insertData = append(insertData, psm.EndTime)
  495. insertData = append(insertData, psm.CreateTime)
  496. insertData = append(insertData, psm.Sjscsj)
  497. insertData = append(insertData, psm.Xgbz)
  498. thisSQL += strings.Join(insertParams, ", ")
  499. utx.Exec(thisSQL, insertData...)
  500. }
  501. // if err != nil {
  502. // utx.Rollback()
  503. // return
  504. // }
  505. }
  506. // utx.Commit()
  507. }
  508. return
  509. }
  510. func BatchCreatePatientOut(patientOuts []*sz.TempHdPatientOut, rdb *gorm.DB) (err error) {
  511. if len(patientOuts) > 0 {
  512. utx := rdb
  513. if len(patientOuts) > 0 {
  514. 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 "
  515. insertParams := make([]string, 0)
  516. insertData := make([]interface{}, 0)
  517. for _, out := range patientOuts {
  518. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  519. insertData = append(insertData, out.Sn)
  520. insertData = append(insertData, out.HospitalId)
  521. insertData = append(insertData, out.PatientNk)
  522. insertData = append(insertData, out.SequelaeDate)
  523. insertData = append(insertData, out.SequelaeType)
  524. insertData = append(insertData, out.CreateTime)
  525. insertData = append(insertData, out.DeathReason)
  526. insertData = append(insertData, out.ExtReason)
  527. insertData = append(insertData, out.Sjscsj)
  528. insertData = append(insertData, out.Xgbz)
  529. }
  530. thisSQL += strings.Join(insertParams, ", ")
  531. utx.Exec(thisSQL, insertData...)
  532. // if err != nil {
  533. // utx.Rollback()
  534. // return
  535. // }
  536. }
  537. // utx.Commit()
  538. }
  539. return
  540. }
  541. func BatchCreateDoctorsAdvice(advices []*sz.TempHdDoctorsAdvice, rdb *gorm.DB) (err error) {
  542. if len(advices) > 0 {
  543. utx := rdb
  544. if len(advices) > 0 {
  545. for _, advice := range advices {
  546. 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 "
  547. insertParams := make([]string, 0)
  548. insertData := make([]interface{}, 0)
  549. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  550. insertData = append(insertData, advice.MedicalOrderId)
  551. insertData = append(insertData, advice.HospitalId)
  552. insertData = append(insertData, advice.DialysisId)
  553. insertData = append(insertData, advice.OrderType)
  554. insertData = append(insertData, advice.PatientNk)
  555. insertData = append(insertData, advice.DialysisDuration)
  556. insertData = append(insertData, advice.BloodVol)
  557. insertData = append(insertData, advice.Anticoagulant)
  558. insertData = append(insertData, advice.CreateTime)
  559. insertData = append(insertData, advice.Sjscsj)
  560. insertData = append(insertData, advice.Xgbz)
  561. insertData = append(insertData, advice.RrtType)
  562. insertData = append(insertData, advice.RrtTypeName)
  563. insertData = append(insertData, advice.DryWeight)
  564. thisSQL += strings.Join(insertParams, ", ")
  565. utx.Exec(thisSQL, insertData...)
  566. }
  567. // if err != nil {
  568. // utx.Rollback()
  569. // return
  570. // }
  571. }
  572. // utx.Commit()
  573. }
  574. return
  575. }
  576. func BatchCreateMonitor(advices []*sz.TempHdMiddle, rdb *gorm.DB) (err error) {
  577. if len(advices) > 0 {
  578. utx := rdb
  579. if len(advices) > 0 {
  580. for _, advice := range advices {
  581. thisSQL := "INSERT INTO t_hd_middle (sn,hospital_id, patient_nk,dialysis_id,monitor_time,sbp,dbp,create_time,sjscsj,xgbz) VALUES "
  582. insertParams := make([]string, 0)
  583. insertData := make([]interface{}, 0)
  584. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  585. insertData = append(insertData, advice.Sn)
  586. insertData = append(insertData, advice.HospitalId)
  587. insertData = append(insertData, advice.PatientNk)
  588. insertData = append(insertData, advice.DialysisId)
  589. insertData = append(insertData, advice.MonitorTime)
  590. insertData = append(insertData, advice.Sbp)
  591. insertData = append(insertData, advice.Dbp)
  592. insertData = append(insertData, advice.CreateTime)
  593. insertData = append(insertData, advice.Sjscsj)
  594. insertData = append(insertData, advice.Xgbz)
  595. thisSQL += strings.Join(insertParams, ", ")
  596. utx.Exec(thisSQL, insertData...)
  597. }
  598. // if err != nil {
  599. // utx.Rollback()
  600. // return
  601. // }
  602. }
  603. // utx.Commit()
  604. }
  605. return
  606. }
  607. func FindOrgOtherMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
  608. db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ? AND (device_type = 1 OR device_type = 3)", org_id)
  609. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  610. err = db.Find(&waterMachine).Error
  611. return
  612. }
  613. func FindOrgMachineRepairData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.DeviceRepair, err error) {
  614. db := readUserDb.Model(&models.DeviceRepair{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("VMDeviceAddmacher", "status = 1")
  615. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  616. err = db.Find(&waterMachine).Error
  617. return
  618. }
  619. func BatchCreateOtherMachineRecord(wms []*sz.TempHdOtherMachine, rdb *gorm.DB) (err error) {
  620. if len(wms) > 0 {
  621. utx := rdb
  622. if len(wms) > 0 {
  623. for _, wm := range wms {
  624. thisSQL := "INSERT INTO t_hd_other_machine (hospital_id, equipment_id, equipment_brand, equipment_model, enable_time,status,equipment_type,xgbz,create_time,update_time,sjscsj) VALUES "
  625. insertParams := make([]string, 0)
  626. insertData := make([]interface{}, 0)
  627. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  628. insertData = append(insertData, wm.HospitalId)
  629. insertData = append(insertData, wm.EquipmentId)
  630. insertData = append(insertData, wm.EquipmentBrand)
  631. insertData = append(insertData, wm.EquipmentModel)
  632. insertData = append(insertData, wm.EnableTime)
  633. insertData = append(insertData, wm.Status)
  634. insertData = append(insertData, wm.EquipmentType)
  635. insertData = append(insertData, wm.Xgbz)
  636. insertData = append(insertData, wm.CreateTime)
  637. insertData = append(insertData, wm.UpdateTime)
  638. insertData = append(insertData, wm.Sjscsj)
  639. thisSQL += strings.Join(insertParams, ", ")
  640. utx.Exec(thisSQL, insertData...)
  641. }
  642. }
  643. // utx.Commit()
  644. }
  645. return
  646. }
  647. func BatchCreateMainTain(maintain []*sz.TempHdMaintain, rdb *gorm.DB) (err error) {
  648. if len(maintain) > 0 {
  649. utx := rdb
  650. if len(maintain) > 0 {
  651. thisSQL := "INSERT INTO t_hd_maintain (hospital_id, equipment_id, equipment_type, repair_time, xgbz,create_time,sjscsj) VALUES "
  652. insertParams := make([]string, 0)
  653. insertData := make([]interface{}, 0)
  654. for _, wm := range maintain {
  655. insertParams = append(insertParams, "(?,?,?,?,?,?,?)")
  656. insertData = append(insertData, wm.HospitalId)
  657. insertData = append(insertData, wm.EquipmentId)
  658. insertData = append(insertData, wm.EquipmentType)
  659. insertData = append(insertData, wm.RepairTime)
  660. insertData = append(insertData, wm.Xgbz)
  661. insertData = append(insertData, wm.CreateTime)
  662. insertData = append(insertData, wm.Sjscsj)
  663. }
  664. thisSQL += strings.Join(insertParams, ", ")
  665. utx.Exec(thisSQL, insertData...)
  666. // if err != nil {
  667. // utx.Rollback()
  668. // return
  669. // }
  670. }
  671. // utx.Commit()
  672. }
  673. return
  674. }
  675. func FindOrgMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
  676. db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
  677. return readDb.Model(&models.DeviceNumber{}).Where("status = 1")
  678. })
  679. db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
  680. err = db.Find(&waterMachine).Error
  681. return
  682. }
  683. func BatchCreateHDMRecord(wms []*sz.TempHdDm, rdb *gorm.DB) (err error) {
  684. if len(wms) > 0 {
  685. utx := rdb
  686. if len(wms) > 0 {
  687. for _, wm := range wms {
  688. thisSQL := "INSERT INTO t_hd_dm (hospital_id, equipment_id,sickbed_no,sickbed_type ,equipment_brand, equipment_model, enable_time,status,equipment_type, xgbz,bbp,create_time,update_time,sjscsj) VALUES "
  689. insertParams := make([]string, 0)
  690. insertData := make([]interface{}, 0)
  691. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  692. insertData = append(insertData, wm.HospitalId)
  693. insertData = append(insertData, wm.EquipmentId)
  694. insertData = append(insertData, wm.SickbedNo)
  695. insertData = append(insertData, wm.SickbedType)
  696. insertData = append(insertData, wm.EquipmentBrand)
  697. insertData = append(insertData, wm.EquipmentModel)
  698. insertData = append(insertData, wm.EnableTime)
  699. insertData = append(insertData, wm.Status)
  700. insertData = append(insertData, wm.EquipmentType)
  701. insertData = append(insertData, wm.Xgbz)
  702. insertData = append(insertData, wm.Bbp)
  703. insertData = append(insertData, wm.CreateTime)
  704. insertData = append(insertData, wm.UpdateTime)
  705. insertData = append(insertData, wm.Sjscsj)
  706. thisSQL += strings.Join(insertParams, ", ")
  707. utx.Exec(thisSQL, insertData...)
  708. }
  709. // if err != nil {
  710. // utx.Rollback()
  711. // return
  712. // }
  713. }
  714. // utx.Commit()
  715. }
  716. return
  717. }
  718. func CreateHDDivision(wms []*sz.TempHdDivision, rdb *gorm.DB) (err error) {
  719. if len(wms) > 0 {
  720. utx := rdb
  721. if len(wms) > 0 {
  722. for _, wm := range wms {
  723. thisSQL := "INSERT INTO t_hd_division (division_id,hospital_id, division_name,division_type, xgbz,create_time,update_time,sjscsj) VALUES "
  724. insertParams := make([]string, 0)
  725. insertData := make([]interface{}, 0)
  726. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?)")
  727. insertData = append(insertData, wm.DivisionId)
  728. insertData = append(insertData, wm.HospitalId)
  729. insertData = append(insertData, wm.DivisionName)
  730. insertData = append(insertData, wm.DivisionType)
  731. insertData = append(insertData, wm.Xgbz)
  732. insertData = append(insertData, wm.CreateTime)
  733. insertData = append(insertData, wm.UpdateTime)
  734. insertData = append(insertData, wm.Sjscsj)
  735. thisSQL += strings.Join(insertParams, ", ")
  736. utx.Exec(thisSQL, insertData...)
  737. }
  738. }
  739. }
  740. return
  741. }
  742. func CreateAccess(wms []*sz.TempHdAccess, rdb *gorm.DB) (err error) {
  743. if len(wms) > 0 {
  744. utx := rdb
  745. if len(wms) > 0 {
  746. for _, wm := range wms {
  747. 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 "
  748. insertParams := make([]string, 0)
  749. insertData := make([]interface{}, 0)
  750. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
  751. insertData = append(insertData, wm.AccessId)
  752. insertData = append(insertData, wm.HospitalId)
  753. insertData = append(insertData, wm.PatientNk)
  754. insertData = append(insertData, wm.AccessType)
  755. insertData = append(insertData, wm.AccessTypeName)
  756. insertData = append(insertData, wm.AccessStatus)
  757. insertData = append(insertData, wm.SetupDate)
  758. insertData = append(insertData, wm.FirstUseTime)
  759. insertData = append(insertData, wm.Xgbz)
  760. insertData = append(insertData, wm.CreateTime)
  761. insertData = append(insertData, wm.UpdateTime)
  762. insertData = append(insertData, wm.Sjscsj)
  763. thisSQL += strings.Join(insertParams, ", ")
  764. utx.Exec(thisSQL, insertData...)
  765. }
  766. }
  767. }
  768. return
  769. }
  770. func CreateSickbed(wms []*sz.TempHdSickbed, rdb *gorm.DB) (err error) {
  771. if len(wms) > 0 {
  772. utx := rdb
  773. if len(wms) > 0 {
  774. for _, wm := range wms {
  775. thisSQL := "INSERT INTO t_hd_sickbed (sickbed_no,hospital_id,division_id,sickbed_code,sickbed_type,xgbz,create_time,update_time,sjscsj) VALUES "
  776. insertParams := make([]string, 0)
  777. insertData := make([]interface{}, 0)
  778. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
  779. insertData = append(insertData, wm.SickbedNo)
  780. insertData = append(insertData, wm.HospitalId)
  781. insertData = append(insertData, wm.DivisionId)
  782. insertData = append(insertData, wm.SickbedCode)
  783. insertData = append(insertData, wm.SickbedType)
  784. insertData = append(insertData, wm.Xgbz)
  785. insertData = append(insertData, wm.CreateTime)
  786. insertData = append(insertData, wm.UpdateTime)
  787. insertData = append(insertData, wm.Sjscsj)
  788. thisSQL += strings.Join(insertParams, ", ")
  789. utx.Exec(thisSQL, insertData...)
  790. }
  791. }
  792. }
  793. return
  794. }
  795. func CreateDiagnosis(wms []*sz.TempHdDiagnosis, rdb *gorm.DB) (err error) {
  796. if len(wms) > 0 {
  797. utx := rdb
  798. if len(wms) > 0 {
  799. for _, wm := range wms {
  800. 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,update_time,sjscsj) VALUES "
  801. insertParams := make([]string, 0)
  802. insertData := make([]interface{}, 0)
  803. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  804. insertData = append(insertData, wm.DiagnosisId)
  805. insertData = append(insertData, wm.HospitalId)
  806. insertData = append(insertData, wm.PatientNk)
  807. insertData = append(insertData, wm.DiagnosisTime)
  808. insertData = append(insertData, wm.DiagnosisType)
  809. insertData = append(insertData, wm.DiagnosisTypeItem)
  810. insertData = append(insertData, wm.DiagnosisTypeDetail)
  811. insertData = append(insertData, wm.Xgbz)
  812. insertData = append(insertData, wm.CreateTime)
  813. insertData = append(insertData, wm.UpdateTime)
  814. insertData = append(insertData, wm.Sjscsj)
  815. thisSQL += strings.Join(insertParams, ", ")
  816. utx.Exec(thisSQL, insertData...)
  817. }
  818. }
  819. }
  820. return
  821. }
  822. func CreateInfection(wms []*sz.TempHdInfection, rdb *gorm.DB) (err error) {
  823. if len(wms) > 0 {
  824. utx := rdb
  825. if len(wms) > 0 {
  826. for _, wm := range wms {
  827. 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 "
  828. insertParams := make([]string, 0)
  829. insertData := make([]interface{}, 0)
  830. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  831. insertData = append(insertData, wm.Sn)
  832. insertData = append(insertData, wm.HospitalId)
  833. insertData = append(insertData, wm.PatientNk)
  834. insertData = append(insertData, wm.Hbv)
  835. insertData = append(insertData, wm.Hcv)
  836. insertData = append(insertData, wm.Rpr)
  837. insertData = append(insertData, wm.Hiv)
  838. insertData = append(insertData, wm.Hbsag)
  839. insertData = append(insertData, wm.Hbsab)
  840. insertData = append(insertData, wm.Hbeag)
  841. insertData = append(insertData, wm.Hbeab)
  842. insertData = append(insertData, wm.Hbcab)
  843. insertData = append(insertData, wm.CheckDate)
  844. insertData = append(insertData, wm.DoctorId)
  845. insertData = append(insertData, wm.Xgbz)
  846. insertData = append(insertData, wm.CreateTime)
  847. insertData = append(insertData, wm.Sjscsj)
  848. thisSQL += strings.Join(insertParams, ", ")
  849. utx.Exec(thisSQL, insertData...)
  850. }
  851. }
  852. }
  853. return
  854. }
  855. func CreateComplication(wms []*sz.TempHdComplication, rdb *gorm.DB) (err error) {
  856. if len(wms) > 0 {
  857. utx := rdb
  858. if len(wms) > 0 {
  859. for _, wm := range wms {
  860. 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 "
  861. insertParams := make([]string, 0)
  862. insertData := make([]interface{}, 0)
  863. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
  864. insertData = append(insertData, wm.Sn)
  865. insertData = append(insertData, wm.HospitalId)
  866. insertData = append(insertData, wm.PatientNk)
  867. insertData = append(insertData, wm.DialysisId)
  868. insertData = append(insertData, wm.MonitorId)
  869. insertData = append(insertData, wm.NeopathyTime)
  870. insertData = append(insertData, wm.NeopathyType)
  871. insertData = append(insertData, wm.NeopathyDesc)
  872. insertData = append(insertData, wm.Xgbz)
  873. insertData = append(insertData, wm.CreateTime)
  874. insertData = append(insertData, wm.Sjscsj)
  875. thisSQL += strings.Join(insertParams, ", ")
  876. utx.Exec(thisSQL, insertData...)
  877. }
  878. }
  879. }
  880. return
  881. }
  882. func CreateLisReport(wms []*sz.TempHdLisReport, rdb *gorm.DB) (err error) {
  883. if len(wms) > 0 {
  884. utx := rdb
  885. if len(wms) > 0 {
  886. for _, wm := range wms {
  887. 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 "
  888. insertParams := make([]string, 0)
  889. insertData := make([]interface{}, 0)
  890. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  891. insertData = append(insertData, wm.LabSno)
  892. insertData = append(insertData, wm.HospitalId)
  893. insertData = append(insertData, wm.PatientNk)
  894. insertData = append(insertData, wm.ReportDate)
  895. insertData = append(insertData, wm.CheckDate)
  896. insertData = append(insertData, wm.JzNo)
  897. insertData = append(insertData, wm.MzFlag)
  898. insertData = append(insertData, wm.ZyNo)
  899. insertData = append(insertData, wm.MzNo)
  900. insertData = append(insertData, wm.DepartmentCode)
  901. insertData = append(insertData, wm.DepartmentName)
  902. insertData = append(insertData, wm.CardNo)
  903. insertData = append(insertData, wm.CardType)
  904. insertData = append(insertData, wm.PatientName)
  905. insertData = append(insertData, wm.DepCode)
  906. insertData = append(insertData, wm.DepName)
  907. insertData = append(insertData, wm.InspectedType)
  908. insertData = append(insertData, wm.ReportCategry)
  909. insertData = append(insertData, wm.ApplicationName)
  910. insertData = append(insertData, wm.ApplicationType)
  911. insertData = append(insertData, wm.CheckName)
  912. insertData = append(insertData, wm.CheckItemName)
  913. insertData = append(insertData, wm.CheckItemCode)
  914. insertData = append(insertData, wm.RecordCcount)
  915. insertData = append(insertData, wm.CheckResult)
  916. insertData = append(insertData, wm.DiagnoseName)
  917. insertData = append(insertData, wm.Xgbz)
  918. insertData = append(insertData, wm.CreateTime)
  919. insertData = append(insertData, wm.Sjscsj)
  920. thisSQL += strings.Join(insertParams, ", ")
  921. utx.Exec(thisSQL, insertData...)
  922. }
  923. }
  924. }
  925. return
  926. }
  927. func CreateLisIndicators(wms []*sz.TempHdLisIndicators, rdb *gorm.DB) (err error) {
  928. if len(wms) > 0 {
  929. utx := rdb
  930. if len(wms) > 0 {
  931. for _, wm := range wms {
  932. 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,xgbz,create_time,sjscsj) VALUES "
  933. insertParams := make([]string, 0)
  934. insertData := make([]interface{}, 0)
  935. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
  936. insertData = append(insertData, wm.InspectedResultNo)
  937. insertData = append(insertData, wm.HospitalId)
  938. insertData = append(insertData, wm.LabSno)
  939. insertData = append(insertData, wm.ReportDate)
  940. insertData = append(insertData, wm.CheckDate)
  941. insertData = append(insertData, wm.InspectedIndicate)
  942. insertData = append(insertData, wm.InspectedItemEnName)
  943. insertData = append(insertData, wm.InspectedItemCnName)
  944. insertData = append(insertData, wm.InspectedResultDesc)
  945. insertData = append(insertData, wm.InspectedResultValue)
  946. insertData = append(insertData, wm.InspectedResultUnit)
  947. insertData = append(insertData, wm.RefRange)
  948. insertData = append(insertData, wm.UnitType)
  949. insertData = append(insertData, wm.InspectedResult)
  950. insertData = append(insertData, wm.Xgbz)
  951. insertData = append(insertData, wm.CreateTime)
  952. insertData = append(insertData, wm.Sjscsj)
  953. thisSQL += strings.Join(insertParams, ", ")
  954. utx.Exec(thisSQL, insertData...)
  955. }
  956. }
  957. }
  958. return
  959. }
  960. func FindOrgCulture(org_id int64, lastUploadTime int64, nowTime int64) (culture []*models.XtDeviceCulture, err error) {
  961. err = UserReadDB().Model(&culture).Where("status = 1 and user_org_id = ? and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&culture).Error
  962. return culture, err
  963. }
  964. func CreateLisCulture(wms []*sz.TempHdLisCulture, rdb *gorm.DB) (err error) {
  965. if len(wms) > 0 {
  966. utx := rdb
  967. if len(wms) > 0 {
  968. for _, wm := range wms {
  969. thisSQL := "INSERT INTO t_hd_dm_dialysate_bc (sn,hospital_id,equipment_id,inspection_time,is_qualified,is_substitution_qualified,case_order,create_time,sjscsj,xgbz) VALUES "
  970. insertParams := make([]string, 0)
  971. insertData := make([]interface{}, 0)
  972. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  973. insertData = append(insertData, wm.Sn)
  974. insertData = append(insertData, wm.HospitalId)
  975. insertData = append(insertData, wm.EquitmentId)
  976. insertData = append(insertData, wm.InspectionTime)
  977. insertData = append(insertData, wm.IsQualified)
  978. insertData = append(insertData, wm.IsSubstitutionQualified)
  979. insertData = append(insertData, wm.CaseOrder)
  980. insertData = append(insertData, wm.CreateTime)
  981. insertData = append(insertData, wm.Sjscsj)
  982. insertData = append(insertData, wm.Xgbz)
  983. thisSQL += strings.Join(insertParams, ", ")
  984. utx.Exec(thisSQL, insertData...)
  985. }
  986. }
  987. }
  988. return
  989. }
  990. func FindOrgDialysate(org_id int64, lastUploadTime int64, nowTime int64) (dialysate []*models.XtDeviceDialysate, err error) {
  991. err = UserReadDB().Model(&dialysate).Where("status = 1 and user_org_id = ? and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&dialysate).Error
  992. return dialysate, err
  993. }
  994. func CreateLisDialysate(wms []*sz.TempHdLisDialysate, 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_dm_dialysate_en (sn,hospital_id,equipment_id,inspection_time,is_qualified,case_order,create_time,sjscsj,xgbz) VALUES "
  1000. insertParams := make([]string, 0)
  1001. insertData := make([]interface{}, 0)
  1002. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
  1003. insertData = append(insertData, wm.Sn)
  1004. insertData = append(insertData, wm.HospitalId)
  1005. insertData = append(insertData, wm.EquitmentId)
  1006. insertData = append(insertData, wm.InspectionTime)
  1007. insertData = append(insertData, wm.IsQualified)
  1008. insertData = append(insertData, wm.CaseOrder)
  1009. insertData = append(insertData, wm.CreateTime)
  1010. insertData = append(insertData, wm.Sjscsj)
  1011. insertData = append(insertData, wm.Xgbz)
  1012. thisSQL += strings.Join(insertParams, ", ")
  1013. utx.Exec(thisSQL, insertData...)
  1014. }
  1015. }
  1016. }
  1017. return
  1018. }
  1019. func FindOrgArialDetection(org_id int64, lastUploadTime int64, nowTime int64) (airdetection []*models.XtAerialDetection, err error) {
  1020. err = XTReadDB().Model(&airdetection).Where("user_org_id = ? and status=1 and created_time>=? and created_time<=?", org_id, lastUploadTime, nowTime).Find(&airdetection).Error
  1021. return airdetection, err
  1022. }
  1023. func CreateAirDisinfect(wms []*sz.TempHdLisAirDisinfect, rdb *gorm.DB) (err error) {
  1024. if len(wms) > 0 {
  1025. utx := rdb
  1026. if len(wms) > 0 {
  1027. for _, wm := range wms {
  1028. thisSQL := "INSERT INTO t_hd_air_disinfect (sn,hospital_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
  1029. insertParams := make([]string, 0)
  1030. insertData := make([]interface{}, 0)
  1031. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
  1032. insertData = append(insertData, wm.Sn)
  1033. insertData = append(insertData, wm.HospitalId)
  1034. insertData = append(insertData, wm.InspectionTime)
  1035. insertData = append(insertData, wm.IsQualified)
  1036. insertData = append(insertData, wm.InspectedValue)
  1037. insertData = append(insertData, wm.CaseOrder)
  1038. insertData = append(insertData, wm.CreateTime)
  1039. insertData = append(insertData, wm.Sjscsj)
  1040. insertData = append(insertData, wm.Xgbz)
  1041. thisSQL += strings.Join(insertParams, ", ")
  1042. utx.Exec(thisSQL, insertData...)
  1043. }
  1044. }
  1045. }
  1046. return
  1047. }
  1048. func FindOrgBodyDetection(org_id int64, lastUploadTime int64, nowTime int64) (body []*models.XtBodyDetection, err error) {
  1049. err = XTReadDB().Model(&body).Where("user_org_id = ? and status=1 and created_time>=? and created_time<=?", org_id, lastUploadTime, nowTime).Find(&body).Error
  1050. return body, err
  1051. }
  1052. func CreateBodyDisinfect(wms []*sz.TempHdLisBodyDisinfect, rdb *gorm.DB) (err error) {
  1053. if len(wms) > 0 {
  1054. utx := rdb
  1055. if len(wms) > 0 {
  1056. for _, wm := range wms {
  1057. thisSQL := "INSERT INTO t_hd_surface_disinfect (sn,hospital_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz,update_time) VALUES "
  1058. insertParams := make([]string, 0)
  1059. insertData := make([]interface{}, 0)
  1060. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  1061. insertData = append(insertData, wm.Sn)
  1062. insertData = append(insertData, wm.HospitalId)
  1063. insertData = append(insertData, wm.InspectionTime)
  1064. insertData = append(insertData, wm.IsQualified)
  1065. insertData = append(insertData, wm.InspectedValue)
  1066. insertData = append(insertData, wm.CaseOrder)
  1067. insertData = append(insertData, wm.CreateTime)
  1068. insertData = append(insertData, wm.Sjscsj)
  1069. insertData = append(insertData, wm.Xgbz)
  1070. insertData = append(insertData, wm.UpdateTime)
  1071. thisSQL += strings.Join(insertParams, ", ")
  1072. utx.Exec(thisSQL, insertData...)
  1073. }
  1074. }
  1075. }
  1076. return
  1077. }
  1078. func FindOrgWaterFc(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDeviceWater, err error) {
  1079. err = UserReadDB().Model(&water).Where("user_org_id = ? and status = 1 and sampling_date>=? and sampling_date<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
  1080. return water, err
  1081. }
  1082. func CreateWaterFc(wms []*sz.TempHdLisWaterFc, rdb *gorm.DB) (err error) {
  1083. if len(wms) > 0 {
  1084. utx := rdb
  1085. if len(wms) > 0 {
  1086. for _, wm := range wms {
  1087. thisSQL := "INSERT INTO t_hd_water_fc(sn,hospital_id,equitpment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz,update_time) VALUES "
  1088. insertParams := make([]string, 0)
  1089. insertData := make([]interface{}, 0)
  1090. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
  1091. insertData = append(insertData, wm.Sn)
  1092. insertData = append(insertData, wm.HospitalId)
  1093. insertData = append(insertData, wm.EquitmentId)
  1094. insertData = append(insertData, wm.WaterType)
  1095. insertData = append(insertData, wm.InspectionOrgId)
  1096. insertData = append(insertData, wm.InspectionTime)
  1097. insertData = append(insertData, wm.IsQualified)
  1098. insertData = append(insertData, wm.InspectedValue)
  1099. insertData = append(insertData, wm.CaseOrder)
  1100. insertData = append(insertData, wm.CreateTime)
  1101. insertData = append(insertData, wm.Sjscsj)
  1102. insertData = append(insertData, wm.Xgbz)
  1103. insertData = append(insertData, wm.UpdateTime)
  1104. thisSQL += strings.Join(insertParams, ", ")
  1105. utx.Exec(thisSQL, insertData...)
  1106. }
  1107. }
  1108. }
  1109. return
  1110. }
  1111. func FindOrgWaterNc(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDeviceOxygenates, err error) {
  1112. err = UserReadDB().Model(&water).Where("user_org_id = ? and status = 1 and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
  1113. return water, err
  1114. }
  1115. func CreateWaterNc(wms []*sz.TempHdLisWaterNc, rdb *gorm.DB) (err error) {
  1116. if len(wms) > 0 {
  1117. utx := rdb
  1118. if len(wms) > 0 {
  1119. for _, wm := range wms {
  1120. thisSQL := "INSERT INTO t_hd_water_nc(sn,hospital_id,equitpment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz,update_time) VALUES "
  1121. insertParams := make([]string, 0)
  1122. insertData := make([]interface{}, 0)
  1123. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
  1124. insertData = append(insertData, wm.Sn)
  1125. insertData = append(insertData, wm.HospitalId)
  1126. insertData = append(insertData, wm.EquitmentId)
  1127. insertData = append(insertData, wm.WaterType)
  1128. insertData = append(insertData, wm.InspectionOrgId)
  1129. insertData = append(insertData, wm.InspectionTime)
  1130. insertData = append(insertData, wm.IsQualified)
  1131. insertData = append(insertData, wm.InspectedValue)
  1132. insertData = append(insertData, wm.CaseOrder)
  1133. insertData = append(insertData, wm.CreateTime)
  1134. insertData = append(insertData, wm.Sjscsj)
  1135. insertData = append(insertData, wm.Xgbz)
  1136. insertData = append(insertData, wm.UpdateTime)
  1137. thisSQL += strings.Join(insertParams, ", ")
  1138. utx.Exec(thisSQL, insertData...)
  1139. }
  1140. }
  1141. }
  1142. return
  1143. }
  1144. func FindOrgWaterPh(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDevicePh, err error) {
  1145. err = UserReadDB().Model(&water).Where("user_org_id = ? and sampling_date>? and sampling_date<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
  1146. return water, err
  1147. }
  1148. func CreateWaterPh(wms []*sz.TempHdLisWaterPh, rdb *gorm.DB) (err error) {
  1149. if len(wms) > 0 {
  1150. utx := rdb
  1151. if len(wms) > 0 {
  1152. for _, wm := range wms {
  1153. thisSQL := "INSERT INTO t_hd_water_ph(sn,hospital_id,equitpment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz,update_time) VALUES "
  1154. insertParams := make([]string, 0)
  1155. insertData := make([]interface{}, 0)
  1156. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
  1157. insertData = append(insertData, wm.Sn)
  1158. insertData = append(insertData, wm.HospitalId)
  1159. insertData = append(insertData, wm.EquitmentId)
  1160. insertData = append(insertData, wm.WaterType)
  1161. insertData = append(insertData, wm.InspectionOrgId)
  1162. insertData = append(insertData, wm.InspectionTime)
  1163. insertData = append(insertData, wm.IsQualified)
  1164. insertData = append(insertData, wm.InspectedValue)
  1165. insertData = append(insertData, wm.CaseOrder)
  1166. insertData = append(insertData, wm.CreateTime)
  1167. insertData = append(insertData, wm.Sjscsj)
  1168. insertData = append(insertData, wm.Xgbz)
  1169. insertData = append(insertData, wm.UpdateTime)
  1170. thisSQL += strings.Join(insertParams, ", ")
  1171. utx.Exec(thisSQL, insertData...)
  1172. }
  1173. }
  1174. }
  1175. return
  1176. }
  1177. func FindOrgWaterWh(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDeviceHadwater, err error) {
  1178. err = UserReadDB().Model(&water).Where("user_org_id = ? and sampling_date>=? and sampling_date<=? and status =1", org_id, lastUploadTime, nowTime).Find(&water).Error
  1179. return water, err
  1180. }
  1181. func CreateWaterWh(wms []*sz.TempHdLisWaterWh, rdb *gorm.DB) (err error) {
  1182. if len(wms) > 0 {
  1183. utx := rdb
  1184. if len(wms) > 0 {
  1185. for _, wm := range wms {
  1186. thisSQL := "INSERT INTO t_hd_water_wh(sn,hospital_id,equitpment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz,update_time) VALUES "
  1187. insertParams := make([]string, 0)
  1188. insertData := make([]interface{}, 0)
  1189. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
  1190. insertData = append(insertData, wm.Sn)
  1191. insertData = append(insertData, wm.HospitalId)
  1192. insertData = append(insertData, wm.EquitmentId)
  1193. insertData = append(insertData, wm.WaterType)
  1194. insertData = append(insertData, wm.InspectionOrgId)
  1195. insertData = append(insertData, wm.InspectionTime)
  1196. insertData = append(insertData, wm.IsQualified)
  1197. insertData = append(insertData, wm.InspectedValue)
  1198. insertData = append(insertData, wm.CaseOrder)
  1199. insertData = append(insertData, wm.CreateTime)
  1200. insertData = append(insertData, wm.Sjscsj)
  1201. insertData = append(insertData, wm.Xgbz)
  1202. insertData = append(insertData, wm.UpdateTime)
  1203. thisSQL += strings.Join(insertParams, ", ")
  1204. utx.Exec(thisSQL, insertData...)
  1205. }
  1206. }
  1207. }
  1208. return
  1209. }
  1210. func FindOrgHdCi(org_id int64, lastUploadTime int64, nowTime int64) (access []*models.XtPatientVascularAccess, err error) {
  1211. err = XTReadDB().Model(&access).Where("user_org_id = ? and start_time>=? and start_time<=? and access_project = 2 and status =1", org_id, lastUploadTime, nowTime).Find(&access).Error
  1212. return access, err
  1213. }
  1214. func CreateHdCi(wms []*sz.TempHdCi, rdb *gorm.DB) (err error) {
  1215. if len(wms) > 0 {
  1216. utx := rdb
  1217. if len(wms) > 0 {
  1218. for _, wm := range wms {
  1219. 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 "
  1220. insertParams := make([]string, 0)
  1221. insertData := make([]interface{}, 0)
  1222. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
  1223. insertData = append(insertData, wm.InfectSn)
  1224. insertData = append(insertData, wm.HospitalId)
  1225. insertData = append(insertData, wm.PatientNk)
  1226. insertData = append(insertData, wm.AccessId)
  1227. insertData = append(insertData, wm.CiType)
  1228. insertData = append(insertData, wm.BloodCulture)
  1229. insertData = append(insertData, wm.InfectionDate)
  1230. insertData = append(insertData, wm.CreateTime)
  1231. insertData = append(insertData, wm.Sjscsj)
  1232. insertData = append(insertData, wm.Xgbz)
  1233. thisSQL += strings.Join(insertParams, ", ")
  1234. utx.Exec(thisSQL, insertData...)
  1235. }
  1236. }
  1237. }
  1238. return
  1239. }
  1240. func FindOrgHdCiOutCome(org_id int64, lastUploadTime int64, nowTime int64) (access []*models.XtPatientVascularAccess, err error) {
  1241. err = XTReadDB().Model(&access).Where("user_org_id = ? and start_time>=? and start_time<=? and access_project = 2 and status =1", org_id, lastUploadTime, nowTime).Find(&access).Error
  1242. return access, err
  1243. }
  1244. func CreateHdCiOutCome(wms []*sz.TempHdCiOutCome, rdb *gorm.DB) (err error) {
  1245. if len(wms) > 0 {
  1246. utx := rdb
  1247. if len(wms) > 0 {
  1248. for _, wm := range wms {
  1249. thisSQL := "INSERT INTO t_hd_ci_outcome(hospital_id,sn,infect_sn,patient_nk,sequelae_type,sjscsj,xgbz,create_time,update_time) VALUES "
  1250. insertParams := make([]string, 0)
  1251. insertData := make([]interface{}, 0)
  1252. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
  1253. insertData = append(insertData, wm.HospitalId)
  1254. insertData = append(insertData, wm.Sn)
  1255. insertData = append(insertData, wm.InfectSn)
  1256. insertData = append(insertData, wm.PatientNk)
  1257. insertData = append(insertData, wm.SequelaeType)
  1258. insertData = append(insertData, wm.Sjscsj)
  1259. insertData = append(insertData, wm.Xgbz)
  1260. insertData = append(insertData, wm.CreateTime)
  1261. insertData = append(insertData, wm.UpdateTime)
  1262. thisSQL += strings.Join(insertParams, ", ")
  1263. utx.Exec(thisSQL, insertData...)
  1264. }
  1265. }
  1266. }
  1267. return
  1268. }
  1269. func CreateLisWaterBc(wms []*sz.TempHdLisWaterBc, rdb *gorm.DB) (err error) {
  1270. if len(wms) > 0 {
  1271. utx := rdb
  1272. if len(wms) > 0 {
  1273. for _, wm := range wms {
  1274. thisSQL := "INSERT INTO t_hd_water_bc (hospital_id,sn,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,sjscsj,xgbz,create_time,update_time) VALUES "
  1275. insertParams := make([]string, 0)
  1276. insertData := make([]interface{}, 0)
  1277. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
  1278. insertData = append(insertData, wm.HospitalId)
  1279. insertData = append(insertData, wm.Sn)
  1280. insertData = append(insertData, wm.EquitmentId)
  1281. insertData = append(insertData, wm.WaterType)
  1282. insertData = append(insertData, wm.InspectionOrgId)
  1283. insertData = append(insertData, wm.InspectionTime)
  1284. insertData = append(insertData, wm.IsQualified)
  1285. insertData = append(insertData, wm.InspectedValue)
  1286. insertData = append(insertData, wm.CaseOrder)
  1287. insertData = append(insertData, wm.Sjscsj)
  1288. insertData = append(insertData, wm.Xgbz)
  1289. insertData = append(insertData, wm.CreateTime)
  1290. insertData = append(insertData, wm.UpdateTime)
  1291. thisSQL += strings.Join(insertParams, ", ")
  1292. utx.Exec(thisSQL, insertData...)
  1293. }
  1294. }
  1295. }
  1296. return
  1297. }
  1298. func CreateLisWaterEn(wms []*sz.TempHdLisWaterEn, 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_water_en (hospital_id,sn,equipment_id,water_type,inspection_org_id,inspection_time,is_qualified,inspected_value,case_order,sjscsj,xgbz,create_time,update_time) VALUES "
  1304. insertParams := make([]string, 0)
  1305. insertData := make([]interface{}, 0)
  1306. insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
  1307. insertData = append(insertData, wm.HospitalId)
  1308. insertData = append(insertData, wm.Sn)
  1309. insertData = append(insertData, wm.EquitmentId)
  1310. insertData = append(insertData, wm.WaterType)
  1311. insertData = append(insertData, wm.InspectionOrgId)
  1312. insertData = append(insertData, wm.InspectionTime)
  1313. insertData = append(insertData, wm.IsQualified)
  1314. insertData = append(insertData, wm.InspectedValue)
  1315. insertData = append(insertData, wm.CaseOrder)
  1316. insertData = append(insertData, wm.Sjscsj)
  1317. insertData = append(insertData, wm.Xgbz)
  1318. insertData = append(insertData, wm.CreateTime)
  1319. insertData = append(insertData, wm.UpdateTime)
  1320. thisSQL += strings.Join(insertParams, ", ")
  1321. utx.Exec(thisSQL, insertData...)
  1322. }
  1323. }
  1324. }
  1325. return
  1326. }
  1327. func BatchCreateTBDICPractitioner(ps *sz.TBDICPractitioner, rdb *gorm.DB) (err error) {
  1328. err = rdb.Create(&ps).Error
  1329. return err
  1330. }
  1331. func BatchCreateTMDICTBED(ps *sz.TM_DICT_BED, rdb *gorm.DB) (err error) {
  1332. err = rdb.Create(&ps).Error
  1333. return err
  1334. }
  1335. func BatchCreateTB_MZ_Patient_Information(ps *sz.TB_MZ_Patient_Information, rdb *gorm.DB) (err error) {
  1336. err = rdb.Create(&ps).Error
  1337. return err
  1338. }
  1339. func BatchCreateTB_HIS_MZ_Reg(ps *sz.TB_HIS_MZ_Reg, rdb *gorm.DB) (err error) {
  1340. err = rdb.Create(&ps).Error
  1341. return err
  1342. }
  1343. func BatchCreateTB_YL_MZ_Medical_Record(ps *sz.TB_YL_MZ_Medical_Record, rdb *gorm.DB) (err error) {
  1344. err = rdb.Create(&ps).Error
  1345. return err
  1346. }
  1347. func BatchCreateTB_CIS_Prescription(ps *sz.TB_CIS_Prescription, rdb *gorm.DB) (err error) {
  1348. err = rdb.Create(&ps).Error
  1349. return err
  1350. }
  1351. func BatchCreateTB_CIS_Prescription_Detail(ps *sz.TB_CIS_Prescription_Detail, rdb *gorm.DB) (err error) {
  1352. err = rdb.Create(&ps).Error
  1353. return err
  1354. }
  1355. func BatchCreateTB_HIS_MZ_Charge(ps *sz.TB_HIS_MZ_Charge, rdb *gorm.DB) (err error) {
  1356. err = rdb.Create(&ps).Error
  1357. return err
  1358. }
  1359. func BatchCreateTB_HIS_MZ_Fee_Detail(ps *sz.TB_HIS_MZ_Fee_Detail, rdb *gorm.DB) (err error) {
  1360. err = rdb.Create(&ps).Error
  1361. return err
  1362. }