예제 #1
0
    def run(self):
        subtasks = []
        start_datetime = to_timestamp(self.visit_datetime)
        if self.visit_type:
            stop_datetime = to_timestamp(
                self.visit_datetime + timedelta(days=1) - timedelta(seconds=1)
            )
            visit = {
                'patient': self.person_uuid,
                'visitType': self.visit_type,
                'startDatetime': start_datetime,
                'stopDatetime': stop_datetime,
            }
            if self.location_uuid:
                visit['location'] = self.location_uuid
            response = self.requests.post('/ws/rest/v1/visit', json=visit, raise_for_status=True)
            self.visit_uuid = response.json()['uuid']

        subtasks.append(
            CreateEncounterTask(
                self.requests, self.person_uuid, self.provider_uuid, start_datetime, self.values_for_concept,
                self.encounter_type, self.openmrs_form, self.visit_uuid, self.location_uuid
            )
        )
        return subtasks
예제 #2
0
    def test_to_timestamp_datetime(self):
        class CAT(datetime.tzinfo):
            def utcoffset(self, dt):
                return datetime.timedelta(hours=2)

            def tzname(self, dt):
                return "CAT"

            def dst(self, dt):
                return datetime.timedelta(0)

        dt = datetime.datetime(2017, 6, 27, 9, 36, 47, tzinfo=CAT())
        openmrs_timestamp = to_timestamp(dt)
        self.assertEqual(openmrs_timestamp, '2017-06-27T09:36:47.000+0200')
예제 #3
0
 def test_to_timestamp_day_num(self):
     day_str = '1'
     with self.assertRaisesMessage(
             ValueError, '"1" is not recognised as a date or a datetime'):
         to_timestamp(day_str)
예제 #4
0
 def test_to_timestamp_date(self):
     date = datetime.date(2017, 6, 27)
     openmrs_timestamp = to_timestamp(date)
     self.assertEqual(openmrs_timestamp, '2017-06-27T00:00:00.000+0000')
예제 #5
0
 def test_to_timestamp_datetime_str(self):
     datetime_str = '2017-06-27T09:36:47.396000Z'
     openmrs_timestamp = to_timestamp(datetime_str)
     self.assertEqual(openmrs_timestamp, '2017-06-27T09:36:47.396+0000')