{scrollbar:icons=false}
h1. {page-info:title}
{section}
{column:width=75%}
{panel:title=Contents of this Page}
{toc:minLevel=2}
{panel}
{column}
{column}
{align:right}{include:Menu LexEVS 6.0 CTS2 to Include}{align}
{column}
{section}

h2. Introduction
LexEVS CTS2 Code System Query API provides capability to query contents of Code System that are available in the system.

h2. Interface
{{org.lexevs.cts2.query.CodeSystemQueryOperation}} is the main interface for all the queries against Code System. This interface can be accessed using main LexEVSCTS2 interface, like:

{code}
org.lexevs.cts2.query.CodeSystemQueryOperation csQueryOp = new org.lexevs.cts2.LexEvsCTS2Impl().getQueryOperation().getCodeSystemQueryOperation();
{code}


h2. Query Functions
Here are the major query functions available using CodeSystemQueryOperation interface:


h3. listCodeSystems
This function lists the coding systems that are available in cts 2 system. Optionally, return list can be restricted to Code System URI, version, local name, formal name or entity description.

{{listCodeSystems(CodingSchemeSummary queryByExample)}}

|| *Description:* | List the coding systems that are available in cts 2 system. |
|| *Input:* |  *_org.LexGrid.LexBIG.DataModel.Core.CodingSchemeSummary queryByExample_* - (Optional) Restrict the return list only to those that matches the supplied data. return list can be restricted to Code System URI, version, local name, formal name or entity description. If empty, all the code systems available in the system will be returned. |
|| *Output:* |  *_org.LexGrid.LexBIG.DataModel.Collections.CodingSchemeRenderingList_* - List of Code Systems |
|| *Exception:* |  *_org.LexGrid.LexBIG.Exceptions.LBException_* |
|| *Sample Call:* | * _Step 1:_ Instantiate CodeSystemQueryOperation if it is not done yet:
{code}
org.lexevs.cts2.query.CodeSystemQueryOperation csQueryOp = new org.lexevs.cts2.LexEvsCTS2Impl().getQueryOperation().getCodeSystemQueryOperation();
{code}
* _Step 2a:_ To get all the code systems:
{code}
org.LexGrid.LexBIG.DataModel.Collections.CodingSchemeRenderingList csrList = csQuery..listCodeSystems(new CodingSchemeSummary());
{code}
* _Step 2b:_ To restrict to code system URI:
{code}
CodingSchemeSummary() queryByExample = new CodingSchemeSummary();
queryByExample.setCodingSchemeURI("urn:oid:cts:1.1.1");
org.LexGrid.LexBIG.DataModel.Collections.CodingSchemeRenderingList csrList= query.listCodeSystems(queryByExample);
{code} |

h3. getCodeSystemDetails
This function provides the ability to retrieve detailed code system.

{{getCodeSystemDetails(String codingSchemeName, CodingSchemeVersionOrTag versionOrTag)}}

|| *Description:* | Return a detailed codingScheme according to provided codingName and versionOrTag |
|| *Input:* | * *_java.lang.String codingSchemeName_* - (*Mandatory*) Name of the code system.
* *_org.LexGrid.LexBIG.DataModel.Core.CodingSchemeVersionOrTag versionOrTag_* - (*Optional*) Version or tag (like 'dev', 'production' etc) of the code system. |
|| *Output:* |  *_org.LexGrid.codingSchemes.CodingScheme_* - detailed Code System |
|| *Exception:* |  *_org.LexGrid.LexBIG.Exceptions.LBException_* |
|| *Sample Call:* | * _Step 1:_ Instantiate CodeSystemQueryOperation if it is not done yet:
{code}
org.lexevs.cts2.query.CodeSystemQueryOperation csQueryOp = new org.lexevs.cts2.LexEvsCTS2Impl().getQueryOperation().getCodeSystemQueryOperation();
{code}
* _Step 2:_ Populate CodeSystemVersionOrTag object:
{code}
CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();

