Skip to content

Instantly share code, notes, and snippets.

@cyyeh
Last active November 3, 2023 03:15
Show Gist options
  • Save cyyeh/f9815e615eb221bbde1acfe1fe957eb8 to your computer and use it in GitHub Desktop.
Save cyyeh/f9815e615eb221bbde1acfe1fe957eb8 to your computer and use it in GitHub Desktop.
長庚poc
{% if context.params.rectype != 'PETscan' and
context.params.rectype != 'PETreport' and
context.params.rectype != 'PETprepare' and
context.params.rectype != 'PETinj' %}
{% error "rectype should be PETscan, PETreport, PETprepare or PETinj" %}
{% endif %}
{% set body = {"body": {"chtno": context.params.chtno, "deptNo": context.params.deptno, "recType": context.params.rectype}} %}
select
fillID,
chtno,
deptNo,
opdno,
sheetid,
recType,
recNo,
assetNo,
status,
recDate,
createUser,
createDate,
cast(detail AS json)
from
unnest(
cast(
json_parse(
{{ body | rest_api(url='https://cghasp.cgmh.org.tw/structure/Struct_IotDataQuery', method='POST') }}
)
as array(
row(
fillID varchar,
chtno varchar,
deptNo varchar,
opdno varchar,
pacsno varchar,
sheetid varchar,
recType varchar,
recNo varchar,
assetNo varchar,
status varchar,
recDate varchar,
createUser varchar,
createDate varchar,
detail array(map(varchar, varchar))
)
)
)
)
{% set body = {"body": {"chtno": context.params.chtno, "deptNo": context.params.deptno, "recType": "PETinj"}} %}
select
fillID,
chtno,
deptNo,
opdno,
sheetid,
recType,
recNo,
assetNo,
status,
recDate,
createUser,
createDate,
cast(detail AS json)
from
unnest(
cast(
json_parse(
{{ body | rest_api(url='https://cghasp.cgmh.org.tw/structure/Struct_IotDataQuery', method='POST') }}
)
as array(
row(
fillID varchar,
chtno varchar,
deptNo varchar,
opdno varchar,
pacsno varchar,
sheetid varchar,
recType varchar,
recNo varchar,
assetNo varchar,
status varchar,
recDate varchar,
createUser varchar,
createDate varchar,
detail array(map(varchar, varchar))
)
)
)
)
{% set body = {"body": {"chtno": context.params.chtno, "deptNo": context.params.deptno, "recType": "PETprepare"}} %}
select
fillID,
chtno,
deptNo,
opdno,
sheetid,
recType,
recNo,
assetNo,
status,
recDate,
createUser,
createDate,
cast(detail AS json)
from
unnest(
cast(
json_parse(
{{ body | rest_api(url='https://cghasp.cgmh.org.tw/structure/Struct_IotDataQuery', method='POST') }}
)
as array(
row(
fillID varchar,
chtno varchar,
deptNo varchar,
opdno varchar,
pacsno varchar,
sheetid varchar,
recType varchar,
recNo varchar,
assetNo varchar,
status varchar,
recDate varchar,
createUser varchar,
createDate varchar,
detail array(map(varchar, varchar))
)
)
)
)
{% set body = {"body": {"chtno": context.params.chtno, "deptNo": context.params.deptno, "recType": "PETreport"}} %}
select
fillID,
chtno,
deptNo,
opdno,
sheetid,
recType,
recNo,
assetNo,
status,
recDate,
createUser,
createDate,
cast(detail AS json)
from
unnest(
cast(
json_parse(
{{ body | rest_api(url='https://cghasp.cgmh.org.tw/structure/Struct_IotDataQuery', method='POST') }}
)
as array(
row(
fillID varchar,
chtno varchar,
deptNo varchar,
opdno varchar,
pacsno varchar,
sheetid varchar,
recType varchar,
recNo varchar,
assetNo varchar,
status varchar,
recDate varchar,
createUser varchar,
createDate varchar,
detail array(map(varchar, varchar))
)
)
)
)
{% set body = {"body": {"chtno": context.params.chtno, "deptNo": context.params.deptno, "recType": "PETscan"}} %}
select
fillID,
chtno,
deptNo,
opdno,
sheetid,
recType,
recNo,
assetNo,
status,
recDate,
createUser,
createDate,
cast(detail AS json)
from
unnest(
cast(
json_parse(
{{ body | rest_api(url='https://cghasp.cgmh.org.tw/structure/Struct_IotDataQuery', method='POST') }}
)
as array(
row(
fillID varchar,
chtno varchar,
deptNo varchar,
opdno varchar,
pacsno varchar,
sheetid varchar,
recType varchar,
recNo varchar,
assetNo varchar,
status varchar,
recDate varchar,
createUser varchar,
createDate varchar,
detail array(map(varchar, varchar))
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment