Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use get_or_create_patient in the IPC status table #1443

Open
wants to merge 1 commit into
base: cerner-merge-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/ipc/management/commands/load_ipc_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ def handle(self, *args, **options):
if len(mrn) == 0:
continue
else:
patient = loader.create_rfh_patient_from_hospital_number(
# The table contains multiple results for the same
# MRN so get or create in case they have already
# recently been created.
patient, _ = loader.get_or_create_patient(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this mean that we care about the ordering of the results in some way?
this overwrites with the arbitrarily last - is that the behaviour we want?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there is an ongoing discussion on how to merge ipc status https://github.com/openhealthcare/Development/issues/166

you're right there is an arbitrary behaviour that already exists, this is more so that the we can run the ipc command as with the new create_rfh_patient_from_hospital_number error handling this will blow up and so the command can't be run.

2 options the way I see it...

  1. We leave it breaking as a reminder its somethings we have to fix
  2. We take add the merge issue to 166 and move on.

I'm happy with either

mrn, elcid_episode_categories.InfectionService
)

Expand Down
6 changes: 3 additions & 3 deletions plugins/ipc/tests/test_load_ipc_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def test_creates(self, ProdAPI):
self.assertEqual(ipc_status.comments, "A comment")

@patch('plugins.ipc.management.commands.load_ipc_status.ProdAPI')
@patch('intrahospital_api.loader.create_rfh_patient_from_hospital_number')
def test_creates_patient(self, create_rfh_patient_from_hospital_number, ProdAPI):
@patch('intrahospital_api.loader.get_or_create_patient')
def test_creates_patient(self, get_or_create_patient, ProdAPI):
ProdAPI.return_value.execute_hospital_query.return_value = [self.upstream_row]
self.upstream_row["Patient_Number"] = "234"
def create_patient():
Expand All @@ -46,7 +46,7 @@ def create_patient():
episode.save()
return patient

create_rfh_patient_from_hospital_number.side_effect = lambda x, y: create_patient()
get_or_create_patient.side_effect = lambda x, y: (create_patient(), True,)
self.cmd.handle()
self.assertTrue(
Patient.objects.filter(
Expand Down