├── .devcontainer └── devcontainer.json ├── .env.example ├── .github ├── config.yml ├── dependabot.yml └── workflows │ ├── bump.yml │ ├── docs.yml │ ├── integration.yml │ ├── publish.yml │ └── pullrequest.yml ├── .gitignore ├── .npmignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── mocktest ├── fake-cui-response.ts ├── fake-key-response.ts ├── fake-search-response.ts ├── mock.cuiSearch.spec.ts ├── mock.generalService.spec.ts └── mock.umlsSearch.spec.ts ├── notes ├── jsdoc.md ├── placeholder.md └── updates.md ├── package-lock.json ├── package.json ├── scripts └── gpr.js ├── src ├── function │ ├── auiSearch.ts │ ├── cuiSearch.ts │ └── umlsSearch.ts ├── index.ts ├── model │ ├── atom.ts │ ├── concept.ts │ ├── conceptrelation.ts │ ├── definition.ts │ ├── queryTemplate.ts │ ├── search.ts │ └── umlsToken.ts └── service │ ├── authService.ts │ └── generalService.ts ├── test ├── auiSearch.test.ts ├── authService.test.ts ├── cuiSearch.test.ts ├── generalService.test.ts ├── index.test.ts └── umlsSearch.test.ts └── tsconfig.json /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": "mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12", 3 | "extensions": [ 4 | "dbaeumer.vscode-eslint" 5 | ], 6 | "forwardPorts": [ 7 | 3000 8 | ] 9 | } -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | UMLS_API_KEY= -------------------------------------------------------------------------------- /.github/config.yml: -------------------------------------------------------------------------------- 1 | # Configurations for todo: https://probot.github.io/apps/todo/ 2 | # Automatically add issues from @todo with @body 3 | # /** 4 | # * @todo What needs to be done 5 | # * @body How to do it. 6 | # */ 7 | 8 | # https://github.com/behaviorbot/welcome 9 | newIssueWelcomeComment: > 10 | Thank you for raising this issue. We will try and get back to you as soon as possible. 11 | 12 | Be sure to star ✨ the repository for a priority response! 13 | 14 | Please make sure you have given us as much context as possible. 15 | 16 | 17 | newPRWelcomeComment: > 18 | Thank you for submitting a pull request. 19 | 20 | Please make sure you have followed our contributing guidelines in CONTRIBUTING.md. We will review it as soon as possible. 21 | 22 | firstPRMergeComment: > 23 | Congrats on merging your first pull request! 🎉🎉🎉 -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "npm" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | # open-pull-requests-limit: 10 8 | 9 | - package-ecosystem: "github-actions" 10 | directory: "/" 11 | schedule: 12 | interval: "weekly" -------------------------------------------------------------------------------- /.github/workflows/bump.yml: -------------------------------------------------------------------------------- 1 | name: "Bump Version" 2 | # include major/minor/patch in commit message 3 | # Pull after pushing to develop 4 | on: 5 | push: 6 | branches: 7 | - develop 8 | 9 | jobs: 10 | bump-version: 11 | name: "Bump Version on release branch" 12 | runs-on: ubuntu-latest 13 | timeout-minutes: 15 14 | steps: 15 | - name: "Checkout source code" 16 | uses: "actions/checkout@v3" 17 | with: 18 | ref: ${{ github.ref }} 19 | - name: Generate changelog 20 | uses: charmixer/auto-changelog-action@v1 21 | with: 22 | token: ${{ secrets.GITHUB_TOKEN }} 23 | - name: "cat package.json" 24 | run: cat ./package.json 25 | - name: "Setup Node.js" 26 | uses: "actions/setup-node@v3.1.0" 27 | with: 28 | node-version: 12 29 | - name: "Automated Version Bump" 30 | uses: "dermatologist/gh-action-bump-version@beapen-1" 31 | with: 32 | tag-prefix: '' 33 | env: 34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 35 | UMLS_API_KEY: ${{secrets.umls_api_key}} 36 | - name: "cat package.json" 37 | run: cat ./package.json 38 | 39 | # - name: Commit changes 40 | # uses: EndBug/add-and-commit@v7 41 | # with: 42 | # default_author: github_actions 43 | # add: '*.md' 44 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Generate and puplish gh-pages 2 | # https://docs.github.com/en/actions/guides/building-and-testing-python 3 | # https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ 4 | on: 5 | release: 6 | types: [published] 7 | 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | timeout-minutes: 15 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: actions/setup-node@v3.1.0 16 | with: 17 | node-version: 12 18 | - run: npm ci 19 | - run: npm run docs 20 | env: 21 | UMLS_API_KEY: ${{secrets.umls_api_key}} 22 | - name: Deploy Docs 🚀 23 | uses: JamesIves/github-pages-deploy-action@v4.3.0 24 | with: 25 | branch: gh-pages # The branch the action should deploy to. 26 | folder: docs # The folder the action should deploy. -------------------------------------------------------------------------------- /.github/workflows/integration.yml: -------------------------------------------------------------------------------- 1 | name: Integration Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop 7 | 8 | release: 9 | types: [created] 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | - uses: actions/setup-node@v3.1.0 17 | with: 18 | node-version: 12 19 | - run: npm ci 20 | - run: npm test 21 | env: 22 | UMLS_API_KEY: ${{secrets.umls_api_key}} 23 | # publish-npm: 24 | # needs: build 25 | # runs-on: ubuntu-latest 26 | # steps: 27 | # - uses: actions/checkout@v3 28 | # - uses: actions/setup-node@v3.1.0 29 | # with: 30 | # node-version: 12 31 | # registry-url: https://registry.npmjs.org/ 32 | # - run: npm ci 33 | # - run: npm publish 34 | # env: 35 | # NODE_AUTH_TOKEN: ${{secrets.npm_token}} 36 | 37 | # publish-gpr: 38 | # needs: build 39 | # runs-on: ubuntu-latest 40 | # steps: 41 | # - uses: actions/checkout@v3 42 | # - uses: actions/setup-node@v3.1.0 43 | # with: 44 | # node-version: 12 45 | # registry-url: https://npm.pkg.github.com/ 46 | # scope: '@dermatologist' 47 | # - run: npm ci 48 | # - run: npm build 49 | # - run: npm run gpr-setup 50 | # - run: npm publish 51 | # env: 52 | # NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} 53 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/setup-node@v3.1.0 13 | with: 14 | node-version: 12 15 | registry-url: https://registry.npmjs.org/ 16 | - run: npm install 17 | - run: npm publish 18 | env: 19 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} 20 | 21 | # name: Publish 22 | 23 | # on: 24 | # push: 25 | # branches: 26 | # - master 27 | 28 | 29 | # jobs: 30 | # publish-gpr: 31 | # runs-on: ubuntu-latest 32 | # steps: 33 | # - uses: actions/checkout@v2.3.4 34 | # - uses: actions/setup-node@v3.1.0 35 | # with: 36 | # node-version: 12 37 | # registry-url: https://npm.pkg.github.com/ 38 | # scope: '@dermatologist' 39 | # - run: npm ci 40 | # - run: npm build 41 | # - run: npm run gpr-setup 42 | # - run: npm publish 43 | # env: 44 | # NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} 45 | 46 | # pull_request: 47 | # branches: 48 | # - master 49 | # - develop 50 | # on: 51 | # release: 52 | # types: [created] 53 | 54 | # jobs: 55 | # build: 56 | # runs-on: ubuntu-latest 57 | # steps: 58 | # - uses: actions/checkout@v2.3.4 59 | # - uses: actions/setup-node@v3.1.0 60 | # with: 61 | # node-version: 12 62 | # - run: npm ci 63 | # - run: npm test 64 | # env: 65 | # UMLS_API_KEY: ${{secrets.umls_api_key}} 66 | # publish-npm: 67 | # needs: build 68 | # runs-on: ubuntu-latest 69 | # steps: 70 | # - uses: actions/checkout@v2.3.4 71 | # - uses: actions/setup-node@v3.1.0 72 | # with: 73 | # node-version: 12 74 | # registry-url: https://registry.npmjs.org/ 75 | # - run: npm ci 76 | # - run: npm publish 77 | # env: 78 | # NODE_AUTH_TOKEN: ${{secrets.npm_token}} 79 | 80 | 81 | -------------------------------------------------------------------------------- /.github/workflows/pullrequest.yml: -------------------------------------------------------------------------------- 1 | name: Node.js Package Pull Request 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | - develop 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: actions/setup-node@v3.1.0 15 | with: 16 | node-version: 12 17 | - run: npm ci 18 | - run: npm test mocktest 19 | - run: npm run build 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | dist 4 | test/api.js 5 | .idea 6 | .env 7 | scratch 8 | docs -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | src 4 | test/api.js 5 | .vscode 6 | .idea 7 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | // https://github.com/formium/tsdx/issues/577 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "TSDX Jest Tests", 10 | "type": "node", 11 | "request": "launch", 12 | "runtimeArgs": [ 13 | "--inspect-brk", 14 | "${workspaceRoot}/node_modules/tsdx/dist/index.js", 15 | "test", 16 | "--detectOpenHandles", 17 | "/mocktest", 18 | "--runInBand" 19 | ], 20 | "console": "integratedTerminal", 21 | "internalConsoleOptions": "neverOpen", 22 | "port": 9229 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "licenser.license": "MIT", 3 | "licenser.author": "Bell Eapen", 4 | "licenser.projectName": "umlsjs", 5 | "licenser.useSingleLineStyle": false, 6 | "cSpell.words": [ 7 | "apikey", 8 | "esnext", 9 | "mocktest", 10 | "postversion", 11 | "preversion", 12 | "tsdx", 13 | "tslib", 14 | "umls", 15 | "umlsjs" 16 | ] 17 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "npm", 6 | "script": "start", 7 | "problemMatcher": [], 8 | "label": "npm: start", 9 | "detail": "tsdx watch", 10 | "group": { 11 | "kind": "build", 12 | "isDefault": true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [v1.2.0](https://github.com/dermatologist/umlsjs/tree/v1.2.0) (2022-04-13) 4 | 5 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.17.3...v1.2.0) 6 | 7 | **Merged pull requests:** 8 | 9 | - Update bump.yml [\#116](https://github.com/dermatologist/umlsjs/pull/116) ([dermatologist](https://github.com/dermatologist)) 10 | - build\(deps-dev\): bump typescript from 4.5.5 to 4.6.3 [\#112](https://github.com/dermatologist/umlsjs/pull/112) ([dependabot[bot]](https://github.com/apps/dependabot)) 11 | - Update package.json [\#111](https://github.com/dermatologist/umlsjs/pull/111) ([dermatologist](https://github.com/dermatologist)) 12 | - build\(deps\): bump JamesIves/github-pages-deploy-action from 4.1.5 to 4.3.0 [\#109](https://github.com/dermatologist/umlsjs/pull/109) ([dependabot[bot]](https://github.com/apps/dependabot)) 13 | - build\(deps\): bump actions/setup-node from 2.5.1 to 3.1.0 [\#108](https://github.com/dermatologist/umlsjs/pull/108) ([dependabot[bot]](https://github.com/apps/dependabot)) 14 | - build\(deps\): bump ansi-regex from 3.0.0 to 3.0.1 [\#107](https://github.com/dermatologist/umlsjs/pull/107) ([dependabot[bot]](https://github.com/apps/dependabot)) 15 | - build\(deps\): bump minimist from 1.2.5 to 1.2.6 [\#106](https://github.com/dermatologist/umlsjs/pull/106) ([dependabot[bot]](https://github.com/apps/dependabot)) 16 | - build\(deps-dev\): bump typedoc from 0.22.10 to 0.22.13 [\#105](https://github.com/dermatologist/umlsjs/pull/105) ([dependabot[bot]](https://github.com/apps/dependabot)) 17 | - build\(deps\): bump axios from 0.24.0 to 0.26.1 [\#103](https://github.com/dermatologist/umlsjs/pull/103) ([dependabot[bot]](https://github.com/apps/dependabot)) 18 | - build\(deps\): bump actions/checkout from 2 to 3 [\#101](https://github.com/dermatologist/umlsjs/pull/101) ([dependabot[bot]](https://github.com/apps/dependabot)) 19 | - build\(deps-dev\): bump typescript from 4.5.4 to 4.5.5 [\#98](https://github.com/dermatologist/umlsjs/pull/98) ([dependabot[bot]](https://github.com/apps/dependabot)) 20 | - build\(deps\): bump follow-redirects from 1.14.5 to 1.14.8 [\#95](https://github.com/dermatologist/umlsjs/pull/95) ([dependabot[bot]](https://github.com/apps/dependabot)) 21 | - build\(deps\): bump phips28/gh-action-bump-version from 8.0.18 to 9.0.16 [\#92](https://github.com/dermatologist/umlsjs/pull/92) ([dependabot[bot]](https://github.com/apps/dependabot)) 22 | 23 | ## [v0.17.3](https://github.com/dermatologist/umlsjs/tree/v0.17.3) (2022-03-20) 24 | 25 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.17.2...v0.17.3) 26 | 27 | **Merged pull requests:** 28 | 29 | - build\(deps-dev\): bump dotenv from 10.0.0 to 16.0.0 [\#93](https://github.com/dermatologist/umlsjs/pull/93) ([dependabot[bot]](https://github.com/apps/dependabot)) 30 | - build\(deps\): bump nanoid from 3.1.23 to 3.2.0 [\#88](https://github.com/dermatologist/umlsjs/pull/88) ([dependabot[bot]](https://github.com/apps/dependabot)) 31 | 32 | ## [v0.17.2](https://github.com/dermatologist/umlsjs/tree/v0.17.2) (2022-02-27) 33 | 34 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.17.1...v0.17.2) 35 | 36 | **Merged pull requests:** 37 | 38 | - build\(deps\): bump shelljs from 0.8.4 to 0.8.5 [\#85](https://github.com/dermatologist/umlsjs/pull/85) ([dependabot[bot]](https://github.com/apps/dependabot)) 39 | 40 | ## [v0.17.1](https://github.com/dermatologist/umlsjs/tree/v0.17.1) (2022-01-14) 41 | 42 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.17.0...v0.17.1) 43 | 44 | **Merged pull requests:** 45 | 46 | - build\(deps\): bump actions/setup-node from 2.5.0 to 2.5.1 [\#81](https://github.com/dermatologist/umlsjs/pull/81) ([dependabot[bot]](https://github.com/apps/dependabot)) 47 | 48 | ## [v0.17.0](https://github.com/dermatologist/umlsjs/tree/v0.17.0) (2022-01-03) 49 | 50 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.16.0...v0.17.0) 51 | 52 | **Merged pull requests:** 53 | 54 | - build\(deps-dev\): bump typescript from 4.4.4 to 4.5.4 [\#79](https://github.com/dermatologist/umlsjs/pull/79) ([dependabot[bot]](https://github.com/apps/dependabot)) 55 | 56 | ## [v0.16.0](https://github.com/dermatologist/umlsjs/tree/v0.16.0) (2021-12-22) 57 | 58 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.15.2...v0.16.0) 59 | 60 | **Merged pull requests:** 61 | 62 | - build\(deps\): bump actions/setup-node from 2.4.1 to 2.5.0 [\#74](https://github.com/dermatologist/umlsjs/pull/74) ([dependabot[bot]](https://github.com/apps/dependabot)) 63 | 64 | ## [v0.15.2](https://github.com/dermatologist/umlsjs/tree/v0.15.2) (2021-12-08) 65 | 66 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.15.1...v0.15.2) 67 | 68 | **Merged pull requests:** 69 | 70 | - build\(deps-dev\): bump typedoc from 0.22.9 to 0.22.10 [\#73](https://github.com/dermatologist/umlsjs/pull/73) ([dependabot[bot]](https://github.com/apps/dependabot)) 71 | 72 | ## [v0.15.1](https://github.com/dermatologist/umlsjs/tree/v0.15.1) (2021-11-19) 73 | 74 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.15.0...v0.15.1) 75 | 76 | **Merged pull requests:** 77 | 78 | - build\(deps-dev\): bump typedoc from 0.22.6 to 0.22.9 [\#70](https://github.com/dermatologist/umlsjs/pull/70) ([dependabot[bot]](https://github.com/apps/dependabot)) 79 | 80 | ## [v0.15.0](https://github.com/dermatologist/umlsjs/tree/v0.15.0) (2021-11-17) 81 | 82 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.14.0...v0.15.0) 83 | 84 | **Merged pull requests:** 85 | 86 | - build\(deps\): bump axios from 0.21.4 to 0.24.0 [\#68](https://github.com/dermatologist/umlsjs/pull/68) ([dependabot[bot]](https://github.com/apps/dependabot)) 87 | 88 | ## [v0.14.0](https://github.com/dermatologist/umlsjs/tree/v0.14.0) (2021-11-15) 89 | 90 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.13.1...v0.14.0) 91 | 92 | **Merged pull requests:** 93 | 94 | - build\(deps\): bump fast-xml-parser from 3.20.3 to 3.21.1 [\#67](https://github.com/dermatologist/umlsjs/pull/67) ([dependabot[bot]](https://github.com/apps/dependabot)) 95 | 96 | ## [v0.13.1](https://github.com/dermatologist/umlsjs/tree/v0.13.1) (2021-11-06) 97 | 98 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.13.0...v0.13.1) 99 | 100 | **Merged pull requests:** 101 | 102 | - build\(deps-dev\): bump husky from 7.0.2 to 7.0.4 [\#65](https://github.com/dermatologist/umlsjs/pull/65) ([dependabot[bot]](https://github.com/apps/dependabot)) 103 | 104 | ## [v0.13.0](https://github.com/dermatologist/umlsjs/tree/v0.13.0) (2021-11-05) 105 | 106 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.12.0...v0.13.0) 107 | 108 | ## [v0.12.0](https://github.com/dermatologist/umlsjs/tree/v0.12.0) (2021-11-05) 109 | 110 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.11.0...v0.12.0) 111 | 112 | **Merged pull requests:** 113 | 114 | - build\(deps-dev\): bump typescript from 4.3.5 to 4.4.4 [\#63](https://github.com/dermatologist/umlsjs/pull/63) ([dependabot[bot]](https://github.com/apps/dependabot)) 115 | - build\(deps\): bump actions/setup-node from 2.3.0 to 2.4.1 [\#56](https://github.com/dermatologist/umlsjs/pull/56) ([dependabot[bot]](https://github.com/apps/dependabot)) 116 | 117 | ## [v0.11.0](https://github.com/dermatologist/umlsjs/tree/v0.11.0) (2021-10-25) 118 | 119 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.10.0...v0.11.0) 120 | 121 | **Merged pull requests:** 122 | 123 | - build\(deps-dev\): bump typedoc from 0.21.6 to 0.22.6 [\#62](https://github.com/dermatologist/umlsjs/pull/62) ([dependabot[bot]](https://github.com/apps/dependabot)) 124 | 125 | ## [v0.10.0](https://github.com/dermatologist/umlsjs/tree/v0.10.0) (2021-10-15) 126 | 127 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.9...v0.10.0) 128 | 129 | **Merged pull requests:** 130 | 131 | - build\(deps\): bump fast-xml-parser from 3.19.0 to 3.20.3 [\#55](https://github.com/dermatologist/umlsjs/pull/55) ([dependabot[bot]](https://github.com/apps/dependabot)) 132 | 133 | ## [v0.9.9](https://github.com/dermatologist/umlsjs/tree/v0.9.9) (2021-10-12) 134 | 135 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.8...v0.9.9) 136 | 137 | ## [v0.9.8](https://github.com/dermatologist/umlsjs/tree/v0.9.8) (2021-10-12) 138 | 139 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.7...v0.9.8) 140 | 141 | **Merged pull requests:** 142 | 143 | - build\(deps\): bump nth-check from 2.0.0 to 2.0.1 [\#54](https://github.com/dermatologist/umlsjs/pull/54) ([dependabot[bot]](https://github.com/apps/dependabot)) 144 | - build\(deps\): bump tmpl from 1.0.4 to 1.0.5 [\#53](https://github.com/dermatologist/umlsjs/pull/53) ([dependabot[bot]](https://github.com/apps/dependabot)) 145 | 146 | ## [v0.9.7](https://github.com/dermatologist/umlsjs/tree/v0.9.7) (2021-09-25) 147 | 148 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.6...v0.9.7) 149 | 150 | **Merged pull requests:** 151 | 152 | - build\(deps\): bump axios from 0.21.1 to 0.21.4 [\#49](https://github.com/dermatologist/umlsjs/pull/49) ([dependabot[bot]](https://github.com/apps/dependabot)) 153 | 154 | ## [v0.9.6](https://github.com/dermatologist/umlsjs/tree/v0.9.6) (2021-09-22) 155 | 156 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.5...v0.9.6) 157 | 158 | **Merged pull requests:** 159 | 160 | - build\(deps\): bump JamesIves/github-pages-deploy-action from 4.1.4 to 4.1.5 [\#48](https://github.com/dermatologist/umlsjs/pull/48) ([dependabot[bot]](https://github.com/apps/dependabot)) 161 | 162 | ## [v0.9.5](https://github.com/dermatologist/umlsjs/tree/v0.9.5) (2021-09-21) 163 | 164 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.4...v0.9.5) 165 | 166 | **Merged pull requests:** 167 | 168 | - build\(deps-dev\): bump husky from 7.0.1 to 7.0.2 [\#47](https://github.com/dermatologist/umlsjs/pull/47) ([dependabot[bot]](https://github.com/apps/dependabot)) 169 | 170 | ## [v0.9.4](https://github.com/dermatologist/umlsjs/tree/v0.9.4) (2021-08-28) 171 | 172 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.3...v0.9.4) 173 | 174 | **Merged pull requests:** 175 | 176 | - build\(deps-dev\): bump typedoc from 0.21.5 to 0.21.6 [\#45](https://github.com/dermatologist/umlsjs/pull/45) ([dependabot[bot]](https://github.com/apps/dependabot)) 177 | 178 | ## [v0.9.3](https://github.com/dermatologist/umlsjs/tree/v0.9.3) (2021-08-19) 179 | 180 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.2...v0.9.3) 181 | 182 | **Merged pull requests:** 183 | 184 | - build\(deps-dev\): bump tslib from 2.3.0 to 2.3.1 [\#44](https://github.com/dermatologist/umlsjs/pull/44) ([dependabot[bot]](https://github.com/apps/dependabot)) 185 | 186 | ## [v0.9.2](https://github.com/dermatologist/umlsjs/tree/v0.9.2) (2021-08-15) 187 | 188 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.1...v0.9.2) 189 | 190 | **Merged pull requests:** 191 | 192 | - build\(deps\): bump path-parse from 1.0.6 to 1.0.7 [\#43](https://github.com/dermatologist/umlsjs/pull/43) ([dependabot[bot]](https://github.com/apps/dependabot)) 193 | 194 | ## [v0.9.1](https://github.com/dermatologist/umlsjs/tree/v0.9.1) (2021-08-03) 195 | 196 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.9.0...v0.9.1) 197 | 198 | **Merged pull requests:** 199 | 200 | - build\(deps-dev\): bump typedoc from 0.21.4 to 0.21.5 [\#40](https://github.com/dermatologist/umlsjs/pull/40) ([dependabot[bot]](https://github.com/apps/dependabot)) 201 | 202 | ## [v0.9.0](https://github.com/dermatologist/umlsjs/tree/v0.9.0) (2021-07-29) 203 | 204 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.8.0...v0.9.0) 205 | 206 | ## [0.8.0](https://github.com/dermatologist/umlsjs/tree/0.8.0) (2021-07-29) 207 | 208 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.8.0...0.8.0) 209 | 210 | ## [v0.8.0](https://github.com/dermatologist/umlsjs/tree/v0.8.0) (2021-07-29) 211 | 212 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.7.0...v0.8.0) 213 | 214 | **Merged pull requests:** 215 | 216 | - Added author tag [\#39](https://github.com/dermatologist/umlsjs/pull/39) ([apar-mistry](https://github.com/apar-mistry)) 217 | - Added name to contributors [\#38](https://github.com/dermatologist/umlsjs/pull/38) ([apar-mistry](https://github.com/apar-mistry)) 218 | 219 | ## [v0.7.0](https://github.com/dermatologist/umlsjs/tree/v0.7.0) (2021-07-28) 220 | 221 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.6.1...v0.7.0) 222 | 223 | ## [v0.6.1](https://github.com/dermatologist/umlsjs/tree/v0.6.1) (2021-07-28) 224 | 225 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.6.0...v0.6.1) 226 | 227 | **Merged pull requests:** 228 | 229 | - Added AUI function [\#37](https://github.com/dermatologist/umlsjs/pull/37) ([apar-mistry](https://github.com/apar-mistry)) 230 | 231 | ## [v0.6.0](https://github.com/dermatologist/umlsjs/tree/v0.6.0) (2021-07-27) 232 | 233 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/v0.5.1...v0.6.0) 234 | 235 | **Merged pull requests:** 236 | 237 | - build\(deps\): bump actions/setup-node from 2.2.0 to 2.3.0 [\#36](https://github.com/dermatologist/umlsjs/pull/36) ([dependabot[bot]](https://github.com/apps/dependabot)) 238 | 239 | ## [v0.5.1](https://github.com/dermatologist/umlsjs/tree/v0.5.1) (2021-07-19) 240 | 241 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.5.0...v0.5.1) 242 | 243 | **Closed issues:** 244 | 245 | - localStorage is available only in a browser context. [\#32](https://github.com/dermatologist/umlsjs/issues/32) 246 | - Getting up and running [\#31](https://github.com/dermatologist/umlsjs/issues/31) 247 | 248 | **Merged pull requests:** 249 | 250 | - Patch 1 [\#34](https://github.com/dermatologist/umlsjs/pull/34) ([apar-mistry](https://github.com/apar-mistry)) 251 | 252 | ## [0.5.0](https://github.com/dermatologist/umlsjs/tree/0.5.0) (2021-07-18) 253 | 254 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/pre-v0.4.1...0.5.0) 255 | 256 | ## [pre-v0.4.1](https://github.com/dermatologist/umlsjs/tree/pre-v0.4.1) (2021-07-18) 257 | 258 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.4.0...pre-v0.4.1) 259 | 260 | ## [0.4.0](https://github.com/dermatologist/umlsjs/tree/0.4.0) (2021-07-18) 261 | 262 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.3.2...0.4.0) 263 | 264 | **Closed issues:** 265 | 266 | - UMLS REST API wrapper [\#8](https://github.com/dermatologist/umlsjs/issues/8) 267 | 268 | **Merged pull requests:** 269 | 270 | - build\(deps\): bump actions/setup-node from 1 to 2.2.0 [\#28](https://github.com/dermatologist/umlsjs/pull/28) ([dependabot[bot]](https://github.com/apps/dependabot)) 271 | - build\(deps-dev\): bump husky from 4.3.0 to 7.0.0 [\#27](https://github.com/dermatologist/umlsjs/pull/27) ([dependabot[bot]](https://github.com/apps/dependabot)) 272 | - build\(deps-dev\): bump typescript from 4.0.3 to 4.3.5 [\#26](https://github.com/dermatologist/umlsjs/pull/26) ([dependabot[bot]](https://github.com/apps/dependabot)) 273 | - build\(deps-dev\): bump dotenv from 8.2.0 to 10.0.0 [\#24](https://github.com/dermatologist/umlsjs/pull/24) ([dependabot[bot]](https://github.com/apps/dependabot)) 274 | - build\(deps-dev\): bump tslib from 2.0.3 to 2.3.0 [\#22](https://github.com/dermatologist/umlsjs/pull/22) ([dependabot[bot]](https://github.com/apps/dependabot)) 275 | - build\(deps\): bump actions/checkout from 1 to 2.3.4 [\#20](https://github.com/dermatologist/umlsjs/pull/20) ([dependabot[bot]](https://github.com/apps/dependabot)) 276 | - update deps [\#19](https://github.com/dermatologist/umlsjs/pull/19) ([dermatologist](https://github.com/dermatologist)) 277 | - build\(deps\): bump ws from 6.2.1 to 6.2.2 [\#18](https://github.com/dermatologist/umlsjs/pull/18) ([dependabot[bot]](https://github.com/apps/dependabot)) 278 | - build\(deps\): bump browserslist from 4.14.5 to 4.16.6 [\#17](https://github.com/dermatologist/umlsjs/pull/17) ([dependabot[bot]](https://github.com/apps/dependabot)) 279 | - build\(deps\): bump hosted-git-info from 2.8.8 to 2.8.9 [\#16](https://github.com/dermatologist/umlsjs/pull/16) ([dependabot[bot]](https://github.com/apps/dependabot)) 280 | - build\(deps\): bump lodash from 4.17.20 to 4.17.21 [\#15](https://github.com/dermatologist/umlsjs/pull/15) ([dependabot[bot]](https://github.com/apps/dependabot)) 281 | - build\(deps\): bump y18n from 4.0.0 to 4.0.1 [\#14](https://github.com/dermatologist/umlsjs/pull/14) ([dependabot[bot]](https://github.com/apps/dependabot)) 282 | - build\(deps\): bump axios from 0.19.2 to 0.21.1 [\#13](https://github.com/dermatologist/umlsjs/pull/13) ([dependabot[bot]](https://github.com/apps/dependabot)) 283 | 284 | ## [0.3.2](https://github.com/dermatologist/umlsjs/tree/0.3.2) (2020-10-21) 285 | 286 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.3.1...0.3.2) 287 | 288 | ## [0.3.1](https://github.com/dermatologist/umlsjs/tree/0.3.1) (2020-10-21) 289 | 290 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.3.0...0.3.1) 291 | 292 | ## [0.3.0](https://github.com/dermatologist/umlsjs/tree/0.3.0) (2020-10-21) 293 | 294 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.2.2...0.3.0) 295 | 296 | **Merged pull requests:** 297 | 298 | - Feature/v2 tsdx 1 [\#11](https://github.com/dermatologist/umlsjs/pull/11) ([dermatologist](https://github.com/dermatologist)) 299 | - Add more mock tests [\#10](https://github.com/dermatologist/umlsjs/pull/10) ([sinujackson](https://github.com/sinujackson)) 300 | - build\(deps\): bump yargs-parser from 13.1.1 to 13.1.2 [\#7](https://github.com/dermatologist/umlsjs/pull/7) ([dependabot[bot]](https://github.com/apps/dependabot)) 301 | - build\(deps\): bump lodash from 4.17.15 to 4.17.19 [\#6](https://github.com/dermatologist/umlsjs/pull/6) ([dependabot[bot]](https://github.com/apps/dependabot)) 302 | - Create LICENSE [\#5](https://github.com/dermatologist/umlsjs/pull/5) ([dermatologist](https://github.com/dermatologist)) 303 | - build\(deps\): bump acorn from 5.7.3 to 5.7.4 [\#4](https://github.com/dermatologist/umlsjs/pull/4) ([dependabot[bot]](https://github.com/apps/dependabot)) 304 | 305 | ## [0.2.2](https://github.com/dermatologist/umlsjs/tree/0.2.2) (2020-01-12) 306 | 307 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.2.1...0.2.2) 308 | 309 | **Merged pull requests:** 310 | 311 | - Create updates.md [\#3](https://github.com/dermatologist/umlsjs/pull/3) ([dermatologist](https://github.com/dermatologist)) 312 | - fix: 124 [\#2](https://github.com/dermatologist/umlsjs/pull/2) ([sinujackson](https://github.com/sinujackson)) 313 | - fix: 123 [\#1](https://github.com/dermatologist/umlsjs/pull/1) ([sinujackson](https://github.com/sinujackson)) 314 | 315 | ## [0.2.1](https://github.com/dermatologist/umlsjs/tree/0.2.1) (2020-01-04) 316 | 317 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.1.2...0.2.1) 318 | 319 | ## [0.1.2](https://github.com/dermatologist/umlsjs/tree/0.1.2) (2020-01-02) 320 | 321 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/0.1.0...0.1.2) 322 | 323 | ## [0.1.0](https://github.com/dermatologist/umlsjs/tree/0.1.0) (2020-01-01) 324 | 325 | [Full Changelog](https://github.com/dermatologist/umlsjs/compare/777241c262ef4816855becb8e1b8ff95b8852cc5...0.1.0) 326 | 327 | 328 | 329 | \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* 330 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | ## Please note: 4 | 5 | * (Optional) We adopt [Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow). Most feature branches are pushed to the repository and deleted when merged to *develop* branch. 6 | * (**Important**): Submit pull requests to the *develop* branch or *feature/* branches 7 | * Use *GitHub Issues* for feature requests and bug reports. Include as much information as possible while reporting bugs. 8 | 9 | 10 | ## Contributing (Step-by-step) 11 | 12 | 1. [Fork the repo](http://help.github.com/fork-a-repo) and clone it to your local computer, and set up the upstream remote: 13 | 14 | git clone https://github.com/YourGithubUsername/umlsjs.git 15 | cd umlsjs 16 | git remote add upstream https://github.com/dermatologist/umlsjs.git 17 | 18 | 2. Checkout out a new local branch based on your master and update it to the latest (BRANCH-123 is the branch name, You can name it whatever you want. Try to give it a meaningful name. If you are fixing an issue, please include the issue #). 19 | 20 | git checkout -b BRANCH-123 develop 21 | git clean -df 22 | git pull --rebase upstream develop 23 | 24 | > Please keep your code clean. If you find another bug, you want to fix while being in a new branch, please fix it in a separated branch instead. 25 | 26 | 3. Push the branch to your fork. Treat it as a backup. 27 | 28 | git push origin BRANCH-123 29 | 30 | 4. Code 31 | 32 | * Adhere to common conventions you see in the existing code. 33 | * Include tests as much as possible, and ensure they pass. 34 | 35 | 5. Commit to your branch 36 | 37 | git commit -m "BRANCH-123: Put change summary here (can be a ticket title)" 38 | 39 | **NEVER leave the commit message blank!** Provide a detailed, clear, and complete description of your commit! 40 | 41 | 6. Update your branch to the latest code. 42 | 43 | git pull --rebase upstream develop 44 | 45 | 7. **Important** If you have made many commits, please squash them into atomic units of work. (Most Git GUIs such as sourcetree and smartgit offer a squash option) 46 | 47 | 48 | git checkout develop 49 | git pull --rebase upstream develop 50 | git merge --squash BRANCH-123 51 | git commit -m "fix: 123" 52 | 53 | Push changes to your fork: 54 | 55 | git push 56 | 57 | 8. Issue a Pull Request 58 | 59 | In order to make a pull request: 60 | * Click "Pull Request". 61 | * Choose the develop branch 62 | * Click 'Create pull request' 63 | * Fill in some details about your potential patch including a meaningful title. 64 | * Click "Create pull request". 65 | 66 | Thanks for that -- we'll get to your pull request ASAP. We love pull requests! 67 | 68 | ## Feedback 69 | 70 | If you need to contact me, see my contact details on my profile page. 71 | 72 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Bell Raj Eapen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # umlsjs (For UMLS REST APIs) 2 | 3 | [![forthebadge](https://forthebadge.com/images/badges/made-with-typescript.svg)](https://github.com/dermatologist/fhir-questionnaire-render-react) 4 | [![npm](https://img.shields.io/npm/dt/umlsjs)](https://www.npmjs.com/package/umlsjs) 5 | [![Build](https://github.com/dermatologist/umlsjs/workflows/Publish/badge.svg)](https://nuchange.ca) 6 | 7 | ## About 8 | This is an unofficial package for accessing [UMLS REST APIs](https://documentation.uts.nlm.nih.gov/rest/home.html). The technical documentation for the APIs is available [here.](https://documentation.uts.nlm.nih.gov/) You need an API-KEY to access UMLS services. You can apply for the license [here.](https://uts.nlm.nih.gov/license.html) 9 | 10 | ## Install 11 | ``` 12 | npm install umlsjs --save 13 | 14 | ``` 15 | 16 | ## Usage 17 | 18 | ``` 19 | import {UMLSJS} from 'umlsjs' 20 | // Create Once 21 | const umls_key = "YOUR_KEY_HERE" ; 22 | const token = new UMLSJS.UMLSToken(umls_key) 23 | 24 | // Generate with each request 25 | let st = await token.getSt() 26 | const search1 = new UMLSJS.UMLSSearch(st) 27 | search1.init('Erythema Multiforme') 28 | await search1.query() 29 | const results = search1.getResults() 30 | 31 | // Generate with each request 32 | st = await token.getSt() 33 | const search2 = new UMLSJS.CUISearch(st) 34 | search2.init('C0009044') 35 | await search2.query() 36 | const result = search2.getResult() 37 | 38 | st = await token.getSt() 39 | const search2 = new UMLSJS.CUISearch(st) 40 | search2.init('C0009044') 41 | await search2.getAtoms() 42 | const result = search2.atoms 43 | 44 | st = await token.getSt() 45 | const search2 = new UMLSJS.CUISearch(st) 46 | search2.init('C0009044') 47 | await search2.getDefinitions() 48 | const result = search2.definitions 49 | 50 | st = await token.getSt() 51 | const search2 = new UMLSJS.CUISearch(st) 52 | search2.init('C0009044') 53 | await search2.getRelations() 54 | const result = search2.relations 55 | 56 | st = await token.getSt(); 57 | const search2 = new UMLSJS.AUISearch(st); 58 | search2.init("A10134087"); 59 | await search2.getChildren(); 60 | const result = search2.children; 61 | 62 | st = await token.getSt(); 63 | const search2 = new UMLSJS.AUISearch(st); 64 | search2.init("A10134087"); 65 | await search2.getDescendents(); 66 | const result = search2.descendants; 67 | 68 | st = await token.getSt(); 69 | const search2 = new UMLSJS.AUISearch(st); 70 | search2.init("A10134087"); 71 | await search2.getParents(); 72 | const result = search2.parents; 73 | 74 | 75 | st = await token.getSt(); 76 | const search2 = new UMLSJS.AUISearch(st); 77 | search2.init("A10134087"); 78 | await search2.getAncestors(); 79 | const result = search2.ancestors; 80 | 81 | ``` 82 | 83 | 84 | ``` 85 | const umlsjs = require('umlsjs) 86 | 87 | // Create Once 88 | const umls_key = "YOUR_KEY_HERE" ; 89 | const token = new umlsjs.UMLSJS.UMLSToken(umls_key) 90 | 91 | // Generate with each request 92 | let st = await token.getSt() 93 | const search1 = new umlsjs.UMLSJS.UMLSSearch(st) 94 | ``` 95 | 96 | ### pagination 97 | 98 | ``` 99 | nextPage() 100 | nextPage(2) 101 | ``` 102 | 103 | ## More to come 104 | 105 | * UMLSContent 106 | * UMLSSubsets 107 | * UMLSSemanticNetwork 108 | * UMLSContentView 109 | * UMLSCrosswalk 110 | 111 | ## Want to join development? 112 | 113 | * Rename .env.example to .env and add your API key. 114 | * Submit PR to the develop branch. 115 | 116 | ## Contributor(s) 117 | 118 | * [Bell Eapen](https://nuchange.ca) | [![Twitter Follow](https://img.shields.io/twitter/follow/beapen?style=social)](https://twitter.com/beapen) 119 | * [Apar Mistry](https://github.com/apar-mistry) 120 | -------------------------------------------------------------------------------- /mocktest/fake-cui-response.ts: -------------------------------------------------------------------------------- 1 | export const fakeCUIRelations = { 2 | "pageSize": 25, 3 | "pageNumber": 1, 4 | "pageCount": 1, 5 | "result": [ 6 | { 7 | "classType": "ConceptRelation", 8 | "ui": "R02986047", 9 | "suppressible": false, 10 | "sourceUi": "NONE", 11 | "obsolete": false, 12 | "sourceOriginated": false, 13 | "rootSource": "MTH", 14 | "relationLabel": "RN", 15 | "additionalRelationLabel": "", 16 | "groupId": "NONE", 17 | "attributeCount": 0, 18 | "relatedId": "https://uts-ws.nlm.nih.gov/rest/content/2016AA/CUI/C0029509", 19 | "relatedIdName": "Unspecified site injury" 20 | } 21 | ] 22 | } 23 | export const fakeCUIDefinitions = { 24 | "pageSize": 25, 25 | "pageNumber": 1, 26 | "pageCount": 1, 27 | "result": [ 28 | { 29 | "classType": "Definition", 30 | "sourceOriginated": true, 31 | "rootSource": "MSH", 32 | "value": "Idiopathic recurrent VERTIGO associated with POSITIONAL NYSTAGMUS. It is associated with a vestibular loss without other neurological or auditory signs. Unlike in LABYRINTHITIS and VESTIBULAR NEURONITIS inflammation in the ear is not observed." 33 | } 34 | ] 35 | } 36 | export const fakeCUIAtoms = { 37 | "pageSize": 25, 38 | "pageNumber": 1, 39 | "pageCount": 1, 40 | "result": [{ 41 | "classType": "Atom", 42 | "ui": "A8345234", 43 | "suppressible": "false", 44 | "obsolete": "false", 45 | "rootSource": "ICD9CM", 46 | "termType": "PT", 47 | "code": "https://uts-ws.nlm.nih.gov/rest/content/2016AA/source/ICD9CM/386.11", 48 | "concept": "https://uts-ws.nlm.nih.gov/rest/content/2016AA/CUI/C0155502", 49 | "sourceConcept": "NONE", 50 | "sourceDescriptor": "NONE", 51 | "attributes": "NONE", 52 | "parents": "NONE", 53 | "ancestors": null, 54 | "children": "NONE", 55 | "descendants": null, 56 | "relations": "https://uts-ws.nlm.nih.gov/rest/content/2016AA/AUI/A8345234/relations", 57 | "name": "Benign paroxysmal positional vertigo", 58 | "language": "ENG", 59 | "contentViewMemberships": [{ 60 | "memberUri": "https://uts-ws.nlm.nih.gov/rest/content-views/2016AA/CUI/C1700357/member/A8345234", 61 | "uri": "https://uts-ws.nlm.nih.gov/rest/content-views/2016AA/CUI/C1700357", 62 | "name": "MetaMap NLP View" 63 | } 64 | ] 65 | }] 66 | } 67 | 68 | export const fakeCUIResponse = { 69 | 70 | "pageSize": 25, 71 | "pageNumber": 1, 72 | "result": 73 | 74 | { 75 | 76 | "classType": "searchResults", 77 | "results": 78 | 79 | [ 80 | 81 | { 82 | 83 | "ui": "C0009044", 84 | "rootSource": "SNOMEDCT_US", 85 | "uri": "https://uts-ws.nlm.nih.gov/rest/content/2015AA/CUI/C0009044", 86 | "name": "Closed fracture carpal bone" 87 | 88 | }] 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /mocktest/fake-key-response.ts: -------------------------------------------------------------------------------- 1 | export const fakeTgt = ` 2 | 3 | 4 | 5 | 201 The request has been fulfilled and resulted in a new resource being created 6 |

