org.eclipse.ohf.ihe.xds.consumer.storedquery
Class StoredQueryBuilderUtils

java.lang.Object
  extended by org.eclipse.ohf.ihe.xds.consumer.storedquery.StoredQueryBuilderUtils

public class StoredQueryBuilderUtils
extends java.lang.Object

Static utilites to aid in building XDS consumer stored query parameters and for use by developers wishing to extends query capabilites of the IHE XDS Consumer (Transaction ITI-18: Registry Stored Query)

Author:
Sarah Knoop
See Also:
IHE Technical Framework, for example use, for example use

Constructor Summary
StoredQueryBuilderUtils()
           
 
Method Summary
static void addCodedParameters(java.util.HashMap queryParameters, java.lang.String codeUUID, CodedMetadataType[] codes)
          Adds the codes given as query parameters for the metadata attribute specifide by codeUUID to the given HashMap of StoredQuery parameters.
static void addDateTimeParameters(java.util.HashMap queryParameters, DateTimeRange range)
          Builds the date/time range query sub clause (included the lower time bound, but excludes the upper time bound).
static void addPatientIdParameter(java.util.HashMap queryParameters, CX patientId)
          Adds the patientId list given as query parameters for the metadata attribute to the given HashMap of StoredQuery parameters.
static void addStatusParameter(java.util.HashMap queryParameters, AvailabilityStatusType[] status)
          Adds the status list given as query parameters for the metadata attribute to the given HashMap of StoredQuery parameters.
static java.lang.String buildListArgs(java.lang.String[] args)
          Builds coma separade list of arguments
static java.lang.String checkForSingleQuote(java.lang.String s)
          In Stored Query, any query parameter value that happens to contain a single quote (') must "escape" the single quote with another ('').
static int validCodeList(CodedMetadataType[] codes)
          Checks to see if the code list provided has one coding scheme documented for each code, or none at all
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StoredQueryBuilderUtils

public StoredQueryBuilderUtils()
Method Detail

buildListArgs

public static java.lang.String buildListArgs(java.lang.String[] args)
Builds coma separade list of arguments


checkForSingleQuote

public static java.lang.String checkForSingleQuote(java.lang.String s)
In Stored Query, any query parameter value that happens to contain a single quote (') must "escape" the single quote with another (''). Example "Children's Hospital" would become "Children''s Hospital".

Parameters:
s - the string to check.
Returns:
the original string, if it contained no single quotes, or the amended string if it did.

addPatientIdParameter

public static void addPatientIdParameter(java.util.HashMap queryParameters,
                                         CX patientId)
                                  throws MalformedStoredQueryException
Adds the patientId list given as query parameters for the metadata attribute to the given HashMap of StoredQuery parameters.

Parameters:
queryParameters - HashMap of stored query parameters, non null
patientId - patient id to add to the query parameters, non null
Throws:
MalformedStoredQueryException

addStatusParameter

public static void addStatusParameter(java.util.HashMap queryParameters,
                                      AvailabilityStatusType[] status)
                               throws MalformedStoredQueryException
Adds the status list given as query parameters for the metadata attribute to the given HashMap of StoredQuery parameters.

Parameters:
queryParameters - HashMap of stored query parameters, non null
status - list of status to add to the query parameters, non null
Throws:
MalformedStoredQueryException

addCodedParameters

public static void addCodedParameters(java.util.HashMap queryParameters,
                                      java.lang.String codeUUID,
                                      CodedMetadataType[] codes)
                               throws MalformedStoredQueryException
Adds the codes given as query parameters for the metadata attribute specifide by codeUUID to the given HashMap of StoredQuery parameters. Validates that each code has a corresponding coding scheme name, or none at all.

Parameters:
queryParameters - HashMap of stored query parameters, non null
codeUUID - codeSchemeParameterName of metadata code element (see UUIDs), non null
codes - list of codes to add to the query parameters, non null
Throws:
MalformedStoredQueryException

addDateTimeParameters

public static void addDateTimeParameters(java.util.HashMap queryParameters,
                                         DateTimeRange range)
                                  throws MalformedStoredQueryException
Builds the date/time range query sub clause (included the lower time bound, but excludes the upper time bound). Date/times are expected to be formatted per the IHE specification.

Parameters:
queryParameters - HashMap of stored query parameters, non null
range - DateTimeRange object in which range.range.getSlotName() is the metadata attribute name to be selected among metadata time slot name constants provided in DocumentEntryConstants, SubmissionSetConstants or FolderConstants , non null
Throws:
MalformedStoredQueryException
MalformedStoredQueryException - if null parameters were given or the range.getSlotName() could not be identified

validCodeList

public static int validCodeList(CodedMetadataType[] codes)
Checks to see if the code list provided has one coding scheme documented for each code, or none at all

Parameters:
codes - array of CodedMetadataTypes to validate
Returns:
return -1 if the list is invalid, return 0 if there are no coding schemes and return 1 if each code has a corresponding coding scheme.