I am building a repository of (anonymous) information about surgical procedures performed at a large research hospital over a period of several years. This data is used to support statistical studies of clinical questions.
In this simplified version of an actual search, I am trying to group by year for 1990 and 1991 those patients who had surgery for the first time (Pri90, Pri91) and those who had a repeat operation (Re90, Re91).
{
for $b in collection(“Demo500”)/PatientRecord,
$c in $b//Surgery
return
(
For $Pri90 in $c[substring(string-value(./@SurgeryDate),1,4)=‘1990’ and
substring(string-value(./HistoryOfCardiacOperations),1,2)=‘No’]
return
{
(
A-Elective Primary ,
{string-value($b/@PatientID)},
{string-value($Pri90/@SurgeryDate)}
)
}
,
For $Pri91 in $c[substring(string-value(./@SurgeryDate),1,4)=‘1991’ and
substring(string-value(./HistoryOfCardiacOperations),1,2)=‘No’]
return
{
(
A-Elective Primary ,
{string-value($b/@PatientID)},
{string-value($Pri91/@SurgeryDate)}
)
}
,
For $Re90 in $c[substring(string-value(./@SurgeryDate),1,4)=‘1990’ and
not(substring(string-value(./HistoryOfCardiacOperations),1,2)=‘No’)]
return
{
(
B-ReOp ,
{string-value($b/@PatientID)},
{string-value($Re90/@SurgeryDate)}
)
}
,
For $Re91 in $c[substring(string-value(./@SurgeryDate),1,4)=‘1991’ and
not(substring(string-value(./HistoryOfCardiacOperations),1,2)=‘No’)]
return
{
(
B-ReOp ,
{string-value($b/@PatientID)},
{string-value($Re91/@SurgeryDate)}
)
}
) sortby (Group, SDate)
}
I was expecting all A-Group items sorted by date followed by all B-Group items sorted by date.
sortby(Group, SDate) produces the following result (all A’s followed by all B’s, but no sort on date):
<?xml version="1.0"?>
<quip:result xmlns:quip=“http://namespaces.softwareag.com/tamino/quip/”>
A-Elective Primary
P-00016
1991-01-03
A-Elective Primary
P-00024
1990-01-02
A-Elective Primary
P-00026
1990-01-02
A-Elective Primary
P-00039
1991-01-03
A-Elective Primary
P-00339
1990-03-23
A-Elective Primary
P-00355
1990-02-20
A-Elective Primary
P-00356
1991-01-16
A-Elective Primary
P-00432
1990-01-04
A-Elective Primary
P-00443
1991-01-02
A-Elective Primary
P-00447
1991-01-02
B-ReOp
P-00163
1991-01-02
B-ReOp
P-00168
1990-01-02
B-ReOp
P-00256
1990-01-02
B-ReOp
P-00269
1990-01-03
B-ReOp
P-00298
1990-01-03
B-ReOp
P-00298
1990-01-04
B-ReOp
P-00446
1991-01-02
</quip:result>
sortby (SDate, Group) produces a correct sort by date, but no grouping of A’s and B’s (see 01-04-1990, 01-02-1991) ):
<?xml version="1.0"?>
<quip:result xmlns:quip=“http://namespaces.softwareag.com/tamino/quip/”>
A-Elective Primary
P-00024
1990-01-02
A-Elective Primary
P-00026
1990-01-02
B-ReOp
P-00168
1990-01-02
B-ReOp
P-00256
1990-01-02
B-ReOp
P-00269
1990-01-03
B-ReOp
P-00298
1990-01-03
B-ReOp
P-00298
1990-01-04
A-Elective Primary
P-00432
1990-01-04
A-Elective Primary
P-00355
1990-02-20
A-Elective Primary
P-00339
1990-03-23
B-ReOp
P-00163
1991-01-02
A-Elective Primary
P-00443
1991-01-02
B-ReOp
P-00446
1991-01-02
A-Elective Primary
P-00447
1991-01-02
A-Elective Primary
P-00016
1991-01-03
A-Elective Primary
P-00039
1991-01-03
A-Elective Primary
P-00356
1991-01-16
</quip:result>
Thanks for helping check this out.
While we’re discussing this query, I would appreciate your comments on another problem I am having. Since it is a different subject, I will post separately under the subject, “Multi-Document Statistics”
Bill
#API-Management#Tamino#webMethods