TGT Created

7 |
Service: 8 |
9 | 10 | 11 | ` 12 | 13 | export const fakeSt = 'ST-134-HUbXGfI765aSj0UqtdvU-cas' -------------------------------------------------------------------------------- /mocktest/fake-search-response.ts: -------------------------------------------------------------------------------- 1 | export const fakeSearch = { 2 | 3 | "pageSize": 25, 4 | "pageNumber": 1, 5 | "result": 6 | 7 | { 8 | 9 | "classType": "searchResults", 10 | "results": 11 | 12 | [ 13 | 14 | { 15 | 16 | "ui": "C0009044", 17 | "rootSource": "SNOMEDCT_US", 18 | "uri": "https://uts-ws.nlm.nih.gov/rest/content/2015AA/CUI/C0009044", 19 | "name": "Closed fracture carpal bone" 20 | 21 | }] 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /mocktest/mock.cuiSearch.spec.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import CUISearch from '../src/function/cuiSearch' 3 | import { fakeTgt, fakeSt } from './fake-key-response' 4 | import { fakeCUIResponse, fakeCUIAtoms, fakeCUIDefinitions, fakeCUIRelations } from './fake-cui-response' 5 | jest.mock('axios') 6 | const mockAxios = axios as jest.Mocked; 7 | 8 | mockAxios.post.mockImplementation((url) => { 9 | switch (url) { 10 | case 'api-key': 11 | return Promise.resolve({ data: fakeTgt }) 12 | default: // Request for ST 13 | return Promise.resolve({ data: fakeSt }) 14 | } 15 | }); 16 | 17 | /* 18 | @IMPORTANT: 19 | UMLS API works only with direct axios(config) calls for get (Why?) 20 | Hence the tests have to be altered as below 21 | */ 22 | 23 | mockAxios.get.mockImplementation((request: string, params: any) => { 24 | console.log(params) 25 | switch (request) { 26 | case 'https://uts-ws.nlm.nih.gov/rest/content/current/CUI/C0009044': 27 | return Promise.resolve({ data: fakeCUIResponse }) 28 | case 'https://uts-ws.nlm.nih.gov/rest/content/current/CUI/C0009044/atoms': 29 | return Promise.resolve({ data: fakeCUIAtoms }) 30 | case 'https://uts-ws.nlm.nih.gov/rest/content/current/CUI/C0009044/definitions': 31 | return Promise.resolve({ data: fakeCUIDefinitions }) 32 | case 'https://uts-ws.nlm.nih.gov/rest/content/current/CUI/C0009044/relations': 33 | return Promise.resolve({ data: fakeCUIRelations }) 34 | default: 35 | console.log(request) 36 | return Promise.resolve({ data: {} }) 37 | } 38 | }); 39 | 40 | test('Get Results for a CUI', async () => { 41 | const search1 = new CUISearch(process.env.UMLS_API_KEY || "test-random-key") 42 | const CUI = 'C0009044' 43 | search1.init(CUI) 44 | await search1.query() 45 | const resp = search1.getResult() 46 | expect(resp['results'][0]['ui']).toBe(CUI) 47 | expect(search1.pageCount).toBeGreaterThan(0) 48 | }) 49 | 50 | test('Get Atoms for a CUI', async () => { 51 | const search1 = new CUISearch(process.env.UMLS_API_KEY) 52 | const CUI = 'C0009044' 53 | search1.init(CUI) 54 | await search1.getAtoms() 55 | const result = search1.atoms 56 | expect(result).toBeTruthy() 57 | if(result) 58 | expect(result.length).toBeGreaterThan(0) 59 | }) 60 | 61 | test('Get Definitions for a CUI', async () => { 62 | const search1 = new CUISearch(process.env.UMLS_API_KEY) 63 | const CUI = 'C0009044' 64 | search1.init(CUI) 65 | await search1.getDefinitions() 66 | const result = search1.definitions 67 | expect(result).toBeTruthy() 68 | if (result) 69 | expect(result.length).toBeGreaterThan(0) 70 | }) 71 | 72 | test('Get Relations for a CUI', async () => { 73 | const search1 = new CUISearch(process.env.UMLS_API_KEY) 74 | const CUI = 'C0009044' 75 | search1.init(CUI) 76 | await search1.getRelations() 77 | const result = search1.relations 78 | expect(result).toBeTruthy() 79 | if (result) 80 | expect(result.length).toBeGreaterThan(0) 81 | }) -------------------------------------------------------------------------------- /mocktest/mock.generalService.spec.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import { getService } from '../src/service/generalService' 3 | import {fakeTgt, fakeSt} from './fake-key-response' 4 | import { fakeSearch } from './fake-search-response' 5 | jest.mock('axios') 6 | const mockAxios = axios as jest.Mocked; 7 | 8 | it('Get Results for General service', async () => { 9 | mockAxios.post.mockImplementation((url) => { 10 | switch (url) { 11 | case 'api-key': 12 | return Promise.resolve({data: fakeTgt}) 13 | default: // Request for ST 14 | return Promise.resolve({data: fakeSt}) 15 | } 16 | }); 17 | 18 | mockAxios.get.mockImplementation((request:string) => { 19 | switch (request) { 20 | case 'https://uts-ws.nlm.nih.gov/rest/search/current': 21 | return Promise.resolve({data: fakeSearch}) 22 | default: 23 | return Promise.resolve({data: {}}) 24 | } 25 | }); 26 | 27 | const params = { 28 | string: 'fracture of carpal bone' 29 | } 30 | const data = await getService("test-key-random", '/search/current', params); 31 | 32 | expect(data.pageNumber).toBe(1) 33 | expect(data.result.classType).toBe('searchResults') 34 | // expect(mockAxios.post).toHaveBeenCalledTimes(2) 35 | expect(mockAxios.get).toHaveBeenCalledTimes(1) 36 | expect(mockAxios.get).toHaveBeenCalledWith("https://uts-ws.nlm.nih.gov/rest/search/current", 37 | { "params": { "string": "fracture of carpal bone", "ticket": "test-key-random" } }) 38 | }); -------------------------------------------------------------------------------- /mocktest/mock.umlsSearch.spec.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import UMLSSearch from '../src/function/umlsSearch' 3 | import { fakeTgt, fakeSt } from './fake-key-response' 4 | import { fakeSearch } from './fake-search-response' 5 | jest.mock('axios') 6 | const mockAxios = axios as jest.Mocked; 7 | 8 | mockAxios.post.mockImplementation((url) => { 9 | switch (url) { 10 | case 'api-key': 11 | return Promise.resolve({ data: fakeTgt }) 12 | default: // Request for ST 13 | return Promise.resolve({ data: fakeSt }) 14 | } 15 | }); 16 | 17 | /* 18 | @IMPORTANT: 19 | UMLS API works only with direct axios(config) calls for get (Why?) 20 | Hence the tests have to be altered as below 21 | */ 22 | mockAxios.get.mockImplementation((request:string, params:any) => { 23 | 24 | switch (request) { 25 | case 'https://uts-ws.nlm.nih.gov/rest/search/current': 26 | if (params.params.string === 'fracture of carpal bone') 27 | return Promise.resolve({ data: fakeSearch }) 28 | else 29 | return Promise.resolve({ data: {} }) 30 | default: 31 | return Promise.resolve({ data: {} }) 32 | } 33 | }); 34 | test('Get Results for General service', async () => { 35 | const search1 = new UMLSSearch(process.env.UMLS_API_KEY || "test-random-key") 36 | search1.init('fracture of carpal bone') 37 | await search1.query() 38 | const results = search1.getResults() 39 | expect(results[0]['name']).toBe('Closed fracture carpal bone') 40 | expect(results.length).toBeGreaterThan(0) 41 | expect(search1.pageNumber).toBe(1) 42 | 43 | }); 44 | -------------------------------------------------------------------------------- /notes/jsdoc.md: -------------------------------------------------------------------------------- 1 | npm install jsdoc --save-dev 2 | npx jsdoc src -r -d docs -R README.md 3 | npm run docs 4 | 5 | 6 | 7 | ## Use typescript instead 8 | 9 | "docs": "typedoc --out docs src", 10 | 11 | "typedoc": "^0.21.0", -------------------------------------------------------------------------------- /notes/placeholder.md: -------------------------------------------------------------------------------- 1 | # Notes -------------------------------------------------------------------------------- /notes/updates.md: -------------------------------------------------------------------------------- 1 | # Updates 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "umlsjs", 3 | "version": "1.2.1", 4 | "description": "Nodejs package to access UMLS REST web-services", 5 | "main": "dist/index.js", 6 | "files": [ 7 | "dist/*" 8 | ], 9 | "scripts": { 10 | "start": "tsdx watch", 11 | "build": "tsdx build", 12 | "test": "tsdx test", 13 | "mocktest": "tsdx test --detectOpenHandles /mocktest", 14 | "lint": "tsdx lint --fix", 15 | "prepare": "tsdx build", 16 | "size": "size-limit", 17 | "analyze": "size-limit --why", 18 | "docs": "typedoc --out docs src", 19 | "preversion": "npm test", 20 | "version": "npm run build", 21 | "postversion": "rm -rf build/temp", 22 | "release": "npm version patch && npm publish", 23 | "gpr-setup": "node scripts/gpr.js" 24 | }, 25 | "repository": { 26 | "type": "git", 27 | "url": "git+https://github.com/dermatologist/umlsjs.git" 28 | }, 29 | "keywords": [ 30 | "UMLS", 31 | "REST" 32 | ], 33 | "dependencies": { 34 | "axios": "^0.26.1", 35 | "fast-xml-parser": "^3.19.0", 36 | "he": "^1.2.0", 37 | "querystring": "^0.2.1" 38 | }, 39 | "devDependencies": { 40 | "@size-limit/preset-small-lib": "^5.0.1", 41 | "dotenv": "^16.0.0", 42 | "husky": "^7.0.1", 43 | "size-limit": "^5.0.1", 44 | "tsdx": "^0.14.1", 45 | "typedoc": "^0.22.6", 46 | "tslib": "^2.3.0", 47 | "typescript": "^4.3.5" 48 | }, 49 | "prettier": { 50 | "printWidth": 80, 51 | "semi": true, 52 | "singleQuote": true, 53 | "trailingComma": "es5" 54 | }, 55 | "module": "dist/umlsjs.esm.js", 56 | "size-limit": [ 57 | { 58 | "path": "dist/umlsjs.cjs.production.min.js", 59 | "limit": "10 KB" 60 | }, 61 | { 62 | "path": "dist/umlsjs.esm.js", 63 | "limit": "10 KB" 64 | } 65 | ], 66 | "author": "Bell Eapen", 67 | "license": "MIT", 68 | "bugs": { 69 | "url": "https://github.com/dermatologist/umlsjs/issues" 70 | }, 71 | "homepage": "https://github.com/dermatologist/umlsjs#readme" 72 | } 73 | -------------------------------------------------------------------------------- /scripts/gpr.js: -------------------------------------------------------------------------------- 1 | // scripts/gpr.js 2 | // http://quabr.com:8182/58347746/automating-the-build-and-publish-process-with-github-actions-and-github-package 3 | 4 | const fs = require('fs') 5 | const { join } = require('path') 6 | 7 | // Get the package obejct and change the name 8 | const pkg = require('../package.json') 9 | pkg.name = '@dermatologist/umlsjs' 10 | 11 | // Update package.json with the udpated name 12 | fs.writeFileSync(join(__dirname, '../package.json'), JSON.stringify(pkg)) -------------------------------------------------------------------------------- /src/function/auiSearch.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Apar Mistry 3 | */ 4 | import { getService } from '../service/generalService' 5 | import ConceptModel from '../model/concept' 6 | import UMLSQueryTemplate from '../model/queryTemplate' 7 | 8 | class AUISearch extends UMLSQueryTemplate { 9 | async getChildren(){ 10 | const params = this.fillParams({}) 11 | const url = `/content/${this.version}/AUI/${this.term}/children` 12 | const response = await getService(this.st, url, params) 13 | this.children = response.result 14 | } 15 | 16 | async getParents(){ 17 | const params = this.fillParams({}) 18 | const url = `/content/${this.version}/AUI/${this.term}/parents` 19 | const response = await getService(this.st, url, params) 20 | this.parents = response.result 21 | } 22 | 23 | async getAncestors(){ 24 | const params = this.fillParams({}) 25 | const url = `/content/${this.version}/AUI/${this.term}/ancestors` 26 | const response = await getService(this.st, url, params) 27 | this.ancestors = response.result 28 | } 29 | 30 | async getDescendents(){ 31 | const params = this.fillParams({}) 32 | const url = `/content/${this.version}/AUI/${this.term}/descendants` 33 | const response = await getService(this.st, url, params) 34 | this.descendants = response.result 35 | } 36 | getResult(): typeof ConceptModel { 37 | return this.result 38 | } 39 | } 40 | 41 | export default AUISearch; 42 | -------------------------------------------------------------------------------- /src/function/cuiSearch.ts: -------------------------------------------------------------------------------- 1 | 2 | import { getService } from '../service/generalService' 3 | import ConceptModel from '../model/concept' 4 | import UMLSQueryTemplate from '../model/queryTemplate' 5 | 6 | class CUISearch extends UMLSQueryTemplate { 7 | 8 | async query() { 9 | const params = this.fillParams({}) 10 | const url = `/content/${this.version}/CUI/${this.term}` 11 | const response = await getService(this.st, url, params) 12 | this.result = response.result 13 | } 14 | 15 | async getAtoms() { 16 | const params = this.fillParams({}) 17 | const url = `/content/${this.version}/CUI/${this.term}/atoms` 18 | const response = await getService(this.st, url, params) 19 | this.atoms = response.result 20 | } 21 | 22 | async getDefinitions() { 23 | const params = this.fillParams({}) 24 | const url = `/content/${this.version}/CUI/${this.term}/definitions` 25 | const response = await getService(this.st, url, params) 26 | this.definitions = response.result 27 | } 28 | 29 | async getRelations() { 30 | const params = this.fillParams({}) 31 | const url = `/content/${this.version}/CUI/${this.term}/relations` 32 | const response = await getService(this.st, url, params) 33 | this.relations = response.result 34 | } 35 | 36 | getResult(): typeof ConceptModel { 37 | return this.result 38 | } 39 | } 40 | 41 | export default CUISearch; -------------------------------------------------------------------------------- /src/function/umlsSearch.ts: -------------------------------------------------------------------------------- 1 | 2 | import { getService } from '../service/generalService' 3 | import SearchModel from '../model/search' 4 | import UMLSQueryTemplate from '../model/queryTemplate' 5 | 6 | class UMLSSearch extends UMLSQueryTemplate{ 7 | 8 | async query() { 9 | //const params: any = {} 10 | const params = this.fillParams({}) 11 | if(this.id) 12 | params.searchType = 'exact' 13 | const url = `/search/${this.version}` 14 | params.string = this.term 15 | //params.pageNumber = this.pageNumber.toString() 16 | //console.log(this.apikey, url, params) 17 | const response = await getService(this.st, url, params) 18 | this.results = response.result.results 19 | } 20 | 21 | getResults(): Array { 22 | return this.results 23 | } 24 | } 25 | 26 | export default UMLSSearch; -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import UMLSSearch from './function/umlsSearch' 2 | import CUISearch from './function/cuiSearch' 3 | import AUISearch from './function/auiSearch' 4 | import UMLSToken from './model/umlsToken' 5 | 6 | export const UMLSJS = { 7 | UMLSToken: UMLSToken, 8 | UMLSSearch: UMLSSearch, 9 | CUISearch: CUISearch, 10 | AUISearch: AUISearch 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/model/atom.ts: -------------------------------------------------------------------------------- 1 | const AtomModel = { 2 | classType : String, 3 | ui : String, 4 | suppressible : Boolean, 5 | obsolete : Boolean, 6 | rootSource : String, 7 | termType : String, 8 | code : String, 9 | concept : String, 10 | sourceConcept : String, 11 | sourceDescriptor : String, 12 | attributes : String, 13 | parents : String, 14 | ancestors : [], 15 | children : String, 16 | descendants : [], 17 | relations : String, 18 | name : String, 19 | language : String, 20 | contentViewMemberships : [{ 21 | memberUri : String, 22 | uri : String, 23 | name : String 24 | } 25 | ] 26 | } 27 | export default AtomModel -------------------------------------------------------------------------------- /src/model/concept.ts: -------------------------------------------------------------------------------- 1 | const ConceptModel = { 2 | classType: String, 3 | ui: String, 4 | suppressible: Boolean, 5 | dateAdded: Date, 6 | majorRevisionDate: Date, 7 | status: String, 8 | semanticTypes: [ 9 | { 10 | name: String, 11 | uri: String 12 | } 13 | ], 14 | atomCount: Number, 15 | attributeCount: Number, 16 | cvMemberCount: Number, 17 | atoms: String, 18 | definitions: String, 19 | relations: String, 20 | defaultPreferredAtom: String, 21 | relationCount: Number, 22 | name: String 23 | } 24 | export default ConceptModel -------------------------------------------------------------------------------- /src/model/conceptrelation.ts: -------------------------------------------------------------------------------- 1 | const ConceptRelationModel = { 2 | classType: String, 3 | ui: String, 4 | suppressible: Boolean, 5 | sourceUi: String, 6 | obsolete: Boolean, 7 | sourceOriginated: Boolean, 8 | rootSource: String, 9 | relationLabel: String, 10 | additionalRelationLabel: String, 11 | groupId: String, 12 | attributeCount: Number, 13 | relatedId: String, 14 | relatedIdName: String 15 | } 16 | export default ConceptRelationModel -------------------------------------------------------------------------------- /src/model/definition.ts: -------------------------------------------------------------------------------- 1 | const DefinitionModel = { 2 | 3 | classType: String, 4 | sourceOriginated: Boolean, 5 | rootSource: String, 6 | value: String 7 | } 8 | export default DefinitionModel -------------------------------------------------------------------------------- /src/model/queryTemplate.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2020 Bell Eapen 3 | * 4 | * This software is released under the MIT License. 5 | * https://opensource.org/licenses/MIT 6 | */ 7 | import AtomModel from './atom' 8 | import DefinitionModel from './definition' 9 | import ConceptRelationModel from './conceptrelation' 10 | 11 | class UMLSQueryTemplate { 12 | st: string 13 | term?: string 14 | id: any 15 | version: string 16 | results: Array 17 | result: any 18 | pageNumber: number 19 | pageSize: number 20 | pageCount: number 21 | sabs: any 22 | ttys: any 23 | language?: string 24 | includeObsolete: boolean 25 | includeSuppressible: boolean 26 | atoms?: Array 27 | atom?: typeof AtomModel 28 | definitions?: Array 29 | definition?: typeof DefinitionModel 30 | relations?: Array 31 | relation?: typeof ConceptRelationModel 32 | child?: typeof AtomModel 33 | children?: Array 34 | 35 | parent?: typeof AtomModel 36 | parents?: Array 37 | 38 | ancestor?: typeof AtomModel 39 | ancestors?: Array 40 | 41 | descendant?: typeof AtomModel 42 | descendants?: Array 43 | constructor(st){ 44 | this.st = st 45 | this.results = [] 46 | this.version = 'current' 47 | this.pageNumber = 1 48 | this.pageSize = 25 49 | this.pageCount = 1 50 | this.includeObsolete = false 51 | this.includeSuppressible = false 52 | } 53 | 54 | async init(term, id=null) { 55 | this.term = term 56 | this.id = id 57 | } 58 | 59 | fillParams(params): any{ 60 | params.pageNumber = this.pageNumber 61 | params.pageSize = this.pageSize 62 | params.pageCount = this.pageCount 63 | params.includeObsolete = this.includeObsolete 64 | params.includeSuppressible = this.includeSuppressible 65 | if(this.ttys) 66 | params.ttys = encodeURIComponent(this.ttys) 67 | if(this.sabs) 68 | params.sabs = encodeURIComponent(this.sabs) 69 | return params 70 | } 71 | 72 | // @Override 73 | query() { 74 | 75 | } 76 | 77 | nextPage(pageNumber=1){ 78 | if(this.pageNumber) 79 | this.pageNumber = this.pageNumber + pageNumber 80 | else 81 | this.pageNumber = pageNumber 82 | } 83 | 84 | getResults(): Array { 85 | return this.results 86 | } 87 | 88 | getResult(): any { 89 | return this.result 90 | } 91 | 92 | setVersion(version: string){ 93 | this.version = version 94 | } 95 | 96 | setPageNumber(pageNumber: number){ 97 | this.pageNumber = pageNumber 98 | } 99 | 100 | setPageSize(pageSize: number){ 101 | this.pageSize = pageSize 102 | } 103 | 104 | setIncludeObsolete(includeObsolete: boolean){ 105 | this.includeObsolete = includeObsolete 106 | } 107 | 108 | setIncludeSuppressible(includeSuppressible: boolean){ 109 | this.includeSuppressible = includeSuppressible 110 | } 111 | 112 | setLanguage(language: string){ 113 | this.language = language 114 | } 115 | 116 | SetSabs(sabs: any){ 117 | this.sabs = sabs 118 | } 119 | 120 | SetTtys(ttys: any){ 121 | this.ttys = ttys 122 | } 123 | 124 | } 125 | 126 | export default UMLSQueryTemplate; 127 | -------------------------------------------------------------------------------- /src/model/search.ts: -------------------------------------------------------------------------------- 1 | 2 | const SearchModel = { 3 | ui: String, 4 | rootSource: String, 5 | uri: String, 6 | name: String 7 | } 8 | 9 | export default SearchModel -------------------------------------------------------------------------------- /src/model/umlsToken.ts: -------------------------------------------------------------------------------- 1 | import { getTgt, getSt } from '../service/authService' 2 | 3 | 4 | class UMLSToken { 5 | apikey: string 6 | tgt: string 7 | st: string 8 | expiry: number 9 | 10 | constructor(apikey: string) { 11 | this.apikey = apikey; 12 | this.tgt = ""; 13 | this.st = ""; 14 | this.expiry = new Date().getTime(); 15 | } 16 | 17 | async getSt(): Promise { 18 | if(this.tgt == "" || this.st == "" || this.expired()) { 19 | this.tgt = await getTgt(this.apikey); 20 | this.expiry = new Date().getTime(); 21 | } 22 | this.st = await getSt(this.tgt); 23 | return this.st; 24 | } 25 | 26 | expired(): boolean { 27 | const expirationDuration = 1000 * 60 * 60 * 8; // 8 hours 28 | const currentTime = new Date().getTime(); 29 | return this.expiry !== undefined && (currentTime - this.expiry) > expirationDuration; 30 | } 31 | } 32 | 33 | export default UMLSToken; -------------------------------------------------------------------------------- /src/service/authService.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | import querystring from 'querystring'; 3 | import parser from 'fast-xml-parser' 4 | import he from 'he' 5 | 6 | /** 7 | * @author Bell Eapen 8 | * @param {string} tgt - The TGT to use for the request 9 | * @returns {string} The ST token 10 | */ 11 | export const getSt = async tgt => { 12 | const config = { 13 | headers: { 14 | 'Content-Type': 'application/x-www-form-urlencoded' 15 | } 16 | } 17 | const url = `https://utslogin.nlm.nih.gov/cas/v1/tickets/${tgt}` 18 | const response = await axios.post(url, 'service=http%3A%2F%2Fumlsks.nlm.nih.gov', config) 19 | return response.data 20 | } 21 | 22 | /** 23 | * @author Bell Eapen 24 | * @param {string} apikey - The API Key obtained from UMLS 25 | * @returns {string} The TGT token 26 | */ 27 | export const getTgt = async apikey => { 28 | const options = { 29 | attributeNamePrefix : "U_", 30 | attrNodeName: "attr", //default is 'false' 31 | textNodeName : "#text", 32 | ignoreAttributes : false, 33 | ignoreNameSpace : false, 34 | allowBooleanAttributes : false, 35 | parseNodeValue : true, 36 | parseAttributeValue : true, 37 | trimValues: true, 38 | cdataTagName: "__cdata", //default is 'false' 39 | cdataPositionChar: "\\c", 40 | localeRange: "", //To support non english character in tag/attribute values. 41 | parseTrueNumberOnly: false, 42 | arrayMode: false, //"strict" 43 | attrValueProcessor: (val) => he.decode(val, {isAttributeValue: true}),//default is a=>a 44 | tagValueProcessor : (val) => he.decode(val), //default is a=>a 45 | stopNodes: ["parse-me-as-string"] 46 | }; 47 | const config = { 48 | baseURL: "https://utslogin.nlm.nih.gov/cas/v1/", 49 | headers: { 50 | 'Content-Type': 'application/x-www-form-urlencoded' 51 | } 52 | } 53 | const requestBody = { 54 | apikey: apikey 55 | } 56 | const apiFunction = 'api-key' 57 | const response = await axios.post(apiFunction, querystring.stringify(requestBody), config) 58 | const jsonObj = parser.parse(response.data, options) 59 | const urlWithTgt = jsonObj.html.body.form.attr.U_action 60 | const url = config.baseURL+apiFunction+'/' 61 | const tgt = urlWithTgt.replace(url, '') 62 | return(tgt) 63 | 64 | }; 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/service/generalService.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | /** 4 | * 5 | * @param {string} ticket the TGT ticket to be used for the request 6 | * @param {string} url url in the form /search/current 7 | * @param {object} params in the form {string: 'psoriasis vulgaris'} 8 | */ 9 | export const getService = async (ticket, url, params:any ={}) => { 10 | const fullUrl = "https://uts-ws.nlm.nih.gov/rest" + url 11 | params.ticket = ticket 12 | const response = await axios.get(fullUrl, {params: params}) 13 | return(response.data) 14 | } 15 | -------------------------------------------------------------------------------- /test/auiSearch.test.ts: -------------------------------------------------------------------------------- 1 | import AUISearch from '../src/function/auiSearch' 2 | import UMLSToken from '../src/model/umlsToken' 3 | 4 | 5 | import dotenv from 'dotenv' 6 | 7 | jest.setTimeout(15000); 8 | var ticket; 9 | beforeAll(async () => { 10 | dotenv.config() 11 | const key = process.env.UMLS_API_KEY || ""; 12 | ticket = new UMLSToken(key) 13 | }); 14 | 15 | test('Testing getChildren ', async () => { 16 | const st = await ticket.getSt() 17 | const search1 = new AUISearch(st) 18 | const AUI = 'A10134087' 19 | search1.init(AUI) 20 | await search1.getChildren() 21 | const result = search1.children 22 | console.log(result) 23 | expect(search1.pageCount).toBeGreaterThan(0) 24 | }) 25 | 26 | test('Testing getParent ', async () => { 27 | const st = await ticket.getSt() 28 | const search1 = new AUISearch(st) 29 | const AUI = 'A19720766' 30 | search1.init(AUI) 31 | await search1.getParents() 32 | const result = search1.parents 33 | console.log(result) 34 | expect(search1.pageCount).toBeGreaterThan(0) 35 | }) 36 | 37 | // These tests take > 5 seconds. Hence jest timeout increased at the top 38 | test('Testing getAncestors ', async () => { 39 | const st = await ticket.getSt() 40 | const search1 = new AUISearch(st) 41 | const AUI = 'A19720766' 42 | search1.init(AUI) 43 | await search1.getAncestors() 44 | const result = search1.ancestors 45 | console.log(result) 46 | expect(search1.pageCount).toBeGreaterThan(0) 47 | }) 48 | 49 | test('Testing getDescendants ', async () => { 50 | const st = await ticket.getSt() 51 | const search1 = new AUISearch(st) 52 | const AUI = 'A10134087' 53 | search1.init(AUI) 54 | await search1.getDescendents() 55 | const result = search1.descendants 56 | console.log(result) 57 | expect(search1.pageCount).toBeGreaterThan(0) 58 | }) 59 | -------------------------------------------------------------------------------- /test/authService.test.ts: -------------------------------------------------------------------------------- 1 | import { getTgt, getSt } from '../src/service/authService' 2 | import dotenv from 'dotenv' 3 | 4 | beforeAll(() => { 5 | dotenv.config() 6 | }); 7 | 8 | test('Get TGT with API-key', async () => { 9 | 10 | const tgt = await getTgt(process.env.UMLS_API_KEY); 11 | expect(tgt.substring(0,3)).toBe('TGT') 12 | }) 13 | 14 | test('Get ST with API-key', async () => { 15 | const tgt = await getTgt(process.env.UMLS_API_KEY); 16 | const st = await getSt(tgt); 17 | expect(st.substring(0,2)).toBe('ST') 18 | }) -------------------------------------------------------------------------------- /test/cuiSearch.test.ts: -------------------------------------------------------------------------------- 1 | import CUISearch from '../src/function/cuiSearch' 2 | import UMLSToken from '../src/model/umlsToken' 3 | 4 | import dotenv from 'dotenv' 5 | 6 | var ticket; 7 | beforeAll(async () => { 8 | dotenv.config() 9 | const key = process.env.UMLS_API_KEY || ""; 10 | ticket = new UMLSToken(key) 11 | }); 12 | 13 | test('Get Results for a CUI', async () => { 14 | const st = await ticket.getSt() 15 | const search1 = new CUISearch(st) 16 | const CUI = 'C0009044' 17 | search1.init(CUI) 18 | await search1.query() 19 | const result = search1.getResult() 20 | expect(result.ui).toBe(CUI) 21 | expect(search1.pageCount).toBeGreaterThan(0) 22 | }) 23 | 24 | test('Get Atoms for a CUI', async () => { 25 | const st = await ticket.getSt() 26 | const search1 = new CUISearch(st) 27 | const CUI = 'C0009044' 28 | search1.init(CUI) 29 | await search1.getAtoms() 30 | const result = search1.atoms 31 | expect(result).toBeTruthy() 32 | if (result) 33 | expect(result.length).toBeGreaterThan(1) 34 | }) 35 | 36 | test('Get Definitions for a CUI', async () => { 37 | const st = await ticket.getSt() 38 | const search1 = new CUISearch(st) 39 | const CUI = 'C0009044' 40 | search1.init(CUI) 41 | await search1.getDefinitions() 42 | const result = search1.definitions 43 | expect(result).toBeTruthy() 44 | if (result) 45 | expect(result.length).toBeGreaterThan(0) 46 | }) 47 | 48 | test('Get Relations for a CUI', async () => { 49 | const st = await ticket.getSt() 50 | const search1 = new CUISearch(st) 51 | const CUI = 'C0009044' 52 | search1.init(CUI) 53 | await search1.getRelations() 54 | const result = search1.relations 55 | expect(result).toBeTruthy() 56 | if (result) 57 | expect(result.length).toBeGreaterThan(1) 58 | }) -------------------------------------------------------------------------------- /test/generalService.test.ts: -------------------------------------------------------------------------------- 1 | import { getService } from '../src/service/generalService' 2 | import dotenv from 'dotenv' 3 | import UMLSToken from '../src/model/umlsToken' 4 | 5 | beforeAll(() => { 6 | dotenv.config() 7 | }); 8 | 9 | test('Get Results for General service', async () => { 10 | const key = process.env.UMLS_API_KEY || ""; 11 | const ticket = new UMLSToken(key) 12 | const st = await ticket.getSt() 13 | const params = { 14 | string: 'psoriasis vulgaris' 15 | } 16 | const data = await getService(st, '/search/current', params); 17 | expect(data.pageNumber).toBe(1) 18 | }) 19 | 20 | // test('Get ST with API-key', async () => { 21 | 22 | // const st = await getSt(API_KEY); 23 | // expect(st.substring(0,2)).toBe('ST') 24 | // }) -------------------------------------------------------------------------------- /test/index.test.ts: -------------------------------------------------------------------------------- 1 | import {UMLSJS} from '../src/index' 2 | import dotenv from 'dotenv' 3 | 4 | beforeAll(() => { 5 | dotenv.config() 6 | }); 7 | 8 | test('Get Results for a term in index', async () => { 9 | const key = process.env.UMLS_API_KEY || ""; 10 | const ticket = new UMLSJS.UMLSToken(key) 11 | const st = await ticket.getSt() 12 | const search1 = new UMLSJS.UMLSSearch(st) 13 | search1.init('Erythema Multiforme') 14 | await search1.query() 15 | const results = search1.getResults() 16 | expect(results.length).toBeGreaterThan(1) 17 | }) 18 | 19 | test('Get Results for a CUI in index', async () => { 20 | 21 | const key = process.env.UMLS_API_KEY || ""; 22 | const ticket = new UMLSJS.UMLSToken(key) 23 | const st = await ticket.getSt() 24 | const search1 = new UMLSJS.CUISearch(st) 25 | search1.init('C0009044') 26 | await search1.query() 27 | search1.getResult() 28 | expect(search1.pageCount).toBeGreaterThan(0) 29 | }) 30 | -------------------------------------------------------------------------------- /test/umlsSearch.test.ts: -------------------------------------------------------------------------------- 1 | import UMLSSearch from '../src/function/umlsSearch' 2 | import dotenv from 'dotenv' 3 | import UMLSToken from '../src/model/umlsToken' 4 | 5 | var ticket; 6 | beforeAll(async () => { 7 | dotenv.config() 8 | const key = process.env.UMLS_API_KEY || ""; 9 | ticket = new UMLSToken(key) 10 | }); 11 | 12 | 13 | 14 | test('Get Results for a term', async () => { 15 | const st = await ticket.getSt() 16 | const search1 = new UMLSSearch(st) 17 | search1.init('Erythema Multiforme') 18 | await search1.query() 19 | const results = search1.getResults() 20 | expect(results.length).toBeGreaterThan(1) 21 | expect(search1.pageNumber).toBe(1) 22 | }) 23 | 24 | test('Get Next page for a term', async () => { 25 | const st = await ticket.getSt() 26 | const search1 = new UMLSSearch(st) 27 | search1.init('Renal failure') 28 | search1.nextPage() 29 | await search1.query() 30 | const results = search1.getResults() 31 | expect(results.length).toBeGreaterThan(1) 32 | expect(search1.pageNumber).toBe(2) 33 | }) 34 | 35 | test('Get Results for a two terms', async () => { 36 | let st = await ticket.getSt() 37 | const search1 = new UMLSSearch(st) 38 | search1.init('Erythema Multiforme') 39 | await search1.query() 40 | const results1 = search1.getResults() 41 | st = await ticket.getSt() 42 | const search2 = new UMLSSearch(st) 43 | search2.init('Psoriasis Vulgaris') 44 | await search2.query() 45 | const results2 = search2.getResults() 46 | // Both have to be different 47 | // Ref: https://jestjs.io/docs/en/expect#expectnotarraycontainingarray 48 | expect(results1).toEqual( 49 | expect.not.arrayContaining(results2), 50 | ); 51 | 52 | }) 53 | 54 | test('Get Results for exact term', async () => { 55 | const st = await ticket.getSt() 56 | const search1 = new UMLSSearch(st) 57 | search1.init('fjhfsdfjlkdhgfjhb') 58 | await search1.query() 59 | const results = search1.getResults() 60 | expect(results).toBeTruthy() 61 | if (results) 62 | expect(results.length).toBeLessThan(2) 63 | }) -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | // tsconfig.json 2 | { 3 | "include": [ 4 | "src", 5 | "types" 6 | ], 7 | "compilerOptions": { 8 | "module": "esnext", 9 | "lib": [ 10 | "dom", 11 | "esnext" 12 | ], 13 | "importHelpers": true, 14 | "declaration": true, 15 | "sourceMap": true, 16 | "rootDir": "./src", 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noImplicitReturns": true, 21 | "noImplicitAny": false, 22 | "noFallthroughCasesInSwitch": true, 23 | "moduleResolution": "node", 24 | "baseUrl": "./", 25 | "paths": { 26 | "*": [ 27 | "src/*", 28 | "node_modules/*" 29 | ] 30 | }, 31 | "jsx": "react", 32 | "esModuleInterop": true 33 | } 34 | } 35 | --------------------------------------------------------------------------------