Skip to content

Commit

Permalink
[IMP] Improved organization handling
Browse files Browse the repository at this point in the history
* Rename pharmacy to organization
* Add foreign keys to organization
  • Loading branch information
lasley committed Sep 6, 2016
1 parent e6d2bbe commit 0e66840
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 14 deletions.
10 changes: 8 additions & 2 deletions carepoint/models/cph/account_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ class AccountActivity(Carepoint.BASE):
Integer,
ForeignKey('cprx_disp.rxdisp_id'),
)
org_id = Column(Integer)
orig_org_id = Column(Integer)
org_id = Column(
Integer,
ForeignKey('csorg.org_id'),
)
orig_org_id = Column(
Integer,
ForeignKey('csorg.org_id'),
)
item_id = Column(
Integer,
ForeignKey('item.item_id'),
Expand Down
5 changes: 4 additions & 1 deletion carepoint/models/cph/doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ class Doctor(Carepoint.BASE):
blue_shield_id = Column(String)
blue_cross_id = Column(String)
npi_id = Column(String)
practice_org_id = Column(Integer)
practice_org_id = Column(
Integer,
ForeignKey('csorg.org_id'),
)
cmt = Column(Text)
status_cn = Column(Integer)
conv_code = Column(String)
Expand Down
5 changes: 4 additions & 1 deletion carepoint/models/cph/order_line_non_rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ class OrderLineNonRx(Carepoint.BASE):
Integer,
ForeignKey('CsOm.order_id'),
)
org_id = Column(Integer)
org_id = Column(
Integer,
ForeignKey('csorg.org_id'),
)
pat_id = Column(
Integer,
ForeignKey('cppat.pat_id'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)


class Pharmacy(Carepoint.BASE):
class Organization(Carepoint.BASE):
__dbname__ = 'cph'
__tablename__ = 'csorg'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)


class PharmacyAddress(AddressMixin, Carepoint.BASE):
class OrganizationAddress(AddressMixin, Carepoint.BASE):
__dbname__ = 'cph'
__tablename__ = 'csorg_addr'
org_id = Column(Integer, primary_key=True)
5 changes: 4 additions & 1 deletion carepoint/models/cph/prescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ class Prescription(Carepoint.BASE):
last_refill_qty = Column(Numeric)
last_refill_date = Column(DateTime)
refill_date = Column(DateTime)
src_org_id = Column(Integer)
src_org_id = Column(
Integer,
ForeignKey('csorg.org_id'),
)
cmt = Column(Text)
exit_state_cn = Column(Integer)
script_status_cn = Column(Integer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import unittest
from sqlalchemy.schema import Table
from carepoint.tests.db.db import DatabaseTest
from carepoint.models.cph.pharmacy import Pharmacy
from carepoint.models.cph.organization import Organization


class TestModelsCphPharmacy(DatabaseTest):
class TestModelsCphOrganization(DatabaseTest):

def test_table_initialization(self, ):
self.assertIsInstance(Pharmacy.__table__, Table)
self.assertIsInstance(Organization.__table__, Table)


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
import unittest
from sqlalchemy.schema import Table
from carepoint.tests.db.db import DatabaseTest
from carepoint.models.cph.pharmacy_address import PharmacyAddress
from carepoint.models.cph.organization_address import OrganizationAddress


class TestModelsCphPharmacyAddress(DatabaseTest):
class TestModelsCphOrganizationAddress(DatabaseTest):

def test_table_initialization(self):
self.assertIsInstance(PharmacyAddress.__table__, Table)
self.assertIsInstance(OrganizationAddress.__table__, Table)

def test_addr_mixin_col(self):
self.assertTrue(
hasattr(PharmacyAddress, 'addr_id')
hasattr(OrganizationAddress, 'addr_id')
)

if __name__ == '__main__':
Expand Down

0 comments on commit 0e66840

Please sign in to comment.