fhirpack package#

Subpackages#

Submodules#

fhirpack.auth module#

class fhirpack.auth.Auth[source]#

Bases: object

__dict__ = mappingproxy({'__module__': 'fhirpack.auth', 'getToken': <staticmethod object>, 'tokenViaPasswordGrant': <staticmethod object>, 'oAuthTokenFromJWT': <staticmethod object>, 'parseSHIPTokenEndpointResponse': <staticmethod object>, '__dict__': <attribute '__dict__' of 'Auth' objects>, '__weakref__': <attribute '__weakref__' of 'Auth' objects>, '__doc__': None, '__annotations__': {}})#
__doc__ = None#
__module__ = 'fhirpack.auth'#
__weakref__#

list of weak references to the object (if defined)

static getToken(grant_type, params={})[source]#
static oAuthTokenFromJWT(token)[source]#
static parseSHIPTokenEndpointResponse(response)[source]#
static tokenViaPasswordGrant(params)[source]#

fhirpack.base module#

class fhirpack.base.BaseMixin[source]#

Bases: object

__dict__ = mappingproxy({'__module__': 'fhirpack.base', 'guessOutputResourceType': <function BaseMixin.guessOutputResourceType>, 'prepareCompositeOutput': <function BaseMixin.prepareCompositeOutput>, 'prepareOutput': <function BaseMixin.prepareOutput>, 'parseReference': <function BaseMixin.parseReference>, 'prepareReferences': <function BaseMixin.prepareReferences>, 'prepareOperationInput': <function BaseMixin.prepareOperationInput>, 'castOperand': <function BaseMixin.castOperand>, 'referencesToIds': <function BaseMixin.referencesToIds>, 'referencesToResources': <function BaseMixin.referencesToResources>, 'prepareInput': <function BaseMixin.prepareInput>, 'isFrame': <property object>, '__dict__': <attribute '__dict__' of 'BaseMixin' objects>, '__weakref__': <attribute '__weakref__' of 'BaseMixin' objects>, '__doc__': None, '__annotations__': {}})#
__doc__ = None#
__module__ = 'fhirpack.base'#
__weakref__#

list of weak references to the object (if defined)

castOperand(input, target, resourceType=None)[source]#
guessOutputResourceType(data)[source]#
property isFrame#
parseReference(reference: Union[str, fhirpy.lib.SyncFHIRReference], resourceType=None)[source]#
prepareCompositeOutput(data: dict)[source]#
prepareInput(data, resourceType)[source]#
prepareOperationInput(input, target, resourceType=None)[source]#
prepareOutput(data, resourceType=None, columns=['data'], wrap=True)[source]#
prepareReferences(referenceList, resourceType=None)[source]#
referencesToIds(referenceList)[source]#
referencesToResources(referenceList)[source]#
class fhirpack.base.Frame(*args, **kwargs)[source]#

Bases: pandas.core.frame.DataFrame, fhirpack.base.BaseMixin, fhirpack.extraction.ExtractorMixin, fhirpack.transformation.TransformerMixin, fhirpack.load.LoaderMixin, fhirpack.custom.PluginMixin

__doc__ = None#
__init__(*args, **kwargs)[source]#
__module__ = 'fhirpack.base'#
property _constructor#

Used when a manipulation result has the same dimensions as the original.

property _constructor_expanddim#
_metadata: list[str] = ['client', 'resourceType']#
_mgr: BlockManager | ArrayManager#
cast(format)[source]#
explode(*args, **kwargs)[source]#

Transform each element of a list-like to a row, replicating index values.

New in version 0.25.0.

Parameters
  • column (IndexLabel) –

    Column(s) to explode. For multiple columns, specify a non-empty list with each element be str or tuple, and all specified columns their list-like data on same row of the frame must have matching length.

    New in version 1.3.0: Multi-column explode

  • ignore_index (bool, default False) –

    If True, the resulting index will be labeled 0, 1, …, n - 1.

    New in version 1.1.0.

Returns

Exploded lists to rows of the subset columns; index will be duplicated for these rows.

Return type

DataFrame

Raises

ValueError :

  • If columns of the frame are not unique. * If specified columns to explode is empty list. * If specified columns to explode have not matching count of elements rowwise in the frame.

