Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML/S ECHMA /XSLT 技術 1. 大綱 電子病歷標準制定過程 CDA R2 實作問題 XML 技術簡介 XML Schema 技術 XSLT 技術 XSLT 語法 XPATH 語法 編寫技巧 2.

Similar presentations


Presentation on theme: "XML/S ECHMA /XSLT 技術 1. 大綱 電子病歷標準制定過程 CDA R2 實作問題 XML 技術簡介 XML Schema 技術 XSLT 技術 XSLT 語法 XPATH 語法 編寫技巧 2."— Presentation transcript:

1 XML/S ECHMA /XSLT 技術 1

2 大綱 電子病歷標準制定過程 CDA R2 實作問題 XML 技術簡介 XML Schema 技術 XSLT 技術 XSLT 語法 XPATH 語法 編寫技巧 2

3 電子病歷標準制定過程

4 背景說明 為什麼醫療院所需要知道電子病歷標準制定流程? 108 張夠用嗎? 不夠?那到底要幾張? 那弄 2000 張好了? 誰來定,誰付錢? 就算衛生署買單,那你買帳嗎?

5 需求 規則 電子病歷標準設計流程 紙本病歷 欄位需求清單 xls/doc 欄位需求清單 xls/doc 實作指引標準書 doc/PDF 實作指引標準書 doc/PDF 整理定義 規範 結構定義檔 xsd 結構定義檔 xsd 內容驗證檔 sch 內容驗證檔 sch 設計 字彙控制檔 xml 字彙控制檔 xml 病歷呈現樣式檔 html XML 範例 xml XML 範例 xml 欄位變數對應檔 xsl 欄位變數對應檔 xsl 比照 呈現樣式轉換檔 xsl 呈現樣式轉換檔 xsl 複製 匯入 參照 XPath 驗證用編碼 呈現用編碼 除錯

6 紙本病歷 1. 由需求單位提出

7 欄位需求清單 xls/doc 欄位需求清單 xls/doc 1. 由病歷管理單位整理 2. 並經電子病歷委員會 認可 1. 由病歷管理單位整理 2. 並經電子病歷委員會 認可

8 實作指引標準書 doc/PDF 實作指引標準書 doc/PDF 1. 由標準管理單位編寫 2. 若是全國通用,則可 至電子病歷標準管理 系統下載。 1. 由標準管理單位編寫 2. 若是全國通用,則可 至電子病歷標準管理 系統下載。

9 病歷呈現樣式檔 html 1. 由實作執行單位與病 歷管理單位共同合作 編寫

10 結構定義檔 xsd 結構定義檔 xsd 1. 此為 CDA R2 標準文 件。 2. 由實作執行單位從電 子病歷標準管理系統 下載取得。 1. 此為 CDA R2 標準文 件。 2. 由實作執行單位從電 子病歷標準管理系統 下載取得。

11 XML 範例 xml XML 範例 xml 1. 由標準管理單位與實 作執行單位共同編輯 設計。

12 欄位變數對應檔 xsl 欄位變數對應檔 xsl 1. 由下列三個單位共同 設計: 病歷管理單位 標準管理單位 實作執行單位 1. 由下列三個單位共同 設計: 病歷管理單位 標準管理單位 實作執行單位

13 呈現樣式轉換檔 xsl 呈現樣式轉換檔 xsl 1. 可由電子病歷標準管 理系統下載參考。 2. 實作執行單位編輯設 計。 1. 可由電子病歷標準管 理系統下載參考。 2. 實作執行單位編輯設 計。

14 字彙控制檔 xml 字彙控制檔 xml 1. 可經由電子病歷標準 管理系統取得。 2. 由標準管理單位負責 維護。 3. 由實作執行單位負責 編輯。 1. 可經由電子病歷標準 管理系統取得。 2. 由標準管理單位負責 維護。 3. 由實作執行單位負責 編輯。

