fhirpack.base module#

class fhirpack.base.BaseMixin[source]#

Bases: object

Base class with methods that are avaialable to all Frame objects and operations according to the mixin pattern. The methods are not directly associated with the Extractor, Transformer or Loader.

attachOperandIds(input, result, metaResourceType)[source]#

Attaches the ids of the input data to the result data.

Parameters:
  • input – Initial Frame on which an operation was performed

  • result – Resulting Frame of the operation, to which the input’s Resource IDs should be attached

  • metaResourceType – _description_

Returns:

Resulting frame with attached IDs under the input’s type column

Return type:

Frame

authenticate(force: bool = False)[source]#
castOperand(input, target, resourceType=None)[source]#
property connected#
guessOutputResourceType(data)[source]#

Guess the resource type of the data received.

Parameters:

data – Data to be processed.

Returns:

Resource type of the output data.

Return type:

str

property isFrame#
parseReference(reference: str | SyncFHIRReference, resourceType: str | None = None)[source]#

Parses a reference string into a SyncFHIRReference object.

Parameters:
  • reference (Union[str, SyncFHIRReference]) – Input reference string or SyncFHIRReference object.

  • resourceType (Union[str, None) – Resource type of the reference. Defaults to None.

Raises:

Exception – If the reference string is not in the correct format.

Returns:

FHIR resource reference constructed from a string or a valid SyncFHIRReference which isn’t associated with a client yet

Return type:

SyncFHIRReference

prepareCompositeOutput(data: dict)[source]#

Constructs a composite Frame, that is a frame containing multiple resource types, from the provided data.

Parameters:

data (dict) – Data stored in the Frame object.

Returns:

Frame object storing the provided data.

Return type:

Frame

prepareInput(data, resourceType)[source]#
prepareOperationInput(input, target, resourceType=None)[source]#
prepareOutput(data, resourceType=None, columns=['data'], wrap=True)[source]#

Constructs a Frame object from the provided data.

Parameters:
  • data – Data stored in the Frame object.

  • resourceType – FHIR resource type of the provided data.

  • columns – Colunn names. Defaults to [“data”].

  • wrap – Defaults to True.

Returns:

Frame object storing the provided data.

Return type:

Frame

prepareReferences(referenceList, resourceType: str | None = None)[source]#

Parses a list of references into a list of SyncFHIRReference objects.

Parameters:
  • referenceList (list) – List of reference strings or SyncFHIRReference objects.

  • resourceType (Union[str,None]) – Resource type of the references. Defaults to None.

Returns:

List of SyncFHIRReference objects.

Return type:

list[SyncFHIRReference]

referencesToIds(referenceList: list[fhirpy.lib.SyncFHIRReference]) list[str][source]#

Converts a list of SyncFHIRReference objects into a list of ids.

Parameters:

referenceList (list[SyncFHIRReference]) – List of SyncFHIRReference objects.

Returns:

List of ids.

Return type:

list[str]

referencesToResources(referenceList)[source]#
resourceType = 'Invalid'#
class fhirpack.base.Frame(*args, **kwargs)[source]#

Bases: DataFrame, BaseMixin, ExtractorMixin, TransformerMixin, LoaderMixin, PluginMixin

This is the main datatstructure of the FHIRPACK package. It inherits from pandas.DataFrame and adds the functionality to work with FHIR resources.

cast(format)[source]#

Casts the Frame object to a different format.

Parameters:

format (str) – Format to cast to.

Raises:

NotImplementedError – If the format is not implemented.

explode(*args, **kwargs)[source]#

Explodes all lists in the Frame object.

Returns:

Exploded Frame object.

Return type:

Frame

property getResourceType#
property keys#

Get the ‘info axis’ (see Indexing for more).

This is index for Series, columns for DataFrame.

Returns:

Info axis.

Return type:

Index

property pretty#

Prints the Frame object in a pretty json format.

resourceTypeIs(resourceType: str) bool[source]#

Returns True if the resourceType of the Frame object matches the given resourceType.

Parameters:

resourceType (str) – Resource type to compare.

Returns:

True if the resourceType of the Frame object matches the given resourceType.

Return type:

bool

setResourceType(resourceType: str)[source]#

Sets the resourceType of the Frame object.

Parameters:

resourceType (str) – Resource type to set.

property summary#

Prints a summary of the Frame object.

Returns:

Summary of the Frame object.

Return type:

Frame