2017-02-10 1 views
0

SPARQLクエリを作成しようとしていますが、特定の診断コード(?ICD9)を関連付けた患者識別子コード(?Crid)特定の投薬を関連させておらず、募集日(?RecruitDate)の前に注文日(?OrderDate)を持っていないでください。私はグラフにOBIBオントロジーを組み込んだ。SPARQL特定の基準を満たしていない結果を検索するクエリ

SELECT DISTINCT ?Crid WHERE 
{?Crid a obib:CRID . 

#-- Return CRIDs with a diagnosis 
?Crid obib:hasPart ?ICD9 . 
?ICD9 a obib:diagnosis . 

#-- Return CRIDs with a medical prescription record 
?Crid obib:hasPart ?medRecord . 
?medRecord a obib:medicalRecord . 

#-- Return CRIDs with an order date 
?medRecord obib:hasPart ?OrderDate . 
?OrderDate a obib:dateOfDataEntry . 

#-- Return CRIDs with a recruitment date 
?Crid obib:hasPart ?FormFilling . 
?FormFilling a obib:formFilling . 
?RecruitDate obib:isAbout ?FormFilling . 
?RecruitDate a obib:dateOfDataEntry . 

#-- Filter results for specific ICD9 codes 
FILTER (?ICD9 = '1') 

#-- Subtract Results with Certain Medication and Order Date Prior to Recruitment 
#-- This is the part that I think is giving me a problem 
MINUS { 
    FILTER (regex (?medRecord, "medication_1", "i")) 
    FILTER (?RecruitDate-?OrderDate < "P0D"^^xsd:dayTimeDuration) 
     } 
} 

私の直感では、私が正しくMINUSを使用していないということである。ここでは

は、私がこれまで(読みやすさ/感度のために省略し、グラフを介してビット簡略化し、いくつかのステップで)持っているものです。このクエリは、のほとんどがの結果を返します。私は10の結果を期待しており、12を返しています。関連のない2つの結果は、 "medication_1"を取得し、募集日の前に注文日を持っていました。セット。

重要な場合は、Stardogエンドポイントを使用してこのクエリを実行し、グラフデータを保存しています。簡単なのだろう(私もおそらく正規表現は適切なツールがここにあるかどうかを検討したい

FILTER (!regex(?medRecord, "medication_1", "i")) 
FILTER (?RecruitDate-?OrderDate >= "P0D"^^xsd:dayTimeDuration) 

:代わりに

#-- Subtract Results with Certain Medication and Order Date Prior to Recruitment 
#-- This is the part that I think is giving me a problem 
MINUS { 
    FILTER (regex (?medRecord, "medication_1", "i")) 
    FILTER (?RecruitDate-?OrderDate < "P0D"^^xsd:dayTimeDuration) 
     } 
} 

答えて

1

私はおそらく同じようMINUSせずにこれを記述します。文字列の比較作業ですか?)、それは別の問題です。

+0

ご回答いただきありがとうございます。このアプローチの問題は、「投薬1」を受けた患者を除外し、募集日後の受注日があることです。患者を除外するには、募集日の前に「medication_1」を注文する必要があります。 – hayfreed

+1

@hayfreedしかし、どのような場合でも、MINUS自体は結果セットを返すグラフパターンです - あなたの例では、MINUS句の中でトリプルパターンを選択していないので、常に空です。 – AKSW

関連する問題