forked from ukf-zks-it/EURO-NMD-Registry-grlc-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kpi-ttd.rq
82 lines (71 loc) · 3 KB
/
kpi-ttd.rq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#+ summary: Returns the Key Performance Indicator of the delay between symptom onset and diagnosis. This data is aggregated by disease, and by year of diagnosis, and is measured in days.
#+ tags:
#+ - KPI diagnosis-delay
#+ defaults:
#+
#+ endpoint_in_url: False
PREFIX sio: <http://semanticscience.org/resource/>
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 ofn: <http://www.ontotext.com/sparql/functions/>
################################################################
# list diagnosis and time from onset to diagnosis
################################################################
SELECT DISTINCT
?ORDO
?yearOfDiagnosis
(xsd:integer(ROUND(AVG(?timeOnsetToDiagnosis))) as ?avgoffset)
WHERE {
BIND(xsd:integer(ofn:asDays(?dateOfDiagnosis - ?dateOfOnset)) AS ?timeOnsetToDiagnosis)
BIND(SUBSTR(str(?dateOfDiagnosis), 1,4) AS ?yearOfDiagnosis)
{
SELECT DISTINCT
?idValue
?dateOfDiagnosis
WHERE {
?id sio:SIO_000020 ?role; #denotes
sio:SIO_000300 ?idValue. #has-value
?role sio:SIO_000356 ?process. #is-realized-in
# diagnosis
?process rdfs:label ?processLabel;
sio:SIO_000229 ?processOutput. #has-output
?processOutput rdfs:label ?processOutputLabel;
rdf:type ?processOutputType.
?processOutput sio:SIO_000300 ?dateOfDiagnosis. #has-value
BIND(BOUND(?processLabel) && strlen(?processLabel)>0 as ?checkDiagnosis).
FILTER (?processLabel = 'Process: Diagnosis date recording process' || !BOUND(?processLabel)).
FILTER (?processOutputType != <http://semanticscience.org/resource/SIO_000015>).
}}
{
SELECT
?idValue
?dateOfOnset
WHERE {
?id sio:SIO_000020 ?role; #denotes
sio:SIO_000300 ?idValue. #has-value
?role sio:SIO_000356 ?process. #is-realized-in
?process rdfs:label ?processLabel;
sio:SIO_000229 ?processOutput. #has-output
?processOutput rdfs:label ?processOutputLabel;
rdf:type ?processOutputType.
?processOutput sio:SIO_000300 ?dateOfOnset. #has-value
BIND(BOUND(?processLabel) && strlen(?processLabel)>0 as ?checkOnset).
FILTER (?processLabel = 'Process: Symptom onset date recording process' || !BOUND(?processLabel)).
FILTER (?processOutputType != <http://semanticscience.org/resource/SIO_000015>).
}}
{
SELECT
?idValue
?ORDO
WHERE {
?id sio:SIO_000020 ?role; #denotes
sio:SIO_000300 ?idValue. #has-value
?entity sio:SIO_000228 ?role; #has-role
sio:SIO_000008 ?attribute. #has-attribute
?output sio:SIO_000628 ?attribute. #refers-to
?attribute rdf:type ?ORDO.
?role rdfs:label ?roleLabel.
FILTER (contains(xsd:string(?ORDO), 'ORDO')).
}}
} group by ?ORDO ?yearOfDiagnosis order by ?yearOfDiagnosis ?ORDO