merge

package
v0.0.0-...-d6db04b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PathsUnsuitableForComparison are paths that don't offer meaningful comparison
	// between two resources. For example, URLs or code systems.
	PathsUnsuitableForComparison = []string{"url", "system", "id", "_id", "text", "reference"}

	// FloatTolerance identifies the minumum difference between 2 floats that still
	// allows them to be considered a match.
	FloatTolerance = 0.0001

	// MatchThreshold is the total percentage of non-nil paths in a resource that must
	// match for the whole resource to be considered a match.
	MatchThreshold = 0.8

	// ErrNoPatientResource occurs if a Patient resource is not found in one or both
	// source bundles.
	ErrNoPatientResource = errors.New("Patient resource not found in one or both source bundles")

	// ErrDuplicatePatientResource occurs if more than one Patient resource is found
	// in either source bundle.
	ErrDuplicatePatientResource = errors.New("Duplicate Patient resources found in one or both source bundles")
)

Functions

This section is empty.

Types

type Detector

type Detector struct{}

Detector provides tools for detecting all conflicts between 2 resources in a Match.

func (*Detector) Conflicts

func (d *Detector) Conflicts(match *Match) (targetResource interface{}, conflict *models.OperationOutcome)

Conflicts identifies all conflicts in a Match, returning a target resource and any conflicts between Left and Right.

type Match

type Match struct {
	ResourceType string
	Left         interface{}
	Right        interface{}
}

Match pairs up to FHIR resources that "match". These resources should be of the same resource type (e.g. Patient).

type Matcher

type Matcher struct{}

Matcher provides tools for identifying all resources in 2 source bundles that "match".

func (*Matcher) Match

func (m *Matcher) Match(leftBundle, rightBundle *models.Bundle) (matches []Match, unmatchables []interface{}, err error)

Match iterates through all resources in the two source bundles and attempts to find resources that "match". These resources can then be compared to each other to see what conflicts may still exist between them. All matches are returned as a slice of Match pairs. Resources without a match are returned separately as a slice of "unmatchables".

type Merger

type Merger struct {
	// contains filtered or unexported fields
}

Merger is the top-level interface used to merge resources and resolve conflicts.

func NewMerger

func NewMerger(fhirHost string) *Merger

NewMerger returns a pointer to a newly initialized Merger with a known FHIR host.

func (*Merger) DeleteTargetResource

func (m *Merger) DeleteTargetResource(targetBundleURL, targetResourceID string) error

DeleteTargetResource deletes a single resource in the target bundle, by ID.

func (*Merger) Merge

func (m *Merger) Merge(source1, source2 string) (outcome *models.Bundle, targetURL string, err error)

Merge attempts to merge two FHIR Bundles containing patient records. If a merge is successful a new FHIR Bundle containing the merged patient record is returned. If a merge fails, a FHIR Bundle containing one or more OperationOutcomes is returned detailing the merge conflicts.

func (*Merger) ResolveConflict

func (m *Merger) ResolveConflict(targetBundleURL, targetResourceID string, updatedResource interface{}) error

ResolveConflict attempts to resolve a single merge conflict. If the conflict resolution is successful and no more conflicts exist, the merged FHIR Bundle is returned. If additional conflicts still exist or the conflict resolution was not successful, a FHIR Bundle of OperationOutcomes is returned detailing the remaining merge conflicts.

func (*Merger) UpdateTargetResource

func (m *Merger) UpdateTargetResource(targetBundleURL, targetResourceID string, updatedResource interface{}) error

UpdateTargetResource updates a single resource in the target bundle, by ID.

type PathMap

type PathMap map[string]reflect.Value

PathMap captures all non-nil paths in a resource and the values at those paths.

func (PathMap) Keys

func (p PathMap) Keys() []string

type ResourceMap

type ResourceMap map[string][]interface{}

ResourceMap is used to map a list of resources to their specific type.

func (ResourceMap) Keys

func (r ResourceMap) Keys() []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL