Package in.cdac.medinfo.csnotk.csnolib.db

## Class QueryManager

- java.lang.Object
- - in.cdac.medinfo.csnotk.csnolib.db.QueryManager

-     public class QueryManager
      extends java.lang.Object

  Establishes a connection to fetch data from SNOMED CT database.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `QueryManager()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `createcRefsetdb​(java.lang.String refsetId, java.lang.String refFilePath, java.util.Set<java.lang.String> moduleIdSet)` | This method will create database for cRefset
    `void` | `createExtensiondb​(java.util.Set<java.lang.String> moduleIdSet, java.lang.String conceptFile, java.lang.String descriptionFile, java.lang.String relationshipFile, java.lang.String refsetLangFile, java.lang.String concreteRelationshipFile)` | This method will create SNOMED CT extension database
    `void` | `createRefsetdb​(java.lang.String refsetId, java.lang.String refFilePath, java.util.Set<java.lang.String> moduleIdSet)` | This method will create database for Refset
    `boolean` | `createSimpleMapdb​(java.lang.String moduleId, java.lang.String simpleMapFilePath)` | This method will create database for simpleMap
    `void` | `createSNOMEDdb​(java.lang.String conceptFile, java.lang.String descriptionFile, java.lang.String relationshipFile, java.lang.String refsetLangFile, java.lang.String textdefinitionFile, java.lang.String concreteRelationshipFile)` | This method will create SNOMED CT database
    `void` | `deleteRelationshipTempFile​(java.lang.String filePath)` | This method will delete temporary relationship file created for TC table generation
    `java.lang.String` | `exportRelationshipTableAndDeleteTCTable()` | This method will export relationship table into a tsv file (for TC table creation)
    `java.lang.String` | `getAcceptabilityId​(java.lang.String descriptionId)` | Returns acceptability Id for specified description id.
    `java.util.List<Description>` | `getDescriptions​(java.lang.String conceptId)` | Returns list of `Description`s associated for a given concept identifier and which is other than FSN.
    `java.lang.String` | `getHierarchy​(java.lang.String conceptId, java.lang.String typeId, java.lang.String term)` | Retrieves the Semantic Tag for a particular Concept id.
    `java.lang.String` | `getPreferredName​(java.lang.String conceptId, EnumLangRefset enumLangRefset)` | Returns list of preferred names in US refset associated with corresponding `Concept` identifier.
    `java.util.List<Relationship>` | `getRelationships​(java.lang.String ConceptId, java.lang.String relationshipType, EnumDirection direction)` | Returns unique Inward/Outward latest relationships with active status.
    `void` | `loadClosureTable​(java.io.File ct_file)` | This function loads the closure table in the database.
    `void` | `populateConcept​(java.lang.String id, Concept concept)` | Returns a SNOMED CT `Concept` associated for a given concept identifier.
    `java.util.Set<Concept>` | `searchConcepts​(java.lang.String searchTerm)` | Searches for concepts in the SNOMED CT repository for the given search term.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### QueryManager

          public QueryManager()

  - ### Method Detail

    - #### getHierarchy

          public java.lang.String getHierarchy​(java.lang.String conceptId,
                                               java.lang.String typeId,
                                               java.lang.String term)
                                        throws java.sql.SQLException

      Retrieves the Semantic Tag for a particular Concept id.
      Parameters:
        `conceptId` - the id for particular Concept whose hierarchy is to be identified.
        `typeId` - type of the description.
        `term` - the description for that concept.
      Returns:
        `String` value corresponding to the hierarchy/Semantic Tag of a particular concept.
      Throws:
        `java.sql.SQLException`

    - #### populateConcept

          public void populateConcept​(java.lang.String id,
                                      Concept concept)
                               throws java.sql.SQLException,
                                      java.text.ParseException

      Returns a SNOMED CT `Concept` associated for a given concept identifier.
      Parameters:
        `id` - identifier of the concept.
        `concept` - SNOMED CT `Concept` which is to be populated.
      Throws:
        `java.sql.SQLException`
        `java.text.ParseException`

    - #### getDescriptions

          public java.util.List<Description> getDescriptions​(java.lang.String conceptId)
                                                      throws java.sql.SQLException,
                                                             java.text.ParseException

      Returns list of `Description`s associated for a given concept identifier and which is other than FSN.
      Parameters:
        `conceptId` - SNOMED CT `Concept` identifier.
      Returns:
        List of `Description`s .
      Throws:
        `java.sql.SQLException` - if any error occurs while accessing database.
        `java.text.ParseException`

    - #### searchConcepts

          public java.util.Set<Concept> searchConcepts​(java.lang.String searchTerm)
                                                throws java.sql.SQLException

      Searches for concepts in the SNOMED CT repository for the given search term.
      Parameters:
        `searchTerm` - `String` term/text to be searched .
      Returns:
        Set of `Concept`s.
      Throws:
        `java.sql.SQLException` - if any error occurs while accessing database.

    - #### getRelationships

          public java.util.List<Relationship> getRelationships​(java.lang.String ConceptId,
                                                               java.lang.String relationshipType,
                                                               EnumDirection direction)
                                                        throws java.sql.SQLException,
                                                               java.text.ParseException

      Returns unique Inward/Outward latest relationships with active status.
      Parameters:
        `ConceptId` - identifier of the `Concept`.
        `enumRelationshipType` - specifies the type of relationship.
        `direction` - specifies the direction(source / destination) `EnumDirection`.
      Returns:
        Set of `Relationship`s .
      Throws:
        `java.sql.SQLException` - if any error occurs while accessing database.
        `java.text.ParseException`

    - #### getPreferredName

          public java.lang.String getPreferredName​(java.lang.String conceptId,
                                                   EnumLangRefset enumLangRefset)
                                            throws java.sql.SQLException

      Returns list of preferred names in US refset associated with corresponding `Concept` identifier.
      Parameters:
        `enumLangRefset` - specifies the Language Refset `EnumLangRefset` }.
        `conceptId` - identifier of the `Concept`.
      Returns:
        Preferred name of `Concept`.
      Throws:
        `java.sql.SQLException`

    - #### loadClosureTable

          public void loadClosureTable​(java.io.File ct_file)
                                throws java.sql.SQLException,
                                       java.io.IOException

      This function loads the closure table in the database.
      Parameters:
        `ct_file` - File associated with the closure table.
      Throws:
        `java.sql.SQLException`
        `java.io.IOException`

    - #### getAcceptabilityId

          public java.lang.String getAcceptabilityId​(java.lang.String descriptionId)
                                              throws java.sql.SQLException

      Returns acceptability Id for specified description id. acceptability id indicates whether particular description is Preferred Term or not.
      Parameters:
        `descriptionId` - `String` identifier of the `Description`.
      Returns:
        `String` value that specifies the acceptability id.
      Throws:
        `java.sql.SQLException`

    - #### createSNOMEDdb

          public void createSNOMEDdb​(java.lang.String conceptFile,
                                     java.lang.String descriptionFile,
                                     java.lang.String relationshipFile,
                                     java.lang.String refsetLangFile,
                                     java.lang.String textdefinitionFile,
                                     java.lang.String concreteRelationshipFile)
                              throws java.sql.SQLException

      This method will create SNOMED CT database
      Parameters:
        `conceptFile` - file path for Concept File
        `descriptionFile` - file path for Description File
        `relationshipFile` - file path for Relationship File
        `refsetLangFile` - file path for Language Refset File
      Throws:
        `java.sql.SQLException`

    - #### createExtensiondb

          public void createExtensiondb​(java.util.Set<java.lang.String> moduleIdSet,
                                        java.lang.String conceptFile,
                                        java.lang.String descriptionFile,
                                        java.lang.String relationshipFile,
                                        java.lang.String refsetLangFile,
                                        java.lang.String concreteRelationshipFile)
                                 throws java.sql.SQLException

      This method will create SNOMED CT extension database
      Parameters:
        `conceptFile` - file path for Concept File
        `descriptionFile` - file path for Description File
        `relationshipFile` - file path for Relationship File
        `refsetLangFile` - file path for Language Refset File
        `Set` - of moduleId
      Throws:
        `java.sql.SQLException`

    - #### createRefsetdb

          public void createRefsetdb​(java.lang.String refsetId,
                                     java.lang.String refFilePath,
                                     java.util.Set<java.lang.String> moduleIdSet)
                              throws java.sql.SQLException

      This method will create database for Refset
      Parameters:
        `refsetId` -
        `refFilePath` -
      Throws:
        `java.sql.SQLException`

    - #### createcRefsetdb

          public void createcRefsetdb​(java.lang.String refsetId,
                                      java.lang.String refFilePath,
                                      java.util.Set<java.lang.String> moduleIdSet)
                               throws java.sql.SQLException

      This method will create database for cRefset
      Parameters:
        `refsetId` -
        `refFilePath` -
        `moduleIdSet` -
      Throws:
        `java.sql.SQLException`

    - #### createSimpleMapdb

          public boolean createSimpleMapdb​(java.lang.String moduleId,
                                           java.lang.String simpleMapFilePath)
                                    throws java.sql.SQLException

      This method will create database for simpleMap
      Parameters:
        `moduleId` -
        `simpleMapFilePath` -
      Throws:
        `java.sql.SQLException`

    - #### exportRelationshipTableAndDeleteTCTable

          public java.lang.String exportRelationshipTableAndDeleteTCTable()
                                                                   throws java.sql.SQLException,
                                                                          java.io.IOException

      This method will export relationship table into a tsv file (for TC table creation)
      Throws:
        `java.sql.SQLException`
        `java.io.IOException`

    - #### deleteRelationshipTempFile

          public void deleteRelationshipTempFile​(java.lang.String filePath)

      This method will delete temporary relationship file created for TC table generation