Beispiel #1
0
def observations():
    with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_observations.json'), 'r') as observations_file:
        observations_data = observations_file.read().replace('\n', '')
    assert observations_data is not None
    observations: List[Observation] = str_to_observations(observations_data)
    yield observations
    del observations, observations_data
    def get_patient_observations(self, id: str) -> List[Observation]:
        """
        Args:
            id: Patient ID or UUID string

        Returns: A list of observations for a patient

        """
        response = requests.get(urllib.parse.urljoin(self.endpoint, 'Observation/' + str(id)),
                                verify=self.verify_ssl)
        self._error_response(response)
        try:
            return str_to_observations(response.text)
        except KeyError:
            raise AttributeError('Observation data from patient is corrupt')
Beispiel #3
0
    def get_patient_observations_page(self, id: str,
                                      page: int) -> List[Observation]:
        """
        Args:
            id: Patient ID or UUID string
            page: Page number int

        Returns: A list of observations for a patient up to the specified page

        """
        response = requests.get(urllib.parse.urljoin(
            self.endpoint, 'Observation/pages/' + str(page) + '/' + str(id)),
                                verify=self.verify_ssl)
        self._error_response(response)
        try:
            return str_to_observations(response.text,
                                       ignore_errors=self.ignore_errors)
        except KeyError:
            raise AttributeError('Observation data from patient is corrupt')