Ejemplo n.º 1
0
    def test_organization_inheritence_search(self):
        # Region at top should apply to leaves
        self.deepen_org_tree()
        count = Organization.query.count()
        assert count > 3

        # add region to one mid-level parent org with two children,
        # we should get only those three
        region = Identifier(value='state:NY', system=PRACTICE_REGION)
        with SessionScope(db):
            db.session.add(region)
            db.session.commit()
        region = db.session.merge(region)
        oi = OrganizationIdentifier(organization_id=1002,
                                    identifier_id=region.id)
        with SessionScope(db):
            db.session.add(oi)
            db.session.commit()

        # use api to obtain FHIR bundle
        self.login()
        response = self.client.get('/api/organization?state=NY')
        assert response.status_code == 200
        bundle = response.json
        assert bundle['resourceType'] == 'Bundle'
        assert len(bundle['entry']) == 3

        # add filter to restrict to just the leaves
        response = self.client.get('/api/organization?state=NY&filter=leaves')
        assert response.status_code == 200
        bundle = response.json
        assert bundle['resourceType'] == 'Bundle'
        assert len(bundle['entry']) == 2
Ejemplo n.º 2
0
    def test_organization_get_by_identifier(self):
        org_id_system = "http://test/system"
        org_id_value = "testval"
        self.login()
        org = Organization(name='test', id=999)
        ident = Identifier(id=99, system=org_id_system, value=org_id_value)
        org_ident = OrganizationIdentifier(organization_id=999,
                                           identifier_id=99)
        with SessionScope(db):
            db.session.add(org)
            db.session.add(ident)
            db.session.commit()
            db.session.add(org_ident)
            db.session.commit()

        # use api to obtain FHIR
        response = self.client.get(
            '/api/organization?system={system}&value={value}'.format(
                system=quote_plus(org_id_system), value=org_id_value))
        assert response.status_code == 200
        assert response.json['total'] == 1
        assert response.json['entry'][0]['id'] == 999

        # use alternative API to obtain organization
        response = self.client.get(
            '/api/organization/{value}?system={system}'.format(
                system=quote_plus(org_id_system), value=org_id_value))
        assert response.status_code == 200
        fetched = Organization.from_fhir(response.json)
        org = db.session.merge(org)
        assert org.id == fetched.id
        assert org.name == fetched.name
    def test_organization_get_by_identifier(self):
        org_id_system = "testsystem"
        org_id_value = "testval"
        self.login()
        org = Organization(name='test', id=999)
        ident = Identifier(id=99, system=org_id_system, value=org_id_value)
        org_ident = OrganizationIdentifier(organization_id=999,
                                           identifier_id=99)
        with SessionScope(db):
            db.session.add(org)
            db.session.add(ident)
            db.session.commit()
            db.session.add(org_ident)
            db.session.commit()

        # use api to obtain FHIR
        rv = self.client.get('/api/organization/{}/{}'.format(
            org_id_system, org_id_value))
        self.assert200(rv)
Ejemplo n.º 4
0
    def test_organization_search(self):
        self.shallow_org_tree()
        count = Organization.query.count()
        assert count > 1

        # add region to one org, we should get only that one back
        region = Identifier(value='state:NY', system=PRACTICE_REGION)
        with SessionScope(db):
            db.session.add(region)
            db.session.commit()
        region = db.session.merge(region)
        oi = OrganizationIdentifier(organization_id=1001,
                                    identifier_id=region.id)
        with SessionScope(db):
            db.session.add(oi)
            db.session.commit()

        # use api to obtain FHIR bundle
        self.login()
        response = self.client.get('/api/organization?state=NY')
        assert response.status_code == 200
        bundle = response.json
        assert bundle['resourceType'] == 'Bundle'
        assert len(bundle['entry']) == 1
    def test_organization_search(self):
        self.shallow_org_tree()
        count = Organization.query.count()
        self.assertTrue(count > 1)

        # add region to one org, we should get only that one back
        region = Identifier(value='state:NY', system=PRACTICE_REGION)
        with SessionScope(db):
            db.session.add(region)
            db.session.commit()
        region = db.session.merge(region)
        oi = OrganizationIdentifier(organization_id=1001,
                                    identifier_id=region.id)
        with SessionScope(db):
            db.session.add(oi)
            db.session.commit()

        # use api to obtain FHIR bundle
        self.login()
        rv = self.client.get('/api/organization?state=NY')
        self.assert200(rv)
        bundle = rv.json
        self.assertTrue(bundle['resourceType'], 'Bundle')
        self.assertEquals(len(bundle['entry']), 1)