《2022年2022年旧版数据导入新版数据方 .pdf》由会员分享,可在线阅读,更多相关《2022年2022年旧版数据导入新版数据方 .pdf(6页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、2010.01.17 龙岗数据转新版数据旧数据库类型A 旧数据库类型B 先备份新旧数据库,然后升级1. DEPART - tbDepartment 31 - 0 其它不变改表与 DOCTORUSER关联,因此要修正DOCTORUSER.DEPARTID SQL 语句如下旧数据库类型A: DELETE FROM MedImgMgrSysLG.dbo.tbDepartment; DELETE FROM EndoscopeLG.dbo.DEPART WHERE DEPARTID=-1; UPDATE EndoscopeLG.dbo.DEPART SET DEPARTID=0 WHERE DEPART
2、ID=31; UPDATE EndoscopeLG.dbo.DOCTORUSER SET DEPARTID=0 WHERE DEPARTID=31; INSERT MedImgMgrSysLG.dbo.tbDepartment(DepartmentID, DepartmentName) SELECT DEPARTID, DEPARTDESC FROM EndoscopeLG.dbo.DEPART; 2. DOCTORUSER - tbDoctor (1)LEVELCODE - AuthCode 255 - 1023 1 - 1 2 - 563 (2)LOGINPWD - LoginPasswd
3、 (3)WORKID - WorkID DOCTORUSER.WorkID = tbDoctor.WORKID + 1000 ? (4) HIRESTATUS - HireStatus DOCTORUSER.Status = tbDoctor.HIRESTATUS - 1 (5) SEX - Sex 0 - 1 1 - 2 2 - 0 (6) DUTYID - DutyID DOCTORUSER.DutyID = tbDoctor.DUTYID - 1 (7) CNNAME - LoginName, NameCN DOCTORUSER.LoginName = tbDoctor.CNNAME D
4、OCTORUSER.NameCN = tbDoctor.CNNAME (8) DEPARTID - DepartmentID 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 6 页 - - - - - - - - - DOCTORUSER.DepartmentID = tbDoctor.DEPARTID SQL 语句如下旧数据库类型A: 首先修改LEVELCODE 类型由 tinyint改为 int ,然后执行UPDATE EndoscopeLG.dbo.DOCTORUS
5、ER SET LEVELCODE=1023 WHERE LEVELCODE=255; UPDATE EndoscopeLG.dbo.DOCTORUSER SET LEVELCODE=563 WHERE LEVELCODE=2; UPDATE EndoscopeLG.dbo.DOCTORUSER SET SEX=SEX+1; UPDATE EndoscopeLG.dbo.DOCTORUSER SET SEX=0 WHERE SEX=3; UPDATE EndoscopeLG.dbo.DOCTORUSER SET HIRESTATUS=HIRESTATUS; UPDATE EndoscopeLG.
6、dbo.DOCTORUSER SET DUTYID=DUTYID-1; INSERT MedImgMgrSysLG.dbo.tbDoctor(WorkID, DepartmentID, LoginName, LoginPasswd, AuthCode, HireStatus, DutyID, Sex) SELECT WORKID, DEPARTID, CNNAME, ISNULL(LOGINPWD,), LEVELCODE, ISNULL(HIRESTATUS, 0), DUTYID, SEX FROM EndoscopeLG.dbo.DOCTORUSER; 3. tbPatientInfor
7、mation - PATIENTE, PATIENTSELF (1) MedicalID - PATIENTSELF.MEDICCAREID (2) InHospitalID - PATIENTSELF.INHOSPITAL (3) OutPatientID - IF (PATIENTSELF.INHOSTPITAL = NULL) IDPATIENTSELF.SICKBEDID ELSE NULL (4) CheckID - 该表的 CheckID 根据旧版数据库的版本情况,由两种可能 1 图片按 PATIENTSELF.ENDSCPID 存放的要对同一机台号的同一天的病例进行处理,生成RE
8、CORDCDNO 然后同 2 处理 2 图片按 PATIENTSELF.RECORDCDNO存放的CheckID - PATIENTSELF.RECORDCDNO (5) InstrumentID - PATIENTSELF.INSTRUMENTID (6) PatientName - PATIENTSELF.PATIENTNAME (7) Sex - PATIENTSELF.SEX 0 - 1 1 - 2 2 - 0 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 6
9、页 - - - - - - - - - (8) Age - PATIENTSELF.AGE AgeType - PATIENTSELF.AGE IF PATIENTSELF.AGE 200 THEN tbPatientInformation.Age = PATIENTSELF.AGE tbPatientInformation.AgeType = 0 IF PATIENTSELF.AGE 200 AND PATIENTSELF.AGE 300 THEN tbPatientInformation.Age = PATIENTSELF.AGE - 300 tbPatientInformation.Ag
10、eType = 2 (9) Address - PATIENTSELF.ADDRESS (10) Phone - PATIENTSELF.PHONE (11) AskDepartment - PATIENTSELF.ASKDEPT (12) AskDoctor - PATIENTSELF.ASKDR (13) CheckDoctor - PATIENTSELF.CHECKDR (14) CheckDepartment - NULL (15) CheckTime - PATIENTSELF.CHECKTIME (16) ReportDoctor - PATIENTSELF.REPORTDR (1
11、7) ReportDepartment - NULL (18) ReportTime - PATIENTSELF.REPORTTIME (19) ImageCount - PATIENTSELF.IMAGECOUNT (20) CheckStatus - PATIENTSELF.CHECKSTATUS (21) CheckDesc - PATIENTSELF.CHECKDESC (22) DiagDesc - PATIENTSELF.DIAGNOSEDESC (23) PatientType - 0 (24) Fee - PATIENTE.FEE (25) AskAdvice - PATIEN
12、TE.ASKADVICE (26) CheckPos - PATIENTE.CHECKPARTDESC (27) BedID - IF (PATIENTSELF.INHOSTPITAL != NULL) IDPATIENTSELF.SICKBEDID ELSE NULL (28) OrganCount - (30) Positive - 对于有阳性的数据表特殊处理SQL 语句如下旧数据库类型A:( 龙岗 78M数据库 ) 修改 PATIENTSELF 表,将 PATIENTE中的部分字段FEE 、ASKADVICE 、CHECKPARTDESC加入其中修改 PATIENTSELF 表,加入AG
13、ETYPE 字段,类型int 修改 PATIENTSELF 表,加入OUTPAITENTID 字段,类型varchar 20 修改 PATIENTSELF 表,加入ASKDATE 字段,类型varchar 20 修改 PATIENTSELF 表,加入CHECKDAYID 字段,类型int 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 6 页 - - - - - - - - - 选中旧数据库UPDATE PATIENTSELF SET PATIENTSELF.FEE=PA
14、TIENTE.FEE, PATIENTSELF.ASKADVICE=PATIENTE.ASKADVICE, PATIENTSELF.CHECKPARTDESC=PATIENTE.CHECKPARTDESC FROM PATIENTSELF, PATIENTE WHERE PATIENTSELF.ENDSCPID=PATIENTE.ENDSCPID AND PATIENTSELF.INSTRUMENTID=PATIENTE.INSTRUMENTID; / 清除错误的数据DELETE FROM PATIENTSELF WHERE ASKTIME IS NULL; UPDATE PATIENTSEL
15、F SET AGETYPE=0 WHERE AGE200 AND AGE300; UPDATE PATIENTSELF SET SEX=SEX+1; UPDATE PATIENTSELF SET SEX=0 WHERE SEX=3; UPDATE PATIENTSELF SET OUTPAITENTID=SICKBEDID, SICKBEDID=NULL WHERE INHOSPITAL IS NULL; UPDATE PATIENTSELF SET OUTPAITENTID=SICKBEDID, SICKBEDID= WHERE INHOSPITAL=; UPDATE PATIENTSELF
16、 SET ASKDATE=LTRIM(STR(DATEPART(year, ASKTIME)+RIGHT(CAST(POWER(10,2) AS varchar)+DATEPART(month, ASKTIME),2)+RIGHT(CAST(POWER(10,2) AS varchar)+DATEPART(day, ASKTIME),2); DROP PROCEDURE UPDATECHECKDAYID; CREATE PROCEDURE UPDATECHECKDAYID INSTRUID INT AS DECLARE dayid int DECLARE patientid int-临时变量,
17、用来保存游标值DECLARE askdate varchar(20) DECLARE oldaskdate varchar(20) set dayid=1 set oldaskdate= BEGIN TRAN - 申明事务- 申明游标为 patientid DECLARE order_cursor CURSOR FOR SELECT PATIENTID, ASKDATE FROM PATIENTSELF WHERE INSTRUMENTID=INSTRUID ORDER BY ASKDATE - 打开游标open order_cursor FETCH NEXT FROM order_curso
18、r INTO patientid, askdate WHILE FETCH_STATUS = 0 - 返回被 FETCH 语句执行的最后游标的状态,而不是任何当前名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 6 页 - - - - - - - - - 被连接打开的游标的状态。begin if askdate=oldaskdate begin set dayid=dayid+1 end else begin set dayid=1 set oldaskdate=askda
19、te end -执行 sql 操作 UPDATE PATIENTSELF SET CHECKDAYID=dayid WHERE PATIENTID=patientid FETCH NEXT FROM order_cursor INTO patientid, askdate end COMMIT TRAN -提交CLOSE order_cursor-关闭游标DEALLOCATE order_cursor-释放游标GO 针对每一个机台号,执行EXEC UPDATECHECKDAYID INSTRUID = 1 EXEC UPDATECHECKDAYID INSTRUID = 2 EXEC UPDA
20、TECHECKDAYID INSTRUID = 3 EXEC UPDATECHECKDAYID INSTRUID = 4 EXEC UPDATECHECKDAYID INSTRUID = 5 EXEC UPDATECHECKDAYID INSTRUID = 6 EXEC UPDATECHECKDAYID INSTRUID = 7 . UPDATE PATIENTSELF SET RECORDCDNO=ASKDATE+RIGHT(CAST(POWER(10,3) AS varchar)+CHECKDAYID,3); INSERT MedImgMgrSysLG.dbo.tbPatientInfor
21、mation(MedicalID, InHospitalID, OutPatientID, CheckID, InstrumentID, PatientName, Sex, Age, AgeType, Address, Phone, AskDepartment, AskDoctor, CheckDoctor, CheckTime, ReportDoctor, ReportTime, ImageCount, CheckStatus, CheckDesc, DiagDesc, PatientType, Fee, AskAdvice, CheckPos, BedID) SELECT MEDICCAR
22、EID, INHOSPITAL, OUTPAITENTID, RECORDCDNO, INSTRUMENTID, PATIENTNAME, SEX, AGE, AGETYPE, ADDRESS, PHONE, ASKDEPT, ASKDR, CHECKDR, CHECKTIME, REPORTDR, REPORTTIME, IMAGECOUNT, CHECKSTATUS, CHECKDESC, DIAGNOSEDESC, 0, FEE, ASKADVICE, CHECKPARTDESC, SICKBEDID FROM EndoscopeLG.dbo.PATIENTSELF; 旧数据库类型B:( 龙岗 20M数据库 ) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 6 页 - - - - - - - - - 4. tbPatientImage - PATIENTIMAGE 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 6 页 - - - - - - - - -