@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 sct: <http://snomed.info/id/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

<http://hl7.org/fhir/Bundle/example-anon0> a fhir:Bundle ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:id [ fhir:v "example-anon0"] ; # 
  fhir:meta [
     fhir:lastUpdated [ fhir:v "2014-08-18T01:43:30Z"^^xsd:dateTime ] ;
     fhir:security ( [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/v3-Confidentiality"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/v3-Confidentiality>
       ] ; #   Bundle confidentiality at high water mark of most sensitive  
       fhir:code [ fhir:v "V" ]
     ] [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/v3-ObservationValue"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/v3-ObservationValue>
       ] ;
       fhir:code [ fhir:v "PSEUDED" ]
     ] )
  ] ; #   a search bundle on anon0 patient by a HIGHLY Priviliaged User that is authorized to see linkage  
  fhir:type [ fhir:v "searchset"] ; # 
  fhir:link ( [
     fhir:relation [ fhir:v "self" ] ;
     fhir:url [
       fhir:v "https://example.com/fhir/Patient/anon0/$everything"^^xsd:anyURI ;
       fhir:l <https://example.com/fhir/Patient/anon0/$everything>
     ]
  ] ) ; # 
  fhir:entry ( [
     fhir:fullUrl [
       fhir:v "http://example.org/fhir/Provenance/anon0"^^xsd:anyURI ;
       fhir:l <http://example.org/fhir/Provenance/anon0>
     ] ;
     fhir:resource ( <http://example.org/fhir/Provenance/anon0> ) ;
     fhir:search [
       fhir:mode [ fhir:v "match" ]
     ]
  ] [
     fhir:fullUrl [
       fhir:v "http://example.org/fhir/Patient/anon0"^^xsd:anyURI ;
       fhir:l <http://example.org/fhir/Patient/anon0>
     ] ;
     fhir:resource ( <http://example.org/fhir/Patient/anon0> ) ;
     fhir:search [
       fhir:mode [ fhir:v "match" ]
     ]
  ] [
     fhir:fullUrl [
       fhir:v "http://example.org/fhir/Condition/anon0"^^xsd:anyURI ;
       fhir:l <http://example.org/fhir/Condition/anon0>
     ] ;
     fhir:resource ( <http://example.org/fhir/Condition/anon0> ) ;
     fhir:search [
       fhir:mode [ fhir:v "match" ]
     ]
  ] ) . # 

<http://example.org/fhir/Provenance/anon0> a fhir:Provenance ;
  fhir:id [ fhir:v "anon0"] ; #   This Provenance shows a link between real-world and anon for a given patient  
  fhir:meta [
     fhir:security ( [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/v3-Confidentiality"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/v3-Confidentiality>
       ] ; #   Provenance is the link between real-world and anon, so is highest possible confidentiality  
       fhir:code [ fhir:v "V" ]
     ] [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/v3-ObservationValue"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/v3-ObservationValue>
       ] ;
       fhir:code [ fhir:v "PSEUDED" ]
     ] )
  ] ; # 
  fhir:text [
     fhir:status [ fhir:v "generated" ] ;
     fhir:div [ fhir:v "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: Provenance anon0</b></p><a name=\"anon0\"> </a><a name=\"hcanon0\"> </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\"/><p style=\"margin-bottom: 0px\">Security Labels: very restricted (Details: Confidentiality code V = 'very restricted'), pseudonymized (Details: ObservationValue code PSEUDED = 'pseudonymized')</p></div><p>Provenance for <a href=\"broken-link.html\">http://example.org/fhir/Patient/anon0</a></p><p>Summary</p><table class=\"grid\"><tr><td>Recorded</td><td>2015-06-27T08:39:24+10:00</td></tr><tr><td>Policy</td><td><a href=\"broken-link.html\">http://example.org/policies/666</a></td></tr><tr><td>Activity</td><td><span title=\"Codes:{http://terminology.hl7.org/CodeSystem/iso-21089-lifecycle deidentify}\">De-Identify (Anononymize) Record Lifecycle Event</span></td></tr></table><p><b>Agents</b></p><table class=\"grid\"><tr><td><b>Type</b></td><td><b>who</b></td></tr><tr><td><span title=\"Codes:{http://terminology.hl7.org/CodeSystem/provenance-participant-type assembler}\">Assembler</span></td><td>Device/software</td></tr></table></div>"^^rdf:XMLLiteral ]
  ] ; # 
  fhir:target ( [
     fhir:l <http://example.org/fhir/Patient/anon0> ;
     fhir:reference [ fhir:v "http://example.org/fhir/Patient/anon0" ]
  ] ) ; # 
  fhir:recorded [ fhir:v "2015-06-27T08:39:24+10:00"^^xsd:dateTime] ; # 
  fhir:policy ( [
     fhir:v "http://example.org/policies/666"^^xsd:anyURI ;
     fhir:l <http://example.org/policies/666>
  ] ) ; #   policy would indicate the rules used for De-Identification, and appropriate purposes of use of the data  
  fhir:activity [
     fhir:coding ( [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/iso-21089-lifecycle"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/iso-21089-lifecycle>
       ] ;
       fhir:code [ fhir:v "deidentify" ]
     ] )
  ] ; # 
  fhir:agent ( [
     fhir:type [
       fhir:coding ( [
         fhir:system [
           fhir:v "http://terminology.hl7.org/CodeSystem/provenance-participant-type"^^xsd:anyURI ;
           fhir:l <http://terminology.hl7.org/CodeSystem/provenance-participant-type>
         ] ;
         fhir:code [ fhir:v "assembler" ]
       ] )
     ] ;
     fhir:who [
       fhir:display [ fhir:v "Device/software" ]
     ]
  ] ) ; #   not identified in original patient compartment as SHOULD NOT show up there (confidentiatltyCode V protected too)  
  fhir:entity ( [
     fhir:role [ fhir:v "source" ] ;
     fhir:what [
       fhir:l <http://hl7.org/fhir/Patient/example> ;
       fhir:reference [ fhir:v "Patient/example" ]
     ]
  ] ) . # 

