CCR Input Functions

The transforms that convert CCR data into HealthVault types are not simple mappings of one data value onto another. The mappings are context sensitive and depend on both the presence and value of individual elements of the CCR.

The logic behind the transforms is described in detail in HealthVault CCR Input Mappings. In order to improve the readability of those descriptions, some sections of the transform logic are described as procedure or function calls. This document provides pseudocode descriptions of those calls.

IsConcept(text, concept)

If(Vocabulary[concept].ImportText.Contains(text)) 
	return true 
Else 
	return false 

IsConcept(ccrtype, concept)

return  IsConcept(ccrtype/type/text, concept)

Concat(args[], separator)

return args[0] + (for (i = 1 to args.Length - 1) { if exists(args[i]) (separator + args[i]) } )

ResolveActor(actorid)

return /ContinuityOfCareRecord/Actors/Actor[./ActorObjectID = actorid]

ResolveActorInRole(actorrefs, role)

$ActorRef = actorrefs[  IsConcept(./ActorRole, role)] 
return /ContinuityOfCareRecord/Actors/Actor[./ActorObjectID = $ActorRef/ActorID] 

ResolveLink(linkRef)

return /ContinuityOfCareRecord/Body/node()[./CCRDataObjectID = linkRef/LinkID]

ResolveComment(id)

return /ContinuityOfCareRecord/Comments/Comment[./CommentObjectID = id]/Description/Text

ResolveComment(concept)

return /ContinuityOfCareRecord/Comments/Comment[  IsConcept(./Type/Text, concept)]/Description/Text

ResolveReference(ref)

return /ContinuityOfCareRecord/References/Reference[./ReferenceObjectID = id]

FindActorInSource(sources, role)

$Source = sources[  IsConcept(./ActorRole, role)] 
return /ContinuityOfCareRecord/Actors/Actor[./ActorObjectID = $Source/ActorID] 

ActorToString(ccractorref)

$Actor =  ResolveActor(ccractorref/ActorID) 
If Exists($Actor/Person/Name) 
	If Exists($Actor/Person/Name/DisplayName) 
		return $Actor/Person/DisplayName 
	If Exists($Actor/Person/Name/CurrentName) 
		return $Actor/Person/Name/CurrentName // PersonNameType => string 
	If Exists($Actor/Person/Name/BirthName) 
		return $Actor/Person/Name/BirthName // PersonNameType => string 
Else If Exists($Actor/Organization/Name) 
	return $Actor/Organization/Name => string 
Else If Exists($Actor/InformationSystem) 
	$System = $Actor/InformationSystem 
	return  Concat($System/Name, $System/Version, $System/Type) 
Else 
	return "Unknown" 	

ActorToStringDetailed(ccractorref)

$String =  ActorToString(ccractorref) 
$Actor =  ResolveActor(ccractorref/ActorID) 
ForEach($Actor/Address) 
	$String =  Concat($String,  AddressToString($Actor/Address), "\n") 
ForEach($Actor/Telephone) 
	$String =  Concat($String,  CommunicationTypeToString($Actor/Telephone), "\n") 
ForEach($Actor/Email) 
	$String =  Concat($String,  CommunicationTypeToString($Actor/EMail), "\n") 
return $String 	

AddressToString(node)

return  Concat(node/Line1, node/Line2, node/City, node/State, node/PostalCode, node/Country, "\n")

CommunicationTypeToString(node)

return  Concat(./node/Value, ./node/Type/Text)

PersonNameTypeToString(node)

return  Concat(node/Title, node/Given, node/Middle, node/Family, node/Suffix, " ")

LocationToString(node)

return  Concat(node/Description/text,  ActorToStringDetailed(node/Actor), "\n")

ReferenceTypeToString(node)

$String = node/Description/Text 
ForEach(node/Locations/Location) 
	$String =  Concat($String,  LocationToString(.), "\n\n") 
return $String 	

SourceTypeToString(node)

If(node/Description/Text = "Unknown") 
	return node/Description/Text 
Else If Exists(node/Actor) 
	return  ActorToStringDetailed(node/Actor[1]) 
Else If Exists(node/Comment) 
	$Comment =  ResolveComment(./CommentID[1]) 
return $Comment/Description/Text 

GetDefaultDate(node)

If (count(node/DateTime)= 1) and If Not Exists (node/DateTime[1]/Type))
	return node/DateTime[1]

GetDateTime(node, concept)

$DateTime = node/DateTime[IsConcept(./Type/Text, concept)][1]
If Not Exists($dateTime)
    $DateTime = GetDefaultDate(node)
return $DateTime