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:
- 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:
- property isFrame#
- parseReference(reference: str | SyncFHIRReference, resourceType: str | None = None)[source]#
Parses a reference string into a SyncFHIRReference object.
- Parameters:
- 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.
- 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:
- prepareReferences(referenceList, resourceType: str | None = None)[source]#
Parses a list of references into a list of SyncFHIRReference objects.
- referencesToIds(referenceList: list[fhirpy.lib.SyncFHIRReference]) list[str] [source]#
Converts a list of SyncFHIRReference objects into a list of ids.
- 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:
- 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.