Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Printing specific field that triggers error in workup's get_initial method #194

Open
ameller1994 opened this issue Dec 1, 2018 · 1 comment

Comments

@ameller1994
Copy link
Member

ameller1994 commented Dec 1, 2018

Certain workups trigger an error when there is an existing workup for a patient and we are trying to pull in the previous workup's fields into the new workup. We would like to create a "Try-Catch" that prints the specific field which triggers an error when we try to pre-populate a new workup based on the old workup.

The relevant lines of code are:

        if wu_previous is not None:
            date_string = wu_previous.written_datetime.strftime("%B %d, %Y")
            for field in settings.OSLER_WORKUP_COPY_FORWARD_FIELDS:
                initial[field] = settings.OSLER_WORKUP_COPY_FORWARD_MESSAGE.\
                    format(date=date_string,
                           contents=getattr(wu_previous, field))
@justinrporter
Copy link
Member

justinrporter commented Dec 15, 2018

Update:

This is caused by the call to string.format when the value of getattr(wu_previous, field) contains any non-ascii character.

  • Possible solution 1: require that OSLER_WORKUP_COPY_FORWARD_MESSAGE be a unicode string via some kind of error mechanism.
  • Possible solution 2: make sure to use from __future__ import unicode_literals everywhere?
  • Possible solution 3: manually transform OSLER_WORKUP_COPY_FORWARD_MESSAGE into a unicode string inside workup/views.py:WorkupCreate.get_initial.

Definitely: create a test for this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants