[go: up one dir, main page]

Skip to content

Raise if Configuration Path Provided but cannot be found

Task Description

In https://gitlab.com/fhirpack/main/-/blob/main/src/fhirpack/config.py it's assumed the user knows what they're doing and has provided a valid path to the configuration file.

    def loadConfig(self, dotenvPath: str = None):
        """Loads a FHIRPACK configuration from the given .env file.

        Args:
            dotenvPath (Union[str, None]): Path to the .env file. Defaults to None.
        """
        if not dotenvPath:
            dotenvPath = dotenv.find_dotenv()
        # TODO: decide whether to fail or attempt rescue via .env.example
        dotenvPath = ".env.example" if not dotenvPath else dotenvPath

        config = dotenv.dotenv_values(dotenvPath)

        self.__CONFIG = config
        self.__DOTENVPATH = dotenvPath

This, however, leads to obscure errors further down the line if the file was not found but a successful configuration of FHIRPACK was assumed:

---------------------------------------------------------------------------
MissingSchema                             Traceback (most recent call last)
Cell In[53], line 7
      4 pack = fp.PACK(envFile='docker-compose.env')
      6 # pack.getPatients(['1']).values
----> 7 p = pack.getPatients(['1'])

File src/fhirpack/extraction/patient.py:40, in ExtractorPatientMixin.getPatients(self, input, searchParams, params, ignoreFrame, *args, **kwargs)
     21 def getPatients(
     22     self,
     23     input: Union[
   (...)
     32     **kwargs,
     33 ):
     34     """Retrieves FHIR Patient resources.
     35 
     36     Returns:
     37         Frame: Frame object storing the Patients.
     38     """
---> 40     return self.getResources(
     41         input=input,
     42         searchParams=searchParams,
     43         params=params,
     44         ignoreFrame=ignoreFrame,
     45         resourceType="Patient",
...
    442     )
    444 if not host:
    445     raise InvalidURL(f"Invalid URL {url!r}: No host supplied")

MissingSchema: Invalid URL '/Patient?_id=1&_count=2': No scheme supplied. Perhaps you meant https:///Patient?_id=1&_count=2?

Sub-tasks

  • TODO
  • TODO

References

[1]

[2]


cc @jdsalaro