@prefix fhir: <http://hl7.org/fhir/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

<http://hl7.org/fhir/uv/dap/Permission/example-exclude> a fhir:Permission ;
  fhir:resourceDefinition http://hl7.org/fhir/StructureDefinition/Permission|1.0.0-current ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:id [ fhir:v "example-exclude"] ; # 
  fhir:meta [
     fhir:security ( [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/v3-ActReason"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/v3-ActReason>
       ] ;
       fhir:code [ fhir:v "HTEST" ]
     ] )
  ] ; # 
  fhir:language [ fhir:v "en"] ; # 
  fhir:text [
     fhir:status [ fhir:v "generated" ] ;
     fhir:div [ fhir:v "<div xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"><p class=\"res-header-id\"><b>Generated Narrative: Permission example-exclude</b></p><a name=\"example-exclude\"> </a><a name=\"hcexample-exclude\"> </a><div style=\"display: inline-block; background-color: #d9e0e7; padding: 6px; margin: 4px; border: 1px solid #8da1b4; border-radius: 5px; line-height: 60%\"><p style=\"margin-bottom: 0px\">Language: en</p><p style=\"margin-bottom: 0px\">Security Label: test health data (Details: ActReason code HTEST = 'test health data')</p></div><p><b>status</b>: Active</p><p><b>asserter</b>: <a href=\"Organization-ex-organization.html\">Organization nowhere</a></p><p><b>date</b>: 2023-11-22</p><p><b>combining</b>: Deny-unless-permit</p><blockquote><p><b>rule</b></p><p><b>type</b>: Permit</p><blockquote><p><b>activity</b></p><p><b>action</b>: <span title=\"Codes:{http://hl7.org/fhir/audit-event-action C}\">Create</span>, <span title=\"Codes:{http://hl7.org/fhir/audit-event-action R}\">Read</span>, <span title=\"Codes:{http://hl7.org/fhir/audit-event-action U}\">Update</span>, <span title=\"Codes:{http://hl7.org/fhir/audit-event-action D}\">Delete</span>, <span title=\"Codes:{http://hl7.org/fhir/audit-event-action E}\">Execute</span></p><p><b>purpose</b>: <span title=\"Codes:{http://terminology.hl7.org/CodeSystem/v3-ActReason HDIRECT}\">directory</span>, <span title=\"Codes:{http://terminology.hl7.org/CodeSystem/v3-ActReason HSYSADMIN}\">health system administration</span></p></blockquote></blockquote><blockquote><p><b>rule</b></p><p><b>type</b>: Permit</p><blockquote><p><b>activity</b></p><p><b>action</b>: <span title=\"Codes:{http://hl7.org/fhir/audit-event-action R}\">Read</span>, <span title=\"Codes:{http://hl7.org/fhir/audit-event-action E}\">Execute</span></p><p><b>purpose</b>: <span title=\"Codes:{http://terminology.hl7.org/CodeSystem/v3-ActReason TREAT}\">treatment</span>, <span title=\"Codes:{http://terminology.hl7.org/CodeSystem/v3-ActReason HPAYMT}\">healthcare payment</span>, <span title=\"Codes:{http://terminology.hl7.org/CodeSystem/v3-ActReason HOPERAT}\">healthcare operations</span></p></blockquote><h3>Limits</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Tag</b></td></tr><tr><td style=\"display: none\">*</td><td><a href=\"http://terminology.hl7.org/6.5.0/CodeSystem-v3-ActCode.html#v3-ActCode-LOCIS\">ActCode: LOCIS</a> (location information sensitivity)</td></tr></table></blockquote><blockquote><p><b>rule</b></p><p><b>type</b>: Permit</p><blockquote><p><b>data</b></p><h3>Expressions</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Description</b></td><td><b>Language</b></td><td><b>Expression</b></td></tr><tr><td style=\"display: none\">*</td><td>select all Practitioner resources where the Practitioner has a PractitionerRole with code of doctor</td><td>application/x-fhir-query</td><td>Practitioner?_has:PractitionerRole:practitioner:role=http://terminology.hl7.org/CodeSystem/practitioner-role|doctor</td></tr></table></blockquote><blockquote><p><b>activity</b></p><p><b>action</b>: <span title=\"Codes:{http://hl7.org/fhir/audit-event-action R}\">Read</span>, <span title=\"Codes:{http://hl7.org/fhir/audit-event-action E}\">Execute</span></p><p><b>purpose</b>: <span title=\"Codes:{http://terminology.hl7.org/CodeSystem/v3-ActReason PATRQT}\">patient requested</span></p></blockquote><h3>Limits</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Tag</b></td></tr><tr><td style=\"display: none\">*</td><td><a href=\"http://terminology.hl7.org/6.5.0/CodeSystem-v3-ActCode.html#v3-ActCode-LOCIS\">ActCode: LOCIS</a> (location information sensitivity)</td></tr></table></blockquote></div>"^^rdf:XMLLiteral ]
  ] ; # 
  fhir:status [ fhir:v "active"] ; # 
  fhir:asserter [
     fhir:l <http://hl7.org/fhir/uv/dap/Organization/ex-organization> ;
     fhir:reference [ fhir:v "Organization/ex-organization" ]
  ] ; # 
  fhir:date ( [ fhir:v "2023-11-22"^^xsd:date] ) ; # 
  fhir:combining [ fhir:v "deny-unless-permit"] ; #  combining rule is deny-unless-permit, ANY permit authorizes access, so rules do not need to be exhaustively processed, but if no permit is found then access is denied.
  fhir:rule ( [
     fhir:type [ fhir:v "permit" ] ; #  rule is #permit for administrative actions on the directory. This enables maintenance by those with directory admin authorization 
     fhir:activity ( [
       fhir:action ( [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://hl7.org/fhir/audit-event-action"^^xsd:anyURI ;
             fhir:l <http://hl7.org/fhir/audit-event-action>
           ] ;
           fhir:code [ fhir:v "C" ]
         ] )
       ] [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://hl7.org/fhir/audit-event-action"^^xsd:anyURI ;
             fhir:l <http://hl7.org/fhir/audit-event-action>
           ] ;
           fhir:code [ fhir:v "R" ]
         ] )
       ] [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://hl7.org/fhir/audit-event-action"^^xsd:anyURI ;
             fhir:l <http://hl7.org/fhir/audit-event-action>
           ] ;
           fhir:code [ fhir:v "U" ]
         ] )
       ] [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://hl7.org/fhir/audit-event-action"^^xsd:anyURI ;
             fhir:l <http://hl7.org/fhir/audit-event-action>
           ] ;
           fhir:code [ fhir:v "D" ]
         ] )
       ] [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://hl7.org/fhir/audit-event-action"^^xsd:anyURI ;
             fhir:l <http://hl7.org/fhir/audit-event-action>
           ] ;
           fhir:code [ fhir:v "E" ]
         ] )
       ] ) ;
       fhir:purpose ( [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://terminology.hl7.org/CodeSystem/v3-ActReason"^^xsd:anyURI ;
             fhir:l <http://terminology.hl7.org/CodeSystem/v3-ActReason>
           ] ;
           fhir:code [ fhir:v "HDIRECT" ]
         ] )
       ] [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://terminology.hl7.org/CodeSystem/v3-ActReason"^^xsd:anyURI ;
             fhir:l <http://terminology.hl7.org/CodeSystem/v3-ActReason>
           ] ;
           fhir:code [ fhir:v "HSYSADMIN" ]
         ] )
       ] )
     ] )
  ] [
     fhir:type [ fhir:v "permit" ] ; #  When anyone that has TPO authority accesses the directory, they get access to all entries in the directory, but any data marked as Location Sensitive is excluded. Presumes Practitioner resources are tagged at the element level following DS4P Inline Security Labels that indicate the sensitive location elements using the LOCIS tag 
     fhir:activity ( [
       fhir:action ( [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://hl7.org/fhir/audit-event-action"^^xsd:anyURI ;
             fhir:l <http://hl7.org/fhir/audit-event-action>
           ] ;
           fhir:code [ fhir:v "R" ]
         ] )
       ] [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://hl7.org/fhir/audit-event-action"^^xsd:anyURI ;
             fhir:l <http://hl7.org/fhir/audit-event-action>
           ] ;
           fhir:code [ fhir:v "E" ]
         ] )
       ] ) ;
       fhir:purpose ( [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://terminology.hl7.org/CodeSystem/v3-ActReason"^^xsd:anyURI ;
             fhir:l <http://terminology.hl7.org/CodeSystem/v3-ActReason>
           ] ;
           fhir:code [ fhir:v "TREAT" ]
         ] )
       ] [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://terminology.hl7.org/CodeSystem/v3-ActReason"^^xsd:anyURI ;
             fhir:l <http://terminology.hl7.org/CodeSystem/v3-ActReason>
           ] ;
           fhir:code [ fhir:v "HPAYMT" ]
         ] )
       ] [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://terminology.hl7.org/CodeSystem/v3-ActReason"^^xsd:anyURI ;
             fhir:l <http://terminology.hl7.org/CodeSystem/v3-ActReason>
           ] ;
           fhir:code [ fhir:v "HOPERAT" ]
         ] )
       ] )
     ] ) ;
     fhir:limit ( [
       fhir:tag ( [
         fhir:system [
           fhir:v "http://terminology.hl7.org/CodeSystem/v3-ActCode"^^xsd:anyURI ;
           fhir:l <http://terminology.hl7.org/CodeSystem/v3-ActCode>
         ] ;
         fhir:code [ fhir:v "LOCIS" ]
       ] )
     ] )
  ] [
     fhir:type [ fhir:v "permit" ] ; #  When a Patient accesses the directory, it will be with PurposeOfUse of PATRQT. They only get access to Doctors, and only non-sensitive data. So not access to kitchen staff, janitor, nurses, etc. 
     fhir:data ( [
       fhir:expression [
         fhir:description [ fhir:v "select all Practitioner resources where the Practitioner has a PractitionerRole with code of doctor" ] ;
         fhir:language [ fhir:v "application/x-fhir-query" ] ;
         fhir:expression [ fhir:v "Practitioner?_has:PractitionerRole:practitioner:role=http://terminology.hl7.org/CodeSystem/practitioner-role|doctor" ]
       ]
     ] ) ;
     fhir:activity ( [
       fhir:action ( [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://hl7.org/fhir/audit-event-action"^^xsd:anyURI ;
             fhir:l <http://hl7.org/fhir/audit-event-action>
           ] ;
           fhir:code [ fhir:v "R" ]
         ] )
       ] [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://hl7.org/fhir/audit-event-action"^^xsd:anyURI ;
             fhir:l <http://hl7.org/fhir/audit-event-action>
           ] ;
           fhir:code [ fhir:v "E" ]
         ] )
       ] ) ;
       fhir:purpose ( [
         fhir:coding ( [
           fhir:system [
             fhir:v "http://terminology.hl7.org/CodeSystem/v3-ActReason"^^xsd:anyURI ;
             fhir:l <http://terminology.hl7.org/CodeSystem/v3-ActReason>
           ] ;
           fhir:code [ fhir:v "PATRQT" ]
         ] )
       ] )
     ] ) ;
     fhir:limit ( [
       fhir:tag ( [
         fhir:system [
           fhir:v "http://terminology.hl7.org/CodeSystem/v3-ActCode"^^xsd:anyURI ;
           fhir:l <http://terminology.hl7.org/CodeSystem/v3-ActCode>
         ] ;
         fhir:code [ fhir:v "LOCIS" ]
       ] )
     ] )
  ] ) . # 

<http://hl7.org/fhir/uv/dap/Organization/ex-organization> a fhir:Uv .

# -------------------------------------------------------------------------------------