versionOrTag.setVersion("1.0");
{code}
* _Step 3:_ Call getCodeSystemDetails method to get detailed code system:
{code}
CodingScheme result = query.getCodeSystemDetails("Automobiles", versionOrTag);
{code} |


h3. listCodeSystemConcepts
This function provides the ability to list concepts in specific code system.

{{listCodeSystemConcepts(String codingSchemeName, CodingSchemeVersionOrTag versionOrTag, LocalNameList entityTypes, SortOptionList sortOptionList)}}

|| *Description:* | List the concepts in a specific codingSystem |
|| *Input:* | * *_java.lang.String codingSchemeName_* - (*Mandatory*) Name of the code system.
* *_org.LexGrid.LexBIG.DataModel.Core.CodingSchemeVersionOrTag versionOrTag_* - (Optional) Version or tag (like 'dev', 'production' etc) of the code system.
* *_org.LexGrid.LexBIG.DataModel.Collections.LocalNameList entityTypes_* - (Optional) List of entity types to restrict. Ex. 'concept', instance' etc.
* *_org.LexGrid.LexBIG.DataModel.Collections.SortOptionList sortOptionList_* - (Optional) Sort option to apply on the returned list. |
|| *Output:* |  *_org.LexGrid.LexBIG.Utility.Iterators.ResolvedConceptReferencesIterator_* - An iterator for resolved concepts list |
|| *Exception:* |  *_org.LexGrid.LexBIG.Exceptions.LBException_* |
|| *Sample Call:* | * _Step 1:_ Instantiate CodeSystemQueryOperation if it is not done yet:
{code}
org.lexevs.cts2.query.CodeSystemQueryOperation csQueryOp = new org.lexevs.cts2.LexEvsCTS2Impl().getQueryOperation().getCodeSystemQueryOperation();
{code}
* _Step 2:_ Populate CodeSystemVersionOrTag object:
{code}
CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
versionOrTag.setVersion("1.0");
{code}
* _Step 3a:_ Without SortOptions, call listCodeSystemConcepts method to get code system concepts:
{code}
ResolvedConceptReferencesIterator conceptIterator = csQueryOp.listCodeSystemConcepts("Automobiles", versionOrTag,
org.LexGrid.LexBIG.Utility.Constructors.createLocalNameList(org.LexGrid.commonTypes.types.EntityTypes.CONCEPT.toString()), null);
{code}
* _Step 3a:_ With SortOptions, call listCodeSystemConcepts method to get code system concepts:
{code}
ResolvedConceptReferencesIterator conceptIterator = csQueryOp.listCodeSystemConcepts("Automobiles", versionOrTag,
org.LexGrid.LexBIG.Utility.Constructors.createLocalNameList(org.LexGrid.commonTypes.types.EntityTypes.CONCEPT.toString()), Constructors.createSortOptionList(new String[VKC:) ( "code" ), new Boolean(] { new Boolean(true) }));
{code} |


h3. getConceptDetails
This function returns details of an entity specified.

{{getConceptDetails(String codingSchemeName, CodingSchemeVersionOrTag versionOrTag, String code, String namespace)}}

