Provider XML representation of organizational-facility hierarchy a FHIR value set resource.
import module namespace csr_proc = "https://github.com/openhie/openinfoman/csr_proc"; import module namespace csd_webconf = "https://github.com/openhie/openinfoman/csd_webconf"; import module namespace functx = 'http://www.functx.com'; declare namespace csd = "urn:ihe:iti:csd:2013"; declare namespace fhir = "http://hl7.org/fhir"; declare variable $careServicesRequest as item() external; let $org_id := $careServicesRequest/fhir:_id/text() let $search_name := string($careServicesRequest/@function) let $resource := string($careServicesRequest/@resource) let $function := csr_proc:get_function_definition($search_name) let $entity := string(($function/csd:extension[@urn='urn:openhie.org:openinfoman:adapter:fhir:valueset' ])[1]/@type) let $t_base_url := if (exists($careServicesRequest/@xml:base)) then string($careServicesRequest/@xml:base) else string($careServicesRequest/@base_url) let $base_url := concat($t_base_url, "CSD/csr/", $resource, "/careServicesRequest/" , $search_name , "/adapter/fhir/" , $entity , "/valueset" ) let $expand := (exists($careServicesRequest/fhir:_query) and matches(functx:trim(($careServicesRequest/fhir:_query)[1]/text()),'expand','i') ) let $org := (/csd:CSD/csd:organizationDirectory/csd:organization[@entityID = $org_id])[1] let $child_orgs := /csd:CSD/csd:organizationDirectory/csd:organization[ ./csd:parent[@entityID = $org_id]] let $child_facs := /csd:CSD/csd:facilityDirectory/csd:facility[ ./csd:organizations/csd:organization[@entityID = $org_id]] let $org_name := ($org/csd:primaryName)[1]/text() return if (exists($org) ) then <fhir:ValueSet> <fhir:text> <fhir:status value="generated"/> <div xmlns="http://www.w3.org/1999/xhtml"> <h2>Value Set {$org_id}</h2> <h3>Valueset {$entity}: {$org/csd:primaryName/text()}</h3> { let $parent := (/csd:CSD/csd:organizationDirectory/csd:organization[@entityID = $org/csd:parent/@entityID ])[1] return if (exists($parent)) then <span class='vs_parent'> <p>Parent Oraganization (Imports this value set): </p> <a href="{$base_url}?_id={$parent/@entityID}">{string($parent/@entityID)}</a>{$parent/csd:primaryName} </span> else() } { if (count($child_orgs) > 0) then <span class='vs_child'> <p> Child Organizatons (Imported Value Sets): </p> <ul> { for $child_org in $child_orgs return <li><a href="{$base_url}?_id={$child_org/@entityID}">{string($child_org/@entityID)}</a>{$child_org/csd:primaryName}</li> } </ul> </span> else () } { if (count($child_facs) > 0) then <span class='vs_facs'> <p> Facility codes directly defined by this code set: </p> <ul> { for $child_fac in $child_facs return <li>Value: {string($child_fac/@entityID)} is {$child_fac/csd:primaryName/text()} </li> } </ul> </span> else () } </div> </fhir:text> <fhir:identifier value="{$base_url}?_id={$org_id}"/> <fhir:version value="0"/> <fhir:name>Organization: {$org_name}</fhir:name> <fhir:status value="active"/> <fhir:date>{string($org/csd:record/@lastModified)}</fhir:date> <fhir:define> <fhir:system value="{$base_url}?_id={$org_id}"/> <fhir:version value="0"/> <fhir:caseSensitive value="true"/> { for $child_fac in $child_facs let $fac_name := ($child_fac/csd:primaryName[1])/text() let $definition := out:format("%s in %s", $fac_name,$org_name) let $value := string($child_fac/@entityID) where (not (functx:all-whitespace($value)) and not (functx:all-whitespace($fac_name))) return <fhir:concept> <fhir:code value="{$value}"/> <fhir:display value="{$fac_name}"/> <fhir:definition value="{$definition}"/> </fhir:concept> } </fhir:define> { if(not($expand) ) then <fhir:compose> { for $child_org in $child_orgs let $child_id := string($child_org/@entityID) where not (functx:all-whitespace($child_id)) return <fhir:import value="{$base_url}?_id={$child_id}"/> } </fhir:compose> else () } </fhir:ValueSet> else $careServicesRequest
Provider XML representation of a faciltiy as a FHIR location resource.
import module namespace csr_proc = "https://github.com/openhie/openinfoman/csr_proc"; import module namespace csd_webconf = "https://github.com/openhie/openinfoman/csd_webconf"; import module namespace fadpt = "https://github.com/openhie/openinfoman/adapter/fhir"; import module namespace functx = 'http://www.functx.com'; declare namespace csd = "urn:ihe:iti:csd:2013"; declare namespace fhir = "http://hl7.org/fhir"; declare variable $careServicesRequest as item() external; (: The query will be executed against the root element of the CSD document. The dynamic context of this query has $careServicesRequest set to contain any of the search and limit paramaters as sent by the Service Finder :) let $search_name := "urn:ihe:iti:csd:2014:stored-function:facility-search" let $careServicesSubRequest := <csd:careServicesRequest> <csd:function urn="{$search_name}" resource="{$careServicesRequest/@resource}" base_url="{$careServicesRequest/@base_url}"> <csd:requestParams> { let $id := $careServicesRequest/fhir:_id/text() return if (functx:all-whitespace($id)) then () else <csd:id entityID="{$id}"/> } { let $cn := $careServicesRequest/fhir:name/text() return if (functx:all-whitespace($cn)) then () else <csd:primaryName>{$cn}</csd:primaryName> } { let $org := string($careServicesRequest/fhir:manaingOrganization/@value) return if (functx:all-whitespace($org)) then () else <csd:organizations><csd:organization>{$org}</csd:organization></csd:organizations> } { let $t_start := $careServicesRequest/page/text() return if (functx:is-a-number($t_start)) then let $start := max((xs:int($t_start),1)) let $t_count := $careServicesRequest/fhir:_count/text() let $count := if(functx:is-a-number($t_count)) then max((xs:int($t_count),1)) else 50 let $startIndex := ($start - 1)*$count + 1 return <csd:start>{$startIndex}</csd:start> else () } { let $count := $careServicesRequest/fhir:_count/text() return if(functx:is-a-number($count)) then <csd:max>{max((xs:int($count),1))} </csd:max> else () } { let $since := $careServicesRequest/fhir:_since/text() return if (functx:all-whitespace($since)) then () else <csd:record updated="{$since}"/> } </csd:requestParams> </csd:function> </csd:careServicesRequest> let $contents := csr_proc:process_CSR_stored_results( /. , $careServicesSubRequest) (:note this is a CSD:csd element, not a document :) return $contents/csd:facilityDirectory/csd:facility
Provider XML representation of a organization as a FHIR organization resource.
import module namespace csr_proc = "https://github.com/openhie/openinfoman/csr_proc"; import module namespace csd_webconf = "https://github.com/openhie/openinfoman/csd_webconf"; import module namespace fadpt = "https://github.com/openhie/openinfoman/adapter/fhir"; import module namespace functx = 'http://www.functx.com'; declare namespace csd = "urn:ihe:iti:csd:2013"; declare namespace fhir = "http://hl7.org/fhir"; declare variable $careServicesRequest as item() external; (: The query will be executed against the root element of the CSD document. The dynamic context of this query has $careServicesRequest set to contain any of the search and limit paramaters as sent by the Service Finder :) let $search_name := "urn:ihe:iti:csd:2014:stored-function:organization-search" let $careServicesSubRequest := <csd:careServicesRequest> <csd:function urn="{$search_name}" resource="{$careServicesRequest/@resource}" base_url="{$careServicesRequest/@base_url}"> <csd:requestParams> { let $id := $careServicesRequest/fhir:_id/text() return if (functx:all-whitespace($id)) then () else <csd:id entityID="{$id}"/> } { let $cn := $careServicesRequest/fhir:name/text() return if (functx:all-whitespace($cn)) then () else <csd:primaryName>{$cn}</csd:primaryName> } { let $org := string($careServicesRequest/fhir:partOf/@value) return if (functx:all-whitespace($org)) then () else <csd:parent>{$org}</csd:parent> } { let $t_start := $careServicesRequest/page/text() return if (functx:is-a-number($t_start)) then let $start := max((xs:int($t_start),1)) let $t_count := $careServicesRequest/fhir:_count/text() let $count := if(functx:is-a-number($t_count)) then max((xs:int($t_count),1)) else 50 let $startIndex := ($start - 1)*$count + 1 return <csd:start>{$startIndex}</csd:start> else () } { let $count := $careServicesRequest/fhir:_count/text() return if(functx:is-a-number($count)) then <csd:max>{max(($count,1))} </csd:max> else () } { let $since := $careServicesRequest/fhir:_since/text() return if ($since) then <csd:record updated="{$since}"/> else () } </csd:requestParams> </csd:function> </csd:careServicesRequest> let $contents := csr_proc:process_CSR_stored_results( /. , $careServicesSubRequest) (:note this is a CSD:csd element, not a document :) return $contents/csd:organizationDirectory/csd:organization
Provider XML representation of a provider as a FHIR practitioner resource.
import module namespace csr_proc = "https://github.com/openhie/openinfoman/csr_proc"; import module namespace csd_webconf = "https://github.com/openhie/openinfoman/csd_webconf"; import module namespace fadpt = "https://github.com/openhie/openinfoman/adapter/fhir"; import module namespace functx = 'http://www.functx.com'; declare namespace csd = "urn:ihe:iti:csd:2013"; declare namespace fhir = "http://hl7.org/fhir"; declare variable $careServicesRequest as item() external; (: The query will be executed against the root element of the CSD document. The dynamic context of this query has $careServicesRequest set to contain any of the search and limit paramaters as sent by the Service Finder :) let $search_name := "urn:ihe:iti:csd:2014:stored-function:provider-search" let $careServicesSubRequest := <csd:careServicesRequest> <csd:function urn="{$search_name}" resource="{$careServicesRequest/@resource}" base_url="{$careServicesRequest/@base_url}"> <csd:requestParams> { let $id := $careServicesRequest/fhir:_id/text() return if (functx:all-whitespace($id)) then () else <csd:id entityID="{$id}"/> } { let $cn := $careServicesRequest/fhir:name/fhir:text/text() return if (functx:all-whitespace($cn)) then () else <csd:commonName>{$cn}</csd:commonName> } { let $org := string($careServicesRequest/fhir:organization/@value) return if (functx:all-whitespace($org)) then () else <csd:organizations><csd:organization>{$org}</csd:organization></csd:organizations> } { let $loc := string($careServicesRequest/fhir:location/@value) return if (functx:all-whitespace($loc)) then () else <csd:facilities><csd:facility>{$loc}</csd:facility></csd:facilities> } { let $t_start := $careServicesRequest/page/text() return if (functx:is-a-number($t_start)) then let $start := max((xs:int($t_start),1)) let $t_count := $careServicesRequest/fhir:_count/text() let $count := if(functx:is-a-number($t_count)) then max((xs:int($t_count),1)) else 50 let $startIndex := ($start - 1)*$count + 1 return <csd:start>{xs:string($startIndex)}</csd:start> else () } { let $count := $careServicesRequest/fhir:_count/text() return if(functx:is-a-number($count)) then <csd:max>{max(($count,1))} </csd:max> else () } { let $since := $careServicesRequest/fhir:_since/text() return if (functx:all-whitespace($since)) then () else <csd:record updated="{$since}"/> } </csd:requestParams> </csd:function> </csd:careServicesRequest> let $contents := csr_proc:process_CSR_stored_results( /. , $careServicesSubRequest) (:note this is a CSD:csd element, not a document :) return $contents/csd:providerDirectory/csd:provider