15 內容驗證檔 sch 內容驗證檔 sch 1. 由實作執行單位依據 實作指引標準書之內 容編輯。 2. 若為全國通用者,則 可至電子病歷標準管 理系統下載。 1. 由實作執行單位依據 實作指引標準書之內 容編輯。 2. 若為全國通用者,則 可至電子病歷標準管 理系統下載。

16 最後成果

17 電子病歷實作問題

18 實踐電子病歷之問題所在 電子病歷 設計管理 電子病歷 文件管理 電子病歷 應用管理 電子病歷 流程管理

19 專注在「產生」電子病歷文件 19

20 實作可能模式 XML 編輯器 軟體有:微軟 XML Notepad 2007 、 Altova XML SPY 、 oXygenXML 等。 對終端使用者不友善。 電子表單軟體 軟體有:微軟 InfoPath 、 Adobe 等 可設計符合使用者介面之資料輸入介面。 SOA/EAI 工具 軟體工具很多。微軟 BizTalk 。 須從系統流程整合角度切入使用。 程式設計 可配合實際需求撰寫。 需要程式設計開發人員。 20

21 技術簡述 – 標準類 臨床類: LOINC :文件類型與區段代碼。 SNOMED :區段內容代碼。 ICD :區段內容代碼。 其他:如藥品等,區段內容代碼。 技術類: XHTML :臨床文件呈現格式 CSS : XHTML 呈現樣式 XML :臨床文件儲存格式 SCHEMA : XML 結構驗證 SCHEMATRON : XML 內容驗證 XSLT : XML 轉成 XHTML XPATH :定義 XML 各元素之位置( XSLT 與 Schematron 中會用 到) HL7 類: RIM 、 DataType 、 Vocabulary 、 RMIM 、 CDA POCD_MT000040.xsd CDA.xsd NarrativeBlock.xsd datatypes.xsd datatypes- base.xsd voc.xsd entries narrative header namespaces body 區段 21

22 C DA R 2 與資料來源的關係 資料來源資料來源 資料庫 表單 檔案 訊息 資料來源資料來源 1. 固定值:由 CDA R2 決定。只要是實 作 CDA R2 就是這個碼。如 typeID 3. 系統值:由 CDA R2 程式所產生。如 文件產生時間。 2. 預設值:由實作指引標準書決定。只 要實作哪份單張就會決定碼。如 code 4. 不變值:資料來源是如何就如何。如 姓名。 5. 限定值 5. 限定值:資料來源需經過轉碼。如性 別。

23 基本概念 CDA XSLT HTML

24 XML 技術簡介 24

25 什麼是 XML XML XML 是指 eXtensible Markup Language 。 XML 是設計用來攜帶資料,不是顯示資料之用。 XML 的標籤 ( tag) 並未事先定義,你必須設計定義自 己的標籤。 XML 被設計為可以自我描述內容。 XML 是 W3C 所推薦標準。 25

26 簡單的 XML 範例 同學 老師 注意事項 下週二小考 注意: 1.XML 沒有特殊規範,只是一個文字檔。 2. 你可以自行創造各種標籤名稱。 3. 他提供了一種與軟體、硬體獨立的交換情境。 26

27 XML 衍生之應用 在網際網路上,因為 XML 而擴展之應用 XHTML the latest version of HTML WSDL for describing available web services WAP and WML as markup languages for handheld devices RSS languages for news feeds RDF and OWL for describing resources and ontology SMIL for describing multimedia for the web 27

28 XML 在產業的應用 http://www.oasis-open.org/cover/xml.html#applications Web Servers: apacheXML parsers, XSL, web publishingapacheXML Travel: openTravel information for airlines, hotels, and car rental placesopenTravel News: NewsML creation, transfer and delivery of newsNewsML Voice: VoxML markup language for voice applicationsVoxML Wireless: WAP (Wireless Application Protocol) wireless devices on the World Wide WebWAP Weather: OMF Weather Observation Markup Format (simulation)OMFsimulation Healthcare: HL7 DTDs for prescriptions, policies & procedures, clinical trialsHL7 Math: MathML (Mathematical Markup Language)MathML 28

