Scenario
The doctor needs a report where on giving a particular symptom the report gives details of all patients having that symptom and their complete medical history. One patient can have many symptoms related to a disease, hence to fetch all patients having a particular symptom, need loop through each patient's PMD is needed and then repeat for all patients.
This report will help to group patient with similar symptoms and hence the doctor could identify how a patient could be treated by comparing with other patient who had similar symptom.
Operation
SQL cursors allow iteration through rows in table. Also it supports cursors on XQuery expressions.
In the following scenario to get patients with a given symptom we can loop through the
CREATE PROCEDURE
--> creates a SQL procedure inside which a cursor will be declared.Xquery FLOWR
--> To iterate through individual patient medical history to get the particular symptom.DECLARE curSymptom CURSOR
--> to iterate all those patients who have that symptom and consolidate into one report.
Solution
All the patients who have a particular symptom is fetched and given as a consolidated report.