|| *Description:* | Return an instance of Entity according the requests. |
|| *Input:* | * *_java.lang.String codingSchemeName_* - (*Mandatory*) Name of the code system.
* *_org.LexGrid.LexBIG.DataModel.Core.CodingSchemeVersionOrTag versionOrTag_* - (Optional) Version or tag (like 'dev', 'production' etc) of the code system.
* *_java.lang.String code_* - (*Mandatory*) Entity code.
* *_java.lang.String namespace_* - (Optional) Namespace of an entity code. |
|| *Output:* | *_org.LexGrid.concepts.Entity_* - Detailed Entity object |
|| *Exception:* |  *_org.LexGrid.LexBIG.Exceptions.LBException_* |
|| *Sample Call:* | * _Step 1:_ Instantiate CodeSystemQueryOperation if it is not done yet:
{code}
org.lexevs.cts2.query.CodeSystemQueryOperation csQueryOp = new org.lexevs.cts2.LexEvsCTS2Impl().getQueryOperation().getCodeSystemQueryOperation();
{code}
* _Step 2:_ Populate CodeSystemVersionOrTag object:
{code}
CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
versionOrTag.setVersion("1.0");
{code}
* _Step 3:_ Call getConceptDetails method by providing code system version and entity code:
{code}
Entity entity = csQueryOp.getConceptDetails("Automobiles", versionOrTag, "C0001", "Automobiles");
{code} |


h3. listAssociationTypes
This function returns all the supported association types with in the specified code system version.

{{listAssociationTypes(String codingSchemeName, CodingSchemeVersionOrTag versionOrTag)}}

|| *Description:* | List all the associationTypes in a specific code system. |
|| *Input:* |  *_java.lang.String codingSchemeName_* - (*Mandatory*) Name of the code system.
 *_org.LexGrid.LexBIG.DataModel.Core.CodingSchemeVersionOrTag versionOrTag_* - (Optional) Version or tag (like 'dev', 'production' etc) of the code system. |
|| *Output:* |  *_java.util.List<org.LexGrid.naming.SupportedAssociation>_* - List of all supported association types in supplied code system version |
|| *Exception:* |  *_org.LexGrid.LexBIG.Exceptions.LBException_* |
|| *Sample Call:* | * _Step 1:_ Instantiate CodeSystemQueryOperation if it is not done yet:
{code}
org.lexevs.cts2.query.CodeSystemQueryOperation csQueryOp = new org.lexevs.cts2.LexEvsCTS2Impl().getQueryOperation().getCodeSystemQueryOperation();
{code}
* _Step 2:_ Populate CodeSystemVersionOrTag object:
{code}
CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
versionOrTag.setVersion("1.0");
{code}
* _Step 3:_ Call listAssociationTypes method by providing code system version and entity code:
{code}
List<SupportedAssociation> associationList = csQueryOp.listAssociationTypes("Automobiles", versionOrTag);
{code} |

h3. getAssociationTypeDetails
This function returns detailed information for a certain association type with in the specified code system version.

{{getAssociationTypeDetails(String codingSchemeName, CodingSchemeVersionOrTag versionOrTag, String associationName)}}

|| *Description:* | Return detailed information for a certain associationType in a specific code system. |
|| *Input:* | * *_java.lang.String codingSchemeName_* - (*Mandatory*) Name of the code system.
* *_org.LexGrid.LexBIG.DataModel.Core.CodingSchemeVersionOrTag versionOrTag_* - (Optional) Version or tag (like 'dev', 'production' etc) of the code system.
* *_java.lang.String associationName_* - (*Mandatory*) Name of an association |
|| *Output:* |  *_org.LexGrid.relations.AssociationEntity_* - Association type details |
|| *Exception:* |  *_org.LexGrid.LexBIG.Exceptions.LBException_* |
|| *Sample Call:* | * _Step 1:_ Instantiate CodeSystemQueryOperation if it is not done yet:
{code}
org.lexevs.cts2.query.CodeSystemQueryOperation csQueryOp = new org.lexevs.cts2.LexEvsCTS2Impl().getQueryOperation().getCodeSystemQueryOperation();
{code}
* _Step 2:_ Populate CodeSystemVersionOrTag object:
{code}
CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
versionOrTag.setVersion("1.0");
{code}
* _Step 3:_ Call getAssociationTypeDetailsmethod by providing code system version and entity code:
{code}
AssociationEntity associationEntity = csQueryOp.getAssociationTypeDetails("Automobiles", versionOrTag, "uses");
{code} |

{scrollbar:icons=false}