29 術語說明 element type character content element Empty element Y.Papakonstantinou S. Abiteboul H. Garcia-Molina Object Fusion in Mediator Systems VLDB 96 element content Root element type Attribute (name,value) 29

30 XML 之規則 All XML Elements Must Have a Closing Tag XML Tags are Case Sensitive XML Elements Must be Properly Nested This is a paragraph This is another paragraph This is incorrect This is correct This text is bold and italic 30

31 XML 之規則 4. XML Documents Must Have a Root Element 5. XML Attribute Values Must be Quoted 6. Entity References..... Tove Jani <greater than &&ersand '' apostrophe "“quotation mark 31

32 XML 之規則 7. Comments in XML 8. White-space is Preserved in XML 9. XML Stores New Line as LF 32

33 XML 之驗證 Well Formed XML Documents XML documents must have a root element XML elements must have a closing tag XML tags are case sensitive XML elements must be properly nested XML attribute values must be quoted Valid XML Documents 符合 DTD 規範或 XML Schema XML Namespaces identify your vocabulary 33

34 XML S CHEMA 技術 34

35 為什麼需要 XML SCHEMA 35

36 36

37 XML 與 SCHEMA 37

38 建立 SCHEMA 檔 Xml 文件宣告 建立 root element 宣告 namespace http://www.w3.org/2001/XMLSchema 38

39 X ML 檔案之引用 39

40 X ML S CHEMA 的註解 透過 xml 編輯器,可以將此段文字顯示出來。有即時 說明的作用。 40

41 定義簡易型態元素 41 正確 錯誤

42 簡易型態 42

43 固定值與預設值 43 Valid No valid Valid

44 自定簡易型態 44 在元素中定義可重複使用

45 限定範圍值 ─ 列舉 45

46 複雜型態 46

47 基本說明 Xml 的元素可以分成簡單型態與複雜型態 屬於複雜型態的元素,可以有子元素與屬性。 簡單型態不行有子元素與屬性。 複雜型態又可以在分成簡單內容與複雜內容 簡單內容就只能放字串。 複雜內容則可以有子元素。 Xml 範例 47

48 定義子元素 In order 48

49 定義子元素 In any order 49

50 定義子元素 Choices 50

51 參照全域變數 51

52 控制次數 52

53 定義屬性 53

54 X SLT 技術 54

