Replies: 1 comment
-
Hello, You seem to have included the query in your mapping/obda file, the latter should only contain mappings. The obda file did not expect any SPARQL and threw an error. You should only have mappingId-s, source and target. Moreover, you need to add more mappings in order to run the desired query. You have only one mapping for diag:diagnostics which also does not look correct since you do not specify the mapped column. I do not know which columns in your tables uniquely identify pacientes and diagnosticos but for example the following mappings could work if I understood what the SQL schema is correctly (take them only as indicative and test accordingly):
You would need to continue mapping all the classes and properties you want to model. The Ontop plugin bundled Protege might be helpful for this [https://github.com/ontop/ontop/releases/tag/ontop-5.0.2](see assets) instead of having to write manually the obda file. For further information you could also have a look the detailed tutorial and a sample mapping file in the tutorial. |
Beta Was this translation helpful? Give feedback.
-
Hello!
I have an ontology of Diagnostics (prefix:diag) in which there is a class called Patients, where real patients are instantiated as individuals. There is also a class called Diagnostics, where real patient diagnoses are instantiated as individuals. There is an objectProperty (diag:diagnostico) with domain diag:Paciente and range diag:Diagnosticos. In turn, individuals of Diagnosticos have properties: datatype (diag:fecha_hora_dx: datetime, diag:paciente_id: string, diag:episodio_id: string) and objectProperty (diag:codigo_dx). The property diag:codigo_dx has domain diag:Diagnosticos and range diag:PosiblesDiagnosticos. The class diag:PosiblesDiagnosticos contains all individuals with the values that can be taken by diagnostic codes.
In SQL, I have a covid schema with a table called diagnosticos, which has columns NHC, idEpisodi, Referencia, and FechaHora. I need an OBDA file to map the SQL data to RDF.
To map the data, I will use the following conventions:
NHC = diag:paciente_id
idEpisodi = diag:episodio_id
FechaHora = diag:fecha_hora_dx
For the objectProperty diag:codigo_dx, I need to map the values of Referencia to individuals of the class diag:PosiblesDiagnosticos. The values in the Referencia column of the diagnosticos SQL table will have ICD10-CM codes (e.g., R64, I67.850, etc.). The individuals of diag:PosiblesDiagnosticos will be identified by a URI composed of 'http://ontoar.clinic.cat/ontologias/diagnosticos.owl#' + Referencia code (e.g., http://ontoar.clinic.cat/ontologias/diagnosticos.owl#I67.850).
This is the .obda file I created:
[PrefixDeclaration]
rr: http://www.w3.org/ns/r2rml#
diag: http://ontoar.clinic.cat/ontologias/diagnosticos.owl#
xsd: http://www.w3.org/2001/XMLSchema#
[MappingDeclaration] @collection [[
mappingId diagnosticos-mapping
target diag:diagnosticos a rr:TriplesMap ;
source SELECT NHC, idEpisodi, Referencia, FechaHora FROM diagnosticos
queryExtension SELECT ?paciente ?diagnostico ?fecha ?codigo WHERE {
?paciente rdf:type diag:Paciente ;
diag:paciente_id ?nhc .
?diagnostico rdf:type diag:Diagnosticos ;
diag:episodio_id ?episodio ;
diag:fecha_hora_dx ?fecha ;
diag:codigo_dx ?codigo .
FILTER(?nhc = ?paciente_id && ?episodio = ?idEpisodi)
BIND(IRI(CONCAT("http://ontoar.clinic.cat/ontologias/diagnosticos.owl#", ?codigo)) AS ?codigo_uri)
}
]]
But I get RROR reading .obda file at line: 13 MESSAGE: Unknown parameter name "queryExtension" at line: 13.
Could anyone please help me? I thought queryExtension was valid, if it's not then how could I approach this?
Beta Was this translation helpful? Give feedback.
All reactions