Closed DevaRajan19 closed 3 years ago
Hi. Not sure I can answer all questions. First, you can make your own MdsolQuery subclass to add requery action. It's not as easy as it should be but:
from rwslib.builders.clinicaldata import MdsolQuery, QueryStatusType
from rwslib.builders.common import bool_to_yes_no
class MdsolQuery2(MdsolQuery):
"""MdsolQuery type with preceding_query_repeat_key"""
def __init__(self, **kwargs):
self.preceding_query_repeat_key = kwargs.pop("preceding_query_repeat_key", None)
MdsolQuery.__init__(self, **kwargs)
def build(self, builder):
"""
Build XML by appending to builder
"""
params = {}
if self.value is not None:
params["Value"] = str(self.value)
if self.query_repeat_key is not None:
params["QueryRepeatKey"] = str(self.query_repeat_key)
# ADDED PART ---
if self.preceding_query_repeat_key is not None:
params["PrecedingQueryRepeatKey"] = str(self.preceding_query_repeat_key)
# --- ADDED PART
if self.recipient is not None:
params["Recipient"] = str(self.recipient)
if self.status is not None:
params["Status"] = self.status.value
if self.requires_response is not None:
params["RequiresResponse"] = bool_to_yes_no(self.requires_response)
# When closing a query
if self.response is not None:
params["Response"] = str(self.response)
builder.start("mdsol:Query", params)
builder.end("mdsol:Query")
#Query Text String to open
QT1 = 'TestQueryField1'
#Query Text Status
QT_Status_Open = QueryStatusType.Open
#Query Requires Response(true/false)
QT_ReqResp = 'true'
#Query Text string for the response
QT_Response = 'This is the response of the Query'
#Query Text Recipient
QT_MG = 'Site from DM'
#Query ID from the DB
QT_RepeatKey1='123' #AETERM #Masked
query1 = MdsolQuery2(value=QT1, query_repeat_key = QT_RepeatKey1, requires_response = QT_ReqResp, recipient=QT_MG, status=QT_Status_Open,
preceding_query_repeat_key=99
)
print(str(query1))
# <mdsol:Query Value="TestQueryField1" QueryRepeatKey="123" PrecedingQueryRepeatKey="99" Recipient="Site from DM" Status="Open" RequiresResponse="Yes" />
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I personally have not used the PrecedingQueryRepeatKey to re-open a query and I can't test right now. Maybe you can experiment with the above to see what works for you.
Thanks for the help @iansparks. I will verify the code and let you know.
So basically what I understood with the code is that we are creating a user defined sub class of the MdsolQuery class and defining the parameters.
Could you confirm that apart from using PrecedingQueryRepeatKey, are there any other way we can re-query using the existing predefined functions(Open?
So basically what I understood with the code is that we are creating a user defined sub class of the MdsolQuery class and defining the parameters.
Yes. An update to the library should be made to add this parameter to the existing MdsolQuery class. I'll see if I can do that.
Could you confirm that apart from using PrecedingQueryRepeatKey, are there any other way we can re-query using the existing predefined functions(Open?
By re-query you mean re-open a query that has been answered/closed by the user. I haven't tried this myself, it seems like the PrecedingQueryRepeatKey is the (database?) ID of a query that was already opened. So you open a query with your original request:
#To Open Queries
query1 = MdsolQuery(value=QT1, requires_response = QT_ReqResp, recipient=QT_MG, status=QT_Status_Open)
What response do you get back from that? Does it include some kind of Query ID? in other words, what is printed when you do:
responseobject = rwscon.send_request(PostDataRequest(str(Odm)))
print(str(responseobject))
Sorry I can't test this myself at the moment.
Hi @DevaRajan19 I was able to do a bit of testing with help from @anewbigging
I was writing a query to a standard field. When I ran the "OpenQuery" ODM I got back:
<Response ReferenceNumber="d4891797-147d-4d97-8cae-6898e2511cb2" InboundODMFileOID="3b5acb0a-25de-4a24-8a9b-d1dca57eb621" IsTransactionSuccessful="1" SuccessStatistics="Rave objects touched: Subjects=0; Folders=0; Forms=0; Fields=1; LogLines=0" NewRecords=""><Query ID="153083" FieldOID="SVSTDTC"/></Response>
And the query appeared in Rave. Notice the Query ID="153083" that's going to be what you need to work with this query in future. Then I could close it:
query1 = MdsolQuery(query_repeat_key = "153083", recipient=QT_MG, status=QT_Status_Close)
and then I could re-open it:
query1 = MdsolQuery2(value=QT1, requires_response = QT_ReqResp, recipient=QT_MG, status=QT_Status_Open,
preceding_query_repeat_key="153083")
Requeried:
Thanks to @glow-mdsol for merging the PR which includes preceding_query_repeat key in the MdsolQuery object. version 1.2.5.
Hi @iansparks @anewbigging and @glow-mdsol; Apologies for the delayed response.
Once I had defined the custom MdsolQuery2 subClass and called the function for opening the queries using preceding key, it worked!
Thanks for the help!
Hello Team,
We were programming the RWS calls using python builders for query opening, cancelling, closing and re-opening on the log fields of AETERM, AESTDAT and AEENDAT in AE form. Please find below the code:
As per the RWS tutorials in Knowledge Space https://learn.mdsol.com/api/rws/use-field-queries-95587384.html, we find that for re-query action we need the following parameters
We observed a few issues with the Re-Query part mainly
class rwslib.builders.clinicaldata.MdsolQuery does not contain an attribute for PrecedingQueryRepeatKey for definition
when executing the re-query code(mentioned above), we get the RWS error denoting
raise RWSException(error.errordescription, error) - RWSException: Query cannot be opened with query repeat key
Could you please confirm if there is an option to re-query (along with requires response) and provide us the snippet for the same.