55 什麼是 XSLT eXtensible Stylesheet Language for Transformations Language for transforming XML documents A programming language for XML documents A functional language, based on value substitution Augmented with pattern matching And also template substitution to construct output (based on namespaces Uses XML syntax

56 常見應用 XML to HTML— for old browsers XML to LaTeX—for TeX layout XML to SVG—graphs, charts, trees XML to tab-delimited—for db/stat packages XML to plain-text—occasionally useful XML to FO—XSL formatting objects

57 簡單範例 File data.xml : Howdy! File render.xsl :

58 XSLT 語法

59 T HE. XSL FILE An XSLT document has the.xsl extension The XSLT document begins with: Contains one or more templates, such as:... And ends with:

60 F INDING THE MESSAGE TEXT The template says to select the entire file You can think of this as selecting the root node of the XML tree Inside this template, selects the message child Alternative Xpath expressions that would also work:./message /message/text() (text() is an XPath function)./message/text()

61 P UTTING IT TOGETHER The XSL was: The chooses the root The is written to the output file The contents of message is written to the output file The is written to the output file The resultant file looks like: Howdy!

62 H OW XSLT WORKS The XML text document is read in and stored as a tree of nodes The template is used to select the entire tree The rules within the template are applied to the matching nodes, thus changing the structure of the XML tree If there are other templates, they must be called explicitly from the main template Unmatched parts of the XML tree are not changed After the template is applied, the tree is written out again as a text document

63 W HERE XSLT CAN BE USED With an appropriate program, such as Xerces, XSLT can be used to read and write files A server can use XSLT to change XML files into HTML files before sending them to the client A modern browser can use XSLT to change XML into HTML on the client side This is what we will mostly be doing in this class Most users seldom update their browsers If you want “everyone” to see your pages, do any XSL processing on the server side Otherwise, think about what best fits your situation

64 M ODERN BROWSERS Internet Explorer 6 best supports XML Netscape 6 supports some of XML Internet Explorer 5.x supports an obsolete version of XML IE5 is not good enough for this course If you must use IE5, the initial PI is different (you can look it up if you ever need it)

65 XSL : VALUE - OF selects the contents of an element and adds it to the output stream The select attribute is required Notice that xsl:value-of is not a container, hence it needs to end with a slash Example (from an earlier slide):

66 XSL : FOR - EACH xsl:for-each is a kind of loop statement The syntax is Text to insert and rules to apply Example: to select every book ( //book ) and make an unordered list ( ) of their titles ( title ), use:

67 F ILTERING OUTPUT You can filter (restrict) output by adding a criterion to the select attribute’s value: This will select book titles by Terry Pratchett

68 F ILTER DETAILS Here is the filter we just used: author is a sibling of title, so from title we have to go up to its parent, book, then back down to author This filter requires a quote within a quote, so we need both single quotes and double quotes Legal filter operators are: = != < > Numbers should be quoted, but apparently don’t have to be

69 B UT IT DOESN ’ T WORK RIGHT ! Here’s what we did: This will output and for every book, so we will get empty bullets for authors other than Terry Pratchett There is no obvious way to solve this with just xsl:value-of

70 XSL : IF xsl:if allows us to include content if a given condition (in the test attribute) is true Example: 作者 This does work correctly!

71 XSL : CHOOSE The xsl:choose... xsl:when... xsl:otherwise construct is XML’s equivalent of Java’s switch... case... default statement The syntax is:... some code...... some code... xsl:choose is often used within an xsl:for-each loop

72 XSL : SORT You can place an xsl:sort inside an xsl:for-each The attribute of the sort tells what field to sort on Example: by This example creates a list of titles and authors, sorted by author

73 XSL : TEXT... helps deal with two common problems: XSL isn’t very careful with whitespace in the document This doesn’t matter much for HTML, which collapses all whitespace anyway (though the HTML source may look ugly) gives you much better control over whitespace; it acts like the element in HTML Since XML defines only five entities, you cannot readily put other entities (such as ) in your XSL &nbsp; almost works, but is visible on the page Here’s the secret formula for entities: &nbsp;

74 XPATH 技術

75 W HAT IS XP ATH ? XPath is a syntax used for selecting parts of an XML document The way XPath describes paths to elements is similar to the way an operating system describes paths to files XPath is almost a small programming language; it has functions, tests, and expressions XPath is a W3C standard XPath is not itself written as XML, but is used heavily in XSLT

76 重要術語 library is the parent of book ; book is the parent of the two chapter s The two chapter s are the children of book, and the section is the child of the second chapter The two chapter s of the book are siblings (they have the same parent) library, book, and the second chapter are the ancestors of the section The two chapter s, the section, and the two paragraph s are the descendents of the book library is the parent of book ; book is the parent of the two chapter s The two chapter s are the children of book, and the section is the child of the second chapter The two chapter s of the book are siblings (they have the same parent) library, book, and the second chapter are the ancestors of the section The two chapter s, the section, and the two paragraph s are the descendents of the book

77 路徑描述 Operating system: XPath: / = the root directory /library = the root element (if named library ) /users/dave/foo = the file named foo in dave in users /library/book/chapter/section = every section element in a chapter in every book in the library. = the current directory. = the current element.. = the parent directory.. = parent of the current element /users/dave/* = all the files in /users/dave /library/book/chapter/* = all the elements in /library/book/chapter foo = the file named foo in the current directory section = every section element that is a child of the current element

78 斜線應用 A path that begins with a / represents an absolute path, starting from the top of the document Example: /email/message/header/from Note that even an absolute path can select more than one element A slash by itself means “the whole document” A path that does not begin with a / represents a path starting from the current element Example: header/from A path that begins with // can start from anywhere in the document Example: //header/from selects every element from that is a child of an element header This can be expensive, since it involves searching the entire document

79 中括弧與 LAST () 函數 A number in brackets selects a particular matching child (counting starts from 1, except in Internet Explorer) Example: /library/book[1] selects the first book of the library Example: //chapter/section[2] selects the second section of every chapter in the XML document Example: //book/chapter[1]/section[2] Only matching elements are counted; for example, if a book has both section s and exercise s, the latter are ignored when counting section s The function last() in brackets selects the last matching child Example: /library/book/chapter[last()] You can even do simple arithmetic Example: /library/book/chapter[last()-1]

80 星號應用 A star, or asterisk, is a “wild card”--it means “all the elements at this level” Example: /library/book/chapter/* selects every child of every chapter of every book in the library Example: //book/* selects every child of every book ( chapter s, tableOfContents, index, etc.) Example: /*/*/*/paragraph selects every paragraph that has exactly three ancestors Example: //* selects every element in the entire document

81 取屬性 I You can select attributes by themselves, or elements that have certain attributes Remember: an attribute consists of a name-value pair, for example in, the attribute is named num To choose the attribute itself, prefix the name with @ Example: @num will choose every attribute named num Example: //@* will choose every attribute, everywhere in the document To choose elements that have a given attribute, put the attribute name in square brackets Example: //chapter[@num] will select every chapter element (anywhere in the document) that has an attribute named num

82 取屬性 II //chapter[@num] selects every chapter element with an attribute num //chapter[not(@num)] selects every chapter element that does not have a num attribute //chapter[@*] selects every chapter element that has any attribute //chapter[not(@*)] selects every chapter element with no attributes

83 屬性值 //chapter[@num='3'] selects every chapter element with an attribute num with value 3 //chapter[not(@num)] selects every chapter element that does not have a num attribute //chapter[@*] selects every chapter element that has any attribute //chapter[not(@*)] selects every chapter element with no attributes The normalize-space() function can be used to remove leading and trailing spaces from a value before comparison Example: //chapter[normalize-space(@num)="3"]

84 軸 ( AXIS ) 的概念 An axis (plural axes) is a set of nodes relative to a given node; X::Y means “choose Y from the X axis” self:: is the set of current nodes (not too useful) self::node() is the current node child:: is the default, so /child:: X is the same as / X parent:: is the parent of the current node ancestor:: is all ancestors of the current node, up to and including the root descendant:: is all descendants of the current node (Note: never contains attribute or namespace nodes) preceding:: is everything before the current node in the entire XML document following:: is everything after the current node in the entire XML document

85 軸範例 Starting from a given node, the self, preceding, following, ancestor, and descendant axes form a partition of all the nodes (if we ignore attribute and namespace nodes) //chapter[2]/self::* //chapter[2]/preceding::* //chapter[2]/following::* //chapter[2]/ancestor::* //chapter[2]/descendant::*

86 算數式 +add -subtract *multiply div (not / ) divide mod modulo (remainder)

87 等式測試 = “equals”(Notice it’s not == ) != “not equals” But it’s not that simple! value = node-set will be true if the node-set contains any node with a value that matches value value ! = node-set will be true if the node-set contains any node with a value that does not match value Hence, value = node-set and value ! = node-set may both be true at the same time!

88 其他布林運算子 and(infix operator) or(infix operator) Example: count = 0 or count = 1 not()(function) The following are used for numerical comparisons only: < “less than”Some places may require < <= “less thanSome places may require <= or equal to” > “greater than”Some places may require > >= “greater thanSome places may require >= or equal to”

89 感 謝 聆 聽感 謝 聆 聽感 謝 聆 聽感 謝 聆 聽 感 謝 聆 聽感 謝 聆 聽感 謝 聆 聽感 謝 聆 聽 電子病歷是一門學問 不是一項技術


Download ppt "XML/S ECHMA /XSLT 技術 1. 大綱 電子病歷標準制定過程 CDA R2 實作問題 XML 技術簡介 XML Schema 技術 XSLT 技術 XSLT 語法 XPATH 語法 編寫技巧 2."

Similar presentations


Ads by Google