示例#1
0
 def test_list_items(self):
     table = self.create_session_table()
     d = DataStore('dynamodb', 'Sessions', 'PatientId', 'SessionId')
     d.save(SESSION_INFO_1)
     response = d.listItems()
     self.assertEqual(1, len(response))
     d.save(SESSION_INFO_1)
     response = d.listItems()
     self.assertEqual(1, len(response))
     d.save(SESSION_INFO_2)
     response = d.listItems()
     self.assertEqual(2, len(response))
     d.save(SESSION_INFO_3)
     response = d.listItems()
     self.assertEqual(3, len(response))
class HealthCareProfessional:
    def __init__(self):
        """Constructor for the health care professional class to store information regarding the health care professional table
        
        Args:
            None

        Returns:
            The HealthCareProfessional object
        """
        self._databaseName = "dynamodb"
        self._tableName = "HealthCareProfessionals"
        self._partitionKeyName = "HealthCareProfessionalId"
        self._healthCareProfessionalDataStore = DataStore(self._databaseName, self._tableName, self._partitionKeyName)

    def createHealthCareProfessional(self, info):
        """Create the healthcare care professional and store the data into database
        
        Args:
            info(dict): information regarding the health care professional (health care professional id, health care professional name, etc.)

        Returns:
            None
        """
        return self._healthCareProfessionalDataStore.save(info)

    def requestHealthCareProfessionals(self, partitionKey):
        """Request and get the specific health care professional from the database based on partition key.
        If there is no partition key provided, return list of all health care professionals through pagination
        
        Args:
            partitionKey(str): partition key value of the health care professional table

        Returns:
            List of health care professional(s) info
        """
        return self._healthCareProfessionalDataStore.queryByPartitionKey(partitionKey) if partitionKey else self._healthCareProfessionalDataStore.listItems()
class Patient:
    def __init__(self):
        """Constructor for the Patient class to store information regarding the Patient table
        
        Args:
            None

        Returns:
            The Patient object
        """
        self._databaseName = "dynamodb"
        self._tableName = "Patients"
        self._partitionKeyName = "PatientId"
        self._patientDataStore = DataStore(self._databaseName, self._tableName, self._partitionKeyName)

    def createPatient(self, info):
        """Create the patient and store the data into database
        
        Args:
            info(dict): information regarding the patient (patient id, patient name, etc.)

        Returns:
            None
        """
        return self._patientDataStore.save(info) 

    def requestPatients(self, partitionKey):
        """Request and get the specific patient from the database based on partition key.
        If there is no partition key provided, return list of all patients through pagination
        
        Args:
            partitionKey(str): partition key value of the patient table

        Returns:
            List of patient(s) info
        """
        return self._patientDataStore.queryByPartitionKey(partitionKey) if partitionKey else self._patientDataStore.listItems()
示例#4
0
 def test_list_items_empty(self):
     table = self.create_session_table()
     d = DataStore('dynamodb', 'Sessions', 'PatientId', 'SessionId')
     response = d.listItems()
     self.assertEqual(0, len(response))