Stored Functions

Content-Type: application/json
URN: urn:openhie.org:openinfoman-rapidpro:get_json_for_import

Description



 
    Get JSON representation of CSD for import to RapidPro via API
  

Definition

Source:
import module namespace csr_proc = "https://github.com/openhie/openinfoman/csr_proc";
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 $careServicesSubRequest :=  
  <csd:careServicesRequest>
    <csd:function  urn="urn:ihe:iti:csd:2014:stored-function:provider-search" >
      <csd:requestParams/>
    </csd:function>
  </csd:careServicesRequest> 

let $providers := csr_proc:process_CSR_stored_results($csd_webconf:db, /. , $careServicesSubRequest)


let $contacts :=  
  <json type='object'>
    <contacts type="array">
    {
      for $provider in  $providers/csd:providerDirectory/csd:provider
      let $uuid := lower-case(string($provider/@entityID))
      let $payrollnum := $provider/csd:otherID[@code="1"]/text()
      let $payrollisssue := string($provider/csd:otherID[@code="1"]/@issuedate)
      let $name := ($provider/csd:demographic/csd:name/csd:commonName)[1]/text()
      let $tels := $provider/csd:demographic/csd:contactPoint/csd:codedType[@code="BP" and  @codingScheme="urn:ihe:iti:csd:2013:contactPoint"]
      let $tel_1 := $tels[1]/text()
      let $tel_2 := $tels[2]/text()
      let $tel_3 := $tels[3]/text()
      return 
	if (true()) (:  ($uuid and $name)  :)
       then 
         <_  type="object">
	   <name>{$name}</name>
	   <urns type="array">
             { if ($tel_1) then   <_ type='string'>tel:{$tel_1}</_> else ()} 
             { if ($tel_2) then   <_ type='string'>tel:{$tel_2}</_> else ()} 
             { if ($tel_3) then   <_ type='string'>tel:{$tel_3}</_> else ()} 
	   </urns>
	   <fields type="object">
             <globalid>{$uuid}</globalid>
             <payrollnum>{$payrollnum}</payrollnum>
             <payrollissue>{$payrollisssue}</payrollissue>
	   </fields>
         </_>
       else ()
    }
    </contacts>
  </json>


return json:serialize($contacts,map{"format":"direct"})  
Content-Type: text/xml
URN: urn:openhie.org:openinfoman-liberia:mhero-merge

Description



 
    Performs merge for Liberia preserving any mHero/RapidPRO identifiers for existing providers.
  

Definition

Source:
import module namespace csd_webconf =  "https://github.com/openhie/openinfoman/csd_webconf";

import module namespace csd_dm = "https://github.com/openhie/openinfoman/csd_dm";

import module namespace mhero = "https://github.com/openhie/openinfoman-mhero";

declare namespace csd  =  "urn:ihe:iti:csd:2013";

declare variable $careServicesRequest as item() external;


let $mhero_doc := /.
let $mhero := $careServicesRequest/@resource
let $mhero := $careServicesRequest/documents/mhero/@resource


for $doc  in $careServicesRequest/documents/document
let $name := $doc/@resource
let $src_doc :=
  if (not ($name  = '')) 
  then if (not ($name = $mhero)) then csd_dm:open_document( $name) else ()
  else $doc
return mhero:merge_into($mhero_doc, $src_doc)