Scenario
Over a period of time a patient medical information keeps on adding to the PMD. The entire medical history would be the cumulation of all the diagnosis or observation done on the patient. The doctor needs a entire history of a patient medical history.
Operation
The PMD document contains a node called component which holds information about a patient's visit. Additional nodes are added for subsequent visits. Hence to get the complete information we need to loop through the nodes. For example a patient who visited the provider 10 times will have 10 component nodes.
The FLWOR expression helps to iterate over a sequence and bind the values to intermediate results. The FLWOR expression s are useful when two XML column or documents are joined.
Solution
The following Xquery explains the FLWOR expression where a patient's entire medical history is fetched as a single XML document by iterating through his medical history where the date of consultancy filters the particular date when the patient consulted.
The queries on the right hand side shows few basic XQuery features. The results are displayed in separate tabs.
Best Practices