OHDSI ATLAS 구동하기
#develop, #ohdsi, #healthcare, #open-source, #data
OHDSI 공식 홈페이지 에서 Software Tools 메뉴 를 찾아보면 ATLAS 를 가장 먼저 소개하는데 CDM 데이터베이스를 구축하였으니 이제 ATLAS 를 구동해보려고 한다
실제로도 ATLAS 는 OHDSI 프로젝트의 중추라 볼 수 있다.
Wiki 를 보면 Atlas Setup Guide 페이지가 있는데, 이를 따라서 구축을 해보자.
WebAPI
Prerequisites 중 WebAPI 를 먼저 구동한다.
WebAPI Installation Guide 를 참고해보자.
미리 설치해야 하는 것들 을 체크하자.
이 중에 Maven 은 구현하려는 개발기기에, Tomcat 8 는 구동하려는 서버에 설치한다.
간단하게 가이드를 따라가보자.
- Git 으로 Clone 을 받는다.
- Create settings.xml file
- WebAPIConfig 폴더를 만들고
- sample_settings.xml 을 WebAPIConfig/settings.xml 으로 복사
- settings.xml 에서 필요한 profile 만 남기고 편집한다.
주의할 점 (PostgreSQL 사용시) 아래 항목에 구축된 CDM schema 가 아니라 새로운 schema 를 생성해서 입력해야 한다.
<datasource.ohdsi.schema>
그렇지 않은 경우 Tomcat deploy 시 아래와 같은 에러가 발생한다.
Migration V1.0.0.3__cohort_definition_persistence.sql failed
------------------------------------------------------------
SQL State : 42P07
Error Code : 0
Message : ERROR: relation "cohort_definition" already exists
Location : db/migration/postgresql/V1.0.0.3__cohort_definition_persistence.sql (/var/lib/tomcat8/webapps/WebAPI/WEB-INF/classes/db/migration/postgresql/V1.0.0.3__cohort_definition_persistence.sql)
Line : 1
Statement : CREATE TABLE synpuf5.cohort_definition(
id int NOT NULL,
name varchar(255) NOT NULL,
description varchar(1000) NULL,
expression_type varchar(50) NULL,
created_by varchar(255) NULL,
created_date Timestamp(3) NULL,
modified_by varchar(255) NULL,
modified_date Timestamp(3) NULL,
CONSTRAINT PK_cohort_definition PRIMARY KEY (id)
)
편집이 완료 되었으면, Maven 사용하여 .war 파일을 만든다.
mvn clean package -DskipTests -s WebAPIConfig/settings.xml -P webapi-postgresql
처음 시도시는 꽤 오랜 시간이 소요된다.
완료시 메세지
[INFO] Analysis done.
[INFO] Constructing Html documentation
[INFO] Your html documentation was generated in ~/Workspace/WebAPI/target/miredot
[INFO] MireDot: Completed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30:32 min
[INFO] Finished at: 2020-03-25T21:51:56+09:00
[INFO] ------------------------------------------------------------------------
.war 파일을 실제로 구동할 Tomcat 을 설치하자. (Ubuntu 기준)
$ sudo apt install tomcat8
$ sudo apt install tomcat8-docs tomcat8-examples tomcat8-admin
Tomcat 의 설정파일은 /etc/tomcat8
을 참고한다.
가이드의 C:\tomcat\webapps\manager\WEB-INF\web.xml
은 Ubuntu 를 기준으로 /usr/share/tomcat8-admin/manager/WEB-INF
에서 찾을 수 있다.
설정 후 Tomcat 을 재시작한다.
$ sudo systemctl restart tomcat8
http://server:8080/manager/html
설치한 주소로 접속하고 위에서 설정한 계정으로 로그인 할 수 있다.
로그인하면 WAR file to deploy
에서 위에서 Maven 을 통해 생성된 .war 파일을 선택하면 되는데,
WebAPI 폴더/target/WebAPI.war
를 선택하여 업로드하면 된다.
Deploy 가 완료되고 나면 http://server:8080/WebAPI/info
에서 결과를 확인할 수 있다.
이 작업을 하고 나면 기존 CDM 데이터를 연결해야 한다.
CDM Configuration for use with WebAPI 여기서 그 내용을 찾을 수 있다.
⭐️ We would highly recommend that you run Achilles to characterize your CDM data. As part of that process, you will establish a Results schema to hold the results.
아직 Achilles 는 실행하지 않았기 때문에 (다음 포스트 예정) result 를 제외하고 아래 내용을 실행한다. 샘플에서 전 포스팅에 맞추어 내용을 바꾸었다. (table_qualifier 에 관련 schema 이름을 입력해야 한다.) vocabulary 는 여러가지 데이터 소스와는 별도로 중복되지 않게 구축할 수 있을 것이라 이것도 추후 정리해서 포스팅 예정.
INSERT INTO ohdsi.source (source_id, source_name, source_key, source_connection, source_dialect) VALUES (1, ‘Synpuf5’, ‘SYNPUF5’, ‘jdbc:postgresql://server:5432/cdm?user={user}&password={password}’, ‘postgresql’);
INSERT INTO ohdsi.source_daimon (source_daimon_id, source_id, daimon_type, table_qualifier, priority) VALUES (1,1,0, ‘synpuf5’, 0);
INSERT INTO ohdsi.source_daimon (source_daimon_id, source_id, daimon_type, table_qualifier, priority) VALUES (2,1,1, ‘synpuf5’, 1);
http://server:8080/WebAPI/source/sources
에 접속하면 Daimon 이 추가 된 것을 확인할 수 있다.
여기까지 진행하면 webapi 를 설치하고 cdm data 에 연결까지 진행한 것이다.
ATLAS
이제 ATLAS 를 설치해보자. webapi 에 비해서 굉장히 단순하다.
설치해야 되는 것은 npm
과 nginx
이다.
아래와 같이 빌드를 하면 된다.
$ npm run build
Then copy all of the files from the Atlas repository to your web server including the node_modules folder (this is required to resolve all JavaScript dependencies). Set up your webserver such that the application will be reachable via a URL such as:
굳이 복사를 하진 말고 ln 명령어를 이용하여 심볼릭 링크를 걸어주자.
그리고 여기서도 설정 파일 /js/config-local.js
을 만들어야 한다.
url 에는 위에서 구동한 webapi 를 참고하여 입력하자.
atlas-server-url/atlas
로 접속하면 정상 구동된 것을 확인할 수 있다.