See also

DataFrame.unstack

Pivot a level of the (necessarily hierarchical) index labels.

DataFrame.melt

Unpivot a DataFrame from wide format to long format.

Series.explode

Explode a DataFrame from list-like columns to long format.

Notes

This routine will explode list-likes including lists, tuples, sets, Series, and np.ndarray. The result dtype of the subset rows will be object. Scalars will be returned unchanged, and empty list-likes will result in a np.nan for that row. In addition, the ordering of rows in the output will be non-deterministic when exploding sets.

Reference the user guide for more examples.

Examples

>>> df = pd.DataFrame({'A': [[0, 1, 2], 'foo', [], [3, 4]],
...                    'B': 1,
...                    'C': [['a', 'b', 'c'], np.nan, [], ['d', 'e']]})
>>> df
           A  B          C
0  [0, 1, 2]  1  [a, b, c]
1        foo  1        NaN
2         []  1         []
3     [3, 4]  1     [d, e]

Single-column explode.

>>> df.explode('A')
     A  B          C
0    0  1  [a, b, c]
0    1  1  [a, b, c]
0    2  1  [a, b, c]
1  foo  1        NaN
2  NaN  1         []
3    3  1     [d, e]
3    4  1     [d, e]

Multi-column explode.

>>> df.explode(list('AC'))
     A  B    C
0    0  1    a
0    1  1    b
0    2  1    c
1  foo  1  NaN
2  NaN  1  NaN
3    3  1    d
3    4  1    e
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#
resourceTypeIs(resourceType)[source]#
setResourceType(resourceType)[source]#

fhirpack.base_test module#

fhirpack.cli module#

fhirpack.cli.info(msg)[source]#
fhirpack.cli.loadToDestination(data, destination: str) None[source]#
fhirpack.cli.processParams(string: str) dict[source]#
fhirpack.cli.run()[source]#

Calls main() passing the CLI arguments extracted from sys.argv

This function can be used as entry point to create console scripts with setuptools.

fhirpack.cli.setupLogging()[source]#

fhirpack.cli_test module#

fhirpack.config module#

class fhirpack.config.Config[source]#

Bases: object

__CONFIG = {}#
__DOTENVPATH = None#
__configLogger()#
__dict__ = mappingproxy({'__module__': 'fhirpack.config', '_Config__CONFIG': {}, '_Config__DOTENVPATH': None, '__init__': <function Config.__init__>, 'loadConfig': <function Config.loadConfig>, 'globalExceptionHandler': <function Config.globalExceptionHandler>, 'data': <property object>, '_Config__configLogger': <staticmethod object>, 'set': <function Config.set>, 'get': <function Config.get>, 'getLogger': <function Config.getLogger>, '__dict__': <attribute '__dict__' of 'Config' objects>, '__weakref__': <attribute '__weakref__' of 'Config' objects>, '__doc__': None, '__annotations__': {}})#
__doc__ = None#
__init__()[source]#
__module__ = 'fhirpack.config'#
__weakref__#

list of weak references to the object (if defined)

property data#
get(key)[source]#
getLogger(name)[source]#
globalExceptionHandler(exctype, value, tb)[source]#
loadConfig(dotenvPath=None)[source]#
set(key, value, saveToEnv=False)[source]#

fhirpack.config_test module#

fhirpack.config_test.envFile(tmp_path)[source]#

Crates a temporary dot env file so the original one is not manipulated

fhirpack.conftest module#

fhirpack.conftest.observationFrame(packUnconnected)[source]#
fhirpack.conftest.observationResourceList(observationFrame)[source]#
fhirpack.conftest.packageSessionFixture(request)[source]#
fhirpack.conftest.patientAsDict(patientResourceList)[source]#
fhirpack.conftest.patientFrame(packUnconnected)[source]#
fhirpack.conftest.patientReference(patientReferenceList)[source]#
fhirpack.conftest.patientReferenceList(patientResourceList)[source]#
fhirpack.conftest.patientResource(patientResourceList)[source]#
fhirpack.conftest.patientResourceList(patientFrame)[source]#

fhirpack.constants module#

class fhirpack.constants.SampleEnum(value)[source]#