<http://hl7.org/fhir/Patient/example> a fhir:Patient .

<http://example.org/fhir/Patient/anon0> a fhir:Patient ;
  fhir:id [ fhir:v "anon0"] ; # 
  fhir:meta [
     fhir:security ( [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/v3-Confidentiality"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/v3-Confidentiality>
       ] ;
       fhir:code [ fhir:v "L" ]
     ] [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/v3-ObservationValue"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/v3-ObservationValue>
       ] ;
       fhir:code [ fhir:v "PSEUDED" ]
     ] )
  ] ; #   De-Identifed equivilant, removing all direct identifiers, and keeping only minimally necessary indirect identifiers  
  fhir:text [
     fhir:status [ fhir:v "generated" ] ;
     fhir:div [ fhir:v "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: Patient anon0</b></p><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\"/><p style=\"margin-bottom: 0px\">Security Labels: low (Details: Confidentiality code L = 'low'), pseudonymized (Details: ObservationValue code PSEUDED = 'pseudonymized')</p></div><p style=\"border: 1px #661aff solid; background-color: #e6e6ff; padding: 10px;\">First-0 Anon-0  Male, DoB: 1974-12-01</p><hr/></div>"^^rdf:XMLLiteral ]
  ] ; # 
  fhir:name ( [
     fhir:family [ fhir:v "Anon-0" ] ; #   some made up name  
     fhir:given ( [ fhir:v "First-0" ] )
  ] ) ; # 
  fhir:gender [ fhir:v "male"] ; #   male/female gender is needed, and group is big enough.   
  fhir:birthDate [ fhir:v "1974-12-01"^^xsd:date] . #   birthdate is generalized to 1st of month of the birth year  

