2019年12月9日 星期一

RESTfulServer安裝設定

                                RESTfulServer安裝設定

  • FHIR_RESTfulAPI功能介紹
  • RESTfulServer_HapiFHIR安裝與設定

    • Oracle JDK8 Install
    • Apache Maven 3.6.3 Install
    • IntelliJ IDEA Install (下載專案)
    • hapi-jpaserver start

RESTfulServer開發主要分成前端的Web App跟後端的Api Server,FB所開發的GraphQL能解決Restful Api資料結構過於分散的問題,後續會開篇章節來詳盡介紹GraphQL指令語法,運用Client API從RESTfulServer下載資料。
  • Restful Api是由三種元件組成的,Nouns、Verb和Content-Types。
    1. Nouns 名詞:用來定義Api接口的網址 URL,每一個Nouns代表著一個Data資源,每一個資源僅有一個唯一的識別位置,例如查詢patirnt的Data,那麼api接口的URL可以會為https://server/path/Patient。
    2. Verbs 動詞:描述了對 Nouns 名詞 (資源 URL) 的操作動作,在 HTTP 1.1 的實作當然就是 HTTP Method。所以對Data的操作動作就是用HTTP的Method,例如Get、Post、Put、Patch、Delete。Web Server必須使用HTTP Method來與Client互動,例如展示某個Nouns名詞內的資料用Get,新增資料時用Post,修改用Put或Patch,刪除則用Delete。
    3. Content Types 資源呈現方式:比如取得某一個 URL 文章的 HTML 格式,常見的格式有JSON、XML、YAML等等,比較常用的是輕量JSON,可以傳送互動式網頁所需的資料,很適合HTTP的傳輸, URL 資源可以由不同型態方式表現。通常Web Server接受的HTTP Response後會透過HTTP Header中的content-type去查看response的資料格式,並呼叫對應的function去解析資料內容,這個動作稱作序列化(Serialization),將一般的檔案格式轉化成,程式語言可以使用的資料結構,例如Array或Hash。
  • 適用FHIR的兩種RESTfulServer介紹


    連結網址https://test.fhir.org/


     連結網址 http://fhirtest.uhn.ca/home


Oracle JDK 8 on Ubuntu Install 

Step1:Download the latest JDK(jdk-8u231-linux-x64.tar.gz) from this official site


Step2:Open the terminal (Ctrl + Alt + T)
sudo mkdir /usr/lib/jvm

Step3:Enter the following command to change the directory.

cd /usr/lib/jvm

Step4:Extract the jdk-8u231-linux-x64.tar.gz file in that directory using this command

sudo tar -xvzf ~/Downloads/jdk-8u231-linux-x64.tar.gz

Step5:Enter the following command to open the environment variables file.

sudo gedit /etc/environment
Step6:In the opened file, add the following bin folders to the existing PATH variable.


/usr/lib/jvm/jdk1.8.0_231/bin
/usr/lib/jvm/jdk1.8.0_231/db/bin
/usr/lib/jvm/jdk1.8.0_231/jre/bin
Notice that the installed JDK version is 1.8 update 231. Depending on your JDK version, the paths can be different.


Add the following environment variables at the end of the file.
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_231/bin:/usr/lib/jvm/jdk1.8.0_231/db/bin:/usr/lib/jvm/jdk1.8.0_231/jre/bin"
J2SDKDIR="/usr/lib/jvm/jdk1.8.0_231"
J2REDIR="/usr/lib/jvm/jdk1.8.0_231/jre"
JAVA_HOME="/usr/lib/jvm/jdk1.8.0_231"
DERBY_HOME="/usr/lib/jvm/jdk1.8.0_231/db"

Step7:

Enter the following commands to inform the system about the Java's location. Depending on your JDK version, the paths can be different.


sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_231/bin/java" 0



sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_231/bin/javac" 0



sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_231/bin/java



sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_231/bin/javac

Step8:

To verify the setup enter the following commands and make sure that they print the location of java and javac as you have provided in the previous step.



update-alternatives --list java



update-alternatives --list javac




Step9:
Restart the computer (or just log-out and login) and open the terminal again.
Enter the following command.


java -version

JAVA_HOME環境變數設定

export PATH=$PATH:/usr/lib/jvm/jdk1.8.0_231/bin:/usr/lib/jvm/jdk1.8.0_231/db/bin:/usr/lib/jvm/jdk1.8.0_231/jr

export J2SDKDIR=/usr/lib/jvm/jdk1.8.0_231
export J2REDIR=/usr/lib/jvm/jdk1.8.0_231/jre
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_231



Apache Maven 3.6.3 Install


    Step1: Download Apache Maven 3.6.3 


   
  Step2: 
     1) Unix-based Operating Systems (Linux, Solaris and Mac OS X)
          root#tar zxvf apache-maven-3.0.x.tar.gz
     2) Make sure JAVA_HOME is set to the location of your JDK
     3) Run "mvn --version" to verify that it is correctly installed.

   
  Step3:建立的專案產生target資料夾,並編譯class使專案處於“已編譯”狀態。

    maven定義的生命週期中主要的相位如下:
    1).validate: 驗證專案及相關資訊是否可用。
    2).compile: class程式碼編譯。
    3).test: 進行單元測試。
    4).package: 根據事先指定的格式(比如jar),進行打包。
    5).integration-test: 部署到執行環境中,準備整合測試。
    6).verify: 進行有效性性和質量檢查。
    7).install: 安裝到原生代碼庫。
    8).deploy: 在整合或釋出環境,將包釋出到遠端程式碼庫。

   在“預設”的生命週期之外,還有兩個“階段”,但已完成單元測試後均不會使用:
    1).clean: 清除以前的構建物。
    2).site: 生成專案文件。


我們先從使用HAPI的JPA服務器模塊的範例項目開始安裝測試。

Step1:在GitHub找到hapi-fhir-jpaserver-starter下載後解壓縮。
Step2:進入該資料夾後輸入以下安裝指令(記住資料夾必須為chomd 777可讀寫執行)
$ cd hapi-fhir-jpaserver-example
$ mvn install

Step3:接著在執行啟動Maven伺服服務
$ mvn jetty:run

Step4:通過將瀏覽器指向以下URL來訪問服務器 http://localhost:8080/hapi-fhir-jpaserver/






沒有留言:

ACCESS資料成功轉換SQlite方法

最近忙於系統開發研究,今日來談一下有朋友很有才華自行利用ACCESS開發了CRM(客戶關係管理)系統,但僅限於個人使用考量目前大量使用者成長與需求,洽詢我是否能技術支援同時給了我ACCESS檔案參考,但因電腦OFFICE沒有ACCESS可開啟.accdb檔案,相信有許多微軟OFF...