FindDocuments stored query issue


I'm running into some issues when executing stored queries. The queries complete however they are returning an empty list of reference objects.
Specifically, I am having issues with the FindDocuments stored query at the moment.
My message looks like this-

<query:AdhocQueryRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:query="urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0" xmlns="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" xmlns:rs="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0">
<query:ResponseOption returnComposedObjects="true" returnType="LeafClass"/>
<AdhocQuery id="urn:uuid:14d4debf-8f97-4251-9a74-a90016b0af0d">
    <Slot name="$XDSDocumentEntryStatus">
<Slot name="$XDSDocumentEntryPatientId">

After doing some tracing, I've found that the quotes are not right on the patientUID paramter... so the patientUID values in the stored procedure calls look like this-

exec usp_get_documentEntryDetails_DocumentEntry_Patient @availabilityStatus=N'urn:oasis:names:tc:ebxml-regrep:StatusType:Approved',@patientUID=N'''498ef443e7ac4a6^^^&'''
As you can see, there are two extra single quotes on each side of the patientUID parameter.
My first assumption would be that the AddInParameter method [I'm assuming this comes from Microsoft.Practices.EnterpriseLibrary...] is trying to escape the single quotes which is fine... but if this is the case then it seems to me that the application code should make sure that unnecessary message level quotes get stripped out prior to whenever values get stuffed in the object handling the stored procedure calls
I have tested with other types such as GetDocuments and the paramaters seem to be going through just fine... so I'm thinking this issue could be isolated to FindDocument because it looks like the GetDocuments parameters are getting handled slightly differently than the patientUID parameter within the usp_get_documentEntryDetails_DocumentEntry_Patient SP.
So at this point, it is not clear to me exactly how the enclosing quotes in patientUID paramter were intended to be handled so I'm not sure what needs to be fixed... BUT I suppose my main point here is- The quotes are not being hadled properly as far as I can tell and I have provided the message that I'm using to test, quadruple checked the IHE specs, etc and I'm unable to find any mistakes on my end as far as usage goes.
Let me know if I'm doing something wrong or if I should be submitting this as a bug.


Oganix wrote Nov 5, 2009 at 4:22 PM

I have run into a similar issue. The problem is in the GetDocumentEntries method in the StoredQueryBase class. Following modified version fixed the issue for me:.

protected List<DocumentEntry> GetDocumentEntries(string patientUID, List<string> lstAvailabilityStatus)
        List<DocumentEntry> lstDocumentEntry = null;
        RegistryStoredQueryDataAccess storedQueryDAL = null;
        string availabilityStatus = null;
        string patientId = null;

        storedQueryDAL = new RegistryStoredQueryDataAccess();

        availabilityStatus = PrepareForSqlInStatement(lstAvailabilityStatus);
        patientId = PrepareForSqlInStatement(patientUID);
        lstDocumentEntry = storedQueryDAL.GetDocumentEntries(availabilityStatus, patientId);

        if ((lstDocumentEntry == null) || (lstDocumentEntry.Count == 0))
            return lstDocumentEntry;

        foreach (DocumentEntry documentEntry in lstDocumentEntry)
            documentEntry.EventCodeList = storedQueryDAL.GetDocumentEntryEventCodeList(documentEntry.ID);

        return lstDocumentEntry;
Basiclly the fix is to call PrepareForSqlInStatement for for PatientUID.


wrote Feb 14, 2013 at 6:17 PM