<http://example.org/fhir/Condition/anon0> a fhir:Condition ;
  fhir:id [ fhir:v "anon0"] ; # 
  fhir:meta [
     fhir:security ( [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/v3-Confidentiality"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/v3-Confidentiality>
       ] ;
       fhir:code [ fhir:v "L" ]
     ] [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/v3-ObservationValue"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/v3-ObservationValue>
       ] ;
       fhir:code [ fhir:v "PSEUDED" ]
     ] )
  ] ; #   De-Identified data, change reference to Patient, eliminate free-text, and fuzz dates  
  fhir:text [
     fhir:status [ fhir:v "generated" ] ;
     fhir:div [ fhir:v "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: Condition anon0</b></p><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\"/><p style=\"margin-bottom: 0px\">Security Labels: low (Details: Confidentiality code L = 'low'), pseudonymized (Details: ObservationValue code PSEUDED = 'pseudonymized')</p></div><p><b>clinicalStatus</b>: <span title=\"Codes:{http://terminology.hl7.org/CodeSystem/condition-clinical active}\">Active</span></p><p><b>verificationStatus</b>: <span title=\"Codes:{http://terminology.hl7.org/CodeSystem/condition-ver-status confirmed}\">Confirmed</span></p><p><b>category</b>: <span title=\"Codes:{http://terminology.hl7.org/CodeSystem/condition-category encounter-diagnosis}, {http://snomed.info/sct 439401001}\">Encounter Diagnosis</span></p><p><b>severity</b>: <span title=\"Codes:{http://snomed.info/sct 24484000}\">Severe</span></p><p><b>code</b>: <span title=\"Codes:{http://snomed.info/sct 39065001}\">Burn of ear</span></p><p><b>bodySite</b>: <span title=\"Codes:{http://snomed.info/sct 49521004}\">Left external ear structure</span></p><p><b>subject</b>: <a href=\"broken-link.html\">Patient/anon0</a></p><p><b>onset</b>: 2012-05-01</p></div>"^^rdf:XMLLiteral ]
  ] ; # 
  fhir:clinicalStatus [
     fhir:coding ( [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/condition-clinical"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/condition-clinical>
       ] ;
       fhir:code [ fhir:v "active" ]
     ] )
  ] ; # 
  fhir:verificationStatus [
     fhir:coding ( [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/condition-ver-status"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/condition-ver-status>
       ] ;
       fhir:code [ fhir:v "confirmed" ]
     ] )
  ] ; # 
  fhir:category ( [
     fhir:coding ( [
       fhir:system [
         fhir:v "http://terminology.hl7.org/CodeSystem/condition-category"^^xsd:anyURI ;
         fhir:l <http://terminology.hl7.org/CodeSystem/condition-category>
       ] ;
       fhir:code [ fhir:v "encounter-diagnosis" ] ;
       fhir:display [ fhir:v "Encounter Diagnosis" ]
     ] [
       a sct:439401001 ;
       fhir:system [
         fhir:v "http://snomed.info/sct"^^xsd:anyURI ;
         fhir:l <http://snomed.info/sct>
       ] ;
       fhir:code [ fhir:v "439401001" ] ;
       fhir:display [ fhir:v "Diagnosis" ]
     ] )
  ] ) ; # 
  fhir:severity [
     fhir:coding ( [
       a sct:24484000 ;
       fhir:system [
         fhir:v "http://snomed.info/sct"^^xsd:anyURI ;
         fhir:l <http://snomed.info/sct>
       ] ;
       fhir:code [ fhir:v "24484000" ] ;
       fhir:display [ fhir:v "Severe" ]
     ] )
  ] ; # 
  fhir:code [
     fhir:coding ( [
       a sct:39065001 ;
       fhir:system [
         fhir:v "http://snomed.info/sct"^^xsd:anyURI ;
         fhir:l <http://snomed.info/sct>
       ] ;
       fhir:code [ fhir:v "39065001" ] ;
       fhir:display [ fhir:v "Burn of ear" ]
     ] )
  ] ; # 
  fhir:bodySite ( [
     fhir:coding ( [
       a sct:49521004 ;
       fhir:system [
         fhir:v "http://snomed.info/sct"^^xsd:anyURI ;
         fhir:l <http://snomed.info/sct>
       ] ;
       fhir:code [ fhir:v "49521004" ] ;
       fhir:display [ fhir:v "Left external ear structure" ]
     ] )
  ] ) ; # 
  fhir:subject [
     fhir:l <http://hl7.org/fhir/Patient/anon0> ;
     fhir:reference [ fhir:v "Patient/anon0" ] #   patient as anon0 id  
  ] ; # 
  fhir:onset [
     a fhir:DateTime ;
     fhir:v "2012-05-01"^^xsd:date
  ] . #   dates aligned to first of month  

<http://hl7.org/fhir/Patient/anon0> a fhir:Patient .

# -------------------------------------------------------------------------------------

