以下是測試環境的版本
版本 | 備註 | |
---|---|---|
FHIR版本 | R4 | 目前最常用的版本,衛福部IG使用 |
HAPI FHIR Server版本 | 7.2.1 | |
JAVA | 11 | |
PostgreSQL | 15.1 |
先到HAPI FHIR Server的jpaserver部分的Github下載程式碼
https://github.com/hapifhir/hapi-fhir-jpaserver-starter
File --> New --> Project-from-Version-Control --> Git
Clone Repository
執行Application
Tips:
執行時可能會出現的錯誤:
“Error running 'Application': Command line is too long. Shorten command line for Application or also for Spring Boot default configuration”
解決方法:
https://blog.csdn.net/lzc4869/article/details/88912161
Description:
Web application could not be started as there was no org.springframework.boot.web.servlet.server.ServletWebServerFactory bean defined in the context.
添加依賴:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.5</version>
</dependency>
2.修改連接資料庫
若要連接PostgreSQL資料庫,需要修改application.yaml。
因為預設是連接H2 database,所以要將spring.datasource改為使用PostgreSQL的Driver。(在執行main function前需要先在本地安裝PostgreSQL資料庫)
application.yaml
spring:
main:
allow-circular-references: true
#allow-bean-definition-overriding: true
flyway:
enabled: false
check-location: false
baselineOnMigrate: true
datasource:
url: 'jdbc:postgresql://localhost:5432/hapi'
username: postgres
password: root
driverClassName: org.postgresql.Driver
jpa:
properties:
hibernate.Dialect: ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect
重新執行後即會創建table,成功執行就代表HAPI FHIR Server搭建完成。
使用postman測試,在requestbody輸入測試資料,測試成功後代表HAPI FHIR Server可運行。
範例:
Patient:
url : http://localhost:8080/fhir/Patient/
Post
{
"resourceType" : "Patient",
"id" : "example",
"text" : {
"status" : "generated",
"div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p style=\"border: 1px #661aff solid; background-color: #e6e6ff; padding: 10px;\"><b>Jim </b> male, DoB: 1974-12-25 ( Medical record number: 12345 (use: USUAL, period: 2001-05-06 --> (ongoing)))</p><hr/><table class=\"grid\"><tr><td style=\"background-color: #f3f5da\" title=\"Record is active\">Active:</td><td>true</td><td style=\"background-color: #f3f5da\" title=\"Known status of Patient\">Deceased:</td><td colspan=\"3\">false</td></tr><tr><td style=\"background-color: #f3f5da\" title=\"Alternate names (see the one above)\">Alt Names:</td><td colspan=\"3\"><ul><li>Peter James Chalmers (OFFICIAL)</li><li>Peter James Windsor (MAIDEN)</li></ul></td></tr><tr><td style=\"background-color: #f3f5da\" title=\"Ways to contact the Patient\">Contact Details:</td><td colspan=\"3\"><ul><li>-unknown-(HOME)</li><li>ph: (03) 5555 6473(WORK)</li><li>ph: (03) 3410 5613(MOBILE)</li><li>ph: (03) 5555 8834(OLD)</li><li>534 Erewhon St PeasantVille, Rainbow, Vic 3999(HOME)</li></ul></td></tr><tr><td style=\"background-color: #f3f5da\" title=\"Nominated Contact: Next-of-Kin\">Next-of-Kin:</td><td colspan=\"3\"><ul><li>Bénédicte du Marché (female)</li><li>534 Erewhon St PleasantVille Vic 3999 (HOME)</li><li><a href=\"tel:+33(237)998327\">+33 (237) 998327</a></li><li>Valid Period: 2012 --> (ongoing)</li></ul></td></tr><tr><td style=\"background-color: #f3f5da\" title=\"Patient Links\">Links:</td><td colspan=\"3\"><ul><li>Managing Organization: <a href=\"organization-example-gastro.html\">Organization/1</a> "Gastroenterology"</li></ul></td></tr></table></div>"
},
"identifier" : [{
"use" : "usual",
"type" : {
"coding" : [{
"system" : "http://terminology.hl7.org/CodeSystem/v2-0203",
"code" : "MR"
}]
},
"system" : "urn:oid:1.2.36.146.595.217.0.1",
"value" : "12345",
"period" : {
"start" : "2001-05-06"
},
"assigner" : {
"display" : "Acme Healthcare"
}
}],
"active" : true,
"name" : [{
"use" : "official",
"family" : "Chalmers",
"given" : ["Peter",
"James"]
},
{
"use" : "usual",
"given" : ["Jim"]
},
{
"use" : "maiden",
"family" : "Windsor",
"given" : ["Peter",
"James"],
"period" : {
"end" : "2002"
}
}],
"telecom" : [{
"use" : "home"
},
{
"system" : "phone",
"value" : "(03) 5555 6473",
"use" : "work",
"rank" : 1
},
{
"system" : "phone",
"value" : "(03) 3410 5613",
"use" : "mobile",
"rank" : 2
},
{
"system" : "phone",
"value" : "(03) 5555 8834",
"use" : "old",
"period" : {
"end" : "2014"
}
}],
"gender" : "male",
"birthDate" : "1974-12-25",
"_birthDate" : {
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime" : "1974-12-25T14:35:45-05:00"
}]
},
"deceasedBoolean" : false,
"address" : [{
"use" : "home",
"type" : "both",
"text" : "534 Erewhon St PeasantVille, Rainbow, Vic 3999",
"line" : ["534 Erewhon St"],
"city" : "PleasantVille",
"district" : "Rainbow",
"state" : "Vic",
"postalCode" : "3999",
"period" : {
"start" : "1974-12-25"
}
}],
"contact" : [{
"relationship" : [{
"coding" : [{
"system" : "http://terminology.hl7.org/CodeSystem/v2-0131",
"code" : "N"
}]
}],
"name" : {
"family" : "du Marché",
"_family" : {
"extension" : [{
"url" : "http://hl7.org/fhir/StructureDefinition/humanname-own-prefix",
"valueString" : "VV"
}]
},
"given" : ["Bénédicte"]
},
"telecom" : [{
"system" : "phone",
"value" : "+33 (237) 998327"
}],
"address" : {
"use" : "home",
"type" : "both",
"line" : ["534 Erewhon St"],
"city" : "PleasantVille",
"district" : "Rainbow",
"state" : "Vic",
"postalCode" : "3999",
"period" : {
"start" : "1974-12-25"
}
},
"gender" : "female",
"period" : {
"start" : "2012"
}
}]
}
Observation
url : http://localhost:8080/fhir/Observation/
Post
{
"resourceType": "Observation",
"id": "F111111111",
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
]
},
{
"text": "Vital Signs"
}
],
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "85354-9",
"display": "Blood pressure panel with all children optional"
}
],
"text": "Blood pressure systolic & diastolic"
},
"component": [
{
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8480-6",
"display": "Systolic blood pressure"
}
]
},
"valueQuantity": {
"value": 77,
"unit": "mmHg",
"system": "http://unitsofmeasure.org",
"code": "mm[Hg]"
}
},
{
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8462-4",
"display": "Diastolic blood pressure"
}
]
},
"valueQuantity": {
"value": 119,
"unit": "mmHg",
"system": "http://unitsofmeasure.org",
"code": "mm[Hg]"
}
}
]
}
Tips:
FHIR Resource會儲存於hfj_resource table
FHIR Server支援版本控制,儲存各版本Resource的table是hfj_res_ver
HAPI FHIR Server文件
https://hapifhir.io/hapi-fhir/docs/
HAPI FHIR Server Global Tester
http://hapi.fhir.org/
HL7 FHIR
https://hl7.org/fhir/
臺灣核心實作指引(TW Core IG)
https://twcore.mohw.gov.tw/ig/