----
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX opmo: <file:///homes/rdanger/ontologies/opm/opmoNoURI.owl#>
PREFIX opmv: <file:///homes/rdanger/ontologies/opm/opmvNoURI.owl#>
PREFIX opmsp: <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#>
PREFIX opmlz: <http://openprovenance.org/dprovenance/example/>
select ?p ?d ?authentCertif
where{
    ?p rdf:type opmv:Process .
	?authentCertif opmo:wasGeneratedBy ?p .
	?authentCertif rdf:type <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#SAMLAssertion> .
	?p <http://openprovenance.org/dprovenance/example#processEndTime> ?d .
	FILTER ( ?d > "@DATE1@T00:00:00"^^xsd:dateTime ) .
	FILTER ( ?d < "@DATE2@T00:00:00"^^xsd:dateTime ) .
}
LIMIT 10
--
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX opmo: <file:///homes/rdanger/ontologies/opm/opmoNoURI.owl#>
PREFIX opmv: <file:///homes/rdanger/ontologies/opm/opmvNoURI.owl#>
PREFIX opmsp: <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#>
PREFIX opmlz: <http://openprovenance.org/dprovenance/example/>
select ?p ?d ?authentCertif
where{
	 ?p rdf:type opmv:Process .
	 ?authentCertif opmo:wasGeneratedBy ?p .
	 ?authentCertif rdf:type <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#SAMLAssertion> .
	 ?p <http://openprovenance.org/dprovenance/example#processEndTime> ?d .
	 FILTER ( ?d > "@DATE1@T00:00:00"^^xsd:dateTime ) 
	 FILTER ( ?d < "@DATE2@T00:00:00"^^xsd:dateTime ) .
}
---
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX opmo: <file:///homes/rdanger/ontologies/opm/opmoNoURI.owl#>
PREFIX opmv: <file:///homes/rdanger/ontologies/opm/opmvNoURI.owl#>
PREFIX opmsp: <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#>
PREFIX opmlz: <http://openprovenance.org/dprovenance/example/>
select ?p ?d ?authentCertif
where{
    ?p rdf:type opmv:Process .
	?authentCertif opmo:wasGeneratedBy ?p .
	?authentCertif rdf:type <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#SAMLAssertion> .
	?p <http://openprovenance.org/dprovenance/example#processEndTime> ?d .
	FILTER ( ?d > "@DATE@T00:00:00"^^xsd:dateTime ) .
}
----
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX opmo: <file:///homes/rdanger/ontologies/opm/opmoNoURI.owl#>
PREFIX opmv: <file:///homes/rdanger/ontologies/opm/opmvNoURI.owl#>
PREFIX opmsp: <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#>
PREFIX opmlz: <http://openprovenance.org/dprovenance/example#>
select ?EC ?nPatients
where{
	?p rdf:type <file:///homes/rdanger/ontologies/rcto/v2.0/rcto.owl#ClinicalStudyEligibilityCriteriaQueryProcess> .
	?result opmo:wasGeneratedBy ?p .
	?p opmo:used ?EC .
	?EC rdf:type <file:///homes/rdanger/ontologies/rcto/v2.0/rcto.owl#ClinicalStudyEligibilityCriteria> .
	?result <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#firstRowQueryResult> ?nPatients .
}
----
select ann.PropertyValue, OPMEntity.OPMGraphKey, sum( OPMProcess.OPMProcessEndTime - OPMProcess.OPMProcessStartTime )  from Property, Property prop, OPMProcess, OPMGraph, OPMEntity, OPMAnnotation, OPMAnnotation ann where OPMEntity.OPMGraphKey = OPMGraph.OPMGraphKey and  OPMEntity.OPMEntityKey=OPMProcessKey and  OPMProcess.OPMProcessKey = OPMAnnotation.OPMSubjectKey and  OPMAnnotation.PropertyKey = Property.propertyKey and  Property.propertyKey = 6 and  OPMAnnotation.PropertyValue LIKE '%ClinicalStudyEligibilityCriteriaEditionProcess' and  ann.PropertyKey=prop.PropertyKey and  ann.OPMSubjectKey=OPMGraph.OPMGraphKey and  prop.PropertyKey =1 and  OPMProcess.OPMProcessEndTime is not null and OPMProcess.OPMProcessStartTime is not null  group by OPMGraph.OPMGraphKey
---
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX opmo: <file:///homes/rdanger/ontologies/opm/opmoNoURI.owl#>
PREFIX opmv: <file:///homes/rdanger/ontologies/opm/opmvNoURI.owl#>
PREFIX opmsp: <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#>
PREFIX opmlz: <http://openprovenance.org/dprovenance/example#>
select ?p
where{
	?p rdf:type opmv:Process .
	?p (opmo:used|opmo:wasGeneratedBy|opmo:wasControlledBy|opmo:wasTriggeredBy|opmo:wasGeneratedFrom)* ?e .
	?e <http://openprovenance.org/dprovenance/example#value> "@ClinStudyId@"^^xsd:string .
	?p <http://openprovenance.org/dprovenance/example#processEndTime> ?d .
	FILTER ( ?d > "@DATE1@T00:00:00"^^xsd:dateTime ) .
	FILTER ( ?d < "@DATE2@T00:00:00"^^xsd:dateTime ) .
} 
LIMIT 10
---
SELECT OPMProcess.OPMProcessKey, a1.PropertyValue, OPMEntityAnnotationTime FROM OPMProcess, OPMEntity, OPMGraph, OPMAnnotation, OPMAnnotation as a1, Property, Property as p1 
WHERE OPMProcess.OPMProcessKey = OPMEntity.OPMEntityKey and OPMEntity.OPMGraphKey = OPMGraph.OPMGraphKey and  OPMAnnotation.OPMSubjectKey = OPMGraph.OPMGraphKey and OPMAnnotation.PropertyKey = Property.PropertyKey and Property.PropertyId = 'http://www.doc.ic.ac.uk/~rdanger/transform_ontologies/OPMSoftwareProfile.owl#idProject' and OPMAnnotation.PropertyValue = 'DataQualityTool' and a1.OPMSubjectKey = OPMProcess.OPMProcessKey and a1.PropertyKey = p1.PropertyKey and p1.PropertyId = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' 
LIMIT 20
---
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX opmo: <file:///homes/rdanger/ontologies/opm/opmoNoURI.owl#>
PREFIX opmv: <file:///homes/rdanger/ontologies/opm/opmvNoURI.owl#>
PREFIX opmsp: <file:///homes/rdanger/ontologies/OPMSoftwareProfile/OPMSoftwareProfile.owl#>
PREFIX opmlz: <http://openprovenance.org/dprovenance/example#>
select ?prop ?e
where{
	<@entityURI@> ?prop ?e .
}

