@prefix fhir: <http://hl7.org/fhir/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

<http://fhirfrog.org/fhir/au-core-tests/TestScript/au-core-sexassignedab> a fhir:TestScript ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:Resource.id [ fhir:value "au-core-sexassignedab"] ;
  fhir:DomainResource.text [
     fhir:Narrative.status [ fhir:value "generated" ] ;
     fhir:Narrative.div "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: TestScript au-core-sexassignedab</b></p><a name=\"au-core-sexassignedab\"> </a><a name=\"hcau-core-sexassignedab\"> </a><p><b>url</b>: <a href=\"TestScript-au-core-sexassignedab.html\">TestScript AU Core Sex Assigned at Birth extension — presence &amp; profile conformance</a></p><p><b>version</b>: 0.1.0</p><p><b>name</b>: AUCoreSexAssignedAtBirth</p><p><b>title</b>: AU Core Sex Assigned at Birth extension — presence &amp; profile conformance</p><p><b>status</b>: Active</p><p><b>date</b>: 2026-08-16 05:55:37+0000</p><p><b>publisher</b>: FHIR Frog</p><p><b>contact</b>: FHIR Frog: <a href=\"https://gitlab.com/fhirfrog\">https://gitlab.com/fhirfrog</a></p><p><b>description</b>: </p><div><p>Covers the AU Core Sex Assigned at Birth extension (au-core-rsg-sexassignedab, 2.0.0) requirements identified in fhirfrog/au-core-compiler#25 (AUC-026). Correction to the issue's own framing, discovered while authoring this TestScript: au-core-rsg-sexassignedab is a <em>content-level</em> refinement of the generic individual-recordedSexOrGender extension, not a separately-URL'd one - its own snapshot fixes Extension.url to the base extension's canonical URL (http://hl7.org/fhir/StructureDefinition/individual-recordedSexOrGender), not its own. au-core-patient DOES inherit a Patient.extension:recordedSexOrGender slot from its au-patient (AU Base) baseDefinition (visible only in the snapshot, not the differential - which is why the original gap-analysis missed it), typed generically against individual-recordedSexOrGender rather than specifically against au-core-rsg-sexassignedab. So the real, narrower gap is: nothing distinguishes/tests the 'sex assigned at birth' flavour specifically (identified only by the fixed SNOMED 1515311000168102 'Sex assigned at birth' value on its extension:type sub-extension) from other uses of that same generic slot. Covers presence of both must-support sub-extensions (extension:value - biological sex, extensible-bound to the AU THS biological-sex-1 ValueSet; extension:type - fixed to the SNOMED code identifying this specific flavour) via a generic FHIRPath probe against a fetched Patient, exactly as the issue itself suggested was possible without any new engine capability. ProfileValidation runs validateProfileId against au-core-patient to confirm the whole resource - extension included, now correctly url'd to match the inherited slot - remains profile-conformant.</p>\n</div><blockquote><p><b>fixture</b></p><blockquote><p><b>id</b></p>sexassignedab-patient-fixture</blockquote><p><b>autocreate</b>: true</p><p><b>autodelete</b>: true</p><p><b>resource</b>: <code>au-core-patient-sexassignedab</code></p></blockquote><h3>Variables</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Name</b></td><td><b>Path</b></td><td><b>SourceId</b></td></tr><tr><td style=\"display: none\">*</td><td>patientId</td><td>Patient.id</td><td>sexassignedab-patient-fixture</td></tr></table><blockquote><p><b>test</b></p><p><b>name</b>: Read</p><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>EncodeRequestUrl</b></td><td><b>Params</b></td></tr><tr><td style=\"display: none\">*</td><td><a href=\"http://terminology.hl7.org/7.3.0/CodeSystem-testscript-operation-codes.html#testscript-operation-codes-read\">Test script operation code: read</a> (Read)</td><td>Patient</td><td>true</td><td>/${patientId}</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Response</b></td><td><b>WarningOnly</b></td></tr><tr><td style=\"display: none\">*</td><td>okay</td><td>false</td></tr></table></blockquote></blockquote><blockquote><p><b>test</b></p><p><b>name</b>: ExtensionPresence</p><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>EncodeRequestUrl</b></td><td><b>Params</b></td></tr><tr><td style=\"display: none\">*</td><td><a href=\"http://terminology.hl7.org/7.3.0/CodeSystem-testscript-operation-codes.html#testscript-operation-codes-read\">Test script operation code: read</a> (Read)</td><td>Patient</td><td>true</td><td>/${patientId}</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td style=\"display: none\">*</td><td>Patient.extension.where(url = 'http://hl7.org/fhir/StructureDefinition/individual-recordedSexOrGender').exists()</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td style=\"display: none\">*</td><td>Patient.extension.where(url = 'http://hl7.org/fhir/StructureDefinition/individual-recordedSexOrGender').extension.where(url = 'value').value.exists()</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td style=\"display: none\">*</td><td>Patient.extension.where(url = 'http://hl7.org/fhir/StructureDefinition/individual-recordedSexOrGender').extension.where(url = 'type').value.coding.code.where($this = '1515311000168102').exists()</td><td>false</td></tr></table></blockquote></blockquote><blockquote><p><b>test</b></p><p><b>name</b>: ProfileValidation</p><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>EncodeRequestUrl</b></td><td><b>Params</b></td></tr><tr><td style=\"display: none\">*</td><td><a href=\"http://terminology.hl7.org/7.3.0/CodeSystem-testscript-operation-codes.html#testscript-operation-codes-read\">Test script operation code: read</a> (Read)</td><td>Patient</td><td>true</td><td>/${patientId}</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td style=\"display: none\">-</td><td><b>ValidateProfileId</b></td><td><b>WarningOnly</b></td></tr><tr><td style=\"display: none\">*</td><td>http://hl7.org.au/fhir/core/StructureDefinition/au-core-patient</td><td>false</td></tr></table></blockquote></blockquote></div>"
  ] ;
  fhir:TestScript.url [ fhir:value "http://fhirfrog.org/fhir/au-core-tests/TestScript/au-core-sexassignedab"] ;
  fhir:TestScript.version [ fhir:value "0.1.0"] ;
  fhir:TestScript.name [ fhir:value "AUCoreSexAssignedAtBirth"] ;
  fhir:TestScript.title [ fhir:value "AU Core Sex Assigned at Birth extension — presence & profile conformance"] ;
  fhir:TestScript.status [ fhir:value "active"] ;
  fhir:TestScript.date [ fhir:value "2026-08-16T05:55:37+00:00"^^xsd:dateTime] ;
  fhir:TestScript.publisher [ fhir:value "FHIR Frog"] ;
  fhir:TestScript.contact [
     fhir:index 0 ;
     fhir:ContactDetail.name [ fhir:value "FHIR Frog" ] ;
     fhir:ContactDetail.telecom [
       fhir:index 0 ;
       fhir:ContactPoint.system [ fhir:value "url" ] ;
       fhir:ContactPoint.value [ fhir:value "https://gitlab.com/fhirfrog" ]
     ]
  ] ;
  fhir:TestScript.description [ fhir:value "Covers the AU Core Sex Assigned at Birth extension (au-core-rsg-sexassignedab, 2.0.0) requirements identified in fhirfrog/au-core-compiler#25 (AUC-026). Correction to the issue's own framing, discovered while authoring this TestScript: au-core-rsg-sexassignedab is a *content-level* refinement of the generic individual-recordedSexOrGender extension, not a separately-URL'd one - its own snapshot fixes Extension.url to the base extension's canonical URL (http://hl7.org/fhir/StructureDefinition/individual-recordedSexOrGender), not its own. au-core-patient DOES inherit a Patient.extension:recordedSexOrGender slot from its au-patient (AU Base) baseDefinition (visible only in the snapshot, not the differential - which is why the original gap-analysis missed it), typed generically against individual-recordedSexOrGender rather than specifically against au-core-rsg-sexassignedab. So the real, narrower gap is: nothing distinguishes/tests the 'sex assigned at birth' flavour specifically (identified only by the fixed SNOMED 1515311000168102 'Sex assigned at birth' value on its extension:type sub-extension) from other uses of that same generic slot. Covers presence of both must-support sub-extensions (extension:value - biological sex, extensible-bound to the AU THS biological-sex-1 ValueSet; extension:type - fixed to the SNOMED code identifying this specific flavour) via a generic FHIRPath probe against a fetched Patient, exactly as the issue itself suggested was possible without any new engine capability. ProfileValidation runs validateProfileId against au-core-patient to confirm the whole resource - extension included, now correctly url'd to match the inherited slot - remains profile-conformant."] ;
  fhir:TestScript.fixture [
     fhir:index 0 ;
     fhir:Element.id [ fhir:value "sexassignedab-patient-fixture" ] ;
     fhir:TestScript.fixture.autocreate [ fhir:value "true"^^xsd:boolean ] ;
     fhir:TestScript.fixture.autodelete [ fhir:value "true"^^xsd:boolean ] ;
     fhir:TestScript.fixture.resource [
       fhir:Reference.reference [ fhir:value "au-core-patient-sexassignedab" ]
     ]
  ] ;
  fhir:TestScript.variable [
     fhir:index 0 ;
     fhir:TestScript.variable.name [ fhir:value "patientId" ] ;
     fhir:TestScript.variable.path [ fhir:value "Patient.id" ] ;
     fhir:TestScript.variable.sourceId [ fhir:value "sexassignedab-patient-fixture" ]
  ] ;
  fhir:TestScript.test [
     fhir:index 0 ;
     fhir:TestScript.test.name [ fhir:value "Read" ] ;
     fhir:TestScript.test.action [
       fhir:index 0 ;
       fhir:TestScript.test.action.operation [
         fhir:TestScript.setup.action.operation.type [
           fhir:Coding.system [ fhir:value "http://terminology.hl7.org/CodeSystem/testscript-operation-codes" ] ;
           fhir:Coding.code [ fhir:value "read" ]
         ] ;
         fhir:TestScript.setup.action.operation.resource [ fhir:value "Patient" ] ;
         fhir:TestScript.setup.action.operation.encodeRequestUrl [ fhir:value "true"^^xsd:boolean ] ;
         fhir:TestScript.setup.action.operation.params [ fhir:value "/${patientId}" ]
       ]
     ], [
       fhir:index 1 ;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.response [ fhir:value "okay" ] ;
         fhir:TestScript.setup.action.assert.warningOnly [ fhir:value "false"^^xsd:boolean ]
       ]
     ]
  ], [
     fhir:index 1 ;
     fhir:TestScript.test.name [ fhir:value "ExtensionPresence" ] ;
     fhir:TestScript.test.action [
       fhir:index 0 ;
       fhir:TestScript.test.action.operation [
         fhir:TestScript.setup.action.operation.type [
           fhir:Coding.system [ fhir:value "http://terminology.hl7.org/CodeSystem/testscript-operation-codes" ] ;
           fhir:Coding.code [ fhir:value "read" ]
         ] ;
         fhir:TestScript.setup.action.operation.resource [ fhir:value "Patient" ] ;
         fhir:TestScript.setup.action.operation.encodeRequestUrl [ fhir:value "true"^^xsd:boolean ] ;
         fhir:TestScript.setup.action.operation.params [ fhir:value "/${patientId}" ]
       ]
     ], [
       fhir:index 1 ;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.expression [ fhir:value "Patient.extension.where(url = 'http://hl7.org/fhir/StructureDefinition/individual-recordedSexOrGender').exists()" ] ;
         fhir:TestScript.setup.action.assert.warningOnly [ fhir:value "false"^^xsd:boolean ]
       ]
     ], [
       fhir:index 2 ;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.expression [ fhir:value "Patient.extension.where(url = 'http://hl7.org/fhir/StructureDefinition/individual-recordedSexOrGender').extension.where(url = 'value').value.exists()" ] ;
         fhir:TestScript.setup.action.assert.warningOnly [ fhir:value "false"^^xsd:boolean ]
       ]
     ], [
       fhir:index 3 ;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.expression [ fhir:value "Patient.extension.where(url = 'http://hl7.org/fhir/StructureDefinition/individual-recordedSexOrGender').extension.where(url = 'type').value.coding.code.where($this = '1515311000168102').exists()" ] ;
         fhir:TestScript.setup.action.assert.warningOnly [ fhir:value "false"^^xsd:boolean ]
       ]
     ]
  ], [
     fhir:index 2 ;
     fhir:TestScript.test.name [ fhir:value "ProfileValidation" ] ;
     fhir:TestScript.test.action [
       fhir:index 0 ;
       fhir:TestScript.test.action.operation [
         fhir:TestScript.setup.action.operation.type [
           fhir:Coding.system [ fhir:value "http://terminology.hl7.org/CodeSystem/testscript-operation-codes" ] ;
           fhir:Coding.code [ fhir:value "read" ]
         ] ;
         fhir:TestScript.setup.action.operation.resource [ fhir:value "Patient" ] ;
         fhir:TestScript.setup.action.operation.encodeRequestUrl [ fhir:value "true"^^xsd:boolean ] ;
         fhir:TestScript.setup.action.operation.params [ fhir:value "/${patientId}" ]
       ]
     ], [
       fhir:index 1 ;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.validateProfileId [ fhir:value "http://hl7.org.au/fhir/core/StructureDefinition/au-core-patient" ] ;
         fhir:TestScript.setup.action.assert.warningOnly [ fhir:value "false"^^xsd:boolean ]
       ]
     ]
  ] .

# - ontology header ------------------------------------------------------------

<http://fhirfrog.org/fhir/au-core-tests/TestScript/au-core-sexassignedab.ttl> a owl:Ontology ;
  owl:imports fhir:fhir.ttl .

# -------------------------------------------------------------------------------------

