Performs an ad-hoc search on a CSD document
import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; declare namespace csd = "urn:ihe:iti:csd:2013"; declare variable $careServicesRequest as item() external; let $expr :=$careServicesRequest/adhoc/text() return if ($expr) then xquery:eval($expr,map{"":/.}) else ()
Performs a search for all facilities by name, type, address or ID. The result set consists of all facilities matching the search parameters ( id, primaryName, name, codedType and address ). The results set may be further restricted according to the limit parameters (start, max, record/@status and record/@updated). An ordering of the result set is not specified. Response Results are returned as a valid CSD document with a root document element of <CSD/>. The results set is contained entirely within the <facilityDirectory/> element and consists of the full content of the <facility/> elements of matching facilities as maintained by the Care Services InfoManager. Parameters Query Parameters are defined as the content of following elements: <id/> csd:uniqueID: (optional) If present and the @entityID attribute contains a non-empty value, it is a ID which uniquely identifies a facility. This is an exact match. <primaryName/> xs:string: (optional) If present and contains a non-empty value, then the result set should be restricted to those facilities whose <primaryName/> contains this value. Case insensitive. <name/> xs:string: (optional) If present and contains a non-empty value, then the result set should be restricted to those facilities which have a <primaryName/> or <otherName/> element containing this value. Case insensitive. <codedType/> csd:codedtype: If present and contains a non-empty value the result set should be restricted to those facilities whose <codedType/@code> equals this value for the coding schema specified by the @codingScheme attribute. Case insensitive. <address/> csd:address: (optional) Contains of any-number of child <addressLine/> elements as follows: Text content xs:string: (optional) If present and contains a non-empty value, then the results set should be restricted to those facilities whose have an <addressLine/> with specified @component containing this value exactly. Case insensitive. @component xs:string : (Required attribute) The component of the address we are searching. Case insensitive. <start/> xs:int: (optional) The starting index for results returned. Defaults to 1, which indexes the first facility matching the search parameters <max/> xs:int: (optional) The maximum number of results returned. A value of less than zero implies no maximum. <record/> csd:record : (optional) A child element to limit results according to @status xs:string: (optional) If present and contains a non-empty value, the result set should be restricted to those facilities whose record/@status equals this value. Case insensitive. @updated xs:dateTime: (optional) If present and contains a non-empty value, the result set should be restricted to those facilities whose record/@updated is at least the given value. Example Request <careServicesRequest> <function urn='urn:ihe:iti:csd:2014:stored-function:facility-search'> <codedType code='OPC' codingScheme="USDVA"/> <address> <addressLine component='city'>Chapel Hill</addressLine> </address> <max>5</max> </function> </careServicesRequest>
import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; declare default element namespace "urn:ihe:iti:csd:2013"; 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 :) <CSD xmlns:csd="urn:ihe:iti:csd:2013" > <organizationDirectory/> <serviceDirectory/> <facilityDirectory> { let $facs0 := if (exists($careServicesRequest/id)) then csd_bl:filter_by_primary_id(/CSD/facilityDirectory/*,$careServicesRequest/id) else /CSD/facilityDirectory/* let $facs1 := if (exists($careServicesRequest/primaryName)) then csd_bl:filter_by_primary_name($facs0,$careServicesRequest/primaryName) else $facs0 let $facs2 := if (exists($careServicesRequest/name)) then csd_bl:filter_by_name($facs1,$careServicesRequest/name) else $facs1 let $facs3 := if(exists($careServicesRequest/codedType)) then csd_bl:filter_by_coded_type($facs2,$careServicesRequest/codedType) else $facs2 let $facs4 := if(exists($careServicesRequest/address/addressLine)) then csd_bl:filter_by_address($facs3, $careServicesRequest/address/addressLine) else $facs3 let $facs5 := if (exists($careServicesRequest/record)) then csd_bl:filter_by_record($facs4,$careServicesRequest/record) else $facs4 let $facs6 := if(exists($careServicesRequest/otherID)) then csd_bl:filter_by_other_id($facs5,$careServicesRequest/otherID) else $facs5 let $facs7 := if (exists($careServicesRequest/organizations/organization)) then (csd_bl:filter_by_organizations($facs6,$careServicesRequest/organizations/organization) ) else ($facs6) return if (exists($careServicesRequest/start)) then if (exists($careServicesRequest/max)) then csd_bl:limit_items($facs7,$careServicesRequest/start,$careServicesRequest/max) else csd_bl:limit_items($facs7,$careServicesRequest/start,<max/>) else if (exists($careServicesRequest/max)) then csd_bl:limit_items($facs7,<start/>,$careServicesRequest/max) else $facs7 } </facilityDirectory> <providerDirectory/> </CSD>
Gets the maximum modification times for each of the four directories
declare namespace csd = 'urn:ihe:iti:csd:2013'; declare variable $careServicesRequest as item() external; let $ptime := max( for $dt in /csd:CSD/csd:providerDirectory/csd:provider/csd:record/@updated return xs:dateTime($dt)) let $otime := max( for $dt in /csd:CSD/csd:organizationDirectory/csd:provider/csd:record/@updated return xs:dateTime($dt)) let $ftime := max( for $dt in /csd:CSD/csd:facilityDirectory/csd:provider/csd:record/@updated return xs:dateTime($dt)) let $stime := max( for $dt in /csd:CSD/csd:serviceDirectory/csd:provider/csd:record/@updated return xs:dateTime($dt)) let $time := max (($ptime,$otime,$ftime,$stime)) return <csd:CSD updated="{$time}"> <csd:providerDirectory updated="{$ptime}"/> <csd:facilityDirectory updated="{$ftime}"/> <csd:organizationDirectory updated="{$otime}"/> <csd:serviceDirectory updated="{$stime}"/> </csd:CSD>
Performs a search for all organizations by name, coded type, address or ID. The result set consists of all organizations matching the search parameters ( id, primaryName, name, codedType and address ). The results set may be further restricted according to the limit parameters (start, max, record/@status and record/@updated). An ordering of the result set is not specified. Response Results are returned as a valid CSD document with a root document element of <CSD/>. The results set is contained entirely within the <organizationDirectory/> element and consists of the full content of the <organization/> elements of matching organizations as maintained by the Care Services InfoManager. Parameters Query Parameters are defined as the content of following elements: <id/> csd:uniqueID: (optional) If present and the @entityID attribute contains a non-empty value, it is a ID which uniquely identifies an organization. This is an exact match. <primaryName/> xs:string: (optional) If present and contains a non-empty value, then the result set should be restricted to those organizations whose <primaryName/> contains this value. Case insensitive. <name/> xs:string: (optional) If present and contains a non-empty value, then the result set should be restricted to those organizations which have a <primaryName/> or <otherName/> element containing this value. Case insensitive. <codedType/> csd:codedtype: If present and contains a non-empty value the result set should be restricted to those organizations whose <codedType/@code> equals this value for the coding schema specified by the @codingScheme attribute. Case insensitive. <address/> csd:address: (optional) Contains of any-number of child <addressLine/> elements as follows: Text content xs:string: (optional) If present and contains a non-empty value, then the results set should be restricted to those organizations whose have an <addressLine/> with specified @component containing this value exactly. Case insensitive. @component xs:string : (Required attribute) The component of the address we are searching. Case insensitive. <start/> xs:int: (optional) The starting index for results returned. Defaults to 1, which indexes the first organization matching the search parameters <max/> xs:int: (optional) The maximum number of results returned. A value of less than zero implies no maximum. <record/> csd:record : (optional) A child element to limit results according to @status xs:string: (optional) If present and contains a non-empty value, the result set should be restricted to those organizations whose record/@status equals this value. Case insensitive. @updated xs:dateTime: (optional) If present and contains a non-empty value, the result set should be restricted to those organizations whose record/@updated is at least the given value. Example Request <careServicesRequest> <function urn='urn:ihe:iti:csd:2014:stored-function:service-search'> <codedType codingScheme="moh.gov.rw" code="FBO" /> <address> <addressLine component='city'>Kigali</addressLine> </address> <max>5</max> </function> </careServicesRequest>
import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; declare default element namespace "urn:ihe:iti:csd:2013"; 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 :) <CSD xmlns:csd="urn:ihe:iti:csd:2013" > <organizationDirectory> { let $orgs0 := if (exists($careServicesRequest/id)) then csd_bl:filter_by_primary_id(/CSD/organizationDirectory/*,$careServicesRequest/id) else /CSD/organizationDirectory/* let $orgs1 := if (exists($careServicesRequest/primaryName)) then csd_bl:filter_by_primary_name($orgs0,$careServicesRequest/primaryName) else $orgs0 let $orgs2 := if(exists($careServicesRequest/name)) then csd_bl:filter_by_name($orgs1,$careServicesRequest/name) else $orgs1 let $orgs3 := if(exists($careServicesRequest/codedType)) then csd_bl:filter_by_coded_type($orgs2,$careServicesRequest/codedType) else $orgs2 let $orgs4 :=if (exists($careServicesRequest/address/addressLine)) then csd_bl:filter_by_address($orgs3, $careServicesRequest/address/addressLine) else $orgs3 let $orgs5 := if (exists($careServicesRequest/record)) then csd_bl:filter_by_record($orgs4,$careServicesRequest/record) else $orgs4 let $orgs6 := if (exists($careServicesRequest/otherID)) then csd_bl:filter_by_other_id($orgs5,$careServicesRequest/otherID) else $orgs5 let $orgs7 := if (exists($careServicesRequest/parent)) then csd_bl:filter_by_parent($orgs5,$careServicesRequest/parent) else $orgs6 return if (exists($careServicesRequest/start)) then if (exists($careServicesRequest/max)) then csd_bl:limit_items($orgs7,$careServicesRequest/start,$careServicesRequest/max) else csd_bl:limit_items($orgs7,$careServicesRequest/start,<max/>) else if (exists($careServicesRequest/max)) then csd_bl:limit_items($orgs7,<start/>,$careServicesRequest/max) else $orgs7 } </organizationDirectory> <serviceDirectory/> <facilityDirectory/> <providerDirectory/> </CSD>
Performs a search for all providers by name, coded type, address or ID. The result set consists of all providers matching the search parameters ( id, otherID, commonName,codedType and address ). The results set may be further restricted according to the limit parameters (start, max, record/@status and record/@updated). An ordering of the result set is not specified. Response Results are returned as a valid CSD document with a root document element of <CSD/>. The results set is contained entirely within the <providerDirectory/> element and consists of the full content of the <provider/> elements of matching providers as maintained by the Care Services InfoManager. Parameters Query Parameters are defined as the content of following elements: <id/> csd:uniqueID: (optional) If present and the @entityID attribute contains a non-empty value, it is a ID which uniquely identifies a provider. This is an exact match. <otherID/> csd:otherID: (optional) If present and the @assigningAuthorityName attribute contains a non-empty value, then the result set is restricted to only those providers which have a <otherID/> with the given assigingAuthorityName and @code <commonName/> xsd:string: (optional) If present and contains a non-empty value, then the result set should be restricted to those providers which have a <demographic/name/commonName/> containing this value. Case insensitive. <codedType/> csd:codedtype: If present and contains a non-empty value the result set should be restricted to those providers whose <codeType/@code> equals this value for the coding schema specified by the @codingScheme attribute. Case insensitive. <address/> csd:address: (optional) Contains of any-number of child <addressLine/> elements as follows: Text content xsd:string: (optional) If present and contains a non-empty value, then the results set should be restricted to those providers whose have an <addressLine/> with specified @component containing this value exactly. Case insensitive. @component xsd:string : (Required attribute) The component of the address we are searching. Case insensitive. <start/> xsd:int: (optional) The starting index for results returned. Defaults to 1, which indexes the first provider matching the search parameters <max/> xsd:int: (optional) The maximum number of results returned. A value of less than zero implies no maximum. <record/> csd:record : (optional) A child element to limit results according to @status xsd:string: (optional) If present and contains a non-empty value, the result set should be restricted to those providers whose record/@status equals this value. Case insensitive. @updated xsd:dateTime: (optional) If present and contains a non-empty value, the result set should be restricted to those providers whose record/@updated is at least the given value. Example Request <careServicesRequest> <function urn='urn:ihe:iti:csd:2014:stored-function:service-search'> <codedType code="2221" codingScheme="ISCO-08" /< <address> <addressLine component='city'>Kigali</addressLine> </address> <max>5</max> </function> </careServicesRequest>
import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; declare default element namespace "urn:ihe:iti:csd:2013"; 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 :) <CSD xmlns:csd="urn:ihe:iti:csd:2013" > <organizationDirectory/> <serviceDirectory/> <facilityDirectory/> <providerDirectory> { let $provs0 := if (exists($careServicesRequest/id)) then csd_bl:filter_by_primary_id(/CSD/providerDirectory/*,$careServicesRequest/id) else /CSD/providerDirectory/* let $provs1 := if(exists($careServicesRequest/otherID)) then csd_bl:filter_by_other_id($provs0,$careServicesRequest/otherID) else $provs0 let $provs2 := if(exists($careServicesRequest/commonName)) then csd_bl:filter_by_common_name($provs1,$careServicesRequest/commonName) else $provs1 let $provs3 := if (exists($careServicesRequest/codedType)) then csd_bl:filter_by_coded_type($provs2,$careServicesRequest/codedType) else $provs2 let $provs4 := if (exists($careServicesRequest/address/addressLine)) then csd_bl:filter_by_demographic_address($provs3, $careServicesRequest/address/addressLine) else $provs3 let $provs5 := if (exists($careServicesRequest/record)) then csd_bl:filter_by_record($provs4,$careServicesRequest/record) else $provs4 let $provs6 := if (exists($careServicesRequest/facilities/facility)) then csd_bl:filter_by_facilities($provs5,$careServicesRequest/facilities/facility) else $provs5 let $provs7 := if (exists($careServicesRequest/organizations/organization)) then csd_bl:filter_by_organizations($provs6,$careServicesRequest/organizations/organization) else $provs6 let $provs7a := if(exists($careServicesRequest/language)) then csd_bl:filter_by_languages($provs7,$careServicesRequest/language) else $provs7 return if (exists($careServicesRequest/start)) then if (exists($careServicesRequest/max)) then csd_bl:limit_items($provs7a,$careServicesRequest/start,$careServicesRequest/max) else csd_bl:limit_items($provs7a,$careServicesRequest/start,<max/>) else if (exists($careServicesRequest/max)) then csd_bl:limit_items($provs7a,<start/>,$careServicesRequest/max) else $provs7a } </providerDirectory> </CSD>
Performs a search for all search by coded type or ID. The result set consists of all serices matching the search parameters ( id and codedType ). The results set may be further restricted according to the limit parameters (start, max, record/@status and record/@updated). An ordering of the result set is not specified. Response Results are returned as a valid CSD document with a root document element of <CSD/>. The results set is contained entirely within the <serviceDirectory/> element and consists of the full content of the <service/> elements of matching services as maintained by the Care Services InfoManager. Parameters Query Parameters are defined as the content of following elements: <id/> csd:uniqueID: (optional) If present and the @entityID attribute contains a non-empty value, it is a ID which uniquely identifies a service. This is an exact match. <codedType/> csd:codedtype: If present and contains a non-empty value the result set should be restricted to those services whose <codedType/@code> equals this value for the coding schema specified by the @codingScheme attribute. Case insensitive. <start/> xs:int: (optional) The starting index for results returned. Defaults to 1, which indexes the first service matching the search parameters <max/> xs:int: (optional) The maximum number of results returned. A value of less than zero implies no maximum. <record/> csd:record : (optional) A child element to limit results according to @status xs:string: (optional) If present and contains a non-empty value, the result set should be restricted to those serivces whose record/@status equals this value. Case insensitive. @updatedxs:dateTime: (optional) If present and contains a non-empty value, the result set should be restricted to those serivces whose record/@updated is at least the given value. Example Request <careServicesRequest> <function urn='urn:ihe:iti:csd:2014:stored-function:service-search'> <codedType code="76499" codingScheme="HCPCS" /> <start>101</max> </function> </careServicesRequest>
import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; declare default element namespace "urn:ihe:iti:csd:2013"; 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 :) <CSD xmlns:csd="urn:ihe:iti:csd:2013" > <organizationDirectory/> <serviceDirectory> { let $svcs0 := if (exists($careServicesRequest/id)) then csd_bl:filter_by_primary_id(/CSD/serviceDirectory/*,$careServicesRequest/id) else /CSD/serviceDirectory/* let $svcs1 := if(exists($careServicesRequest/codedType)) then csd_bl:filter_by_coded_type($svcs0,$careServicesRequest/codedType) else $svcs0 let $svcs2 := if (exists($careServicesRequest/record)) then csd_bl:filter_by_record($svcs1,$careServicesRequest/record) else $svcs1 return if (exists($careServicesRequest/start)) then if (exists($careServicesRequest/max)) then csd_bl:limit_items($svcs2,$careServicesRequest/start,$careServicesRequest/max) else csd_bl:limit_items($svcs2,$careServicesRequest/start,<max/>) else if (exists($careServicesRequest/max)) then csd_bl:limit_items($svcs2,<start/>,$careServicesRequest/max) else $svcs2 } </serviceDirectory> <facilityDirectory/> <providerDirectory/> </CSD>
Deletes duplicate record reference. This is done by removing a <csd:otherID/> element on the duplicate record that references the master record. This a <csd:otherID/> is characterized as follows: The @assigningAuthorityName attribute will be the fixed valueurn:openhie.org:openinfoman attribute of the master record The @code attribute will be the fixed value 'duplicate' to indicate this is for marking a duplicate The text() value will be the entity ID used to reference to the master record for the entity A Care Services Request can be submitted to delete the mark that the record as duplicate with the following request parameters: <masterEntity/> should have attribute @entityID which contains the entity ID of the master record that the duplicate record should refer to <duplicateEntity/> should have attribute @entityID which contains the entity ID of the duplicate record
import module namespace csd_lsc = "https://github.com/openhie/openinfoman/csd_lsc"; import module namespace csd_dm = "https://github.com/openhie/openinfoman/csd_dm"; import module namespace csd_webconf = "https://github.com/openhie/openinfoman/csd_webconf"; declare namespace csd = "urn:ihe:iti:csd:2013"; declare variable $careServicesRequest as item() external; let $doc_name := string($careServicesRequest/@resource) let $doc := csd_dm:open_document($doc_name) let $masterID := $careServicesRequest/masterEntity/@entityID let $dupID := $careServicesRequest/duplicateEntity/@entityID let $dupEntity := if (exists($dupID)) then (/csd:CSD/*/*[@entityID = $dupID])[1] else () let $dupRef := $dupEntity/csd:otherID[@assigningAuthorityName='urn:openhie.org:openinfoman' and @code='duplicate' and text()=$masterID] return if (exists($dupRef)) then delete node $dupRef else ()
Deletes potential duplicate record reference. This is done by removing a <csd:otherID/> element on the potetnial duplicate record which references the master record. This a <csd:otherID/> is characterized as follows: The @assigningAuthorityName attribute will be the fixed valueurn:openhie.org:openinfoman attribute of the master record The @code attribute will be the fixed value 'duplicate' to indicate this is for marking a duplicate The text() value will be the entity ID used to reference to the master record for the entity A Care Services Request can be submitted to delete the mark that the record as potential duplicate with the following request parameters: <masterEntity/> should have attribute @entityID which contains the entity ID of the master record that the duplicate record should refer to <duplicateEntity/> should have attribute @entityID which contains the entity ID of the duplicate record
import module namespace csd_lsc = "https://github.com/openhie/openinfoman/csd_lsc"; import module namespace csd_dm = "https://github.com/openhie/openinfoman/csd_dm"; import module namespace csd_webconf = "https://github.com/openhie/openinfoman/csd_webconf"; declare namespace csd = "urn:ihe:iti:csd:2013"; declare variable $careServicesRequest as item() external; let $doc_name := string($careServicesRequest/@resource) let $doc := csd_dm:open_document($doc_name) let $masterID := $careServicesRequest/masterEntity/@entityID let $dupID := $careServicesRequest/duplicateEntity/@entityID let $dupEntity := if (exists($dupID)) then (/csd:CSD/*/*[@entityID = $dupID])[1] else () let $dupRef := $dupEntity/csd:otherID[@assigningAuthorityName='urn:openhie.org:openinfoman' and @code='potential-duplicate' and text()=$masterID] return if (exists($dupRef)) then delete node $dupRef else ()
Performs an organization hierarch extraction from a source document into the target document. Any existing elements in the target document are overwritten by those from the source document(s). There are two required parameters: The document is indicated via <document/%gt; element. If @resource attribute of the <document/> should be the name of a document available to OpenInfoMan. Otherwise the content of the <document/> should be a valid CSD document. Under each <document/> is the required elements: Aa <csd:organization/> element to indicate the part of the hiearchy that should be extracted. Under each <document/> are two optional elements: keepParents 0..1 keepParents element has integer attribute @value. Defaults to 1 which means we keep the parents of the indicated organization when we extract. processFacilities 0..1 processFacilities element has integer attribute @value. Defaults to 1 which means we also include the facilities associated to the organizations in the extracted hierarchy. All parent nodes of the indicated organziation
import module namespace csd_lsc = "https://github.com/openhie/openinfoman/csd_lsc"; import module namespace csd_dm = "https://github.com/openhie/openinfoman/csd_dm"; import module namespace csd_webconf = "https://github.com/openhie/openinfoman/csd_webconf"; import module namespace functx = "http://www.functx.com"; import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; declare namespace csd = "urn:ihe:iti:csd:2013"; declare variable $careServicesRequest as item() external; let $dest_doc := /. let $dest := $careServicesRequest/@resource return for $doc in $careServicesRequest/documents/document let $name := $doc/@resource let $src_doc := if (not (functx:all-whitespace($name))) then if (not ($name = $dest)) then csd_dm:open_document($name) else () else $doc/csd:CSD let $req_org_id := $doc/csd:organization/@entityID let $processFacilities := if (exists($doc/processFacilities/@value)) then ($doc/processFacilities/@value = 1) else true() let $keepParents := if (exists($doc/keepParents/@value)) then ($doc/keepParents/@value = 1) else true() let $all_orgs := $src_doc/csd:CSD/csd:organizationDirectory/csd:organization let $org := $all_orgs[@entityID = $req_org_id] let $orgs := if (not(exists($org))) then () (: nothing to extract:) else ( if ($keepParents) then csd_bl:get_parent_orgs($all_orgs,$org) else () , $org , csd_bl:get_child_orgs($all_orgs,$org) ) let $facs := if (not ($processFacilities) ) then () else for $org in $orgs return $src_doc/csd:CSD/csd:facilityDirectory/csd:facility[./csd:organizations/csd:organization/@entityID = $org/@entityID] return ( csd_lsc:update_directory($dest_doc/csd:CSD/csd:organizationDirectory,$orgs) ,csd_lsc:update_directory($dest_doc/csd:CSD/csd:facilityDirectory,$facs) )
Create or update a facility entity. Request parameters should be one or more CSD facility entities
import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; (: import module namespace random = "http://basex.org/modules/random"; :) import module namespace csd_blu = "https://github.com/openhie/openinfoman/csd_blu"; declare default element namespace "urn:ihe:iti:csd:2013"; 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 :) for $fac in $careServicesRequest/facility let $existing := if (exists($fac/@entityID)) then csd_bl:filter_by_primary_id(/CSD/facilityDirectory/*,$fac) else () return if (exists($existing)) then replace node $existing with $fac else insert node $fac into /CSD/facilityDirectory
Marks a record as a duplicate with another record. This is done by adding a <csd:otherID/> element to the record that is duplicate which references the master record. This a <csd:otherID/> is characterized as follows: The @assigningAuthorityName attribute will be the fixed valueurn:openhie.org:openinfoman attribute of the master record The @code attribute will be the fixed value 'duplicate' to indicate this is for marking a duplicate The text() value will be the entity ID used to reference to the master record for the entity A Care Services Request can be submitted to mark the record as duplicate with the following request parameters: <masterEntity/> should have attribute @entityID which contains the entity ID of the master record that the duplicate record should refer to <duplicateEntity/> should have attribute @entityID which contains the entity ID of the duplicate record
import module namespace csd_lsc = "https://github.com/openhie/openinfoman/csd_lsc"; import module namespace csd_dm = "https://github.com/openhie/openinfoman/csd_dm"; import module namespace csd_webconf = "https://github.com/openhie/openinfoman/csd_webconf"; declare namespace csd = "urn:ihe:iti:csd:2013"; declare variable $careServicesRequest as item() external; let $doc_name := string($careServicesRequest/@resource) let $doc := csd_dm:open_document($doc_name) let $masterID := $careServicesRequest/masterEntity/@entityID let $masterEntity := if (exists($masterID)) then (/csd:CSD/*/*[@entityID = $masterID])[1] else () let $dupID := $careServicesRequest/duplicateEntity/@entityID let $dupEntity := if (exists($dupID)) then (/csd:CSD/*/*[@entityID = $dupID])[1] else () let $masterRef := <csd:otherID assigningAuthorityName='urn:openhie.org:openinfoman' code='duplicate'>{string($masterID)}</csd:otherID> return if (not(exists($masterEntity)) or not( exists($dupEntity))) then () else let $existingRef := ($dupEntity/csd:otherID[@assigningAuthorityName = 'urn:openhie.org:openinfoman' and @code='duplicate'])[1] return ( if (exists($existingRef)) then (replace node $existingRef with $masterRef) else (insert node $masterRef before ($dupEntity/*)[1]) , for $entity in /csd:CSD/*/*[./csd:otherID[@assigningAuthorityName='urn:openhie.org:openinfoman' and @code='duplicate' and ./text()=$dupID]] let $e_existingRef := ($entity/csd:otherID[@assigningAuthorityName='urn:openhie.org:openinfoman' and @code='duplicate' and ./text()=$dupID])[1] return if (not($e_existingRef = $existingRef) ) then replace node $e_existingRef with $masterRef else () (:avoid double replacelement in edge case in which a record is marked as duplicate to itself:) )
Marks a record as a potential duplicate with another record. This is done by adding a <csd:otherID/> element to the record that is the potential duplicate which references the master record. This a <csd:otherID/> is characterized as follows: The @assigningAuthorityName attribute will be the fixed valueurn:openhie.org:openinfoman attribute of the master record The @code attribute will be the fixed value 'potential-duplicate' to indicate this is for marking a potential duplicate The text() value will be the entity ID used to reference to the master record for the entity A Care Services Request can be submitted to mark the record as potential duplicate with the following request parameters: <masterEntity/> should have attribute @entityID which contains the entity ID of the master record that the potential duplicate record should refer to <duplicateEntity/> should have attribute @entityID which contains the entity ID of the duplicate record
import module namespace csd_lsc = "https://github.com/openhie/openinfoman/csd_lsc"; import module namespace csd_dm = "https://github.com/openhie/openinfoman/csd_dm"; import module namespace csd_webconf = "https://github.com/openhie/openinfoman/csd_webconf"; declare namespace csd = "urn:ihe:iti:csd:2013"; declare variable $careServicesRequest as item() external; let $doc_name := string($careServicesRequest/@resource) let $doc := csd_dm:open_document($doc_name) let $masterID := $careServicesRequest/masterEntity/@entityID let $masterEntity := if (exists($masterID)) then (/csd:CSD/*/*[@entityID = $masterID])[1] else () let $dupID := $careServicesRequest/duplicateEntity/@entityID let $dupEntity := if (exists($dupID)) then (/csd:CSD/*/*[@entityID = $dupID])[1] else () let $masterRef := <csd:otherID assigningAuthorityName='urn:openhie.org:openinfoman' code='potential-duplicate'>{string($masterID)}</csd:otherID> return if (not(exists($masterEntity)) or not( exists($dupEntity))) then () else let $existingRef := ($dupEntity/csd:otherID[@assigningAuthorityName = 'urn:openhie.org:openinfoman' and @code='potential-duplicate' and text() = $masterID])[1] return ( if (exists($existingRef)) then (replace node $existingRef with $masterRef) else (insert node $masterRef before ($dupEntity/*)[1]) , for $entity in /csd:CSD/*/*[./csd:otherID[@assigningAuthorityName='urn:openhie.org:openinfoman' and @code='potential-duplicate' and ./text()=$dupID]] let $e_existingRef := ($entity/csd:otherID[@assigningAuthorityName='urn:openhie.org:openinfoman' and @code='potential-duplicate' and ./text()=$dupID])[1] return (replace node $e_existingRef with $masterRef) )
Performs a merge from the indicated source document(s) into the target document. Any entities in the target document are overwritten by the corresponding entity in the source document except that <csd:otherID/> elements are preserved. Documents are indicated via <document/%gt; elements under the top-level <documents/> element. The @resource attribute of the <document/> should be the name of a document available to OpenInfoMan. Otherwise the content of the <document/> should be a valid CSD document. The following optional elements are allowed under each <document/%gt; element : insertNew 0..1 insertNew has integer attribute @value. Defaults to 1 which means we insert any new entities from the source documents if they are not already a part of the destination document
import module namespace csd_lsc = "https://github.com/openhie/openinfoman/csd_lsc"; import module namespace csd_dm = "https://github.com/openhie/openinfoman/csd_dm"; 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 variable $careServicesRequest as item() external; let $dest_doc := /. let $dest := $careServicesRequest/@resource for $doc in $careServicesRequest/documents/document let $insertNew := if (exists($doc/insertNew/@value)) then ($doc/insertNew/@value = 1) else true() let $name := string($doc/@resource) let $src_doc := if (not (functx:all-whitespace($name))) then if (not ($name = $dest)) then csd_dm:open_document( $name) else () else $doc return ( let $src_dir := $src_doc/csd:CSD/csd:organizationDirectory let $dest_dir := $dest_doc/csd:CSD/csd:organizationDirectory return for $e in $src_dir/csd:organization let $existing := $dest_dir/csd:organization[@entityID = $e/@entityID] return if (exists($existing)) then let $new := <csd:organization entityID="{$e/@entityID}"> {$existing/csd:otherID} {$e/*} </csd:organization> return replace node $existing with $new else if ($insertNew) then insert node $e into $dest_dir else () , let $src_dir := $src_doc/csd:CSD/csd:providerDirectory let $dest_dir := $dest_doc/csd:CSD/csd:providerDirectory return for $e in $src_dir/csd:provider let $existing := $dest_dir/csd:provider[@entityID = $e/@entityID] return if (exists($existing)) then let $new := <csd:provider entityID="{$e/@entityID}"> {$existing/csd:otherID} {$e/*} </csd:provider> return replace node $existing with $new else if ($insertNew) then insert node $e into $dest_dir else () , let $src_dir := $src_doc/csd:CSD/csd:serviceDirectory let $dest_dir := $dest_doc/csd:CSD/csd:serviceDirectory return for $e in $src_dir/csd:service let $existing := $dest_dir/csd:service[@entityID = $e/@entityID] return if (exists($existing)) then let $new := <csd:service entityID="{$e/@entityID}"> {$existing/csd:otherID} {$e/*} </csd:service> return replace node $existing with $new else if ($insertNew) then insert node $e into $dest_dir else () , let $src_dir := $src_doc/csd:CSD/csd:facilityDirectory let $dest_dir := $dest_doc/csd:CSD/csd:facilityDirectory return for $e in $src_dir/csd:facility let $existing := $dest_dir/csd:facility[@entityID = $e/@entityID] return if (exists($existing)) then let $new := <csd:facility entityID="{$e/@entityID}"> {$existing/csd:otherID} {$e/*} </csd:facility> return replace node $existing with $new else if ($insertNew) then insert node $e into $dest_dir else () )
Create or update a organization entity. Request parameters should be one or more CSD organization entities
import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; (: import module namespace random = "http://basex.org/modules/random"; :) import module namespace csd_blu = "https://github.com/openhie/openinfoman/csd_blu"; declare default element namespace "urn:ihe:iti:csd:2013"; 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 :) for $org in $careServicesRequest/organization let $existing := if (exists($org/@entityID)) then csd_bl:filter_by_primary_id(/CSD/organizationDirectory/*,$org) else () return if (exists($existing)) then replace node $existing with $org else insert node $org into /CSD/organizationDirectory
Create or update a provider entity. Request parameters should be one or more CSD provider entities
import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; (: import module namespace random = "http://basex.org/modules/random"; :) import module namespace csd_blu = "https://github.com/openhie/openinfoman/csd_blu"; declare default element namespace "urn:ihe:iti:csd:2013"; 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 :) for $prov in $careServicesRequest/provider let $existing := if (exists($prov/@entityID)) then csd_bl:filter_by_primary_id(/CSD/providerDirectory/*,$prov) else () return if (exists($existing)) then replace node $existing with $prov else insert node $prov into /CSD/providerDirectory
Create or update a service entity. Request parameters should be one or more CSD service entities
import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl"; (: import module namespace random = "http://basex.org/modules/random"; :) import module namespace csd_blu = "https://github.com/openhie/openinfoman/csd_blu"; declare default element namespace "urn:ihe:iti:csd:2013"; 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 :) for $srvc in $careServicesRequest/service let $existing := if (exists($srvc/@entityID)) then csd_bl:filter_by_primary_id(/CSD/serviceDirectory/*,$srvc) else () return if (exists($existing)) then replace node $existing with $srvc else insert node $srvc into /CSD/serviceDirectory
Performs a simple merge from the indicated source document(s) into the target document. Documents are indicated via <document/%gt; elements under the top-level <documents/> element. If @resource attribute of the <document/> should be the name of a document available to OpenInfoMan. Otherwise the content of the <document/> should be a valid CSD document. The following optional elements are allowed: overwriteExisting 0..1 overwriteExisting has integer attribute @value. Defaults to 1 which aany existing elements in the target document are overwritten by those from the source document(s).
import module namespace csd_lsc = "https://github.com/openhie/openinfoman/csd_lsc"; import module namespace csd_dm = "https://github.com/openhie/openinfoman/csd_dm"; 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 variable $careServicesRequest as item() external; let $overwriteExisting := if (exists($careServicesRequest/overwriteExisting/@value)) then ($careServicesRequest/overwriteExisting/@value = 1) else true() let $dest_doc := /. let $dest := $careServicesRequest/@resource for $doc in $careServicesRequest/documents/document let $name := $doc/@resource let $src_doc := if (not (functx:all-whitespace($name))) then if (not ($name = $dest)) then csd_dm:open_document($name) else () else $doc return csd_lsc:refresh_doc($dest_doc, $src_doc,$overwriteExisting)