12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964 |
- // 统计后台的 service
-
- package service
-
- import (
- "Data_Upload_Api/models"
- "Data_Upload_Api/models/sz"
- "github.com/jinzhu/gorm"
- "strings"
- "time"
- )
-
- func GetSyncTimeByOrgId(org_id int64, sync_type int64) (sync_info models.XTSyncInfo, err error) {
- err = readDb.Model(&models.XTSyncInfo{}).Where("org_id = ? and sync_type = ? ", org_id, sync_type).Last(&sync_info).Error
- return
- }
-
- func FindAllDataUploadConfigOrgInfo(province_id int64, city_id int64, config_type int64) (data []*sz.DataUploadConfig, err error) {
- 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
- return
- }
-
- func FindDataUploadOrgInfo(org_id int64, module_type int64) (data sz.DataUpload, err error) {
- err = readDb.Model(&sz.DataUpload{}).Where(" org_id = ? AND module_type = ?", org_id, module_type).Last(&data).Error
- return
- }
-
- func FindOrgData(org_id int64, sync_time int64) (org models.UserOrg, err error) {
- err = readUserDb.Model(&models.UserOrg{}).Where("status = 1 AND id = ? AND ctime > ?", org_id, sync_time).Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
- return readDb.Where("status = 1")
- }).Find(&org).Error
- return
- }
- func FindOrgRolesData(org_id int64, lastUploadTime int64, nowTime int64) (role []*models.UserAdminRole, err error) {
- db := readUserDb.Model(&models.UserAdminRole{}).Where("status = 1 AND org_id = ? ", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&role).Error
- return
- }
-
- func FindOrgDeviceZone(org_id int64, lastUploadTime int64, nowTime int64) (role []*models.DeviceZone, err error) {
- db := readDb.Model(&models.DeviceZone{}).Where("status = 1 AND org_id = ? ", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&role).Error
- return
- }
-
- func FindDrugList(org_id int64, lastUploadTime int64, nowTime int64) (drugs []*models.BaseDrugLib, err error) {
- db := readDb.Model(&models.BaseDrugLib{}).Where("status = 1 AND org_id = ? ", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&drugs).Error
- return
- }
-
- func FindProjectList(org_id int64, lastUploadTime int64, nowTime int64) (projects []*models.XtHisProject, err error) {
- db := readDb.Model(&models.XtHisProject{}).Where("status = 1 AND user_org_id = ? ", org_id)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&projects).Error
- return
- }
-
- func FindOrgRolesDataNew(org_id int64, lastUploadTime int64, nowTime int64) (role []*models.App_Role, err error) {
- db := readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? ", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&role).Error
- return
- }
-
- func FindOrgPatientData(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
- db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ?", org_id)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
-
- return
- }
-
- func FindHisPatientData(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPatient, err error) {
- db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND total_dialysis > 0", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
-
- return
- }
-
- func FindOrgPatientInfoById(id int64) (*models.Patients, error) {
- var patient models.Patients
- db := readDb.Model(&models.Patients{}).Where("status = 1 AND id = ?", id)
- err = db.First(&patient).Error
- return &patient, err
- }
-
- func FindOrgHisPatient(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPatient, err error) {
- db := readDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ?", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
-
- return
- }
-
- func FindOrgHisPatientCnt(org_id int64, sync_date int64) (total int64, err error) {
- err = readDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ?", org_id).Where("record_date = ? ", sync_date).Count(&total).Error
- return total, err
- }
-
- func FindOrgHisPatientCntOne(orgid int64, startime int64) (models.ResultOne, error) {
- info := models.ResultOne{}
-
- 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)
- 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
- return info, err
- }
-
- func FindOrgHisPatientCntTwo(orgid int64, startime int64) (models.ResultOne, error) {
- result := models.ResultOne{}
- 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)
-
- 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
- return result, err
- }
-
- func FindOrgHisPrescriptionInfo(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPrescriptionInfo, err error) {
- db := readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ?", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
-
- return
- }
-
- func FindOrgHisPrescription(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisPrescription, err error) {
- db := readDb.Model(&models.HisPrescription{}).Where("status = 1 AND user_org_id = ?", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
- return
- }
-
- func FindOrgHisDoctorAdviceInfo(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisDoctorAdviceInfo, err error) {
- db := readDb.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ?", org_id)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
- return
- }
-
- func FindOrgHisDoctorAdviceInfoByPid(org_id int64, pid int64) (patient []*models.HisDoctorAdviceInfo, err error) {
- db := readDb.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ? and prescription_id = ?", org_id,pid)
- err = db.Find(&patient).Error
- return
- }
-
- func FindOrgHisOrder(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisOrder, err error) {
- db := readDb.Model(&models.HisOrder{}).Where("status = 1 AND user_org_id = ?", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
- return
- }
-
- func FindOrgHisOrderInfo(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisOrderInfo, err error) {
- db := readDb.Model(&models.HisOrderInfo{}).Where("status = 1 AND user_org_id = ?", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
- return
- }
-
- func GetHisOrderByNumber(order_number string) (*models.HisOrder, error) {
- var order models.HisOrder
- db := readDb.Model(&models.HisOrder{}).Where("number = ? AND status = 1 ", order_number)
- err = db.First(&order).Error
- return &order, err
- }
-
- func GetHisDoctorAdviceInfo(id int64) (*models.HisDoctorAdviceInfo, error) {
- var order models.HisDoctorAdviceInfo
- db := readDb.Model(&models.HisDoctorAdviceInfo{}).Where("id = ? AND status = 1 ", id)
- err = db.Find(&order).Error
- return &order, err
- }
-
- func GetHisPrescriptionProjectInfo(id int64) (*models.HisPrescriptionProject, error) {
- var order models.HisPrescriptionProject
- db := readDb.Model(&models.HisPrescriptionProject{}).Where("id = ? AND status = 1 ", id)
- err = db.Find(&order).Error
- return &order, err
- }
-
- func GetHisProjectInfo(id int64) (*models.HisProject, error) {
- var order models.HisProject
- db := readDb.Model(&models.HisProject{}).Where("id = ? AND status = 1 ", id)
- err = db.Find(&order).Error
- return &order, err
- }
-
- func GetGoodInfo(id int64) (*models.GoodInfo, error) {
- var order models.GoodInfo
- db := readDb.Model(&models.GoodInfo{}).Where("id = ? AND status = 1 ", id)
- err = db.Find(&order).Error
- return &order, err
- }
-
- func GetHisOrderInfoByNumber(order_number string) (order []*models.HisOrderInfo, err error) {
- db := readDb.Model(&models.HisOrderInfo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("BaseDrugLib", "status = 1").Where("status = 1")
- })
- err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
- return
- }
-
- func FindOrgHisPrescriptionById(id int64) (*models.HisPrescription, error) {
- var HisPrescription models.HisPrescription
- db := readDb.Model(&models.HisPrescription{}).Where("status = 1 and id =? ", id)
- err = db.First(&HisPrescription).Error
- return &HisPrescription, err
- }
-
- func FindBaseDrugLibById(id int64) (*models.BaseDrugLib, error) {
- var BaseDrugLib models.BaseDrugLib
- db := readDb.Model(&models.BaseDrugLib{}).Where("status = 1 and id =? ", id)
- err = db.First(&BaseDrugLib).Error
- return &BaseDrugLib, err
- }
-
- func FindOrgHisPrescriptionInfoByNumber(org_id int64, prescription_number string) (*models.HisPrescriptionInfo, error) {
- var HisPrescriptionInfo models.HisPrescriptionInfo
- db := readDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ? and prescription_number =? ", org_id, prescription_number)
- err = db.First(&HisPrescriptionInfo).Error
- return &HisPrescriptionInfo, err
- }
-
- func FindOrgHisPatientInfo(org_id int64, record_date int64, patient_id int64) (*models.HisPatient, error) {
- var HisPatient models.HisPatient
- db := readDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ? and record_date =? and patient_id = ?", org_id, record_date, patient_id)
- err = db.First(&HisPatient).Error
- return &HisPatient, err
- }
-
- func FindOrgPatientDataOne(org_id int64) (patient []*models.Patients, err error) {
- db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ?", org_id)
- err = db.Find(&patient).Error
- return
- }
-
- func FindOrgPatientInfectious(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
- db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND lapseto = 2 ", org_id)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
- return
- }
-
- func FindOrgDeviceNumber(org_id int64, lastUploadTime int64, nowTime int64) (devices []*models.DeviceNumber, err error) {
- db := readDb.Model(&models.DeviceNumber{}).Where("status = 1 AND org_id = ?", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&devices).Error
-
- return
- }
-
- func FindOrgPatientOutData(lastUploadTime int64, nowTime int64) (patient []*models.PatientLapseto, err error) {
- db := readDb.Model(&models.PatientLapseto{}).Where("status = 1 AND lapseto_type >= 2 ")
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
- return
- }
-
- func FindOrgPatientOutDataTwo(lastUploadTime int64, nowTime int64) (patient []*models.XtPatientAllergic, err error) {
- db := readDb.Model(&models.XtPatientAllergic{}).Where("status = 1 AND patient_source >= 2 ")
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
- return
- }
-
- func FindOrgPatientOutDataByID(patient_id int64) (*models.PatientLapseto, error) {
- var patient models.PatientLapseto
- db := readDb.Model(&models.PatientLapseto{}).Where("status = 1 AND lapseto_type >= 2 AND patient_id =? ", patient_id)
- err = db.First(&patient).Error
- return &patient, err
- }
-
- func FindOrgScheduleData(org_id int64, lastUploadTime int64, nowTime int64) (sch []*models.Schedule, err error) {
- db := readDb.Model(&models.Schedule{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DeviceNumber", "status = 1")
-
- if lastUploadTime != 0 && nowTime != 0 {
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- }
- err = db.Find(&sch).Error
- return
- }
-
- func FindOrgDialysisPrescriptionData(org_id int64, lastUploadTime int64, nowTime int64) (ps []*models.DialysisPrescription, err error) {
- db := readDb.Model(&models.DialysisPrescription{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DialysisOrder", "status = 1")
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&ps).Error
- return
- }
-
- func FindOrgDoctorAdviceTemplateData(org_id int64, lastUploadTime int64, nowTime int64) (advice []*models.DoctorAdviceTemplate, err error) {
- db := readDb.Model(&models.DoctorAdviceTemplate{}).Where("status = 1 AND org_id = ? and advice_type = 0 ", org_id)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&advice).Error
- return
- }
-
- func FindOrgDoctorAdvice(org_id int64, lastUploadTime int64, nowTime int64) (advice []*models.DoctorAdvice, err error) {
- db := readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND org_id = ? ", org_id)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&advice).Error
- return
- }
-
- func FindAssessmentBeforeDislysis(org_id int64, patient_id int64) (before models.AssessmentBeforeDislysis, err error) {
- db := readDb.Model(&models.AssessmentBeforeDislysis{}).Where("status = 1 AND user_org_id = ? and patient_id = ? ", org_id, patient_id)
- err = db.Last(&before).Error
- return
- }
-
- func FindOrgMonitorRecordData(org_id int64, lastUploadTime int64, nowTime int64) (monitor []*models.MonitoringRecord, err error) {
- db := readDb.Model(&models.MonitoringRecord{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("DialysisOrder", "status = 1")
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&monitor).Error
- return
- }
-
- func FindOrgMonitorRecordByLike(org_id int64, keyword string, lastUploadTime int64, nowTime int64) (monitor []*models.MonitoringRecord, err error) {
- db := readDb.Model(&models.MonitoringRecord{}).Where("status = 1 AND user_org_id = ? AND symptom like ?", org_id, keyword)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&monitor).Error
- return
- }
-
- func FindOrgInspection(org_id int64, lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
- db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("Patients", "status = 1")
- db = db.Where("inspect_date >= ? AND inspect_date <= ?", lastUploadTime, nowTime).Group("inspect_date,project_id,patient_id")
- err = db.Find(&inspection).Error
- return
- }
-
- func FindLisReportByLAB(rdb *gorm.DB, lab_sno string) (lisreport []*sz.TempHdLisReport, err error) {
- db := rdb.Model(&sz.TempHdLisReport{}).Where("LAB_SNO = ? ", lab_sno)
- err = db.Find(&lisreport).Error
- return
- }
-
- func FindLisINDICATORSByNo(rdb *gorm.DB, lab_sno string, inspected_result_no string) (lisreport []*sz.TempHdLisIndicators, err error) {
- db := rdb.Model(&sz.TempHdLisIndicators{}).Where("LAB_SNO = ? AND INSPECTED_RESULT_NO = ?", lab_sno, inspected_result_no)
- err = db.Find(&lisreport).Error
- return
- }
-
- 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) {
- err = rdb.Exec("update t_hd_lis_indicators set inspected_result_desc = ?,inspected_result_value = ?,inspected_result_unit = ?,create_time = ? "+
- "WHERE LAB_SNO = ? and INSPECTED_RESULT_NO = ? ", inspected_result_desc, inspected_result_desc, inspected_result_unit, create_time, lab_sno, inspected_result_no).Error
- return
- }
-
- func FindOrgInspectionTwo(org_id int64, lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
- db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("XtInspectionReference", "status = 1")
- db = db.Where("inspect_date >= ? AND inspect_date <= ?", lastUploadTime, nowTime)
- err = db.Find(&inspection).Error
- return
- }
-
- func FindOrgInspectionThree(org_id int64, lastUploadTime int64, nowTime int64, itemid string) (inspection []*models.XtInspection, err error) {
- db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("XtInspectionReference", "status = 1")
- db = db.Where("inspect_date >= ? AND inspect_date <= ? AND item_id = ?", lastUploadTime, nowTime, itemid)
- err = db.Find(&inspection).Error
- return
- }
-
- // 传染病查询
- func FindOrgInspectionGroupOne(org_id int64, lastUploadTime int64, nowTime int64, patient_id int64) (inspection []*models.XtInspection, err error) {
- db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id = 14 and patient_id = ?", org_id, patient_id)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
- err = db.Find(&inspection).Error
- return
- }
-
- // 传染病查询 龙岗二院
- func FindOrgInspectionGroupLgey(org_id int64, lastUploadTime int64, nowTime int64, patient_id int64) (inspection []*models.XtInspection, err error) {
- 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)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
- err = db.Find(&inspection).Error
- return
- }
-
- // 传染病查询
- func FindOrgInspectionGroupLgeyTwo(org_id int64, inspect_date int64, patient_id int64) (inspection []*models.XtInspection, err error) {
- 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)
- err = db.Find(&inspection).Error
- return
- }
-
- // 传染病查询 深圳百霖
- func FindOrgInspectionGroupSzbl(org_id int64, lastUploadTime int64, nowTime int64, patient_id int64) (inspection []*models.XtInspection, err error) {
- db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id in (1013800,1013870) and patient_id = ?", org_id, patient_id)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
- err = db.Find(&inspection).Error
- return
- }
-
- // 传染病查询 深圳百霖贝尔
- func FindOrgInspectionGroupSzblbr(org_id int64, lastUploadTime int64, nowTime int64, patient_id int64) (inspection []*models.XtInspection, err error) {
- db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id in (1013803,1013856) and patient_id = ?", org_id, patient_id)
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
- err = db.Find(&inspection).Error
- return
- }
-
- // 传染病查询
- func FindOrgInspectionGroupSzblTwo(org_id int64, inspect_date int64, patient_id int64) (inspection []*models.XtInspection, err error) {
- 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)
- err = db.Find(&inspection).Error
- return
- }
-
- // 传染病查询
- func FindOrgInspectionGroupSzblbrTwo(org_id int64, inspect_date int64, patient_id int64) (inspection []*models.XtInspection, err error) {
- 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)
- err = db.Find(&inspection).Error
- return
- }
-
- // 传染病查询
- func FindOrgInspectionGroupTwo(org_id int64, inspect_date int64, patient_id int64) (inspection []*models.XtInspection, err error) {
- 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)
- err = db.Find(&inspection).Error
- return
- }
-
- func FindOrgInspectionReference(org_id int64, lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
- db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("XtInspectionReference", "status = 1")
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
- err = db.Find(&inspection).Error
- return
- }
-
- func CreateOrgRecord(rdb *gorm.DB, hospital *sz.TempHdHospital) (err error) {
- err = rdb.Model(&sz.TempHdHospital{}).Create(&hospital).Error
- return
- }
-
- func CreateUploadRecord(upload *sz.DataUpload) (err error) {
- err = writeDb.Model(&sz.DataUpload{}).Create(&upload).Error
- return
- }
-
- func FindOrgDialysisData(org_id int64, lastUploadTime int64, nowTime int64) (ps []*models.VMDialysisOrder, err error) {
- db := readDb.Model(&models.VMDialysisOrder{}).Where("status = 1 AND user_org_id = ? AND stage = 2 ", org_id).
- Preload("DeviceNumber", "status = 1").
- Preload("VMDialysisPrescription", "status = 1").
- Preload("AssessmentBeforeDislysis", "status = 1").
- Preload("AssessmentAfterDislysis", "status = 1").
- Preload("Schedule", "status = 1").
- Preload("MonitoringRecord", "status = 1")
-
- if lastUploadTime != 0 && nowTime != 0 {
- db = db.Where("updated_time >= ? AND updated_time <= ?", lastUploadTime, nowTime)
- }
- err = db.Find(&ps).Error
- return
- }
- func FindOrgDeviceZoneRecordData(org_id int64, lastUploadTime int64, nowTime int64) (zone []*models.DeviceZone, err error) {
- db := readDb.Model(&models.DeviceZone{}).Where("status = 1 AND org_id = ?", org_id)
- if lastUploadTime != 0 && nowTime != 0 {
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- }
- err = db.Find(&zone).Error
-
- return
- }
-
- func FindOrgWaterMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
- db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ? AND device_type = 2", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&waterMachine).Error
- return
- }
-
- func FindSyncPatientAllData(rdb *gorm.DB) (hdPatients []*sz.TempHdPatient, err error) {
- err = rdb.Model(&sz.TempHdPatient{}).Find(&hdPatients).Error
- return
- }
-
- func UpdateSyncPatient(patientId int64, ylyl1 string, rdb *gorm.DB) (err error) {
- err = rdb.Model(&sz.TempHdPatient{}).Where("patient_nk = ?", patientId).Update("ylyl1", ylyl1).Error
- return
- }
-
- func FindSyncPatient(patientId int64, rdb *gorm.DB) (hdPatients []*sz.TempHdPatient, err error) {
- err = rdb.Model(&sz.TempHdPatient{}).Where("patient_nk = ?", patientId).Find(&hdPatients).Error
- return
- }
-
- func FindSyncPatientOut(patientId int64, rdb *gorm.DB) (hdPatients []*sz.TempHdPatientOut, err error) {
- err = rdb.Model(&sz.TempHdPatientOut{}).Where("patient_nk = ?", patientId).Find(&hdPatients).Error
- return
- }
-
- func FindPatientInfoByIdno(idno string) (patient models.Patients, err error) {
- err = readDb.Model(&models.Patients{}).Where("id_card_no = ?", idno).First(&patient).Error
- return
- }
-
- func BatchCreateWMsRecord(wms []*sz.TempHdWm, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- thisSQL := "INSERT INTO t_hd_wm (hospital_id, equipment_id, equipment_brand, enable_time,equipment_type,xgbz,create_time,update_time,sjscsj) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- for _, wm := range wms {
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquipmentId)
- insertData = append(insertData, wm.EquipmentBrand)
- insertData = append(insertData, wm.EnableTime)
- insertData = append(insertData, wm.EquipmentType)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.UpdateTime)
- insertData = append(insertData, wm.Sjscsj)
- }
- thisSQL += strings.Join(insertParams, ", ")
- // err = utx.Exec(thisSQL, insertData...).Error
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- utx.Exec(thisSQL, insertData...)
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateStaffRecord(staffs []*sz.TempHdStaff, rdb *gorm.DB) (err error) {
- if len(staffs) > 0 {
- utx := rdb
- if len(staffs) > 0 {
- var id_no int64
- id_no = 429001198701091670
- for _, info := range staffs {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
-
- insertData = append(insertData, info.HospitalId)
- insertData = append(insertData, info.StaffId)
- insertData = append(insertData, id_no)
- insertData = append(insertData, "01")
- insertData = append(insertData, info.StaffName)
- insertData = append(insertData, info.Position)
- insertData = append(insertData, "0")
- insertData = append(insertData, info.StaffId)
- insertData = append(insertData, info.PermanentType)
- insertData = append(insertData, "2019-09-01")
- insertData = append(insertData, info.CreateTime)
- insertData = append(insertData, info.Sjscsj)
- insertData = append(insertData, info.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- id_no++
- }
-
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateLayoutRecord(layouts []*sz.TempHdLayout, rdb *gorm.DB) (err error) {
- if len(layouts) > 0 {
- utx := rdb
- if len(layouts) > 0 {
- for _, info := range layouts {
- thisSQL := "INSERT INTO t_hd_layout (hospital_id,partition_name,create_time, sjscsj, xgbz) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?)")
- insertData = append(insertData, info.HospitalId)
- insertData = append(insertData, info.PartitionName)
- insertData = append(insertData, info.CreateTime)
- insertData = append(insertData, info.Sjscsj)
- insertData = append(insertData, info.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
-
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreatePatinet(patients []*sz.TempHdPatient, rdb *gorm.DB) (err error) {
- if len(patients) > 0 {
- utx := rdb
- if len(patients) > 0 {
-
- for _, info := range patients {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, info.HospitalId)
- insertData = append(insertData, info.PatientNk)
- insertData = append(insertData, info.CardNo)
- insertData = append(insertData, info.CardType)
- insertData = append(insertData, info.IdNo)
- insertData = append(insertData, info.IdType)
- insertData = append(insertData, info.PatientName)
- insertData = append(insertData, info.Gender)
- insertData = append(insertData, info.BornDate)
- insertData = append(insertData, info.DiagnosisSummary)
- insertData = append(insertData, info.IsCrf)
- insertData = append(insertData, "02")
- insertData = append(insertData, "1")
- insertData = append(insertData, info.DialysisStartTime)
- insertData = append(insertData, info.LocalStartTime)
- insertData = append(insertData, info.OutpatientNo)
- insertData = append(insertData, info.HospitalizedNo)
- insertData = append(insertData, info.Xgbz)
- insertData = append(insertData, info.CreateTime)
- insertData = append(insertData, info.UpdateTime)
- insertData = append(insertData, info.Sjscsj)
- insertData = append(insertData, info.Ylyl1)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
-
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateSchedual(patients []*sz.TempHdShift, rdb *gorm.DB) (err error) {
- if len(patients) > 0 {
- utx := rdb
- if len(patients) > 0 {
- for _, info := range patients {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, info.PsId)
- insertData = append(insertData, info.HospitalId)
- insertData = append(insertData, info.PatientNk)
- insertData = append(insertData, info.ScheduleDate)
- insertData = append(insertData, info.ShiftType)
- insertData = append(insertData, info.SickbedNo)
- insertData = append(insertData, info.ScheduleStatus)
- insertData = append(insertData, info.CreateTime)
- insertData = append(insertData, info.Sjscsj)
- insertData = append(insertData, info.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
-
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreatePs(patients []*sz.TempHdPs, rdb *gorm.DB) (err error) {
- if len(patients) > 0 {
- utx := rdb
- if len(patients) > 0 {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- for _, info := range patients {
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, info.PrescribeId)
- insertData = append(insertData, info.HospitalId)
- insertData = append(insertData, info.PatientNk)
- insertData = append(insertData, info.RrtType)
- insertData = append(insertData, info.RrtTypeName)
- insertData = append(insertData, info.DialysisFrequency)
- insertData = append(insertData, info.FrequencyUnit)
- insertData = append(insertData, info.PrescribeTime)
- insertData = append(insertData, info.CreateTime)
- insertData = append(insertData, info.Sjscsj)
- insertData = append(insertData, info.Xgbz)
-
- }
- thisSQL += strings.Join(insertParams, ", ")
- // err = utx.Exec(thisSQL, insertData...).Error
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- utx.Exec(thisSQL, insertData...)
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreatePsOther(ps *sz.TempHdPs, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreatePsm(psms []*sz.TempHdPsMedicine, rdb *gorm.DB) (err error) {
- if len(psms) > 0 {
- utx := rdb
- if len(psms) > 0 {
-
- for _, psm := range psms {
- thisSQL := "INSERT INTO t_hd_ps_medicine (sn,hospital_id, medicine_type_id,medicine_id,create_time,sjscsj,xgbz) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?)")
- insertData = append(insertData, psm.Sn)
- insertData = append(insertData, psm.HospitalId)
- insertData = append(insertData, psm.MedicineTypeId)
- insertData = append(insertData, psm.MedicineId)
- insertData = append(insertData, psm.CreateTime)
- insertData = append(insertData, psm.Sjscsj)
- insertData = append(insertData, psm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- // err = utx.Exec(thisSQL, insertData...).Error
- utx.Exec(thisSQL, insertData...)
- }
-
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateDialysis(psms []*sz.TempHdDialysis, rdb *gorm.DB) (err error) {
- if len(psms) > 0 {
- utx := rdb
- if len(psms) > 0 {
-
- for _, psm := range psms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, psm.DialysisId)
- insertData = append(insertData, psm.HospitalId)
- insertData = append(insertData, psm.PatientNk)
- insertData = append(insertData, psm.PsId)
- insertData = append(insertData, psm.DialysisDate)
- insertData = append(insertData, psm.SickbedNo)
- insertData = append(insertData, psm.DivisionId)
- insertData = append(insertData, psm.EquipmentId)
- insertData = append(insertData, psm.MixDialysis)
- insertData = append(insertData, psm.Ufv)
- insertData = append(insertData, psm.TotalTreatDuration)
- insertData = append(insertData, psm.IsHospitalization)
- insertData = append(insertData, psm.IsEmergency)
- insertData = append(insertData, psm.IsPerioperativePeriod)
- insertData = append(insertData, psm.BeforeSbp)
- insertData = append(insertData, psm.BeforeDbp)
- insertData = append(insertData, psm.AfterSbp)
- insertData = append(insertData, psm.AfterDbp)
- insertData = append(insertData, psm.BeforeWeight)
- insertData = append(insertData, psm.AfterWeight)
- insertData = append(insertData, psm.Ktv)
- insertData = append(insertData, psm.Urr)
- insertData = append(insertData, psm.UpNurseId)
- insertData = append(insertData, psm.DownNurseId)
- insertData = append(insertData, psm.CheckNurseId)
- insertData = append(insertData, psm.PunctureNurseId)
- insertData = append(insertData, psm.StartTime)
- insertData = append(insertData, psm.EndTime)
- insertData = append(insertData, psm.CreateTime)
- insertData = append(insertData, psm.Sjscsj)
- insertData = append(insertData, psm.Xgbz)
- insertData = append(insertData, psm.ChargeDoctorId)
- insertData = append(insertData, psm.ChargeNurseId)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
-
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreatePatientOut(patientOuts []*sz.TempHdPatientOut, rdb *gorm.DB) (err error) {
- if len(patientOuts) > 0 {
- utx := rdb
- if len(patientOuts) > 0 {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- for _, out := range patientOuts {
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, out.Sn)
- insertData = append(insertData, out.HospitalId)
- insertData = append(insertData, out.PatientNk)
- insertData = append(insertData, out.SequelaeDate)
- insertData = append(insertData, out.SequelaeType)
- insertData = append(insertData, out.CreateTime)
- insertData = append(insertData, out.DeathReason)
- insertData = append(insertData, out.ExtReason)
- insertData = append(insertData, out.Sjscsj)
- insertData = append(insertData, out.Xgbz)
-
- }
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateDoctorsAdvice(advices []*sz.TempHdDoctorsAdvice, rdb *gorm.DB) (err error) {
- if len(advices) > 0 {
- utx := rdb
- if len(advices) > 0 {
- for _, advice := range advices {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, advice.MedicalOrderId)
- insertData = append(insertData, advice.HospitalId)
- insertData = append(insertData, advice.DialysisId)
- insertData = append(insertData, advice.OrderType)
- insertData = append(insertData, advice.PatientNk)
- insertData = append(insertData, advice.DialysisDuration)
- insertData = append(insertData, advice.BloodVol)
- insertData = append(insertData, advice.Anticoagulant)
- insertData = append(insertData, advice.CreateTime)
- insertData = append(insertData, advice.Sjscsj)
- insertData = append(insertData, advice.Xgbz)
- insertData = append(insertData, advice.RrtType)
- insertData = append(insertData, advice.RrtTypeName)
- insertData = append(insertData, advice.DryWeight)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateMonitor(advices []*sz.TempHdMiddle, rdb *gorm.DB) (err error) {
- if len(advices) > 0 {
- utx := rdb
- if len(advices) > 0 {
-
- for _, advice := range advices {
- thisSQL := "INSERT INTO t_hd_middle (sn,hospital_id, patient_nk,dialysis_id,monitor_time,sbp,dbp,create_time,sjscsj,xgbz) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, advice.Sn)
- insertData = append(insertData, advice.HospitalId)
- insertData = append(insertData, advice.PatientNk)
- insertData = append(insertData, advice.DialysisId)
- insertData = append(insertData, advice.MonitorTime)
- insertData = append(insertData, advice.Sbp)
- insertData = append(insertData, advice.Dbp)
- insertData = append(insertData, advice.CreateTime)
- insertData = append(insertData, advice.Sjscsj)
- insertData = append(insertData, advice.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
-
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- }
- // utx.Commit()
- }
- return
- }
-
- func FindOrgOtherMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
- db := readUserDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ? AND device_type = 3", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&waterMachine).Error
- return
- }
-
- func FindOrgDeviceInformationData(org_id int64, lastUploadTime int64, nowTime int64) (deviceInformation []*models.DeviceInformation, err error) {
- db := readUserDb.Model(&models.DeviceInformation{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("VMDeviceAddmacher", "status = 1")
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&deviceInformation).Error
- return
- }
-
- func FindOrgMachineRepairData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.DeviceRepair, err error) {
- db := readUserDb.Model(&models.DeviceRepair{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("VMDeviceAddmacher", "status = 1")
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&waterMachine).Error
- return
- }
-
- func FindOrgDevicePlan(org_id int64, lastUploadTime int64, nowTime int64) (deviceplan []*models.DevicePlan, err error) {
- db := readUserDb.Model(&models.DevicePlan{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("VMDeviceAddmacher", "status = 1")
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&deviceplan).Error
- return
- }
-
- func BatchCreateOtherMachineRecord(wms []*sz.TempHdOtherMachine, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
-
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquipmentId)
- insertData = append(insertData, wm.EquipmentBrand)
- insertData = append(insertData, wm.EnableTime)
- insertData = append(insertData, wm.Status)
- insertData = append(insertData, wm.EquipmentType)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.UpdateTime)
- insertData = append(insertData, wm.Sjscsj)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateDmDisinfect(dfs []*sz.TempHdDmDisinfect, rdb *gorm.DB) (err error) {
- if len(dfs) > 0 {
- utx := rdb
- if len(dfs) > 0 {
-
- for _, df := range dfs {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, df.Sn)
- insertData = append(insertData, df.HospitalId)
- insertData = append(insertData, df.EquipmentId)
- insertData = append(insertData, df.SickbedNo)
- insertData = append(insertData, df.InspectionTime)
- insertData = append(insertData, df.IsQualified)
- insertData = append(insertData, df.CaseOrder)
- insertData = append(insertData, df.Xgbz)
- insertData = append(insertData, df.CreateTime)
- insertData = append(insertData, df.Sjscsj)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateWmDisinfect(dfs []*sz.TempWdDmDisinfect, rdb *gorm.DB) (err error) {
- if len(dfs) > 0 {
- utx := rdb
- if len(dfs) > 0 {
-
- for _, df := range dfs {
- thisSQL := "INSERT INTO t_hd_wm_disinfect (sn,hospital_id, equipment_id, inspection_time,is_qualified,case_order,xgbz,create_time,sjscsj) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, df.Sn)
- insertData = append(insertData, df.HospitalId)
- insertData = append(insertData, df.EquipmentId)
- insertData = append(insertData, df.InspectionTime)
- insertData = append(insertData, df.IsQualified)
- insertData = append(insertData, df.CaseOrder)
- insertData = append(insertData, df.Xgbz)
- insertData = append(insertData, df.CreateTime)
- insertData = append(insertData, df.Sjscsj)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateMainTain(maintain []*sz.TempHdMaintain, rdb *gorm.DB) (err error) {
- if len(maintain) > 0 {
- utx := rdb
- if len(maintain) > 0 {
- thisSQL := "INSERT INTO t_hd_maintain (sn,hospital_id, equipment_id, equipment_type, repair_time, xgbz,create_time,sjscsj) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- for _, wm := range maintain {
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquipmentId)
- insertData = append(insertData, wm.EquipmentType)
- insertData = append(insertData, wm.RepairTime)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- }
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- }
- // utx.Commit()
- }
- return
- }
-
- func BatchCreateDisinfectMethod(disinfects []*sz.TempHdDisinfectMethod, rdb *gorm.DB) (err error) {
- if len(disinfects) > 0 {
- utx := rdb
- if len(disinfects) > 0 {
- thisSQL := "INSERT INTO t_hd_disinfect_method (hospital_id, equipment_id, equipment_type, disinfect_method,disinfector,concentration, xgbz,create_time,update_time,sjscsj) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- for _, wm := range disinfects {
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquipmentId)
- insertData = append(insertData, wm.EquipmentType)
- insertData = append(insertData, wm.DisinfectMethod)
- insertData = append(insertData, wm.Disinfector)
- insertData = append(insertData, wm.Concentration)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.UpdateTime)
- insertData = append(insertData, wm.Sjscsj)
- }
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- }
- // utx.Commit()
- }
- return
- }
-
- func FindOrgMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
- 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 {
- return readDb.Model(&models.DeviceNumber{}).Where("status = 1")
- })
-
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
-
- err = db.Find(&waterMachine).Error
-
- return
- }
-
- func BatchCreateHDMRecord(wms []*sz.TempHdDm, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
-
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquipmentId)
- insertData = append(insertData, wm.SickbedNo)
- insertData = append(insertData, wm.SickbedType)
- insertData = append(insertData, wm.EquipmentBrand)
- insertData = append(insertData, wm.EnableTime)
- insertData = append(insertData, wm.Status)
- insertData = append(insertData, wm.EquipmentType)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.Bbp)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.UpdateTime)
- insertData = append(insertData, wm.Sjscsj)
-
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
-
- // if err != nil {
- // utx.Rollback()
- // return
- // }
- }
- // utx.Commit()
- }
- return
- }
-
- func CreateHDDivision(wms []*sz.TempHdDivision, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- thisSQL := "INSERT INTO t_hd_division (division_id,hospital_id, division_name,division_type, xgbz,create_time,update_time,sjscsj) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.DivisionId)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.DivisionName)
- insertData = append(insertData, wm.DivisionType)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.UpdateTime)
- insertData = append(insertData, wm.Sjscsj)
-
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
-
- }
- }
- return
- }
-
- func CreateAccess(wms []*sz.TempHdAccess, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.AccessId)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.PatientNk)
- insertData = append(insertData, wm.AccessType)
- insertData = append(insertData, wm.AccessTypeName)
- insertData = append(insertData, wm.AccessStatus)
- insertData = append(insertData, wm.SetupDate)
- insertData = append(insertData, wm.FirstUseTime)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.UpdateTime)
- insertData = append(insertData, wm.Sjscsj)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func CreateSickbed(wms []*sz.TempHdSickbed, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- thisSQL := "INSERT INTO t_hd_sickbed (sickbed_no,hospital_id,division_id,sickbed_code,sickbed_type,xgbz,create_time,update_time,sjscsj) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.SickbedNo)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.DivisionId)
- insertData = append(insertData, wm.SickbedCode)
- insertData = append(insertData, wm.SickbedType)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.UpdateTime)
- insertData = append(insertData, wm.Sjscsj)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
-
- func CreateSickbed2(wms []*sz.TempHdSickbed, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- thisSQL := "INSERT INTO t_hd_sickbed (sickbed_no,hospital_id,division_id,sickbed_code,sickbed_type,xgbz,create_time,update_time,sjscsj,ylyl1) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.SickbedNo)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.DivisionId)
- insertData = append(insertData, wm.SickbedCode)
- insertData = append(insertData, wm.SickbedType)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.UpdateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Ylyl1)
-
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func CreateDiagnosis(wms []*sz.TempHdDiagnosis, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.DiagnosisId)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.PatientNk)
- insertData = append(insertData, wm.DiagnosisTime)
- insertData = append(insertData, wm.DiagnosisType)
- insertData = append(insertData, wm.DiagnosisTypeItem)
- insertData = append(insertData, wm.DiagnosisTypeDetail)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func CreateInfection(wms []*sz.TempHdInfection, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.PatientNk)
- insertData = append(insertData, wm.Hbv)
- insertData = append(insertData, wm.Hcv)
- insertData = append(insertData, wm.Rpr)
- insertData = append(insertData, wm.Hiv)
- insertData = append(insertData, wm.Hbsag)
- insertData = append(insertData, wm.Hbsab)
- insertData = append(insertData, wm.Hbeag)
- insertData = append(insertData, wm.Hbeab)
- insertData = append(insertData, wm.Hbcab)
- insertData = append(insertData, wm.CheckDate)
- insertData = append(insertData, wm.DoctorId)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func CreateComplication(wms []*sz.TempHdComplication, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.PatientNk)
- insertData = append(insertData, wm.DialysisId)
- insertData = append(insertData, wm.MonitorId)
- insertData = append(insertData, wm.NeopathyTime)
- insertData = append(insertData, wm.NeopathyType)
- insertData = append(insertData, wm.NeopathyDesc)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func CreateLisReport(wms []*sz.TempHdLisReport, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.LabSno)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.PatientNk)
- insertData = append(insertData, wm.ReportDate)
- insertData = append(insertData, wm.CheckDate)
- insertData = append(insertData, wm.JzNo)
- insertData = append(insertData, wm.MzFlag)
- insertData = append(insertData, wm.ZyNo)
- insertData = append(insertData, wm.MzNo)
- insertData = append(insertData, wm.DepartmentCode)
- insertData = append(insertData, wm.DepartmentName)
- insertData = append(insertData, wm.CardNo)
- insertData = append(insertData, wm.CardType)
- insertData = append(insertData, wm.PatientName)
- insertData = append(insertData, wm.DepCode)
- insertData = append(insertData, wm.DepName)
- insertData = append(insertData, wm.InspectedType)
- insertData = append(insertData, wm.ReportCategry)
- insertData = append(insertData, wm.ApplicationName)
- insertData = append(insertData, wm.ApplicationType)
- insertData = append(insertData, wm.CheckName)
- insertData = append(insertData, wm.CheckItemName)
- insertData = append(insertData, wm.CheckItemCode)
- insertData = append(insertData, wm.RecordCcount)
- insertData = append(insertData, wm.CheckResult)
- insertData = append(insertData, wm.DiagnoseName)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func CreateLisIndicators(wms []*sz.TempHdLisIndicators, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.InspectedResultNo)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.LabSno)
- insertData = append(insertData, wm.ReportDate)
- insertData = append(insertData, wm.CheckDate)
- insertData = append(insertData, wm.InspectedIndicate)
- insertData = append(insertData, wm.InspectedItemEnName)
- insertData = append(insertData, wm.InspectedItemCnName)
- insertData = append(insertData, wm.InspectedResultDesc)
- insertData = append(insertData, wm.InspectedResultValue)
- insertData = append(insertData, wm.InspectedResultUnit)
- insertData = append(insertData, wm.RefRange)
- insertData = append(insertData, wm.UnitType)
- insertData = append(insertData, wm.InspectedResult)
- insertData = append(insertData, wm.CreateTime)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgCulture(org_id int64, lastUploadTime int64, nowTime int64) (culture []*models.XtDeviceCulture, err error) {
- err = UserReadDB().Model(&culture).Where("status = 1 and user_org_id = ? and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&culture).Error
- return culture, err
- }
-
- func CreateLisCulture(wms []*sz.TempHdLisCulture, rdb *gorm.DB) (err error) {
-
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.IsSubstitutionQualified)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgDialysate(org_id int64, lastUploadTime int64, nowTime int64) (dialysate []*models.XtDeviceDialysate, err error) {
-
- err = UserReadDB().Model(&dialysate).Where("status = 1 and user_org_id = ? and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&dialysate).Error
- return dialysate, err
- }
-
- func CreateLisDialysate(wms []*sz.TempHdLisDialysate, rdb *gorm.DB) (err error) {
-
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgArialDetection(org_id int64, lastUploadTime int64, nowTime int64) (airdetection []*models.XtAerialDetection, err error) {
-
- err = XTReadDB().Model(&airdetection).Where("user_org_id = ? and status=1 and created_time>=? and created_time<=?", org_id, lastUploadTime, nowTime).Find(&airdetection).Error
- return airdetection, err
- }
-
- func CreateAirDisinfect(wms []*sz.TempHdLisAirDisinfect, rdb *gorm.DB) (err error) {
-
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- thisSQL := "INSERT INTO t_hd_air_disinfect (sn,hospital_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgBodyDetection(org_id int64, lastUploadTime int64, nowTime int64) (body []*models.XtBodyDetection, err error) {
- err = XTReadDB().Model(&body).Where("user_org_id = ? and status=1 and created_time>=? and created_time<=?", org_id, lastUploadTime, nowTime).Find(&body).Error
- return body, err
- }
-
- func CreateBodyDisinfect(wms []*sz.TempHdLisBodyDisinfect, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- thisSQL := "INSERT INTO t_hd_surface_disinfect (sn,hospital_id,inspection_time,is_qualified,inspected_value,case_order,create_time,sjscsj,xgbz) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgWaterFc(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDeviceWater, err error) {
-
- err = UserReadDB().Model(&water).Where("user_org_id = ? and status = 1 and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
- return water, err
- }
-
- func CreateWaterFc(wms []*sz.TempHdLisWaterFc, rdb *gorm.DB) (err error) {
-
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.WaterType)
- insertData = append(insertData, wm.InspectionOrgId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgWaterEl(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.DeviceIon, err error) {
-
- err = UserReadDB().Model(&water).Where("user_org_id = ? and status = 1 and sampling_date>=? and sampling_date<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
- return water, err
- }
-
- func CreateWaterEl(wms []*sz.TempHdLisWaterEl, rdb *gorm.DB) (err error) {
-
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.WaterType)
- insertData = append(insertData, wm.InspectionOrgId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func CreateWaterTe(wms []*sz.TempHdLisWaterTe, rdb *gorm.DB) (err error) {
-
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.WaterType)
- insertData = append(insertData, wm.InspectionOrgId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgWaterNc(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDeviceOxygenates, err error) {
-
- err = UserReadDB().Model(&water).Where("user_org_id = ? and status = 1 and ctime>=? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
- return water, err
- }
-
- func CreateWaterNc(wms []*sz.TempHdLisWaterNc, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.WaterType)
- insertData = append(insertData, wm.InspectionOrgId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgWaterPh(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDevicePh, err error) {
-
- err = UserReadDB().Model(&water).Where("user_org_id = ? and ctime>? and ctime<=?", org_id, lastUploadTime, nowTime).Find(&water).Error
- return water, err
- }
-
- func CreateWaterPh(wms []*sz.TempHdLisWaterPh, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.WaterType)
- insertData = append(insertData, wm.InspectionOrgId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgWaterWh(org_id int64, lastUploadTime int64, nowTime int64) (water []*models.XtDeviceHadwater, err error) {
-
- err = UserReadDB().Model(&water).Where("user_org_id = ? and ctime>=? and ctime<=? and status =1", org_id, lastUploadTime, nowTime).Find(&water).Error
- return water, err
- }
-
- func CreateWaterWh(wms []*sz.TempHdLisWaterWh, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.WaterType)
- insertData = append(insertData, wm.InspectionOrgId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgAccess(org_id int64, lastUploadTime int64, nowTime int64) (access []*models.XtPatientVascularAccess, err error) {
- err = XTReadDB().Model(&access).Where("user_org_id = ? and start_time>=? and start_time<=? and status =1", org_id, lastUploadTime, nowTime).Find(&access).Error
- return access, err
- }
-
- func FindOrgHdCi(org_id int64, lastUploadTime int64, nowTime int64) (access []*models.XtPatientVascularAccess, err error) {
- 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
- return access, err
- }
-
- func CreateHdCi(wms []*sz.TempHdCi, rdb *gorm.DB) (err error) {
-
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.InfectSn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.PatientNk)
- insertData = append(insertData, wm.AccessId)
- insertData = append(insertData, wm.CiType)
- insertData = append(insertData, wm.BloodCulture)
- insertData = append(insertData, wm.InfectionDate)
- insertData = append(insertData, wm.CreateTime)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func FindOrgHdCiOutCome(org_id int64, lastUploadTime int64, nowTime int64) (access []*models.XtPatientVascularAccess, err error) {
-
- 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
- return access, err
- }
-
- func CreateHdCiOutCome(wms []*sz.TempHdCiOutCome, rdb *gorm.DB) (err error) {
-
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- thisSQL := "INSERT INTO t_hd_ci_outcome(hospital_id,sn,infect_sn,patient_nk,sequelae_type,sjscsj,xgbz,create_time) VALUES "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.InfectSn)
- insertData = append(insertData, wm.PatientNk)
- insertData = append(insertData, wm.SequelaeType)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func CreateLisWaterBc(wms []*sz.TempHdLisWaterBc, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.WaterType)
- insertData = append(insertData, wm.InspectionOrgId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func CreateLisWaterEn(wms []*sz.TempHdLisWaterEn, rdb *gorm.DB) (err error) {
- if len(wms) > 0 {
- utx := rdb
- if len(wms) > 0 {
- for _, wm := range wms {
- 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 "
- insertParams := make([]string, 0)
- insertData := make([]interface{}, 0)
- insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?)")
- insertData = append(insertData, wm.Sn)
- insertData = append(insertData, wm.HospitalId)
- insertData = append(insertData, wm.EquitmentId)
- insertData = append(insertData, wm.WaterType)
- insertData = append(insertData, wm.InspectionOrgId)
- insertData = append(insertData, wm.InspectionTime)
- insertData = append(insertData, wm.IsQualified)
- insertData = append(insertData, wm.InspectedValue)
- insertData = append(insertData, wm.CaseOrder)
- insertData = append(insertData, wm.Sjscsj)
- insertData = append(insertData, wm.Xgbz)
- insertData = append(insertData, wm.CreateTime)
- thisSQL += strings.Join(insertParams, ", ")
- utx.Exec(thisSQL, insertData...)
- }
- }
- }
- return
- }
-
- func BatchCreateTBDICPractitioner(ps *sz.TBDICPractitioner, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTBDICMedicines(ps *sz.TBDICMedicines, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTBDICZlxmdzzd(ps *sz.TBDICZlxmdzzd, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTBDICYpdzzd(ps *sz.TBDICYpdzzd, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTBDICZlxmml(ps *sz.TBDICZlxmml, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTMDICTBED(ps *sz.TM_DICT_BED, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTB_MZ_Patient_Information(ps *sz.TB_MZ_Patient_Information, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTB_HIS_MZ_Reg(ps *sz.TB_HIS_MZ_Reg, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTB_YL_MZ_Medical_Record(ps *sz.TB_YL_MZ_Medical_Record, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTB_Diagnosis_Detail(ps *sz.TB_Diagnosis_Detail, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTB_CIS_Prescription(ps *sz.TB_CIS_Prescription, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTB_CIS_Prescription_Detail(ps *sz.TB_CIS_Prescription_Detail, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTB_HIS_MZ_Charge(ps *sz.TB_HIS_MZ_Charge, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTB_HIS_MZ_Fee_Detail(ps *sz.TB_HIS_MZ_Fee_Detail, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func BatchCreateTB_STAT_YWL_Report(ps *sz.TB_STAT_YWL_Report, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
-
- func FindOrgPatientDataTwo(org_id int64,ids []int64) (patient []*models.Patients, err error) {
- db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? and id in (?)", org_id,ids)
- err = db.Find(&patient).Error
- return
- }
-
- func FindNewOrgHisOrder(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.HisOrder, err error) {
- db := readDb.Model(&models.HisOrder{}).Preload("HisPatient", "status = 1").Where("status = 1 AND user_org_id = ? AND med_type = 14", org_id)
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&patient).Error
- return
- }
-
- func FindUserRoleData(org_id int64, admin_user_id int64) (role models.UserAdminRole, err error) {
- db := readUserDb.Model(&models.UserAdminRole{}).Where("status = 1 AND org_id = ? and admin_user_id = ? ", org_id, admin_user_id)
- //db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
- err = db.Find(&role).Error
- return
- }
-
-
- func BatchCreateTB_HIS_MZ_BL_Detail(ps *sz.TB_HIS_MZ_BL_Detail, rdb *gorm.DB) (err error) {
- err = rdb.Create(&ps).Error
- return err
- }
|