跳轉到

# searchParameterQueryHandler

此檔案位於 `models/FHIR/`.

## Functions

getStringQuery(query, paramsSearchFields, queryFieldName)
getAddressQuery(query, queryFieldName)
getNameQuery(query, queryFieldName)
getTokenQuery(query, paramsSearchFields, queryFieldName)
getPolyTokenQuery(query, paramsSearchFields, queryFieldName, paramsSearchFunc)
getNumberQuery(query, paramsSearchFields, queryFieldName)
getPolyDateQuery(query, paramsSearchFields, queryFieldName, paramsSearchFunc)

## getStringQuery(query, paramsSearchFields, queryFieldName)

Kind: global function

Param | Type | Description
--- | --- | ---
query | `string` | The request query object
paramsSearchFields | `Array.<string>` | The fields of search parameter that in resource
queryFieldName | `string` | The name of search parameter

Example (Example of `address-city` of search parameter of the Patient resource)

    // refresh query object to
    // {
    //    "$and": [
    //       {
    //           "$or": [
    //               {
    //                   "address.city": {
    //                       "$regex": /^PleasantVille/gi
    //                   }
    //               }
    //          ]
    //      }
    //   ]
    // }
    getStringQuery(
    {
       "address-city": "PleasantVille",
       "gender": "male",
       "$and": []
    }, ["address.city"], "address-city");

## getAddressQuery(query, queryFieldName)

Kind: global function

Param | Type | Description
--- | --- | ---
query | `string` | The request query object
queryFieldName | `string` | The name of search parameter

Example (Example of `address` of search parameter of the Patient resource)

    // refresh query object to
    // {
    //     "$and": [
    //         {
    //             "$or": [
    //                 {
    //                     "address.line": {
    //                         "$regex": /^PleasantVille/gi
    //                     }
    //                 },
    //                 {
    //                     "address.city": {
    //                         "$regex": /^PleasantVille/gi
    //                     }
    //                 },
    //                 {
    //                     "address.district": {
    //                         "$regex": /^PleasantVille/gi
    //                     }
    //                 },
    //                 {
    //                     "address.state": {
    //                         "$regex": /^PleasantVille/gi
    //                     }
    //                 },
    //                 {
    //                     "address.postalCode": {
    //                         "$regex": /^PleasantVille/gi
    //                     }
    //                 },
    //                 {
    //                     "address.country": {
    //                         "$regex": /^PleasantVille/gi
    //                     }
    //                 }
    //             ]
    //         }
    //     ]
    // }
    getAddressQuery(
    {
       "address": "PleasantVille",
       "gender": "male",
       "$and": []
    }, "address");

## getNameQuery(query, queryFieldName)

Kind: global function

Param | Type | Description
--- | --- | ---
query | `string` | The request query object
queryFieldName | `string` | The name of search parameter

Example (Example of `name` of search parameter of the Patient resource)

    // refresh query object to
    // {
    //     "$and": [
    //         {
    //             "$or": [
    //                 {
    //                     "$or": [
    //                         {
    //                             "name.text": {
    //                                 "$regex": /^Chalmers/gi
    //                             }
    //                         },
    //                         {
    //                             "name.family": {
    //                                 "$regex": /^Chalmers/gi
    //                             }
    //                         },
    //                         {
    //                             "name.given": {
    //                                 "$regex": /^Chalmers/gi
    //                             }
    //                         },
    //                         {
    //                             "name.suffix": {
    //                                 "$regex": /^Chalmers/gi
    //                             }
    //                         },
    //                         {
    //                             "name.prefix": {
    //                                 "$regex": /^Chalmers/gi
    //                             }
    //                         }
    //                     ]
    //                 }
    //             ]
    //         }
    //     ]
    // }

Example

    getNameQuery(
    {
        "name": "Chalmers"
    }, ["name"], "name");

## getTokenQuery(query, paramsSearchFields, queryFieldName)

Kind: global function

Param | Type | Description
--- | --- | ---
query | `string` | The request query object that in resource
paramsSearchFields | `Array.<string>` | The fields of search parameter that in resource
queryFieldName | `string` | The name of search parameter

## getPolyTokenQuery(query, paramsSearchFields, queryFieldName, paramsSearchFunc)

Kind: global function

Param | Type | Description
--- | --- | ---
query | `Object` | The request query object
paramsSearchFields | `Array.<string>` | The fields of search parameters that in resource
queryFieldName | `string` | The name of search parameter
paramsSearchFunc | `function` | parameter search function corresponds to data type e.g. code, codeable concept

Example (Example of `address-use` of search parameter of the Patient resource)

    // refresh query object to
    // {
    //     "$and": [
    //         {
    //             "$or": [
    //                 {
    //                     "$or": [
    //                         {
    //                             "address.use.system": "home" //because some data types have system
    //                         },
    //                         {
    //                             "address.use": "home"
    //                         }
    //                     ]
    //                 }
    //             ]
    //         }
    //     ]
    // }
    getPolyTokenQuery(
    {
        "address-use": "home"
    }, ["address.use"], "address-use", (query)=> {
        try {
              queryHandler.getStringQuery(query, paramsSearchFields, *"address-city");
          } catch (e) {
              console.error(e);
              throw e;
          }
    });

## getNumberQuery(query, paramsSearchFields, queryFieldName)

Kind: global function

Param | Type | Description
--- | --- | ---
query | `string` | The request query object
paramsSearchFields | `Array.<string>` | The fields of search parameters that in resource
queryFieldName | `string` | The name of search parameter

Example (Example of `variant-start` of search parameter of the Molecularsequence resource)

    // refresh query object to
    // {
    //     "$and": [
    //         {
    //             "$or": [
    //                 {
    //                     "variant.start": {
    //                         "$eq": 22125503
    //                     }
    //                 }
    //             ]
    //         }
    //     ]
    // }
    getNumberQuery(
    {
        "$and": [],
        "variant-start" : 22125503
    }, ["variant.start"], "variant-start");

## getPolyDateQuery(query, paramsSearchFields, queryFieldName, paramsSearchFunc)

Kind: global function

Param | Type | Description
--- | --- | ---
query | `Object` | The request query object
paramsSearchFields | `string` | The fields of search parameters that in resource
queryFieldName | `string` | The name of search parameter
paramsSearchFunc | `function` | parameter search function corresponds to data type e.g. date, dateTime