Bases: enum.Enum

An enumeration.

__doc__ = 'An enumeration.'#
__module__ = 'fhirpack.constants'#
sample = 'sample'#

fhirpack.exceptions module#

exception fhirpack.exceptions.BaseError[source]#

Bases: Exception

__doc__ = None#
__module__ = 'fhirpack.exceptions'#
__weakref__#

list of weak references to the object (if defined)

class fhirpack.exceptions.ErrorSeverity(value)[source]#

Bases: enum.Enum

An enumeration.

__doc__ = 'An enumeration.'#
__module__ = 'fhirpack.exceptions'#
error = 'error'#
fatal = 'fatal'#
information = 'information'#
warning = 'warning'#
class fhirpack.exceptions.InvalidConfigurationException[source]#

Bases: object

__dict__ = mappingproxy({'__module__': 'fhirpack.exceptions', '__dict__': <attribute '__dict__' of 'InvalidConfigurationException' objects>, '__weakref__': <attribute '__weakref__' of 'InvalidConfigurationException' objects>, '__doc__': None, '__annotations__': {}})#
__doc__ = None#
__module__ = 'fhirpack.exceptions'#
__weakref__#

list of weak references to the object (if defined)

exception fhirpack.exceptions.InvalidInputDataException[source]#

Bases: ValueError

Raised when invalid input types are passed.

__doc__ = 'Raised when invalid input types are passed.'#
__module__ = 'fhirpack.exceptions'#
__weakref__#

list of weak references to the object (if defined)

class fhirpack.exceptions.InvalidOperationException[source]#

Bases: object

Raised when operation is invalid for data.

__dict__ = mappingproxy({'__module__': 'fhirpack.exceptions', '__doc__': 'Raised when operation is invalid for data.', '__dict__': <attribute '__dict__' of 'InvalidOperationException' objects>, '__weakref__': <attribute '__weakref__' of 'InvalidOperationException' objects>, '__annotations__': {}})#
__doc__ = 'Raised when operation is invalid for data.'#
__module__ = 'fhirpack.exceptions'#
__weakref__#

list of weak references to the object (if defined)

exception fhirpack.exceptions.InvalidSearchParams[source]#

Bases: ValueError

Raised when invalid key is used for searchParams

__doc__ = 'Raised when invalid key is used for searchParams'#
__module__ = 'fhirpack.exceptions'#
__weakref__#

list of weak references to the object (if defined)

exception fhirpack.exceptions.SampleError[source]#

Bases: fhirpack.exceptions.BaseError

__doc__ = None#
__module__ = 'fhirpack.exceptions'#
exception fhirpack.exceptions.ServerConnectionException[source]#

Bases: ConnectionError

Raised when pack does not have connection to server.

__doc__ = 'Raised when pack does not have connection to server.'#
__module__ = 'fhirpack.exceptions'#
__weakref__#

list of weak references to the object (if defined)

fhirpack.pack module#

class fhirpack.pack.PACK(apiBase=None, client=None, envFile=None, unconnected=False, authMethod=None, authParams=None)[source]#

Bases: fhirpack.base.BaseMixin, fhirpack.extraction.ExtractorMixin, fhirpack.transformation.TransformerMixin, fhirpack.load.LoaderMixin, fhirpack.custom.PluginMixin

__doc__ = None#
__init__(apiBase=None, client=None, envFile=None, unconnected=False, authMethod=None, authParams=None)[source]#
__module__ = 'fhirpack.pack'#
__setupClient(apiBase=None, authMethod=None, authParams=None)#
countServerResources()[source]#

fhirpack.utils module#

fhirpack.utils.clientFromEnv()[source]#
fhirpack.utils.flattenList(input: list)[source]#
fhirpack.utils.getInstallationPath()[source]#
fhirpack.utils.guessBufferMIMEType(bytes: bytes)[source]#
fhirpack.utils.keys(obj, prefix='')[source]#
fhirpack.utils.textToAscii()[source]#
fhirpack.utils.validateFrame(frame)[source]#
fhirpack.utils.valuesForKeys(data: Union[dict, list], lookupKeys: list)[source]#

fhirpack.utils_test module#

Module contents#