
... and standards to be.
This work is licensed under a
Creative Commons Attribution 3.0 License,
with attribution to W3C.
@prefix edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix galen: <http://www.co-ode.org/ontologies/galen#> .
@prefix snomed: <http://termhost.example/SNOMED/> .
<encounter7> edns:patient <patient3> ;
edns:screeningBP <s20090714c> .
<patient3> r:type galen:Patient ;
foaf:family_name "Levin" ;
foaf:firstName "Henry" .
<s20090714c> dc:date "2009-07-14T18:23"^^xsd:dateTime ;
edns:systolic "132"^^edns:mmHg ;
edns:diastolic "86"^^edns:mmHg .
@prefix edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix galen: <http://www.co-ode.org/ontologies/galen#> .
@prefix snomed: <http://termhost.example/SNOMED/> .
<encounter7> edns:patient <patient3> ;
edns:screeningBP <s20090714c> .
<patient3> r:type galen:Patient ;
foaf:family_name "Levin" ;
foaf:firstName "Henry" .
<s20090714c> dc:date "2009-07-14T18:23"^^xsd:dateTime ;
edns:systolic "132"^^edns:mmHg ;
edns:diastolic "86"^^edns:mmHg ;
edns:posture snomed:_163035008 . # SNOMED:sitting
(skip to new OWL)
Class(a:MGHcharlstStPatient partial a:MGHpatient)
Class(a:MGHcharlstStPatient complete
restriction(a:physician
allValuesFrom(unionOf(a:MGHcharlesStOncologist a:MGHcharlesStOptician))))_:MCSO rdfs:subClassOf :MGHpatient . _:MCSO rdfs:subClassOf _:physType . _:physType owl:onProperty :physician . _:physType owl:allValuesFrom _:list1 . _:list1 rdf:first :MGHcharlesStOncologist . _:list1 rdf:rest _:list2 . _:list2 rdf:first :MGHcharlesStOptician . _:list2 rdf:rest rdf:nil . _:MCSO owl:equivalentClass :MGHcharlstStPatient .
| subset | expressivity | |
|---|---|---|
| EL | popular restrictive subset | SNOMED-CT, NCI Thesaurus |
| QL | SQL | Entity-relationship, UML |
| RL | @@production@@ rules |
<dr>
<iriset>
<includehosts>drugsЯus.com</includehosts>
<includepathstartswith>/antidiabetic/metformin</includepathstartswith>
</iriset>
<descriptorset>
<ex:code>6809</ex:code>
</descriptorset>
</dr>
SERVICE <http://uu3.org:8888/7tm_receptors>
{
?iuphar iface:family ?family .
?iuphar iface:code ?code .
?iuphar iface:iupharName ?iupharNm .
?human iface:iuphar ?iuphar .
?human iface:geneName "GABBR1" .
?human iface:entrezGene ?humanEntrez .
}
SERVICE <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&>
{
_:gene dbp:entrezgene ?humanEntrez ;
rdfs:label ?label ;
FILTER (lang(?label) = "en")
}
GRAPH <http://hcls.deri.org/atag/data/gabab_example.html>
{
?topic rdfs:label ?label .
?post sioc:topic ?topic
}
@prefix edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix galen: <http://www.co-ode.org/ontologies/galen#> .
@prefix snomed: <http://termhost.example/SNOMED/> .
<encounter7> edns:patient <patient3> ;
edns:screeningBP <s20090714c> .
<patient3> r:type galen:Patient ;
foaf:family_name "Levin" ;
foaf:firstName "Henry" .
<s20090714c> dc:date "2009-07-14T18:23"^^xsd:dateTime ;
edns:systolic "132"^^edns:mmHg ;
edns:diastolic "86"^^edns:mmHg ;
edns:posture snomed:_163035008 . # SNOMED:sitting
PREFIX edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX galen: <http://www.co-ode.org/ontologies/galen#>
PREFIX snomed: <http://termhost.example/SNOMED/>
SELECT ?date ?systolic ?diastolic WHERE {
?encounter edns:patient ?patient ;
edns:screeningBP ?screenBP .
?patient foaf:family_name "Levin" ;
foaf:firstName "Henry" .
?screenBP dc:date ?date ;
edns:systolic ?systolic ;
edns:diastolic ?diastolic ;
} ORDER DESC BY ?date
PREFIX edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX galen: <http://www.co-ode.org/ontologies/galen#>
PREFIX snomed: <http://termhost.example/SNOMED/>
SELECT ?date ?systolic ?diastolic WHERE {
?encounter edns:patient ?patient ;
edns:screeningBP ?screenBP .
?patient foaf:family_name "Levin" ;
foaf:firstName "Henry" .
?screenBP dc:date ?date ;
edns:systolic ?systolic ;
edns:diastolic ?diastolic ;
edns:posture ?posture .
FILTER (?posture = snomed:_163035008 || ?posture = snomed:_163035009)
} ORDER DESC BY ?date
PREFIX edns: <http://www.loa-cnr.it/ontologies/ExtendedDnS.owl#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX galen: <http://www.co-ode.org/ontologies/galen#> PREFIX snomed: <http://termhost.example/SNOMED/> SELECT ?date ?systolic ?diastolic ?posture WHERE { ?encounter edns:patient ?patient ; edns:screeningBP ?screenBP . ?patient foaf:family_name "Levin" ; foaf:firstName "Henry" . ?screenBP dc:date ?date ; edns:systolic ?systolic ; edns:diastolic ?diastolic . OPTIONAL { ?screenBP edns:posture ?posture . } } ORDER DESC BY ?date
LeeF's SPARQL tutorial on Semantic Universe
Find me all the people in Tim Berners-Lee's FOAF file that have names and email addresses. Return each person's URI, name, and email address.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
WHERE {
?person foaf:name ?name .
?person foaf:mbox ?email .
}
Try it with HP's ARQ, OpenLink's Virtuoso, or Redland's Rasqal. (Expected results.)
SELECT ?patient ?dob
WHERE {
?patient sdtm:sex ?sex; sdtm:dob ?dob; …
?substAdmin sdtm:subject ?patient; sdtm:medName ?takes …
NOT EXISTS { ?contraAdmin sdtm:subject ?patient; sdtm:medName ?contra … }
}
SELECT ?patient ?dob SUM(?substAdmin) AS ?total WHERE { ?patient sdtm:sex ?sex; sdtm:dob ?dob; … ?substAdmin sdtm:subject ?patient; sdtm:medName "Illudium Phosdex" … } GROUP BY ?patient
SELECT ?patient ?dob
WHERE {
?patient sdtm:sex ?sex; sdtm:dob ?dob; …
?substAdmin sdtm:subject ?patient; sdtm:medName ?takes …
SELECT ?patient
WHERE {
?contraAdmin sdtm:subject ?patient; sdtm:medName ?contra …
} ORDER BY ?contra LIMIT 1
}
SELECT ?patient ?dob ?contraURL
WHERE {
?patient sdtm:sex ?sex; sdtm:dob ?dob; …
?substAdmin sdtm:subject ?patient; sdtm:medName ?takes …
SELECT ?patient fn:concat('http://dbpedia.org/', ?contra) AS ?contraURL
WHERE {
?contraAdmin sdtm:subject ?patient; sdtm:medName ?contra …
} ORDER BY ?contra LIMIT 1
}
SELECT ?patient ?dob
WHERE {
?patient sdtm:sex ?sex; sdtm:dob ?dob; …
?substAdmin sdtm:subject ?patient; sdtm:ingredient* [ spl:classCode ?code ] .
}
SELECT ?patient ?dob
WHERE {
?patient sdtm:sex ?sex; sdtm:dob ?dob; .
?substAdmin sdtm:subject ?patient; sdtm:medName ?takes .
SERVICE <http://drugsЯus.com/> {
?takes stdm:ingredent [ spl:classCode 6809 ] .
}
}
MUST:
INSERT {
GRAPH <http://drugsЯus.com/mmkay> {
?substAdmin sdtm:medName "Illudium Phosdex" .
}
} WHERE {
?patient sdtm:sex ?sex; sdtm:dob ?dob; .
?substAdmin sdtm:subject ?patient .
SERVICE <http://drugsЯus.com/mmkay> {
?takes stdm:ingredent [ spl:classCode 6809 ] .
}
}
<http://drugsЯus.com/> a sd:Service ; sd:language foo:Sparql10_plus_federation ; sd:entailment foo:RDFS ; sd:function fn:concat .
<> a d2r:Server;
rdfs:label "D2R Server";
d2r:baseURI <http://localhost:2020/>;
d2r:port 2020;
d2r:documentMetadata [
rdfs:comment "This comment is custom document metadata.";
];
d2r:vocabularyIncludeInstances true;
.
DROP SILENT GRAPH <request_uri>
PUT <request_uri> = CREATE SILENT GRAPH <request_uri>
… RDF payload … INSERT DATA { GRAPH <request_uri> { … RDF payload … } }
Two models:
Paul rdf:type Worker . Paul :hasFriend Andrea . Andrea rdf:type Employee . Andrea :hasFriend Caroline . Caroline rdf:type Manager .
Paul rdf:type Worker . Paul :hasFriend Simon . Simon rdf:type Employee . Simon :hasFriend Andrea . Andrea rdf:type Manager .
Query:
Paul :hasFriend _:Y . _:Y rdf:type Employee . _:Y hasFriend _:Z . _:Z rdf:type Manager .
<!DOCTYPE Document [
<!ENTITY ppl "http://example.com/people#">
<!ENTITY cpt "http://example.com/concepts#">
<!ENTITY dc "http://purl.org/dc/terms/">
<!ENTITY rif "http://www.w3.org/2007/rif#">
<!ENTITY func "http://www.w3.org/2007/rif-builtin-function#">
<!ENTITY pred "http://www.w3.org/2007/rif-builtin-predicate#">
<!ENTITY xs "http://www.w3.org/2001/XMLSchema#">
]>
<Document
xmlns="http://www.w3.org/2007/rif#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema#">
<payload>
<Group>
<id>
<Const type="&rif;iri">http://sample.org</Const>
</id>
<meta>
<Frame>
<object>
<Const type="&rif;local">pd</Const>
</object>
<slot ordered="yes">
<Const type="&rif;iri">&dc;publisher</Const>
<Const type="&rif;iri">http://www.w3.org/</Const>
</slot>
<slot ordered="yes">
<Const type="&rif;iri">&dc;date</Const>
<Const type="&xs;date">2008-04-04</Const>
</slot>
</Frame>
</meta>
<sentence>
<Forall>
<declare><Var>item</Var></declare>
<declare><Var>deliverydate</Var></declare>
<declare><Var>scheduledate</Var></declare>
<declare><Var>diffduration</Var></declare>
<declare><Var>diffdays</Var></declare>
<formula>
<Implies>
<if>
<And>
<formula>
<Atom>
<op><Const type="&rif;iri">&cpt;perishable</Const></op>
<args ordered="yes"><Var>item</Var></args>
</Atom>
</formula>
<formula>
<Atom>
<op><Const type="&rif;iri">&cpt;delivered</Const></op>
<args ordered="yes">
<Var>item</Var>
<Var>deliverydate</Var>
<Const type="&rif;iri">&ppl;John</Const>
</args>
</Atom>
</formula>
<formula>
<Atom>
<op><Const type="&rif;iri">&cpt;scheduled</Const></op>
<args ordered="yes">
<Var>item</Var>
<Var>scheduledate</Var>
</args>
</Atom>
</formula>
<formula>
<Equal>
<left><Var>diffduration</Var></left>
<right>
<External>
<content>
<Expr>
<op><Const type="&rif;iri">&func;subtract-dateTimes</Const></op>
<args ordered="yes">
<Var>deliverydate</Var>
<Var>scheduledate</Var>
</args>
</Expr>
</content>
</External>
</right>
</Equal>
</formula>
<formula>
<Equal>
<left><Var>diffdays</Var></left>
<right>
<External>
<content>
<Expr>
<op><Const type="&rif;iri">&func;days-from-duration</Const></op>
<args ordered="yes">
<Var>diffduration</Var>
</args>
</Expr>
</content>
</External>
</right>
</Equal>
</formula>
<formula>
<External>
<content>
<Atom>
<op><Const type="&rif;iri">&pred;numeric-greater-than</Const></op>
<args ordered="yes">
<Var>diffdays</Var>
<Const type="&xs;integer">10</Const>
</args>
</Atom>
</content>
</External>
</formula>
</And>
</if>
<then>
<Atom>
<op><Const type="&rif;iri">&cpt;reject</Const></op>
<args ordered="yes">
<Const type="&rif;iri">&ppl;John</Const>
<Var>item</Var>
</args>
</Atom>
</then>
</Implies>
</formula>
</Forall>
</sentence>
<sentence>
<Forall>
<declare><Var>item</Var></declare>
<formula>
<Implies>
<if>
<Atom>
<op><Const type="&rif;iri">&cpt;unsolicited</Const></op>
<args ordered="yes"><Var>item</Var></args>
</Atom>
</if>
<then>
<Atom>
<op><Const type="&rif;iri">&cpt;reject</Const></op>
<args ordered="yes">
<Const type="&rif;iri">&ppl;Fred</Const>
<Var>item</Var>
</args>
</Atom>
</then>
</Implies>
</formula>
</Forall>
</sentence>
</Group>
</payload>
</Document>
Document(
Prefix(ppl <http://example.com/people#>)
Prefix(cpt <http://example.com/concepts#>)
Prefix(dc <http://purl.org/dc/terms/>)
Prefix(rif <http://www.w3.org/2007/rif#>)
Prefix(func <http://www.w3.org/2007/rif-builtin-function#>)
Prefix(pred <http://www.w3.org/2007/rif-builtin-predicate#>)
Prefix(xs <http://www.w3.org/2001/XMLSchema#>)
(* "http://sample.org"^^rif:iri _:pd[dc:publisher -> "http://www.w3.org/"^^rif:iri
dc:date -> "2008-04-04"^^xs:date] *)
Group
(
Forall ?item ?deliverydate ?scheduledate ?diffduration ?diffdays (
cpt:reject(ppl:John ?item) :-
And(cpt:perishable(?item)
cpt:delivered(?item ?deliverydate ppl:John)
cpt:scheduled(?item ?scheduledate)
?diffduration = External(func:subtract-dateTimes(?deliverydate ?scheduledate))
?diffdays = External(func:days-from-duration(?diffduration))
External(pred:numeric-greater-than(?diffdays 10)))
)
Forall ?item (
cpt:reject(ppl:Fred ?item) :- cpt:unsolicited(?item)
)
)
)
Nothing standard... room for experimentation
Prefix ppl <http://example.com/people#>
Prefix cpt <http://example.com/concepts#>
Prefix dc <http://purl.org/dc/terms/>
Prefix rif <http://www.w3.org/2007/rif#>
Prefix func <http://www.w3.org/2007/rif-builtin-function#>
Prefix pred <http://www.w3.org/2007/rif-builtin-predicate#>
Prefix xs <http://www.w3.org/2001/XMLSchema#>
(* lt;http://sample.org> { _:pd dc:publisher lt;http://www.w3.org/>;
dc:date "2008-04-04"^^xs:date] } *)
if cpt:perishable(?item) and
cpt:delivered(?item ?deliverydate ppl:John) and
cpt:scheduled(?item ?scheduledate) and
func:days-from-duration(?deliverydate - ?scheduledate) > 10
then cpt:reject(ppl:John ?item).
if cpt:unsolicited(?item)
then cpt:reject(ppl:Fred ?item).
Slippery slope to "real" rule languages.
Not all engines can implement every feature
Some features (retract and negation) are incompatible
Forward chaining, Backward chaining
Core: common subset
BLD: (basic logic dialect) common subset of Prolog-style languages
PRD: (production rule dialect) common subset of Production Rule languages
if { ?x foaf:firstName ?first;
foaf:surname ?last }
then
{ ?x foaf:family_name ?last;
foaf:givenname ?first;
foaf:name func:string-join(?first " " ?last)
}
if { ?x foaf:name ?name } and
pred:contains(?name, " ")
then
{ ?x foaf:firstName func:string-before(?name, " ");
foaf:surname func:string-after(?name, " ")
}
if { ?p rdfs:range ?c.
?x ?p ?y }
then
{ ?y rdf:type ?c }
See OWL 2 RL in RIF
<?xml version="1.0"?>
<ClinicalDocument transformation="hl7-rim-to-pomr.xslt">
<recordTarget>
<patientRole>
<patientPatient>
<name>
<given>Henry</given>
<family>Levin</family>
</name>
<administrativeGenderCode code="M"/>
<birthTime value="19320924"/>
</patientPatient>
</patientRole>
</recordTarget>
<component>
<StructuredBody>
<Observation>
<code displayName="Cuff blood pressure"/>
<effectiveTime value="200004071430"/>
<targetSiteCode displayName="Left arm"/>
<entryRelationship typeCode="COMP">
<Observation>
<effectiveTime value="200004071530"/>
<value value="132" unit="mm[Hg]"/>
</Observation>
</entryRelationship>
</Observation>
<Observation>
<code displayName="Cuff blood pressure"/>
<effectiveTime value="200004071530"/>
<targetSiteCode displayName="Left arm"/>
<entryRelationship typeCode="COMP">
<Observation>
<code displayName="Systolic BP"/>
<effectiveTime value="200004071530"/>
<value value="135" unit="mm[Hg]"/>
</Observation>
</entryRelationship>
<entryRelationship typeCode="COMP">
<Observation>
<code displayName="Diastolic BP"/>
<effectiveTime value="200004071530"/>
<value value="88" unit="mm[Hg]"/>
</Observation>
</entryRelationship>
</Observation>
</StructuredBody>
</component>
</ClinicalDocument>
http://someheathprovider.example/patientVisits/C1#infohttp://someheathprovider.example/patientVisits/C1#infoprovider:C1 role:patient provider:P1 .provider:C1 role:patient provider:P1 .http://someheathprovider.example/roles#patientISO 8601 datetimesprovider:P1 role:birthdate "1946-11-03"^^xsd:date .
<d2r:ClassMap
d2r:type="eb:Customer"
d2r:sql="SELECT Tab_K_Kunde.KundenNr, Tab_K_Kunde.FullName,
Tab_K_Kunde.Anrede, Tab_K_Kunde_Kreditkarte.CCNo
FROM Tab_K_Kunde_Kreditkarte INNER JOIN Tab_K_Kunde ON
Tab_K_Kunde_Kreditkarte.KundenNr = Tab_K_Kunde.KundenNr;"
d2r:groupBy="Tab_K_Kunde.KundenNr"
d2r:uriPattern=
“http://example.org/customers#@@Tab_K_Kunde.KundenNr@@“>
Re-uses OWL constructs:
<d2r:ObjectPropertyBridge d2r:property="rdf:type" d2r:pattern="iswc:@@Persons.Position@@"/>
Configuration consumable as RDF (SPARQL-able).
create iri class prd:product_iri using
function OPLWEB.DBA.PRODUCT_URI (in id varchar)
returns varchar,
function OPLWEB.DBA.PRODUCT_URI_INVERSE (in id_iri varchar)
returns varchar .
Uses hardened algorithms from SQL land.
PREFIX :mydb <http://cityhospital.example/dbs>
CONSTRUCT { ?o a study:SubjectObservation .
?o study:subject ?p .
?o study:clinician ?d .
?d :foaf:name ?dName }
WHERE { ?o mydb:patient ?p .
?o mydb:doctor ?d .
?d mydb:name ?dName }
Intuitive (testable) semantics.
Named graph proliferation demands different indexes.
SELECT ?g1 ?label ?g2 ?topic WHERE
{
GRAPH ?g1
{
_:gene dbp:entrezgene ?humanEntrez ;
rdfs:label ?label ;
FILTER (lang(?label) = "en")
}
GRAPH ?g2
{
?topic rdfs:label ?label .
?post sioc:topic ?topic
}
}
| person | name | |
|---|---|---|
| <http://www.w3.org/People/karl/karl-foaf.xrdf#me> | "Karl Dubost" | <mailto:karl@w3.org> |
| <http://www.w3.org/People/Berners-Lee/card#amy> | "Amy van der Hiel" | <mailto:amy@w3.org> |
| <http://www.w3.org/People/Berners-Lee/card#edd> | "Edd Dumbill" | <mailto:edd@xmlhack.com> |
| <http://www.w3.org/People/Berners-Lee/card#dj> | "Dean Jackson" | <mailto:dean@w3.org> |
| <http://www.w3.org/People/Berners-Lee/card#edd> | "Edd Dumbill" | <mailto:edd@usefulinc.com> |
| <http://www.aaronsw.com/about.xrdf#aaronsw> | "Aaron Swartz" | <mailto:me@aaronsw.com> |
| <http://www.w3.org/People/Berners-Lee/card#i> | "Timothy Berners-Lee" | <mailto:timbl@w3.org> |
| <http://www.w3.org/People/EM/contact#me> | "Eric Miller" | <mailto:em@w3.org> |
| <http://www.w3.org/People/Berners-Lee/card#edd> | "Edd Dumbill" | <mailto:edd@xml.com> |
| <http://www.w3.org/People/Berners-Lee/card#dj> | "Dean Jackson" | <mailto:dino@grorg.org> |
| <http://www.w3.org/People/Berners-Lee/card#libby> | "Libby Miller" | <mailto:libby.miller@bristol.ac.uk> |
| <http://www.w3.org/People/Connolly/#me> | "Dan Connolly" | <mailto:connolly@w3.org> |
