Examples

Example 1 - main diagnosis of patients

Example of list of patients with their main diagnosis. This means we want:

  • get patient ID (?id), sex (?sex), date of diagnosis (?diagDate) and diagnosis date (?code - as URI)
  • use the https://mre.zcu.cz/metadata/medical graph
  • main diagnosis has value 1 of ds:diagOrder property - used in FILTER clause.
  • order by patient's ID in an ascending order

Query in Sparkle's form-based environment is shown on the next figure.

Filed SELECT query in form elements.

Results you will see when you push Evaluate button.

Results of SELECT query listing main diagnosis of patients.

You can switch to Query tab showing generated SPARQL query in text editor with simple highlighting and auto-complete functions Ctrl + Space when query evaluated.

The generated SPARQL shown in text editor with highlighting.

The generated SELECT query in the SPARQL is:

PREFIX  xsd:  <http://www.w3.org/2001/XMLSchema#>
PREFIX  ds:   <http://mre.zcu.cz/ontology/dasta.owl#>

SELECT ?id ?sex ?diagDate ?code
FROM <https://mre.zcu.cz/metadata/medical>
WHERE
  { ?diagnosis a                       ds:ActualDiagnosis ;
               ds:diagOrder            ?diagnosisOrder ;
               ds:datetimeEvent        ?diagDate ;
               ds:diagCode             ?code .
    ?diagnosis ds:patient/ds:patientID ?id .
    ?diagnosis ds:patient/ds:sex       ?sex
    FILTER ( xsd:int(?diagnosisOrder) = "1"^^xsd:int )
  }
ORDER BY ASC(xsd:int(?id))

You can download example 1 in Sparkle's SQF.

Example 2 - properties count in RDF/RDFS

Query in Sparkle's form-based environment is shown on the next figure.

Filled SELECT query in form elements.

Results you will see when you push Evaluate button.

Results of SELECT query listing count of properties in RDF/RDFS.

You can switch to Query tab showing generated SPARQL query.

The generated SPARQL shown in text editor with highlighting.

The generated SELECT query in the SPARQL is:

SELECT ?property (COUNT(?subject) AS ?count)
WHERE
  { ?subject ?property ?object }
GROUP BY ?property
HAVING ( ?count > 50 )
ORDER BY DESC(?count)

You can download example 2 in Sparkle's SQF.