PREFIX sdtm: PREFIX spl: SELECT ?patient ?dob ?sex ?takes ?indicDate # ?indicEnd ?contra WHERE { ?patient a sdtm:Patient ; sdtm:middleName ?middleName ; sdtm:dateTimeOfBirth ?dob ; sdtm:sex ?sex . [ sdtm:subject ?patient ; sdtm:standardizedMedicationName ?takes ; # nothing by ingredient in sdtm/caBIG/... sdtm:startDateTimeOfMedication ?indicDate ; # ; sdtm:endDateTimeOfMedication ?indicEnd spl:activeIngredient [ spl:classCode 6809 ] ] . OPTIONAL { [ sdtm:subject ?patient ; sdtm:standardizedMedicationName ?contra ; sdtm:startDateTimeOfMedication ?contraDate ; # ; sdtm:endDateTimeOfMedication ?contraEnd spl:activeIngredient [ spl:classCode 11289 ] ] . } FILTER (!BOUND(?contra)) } LIMIT 30