-
Notifications
You must be signed in to change notification settings - Fork 0
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
New script to report isacc Communication resources as a CSV, per #35
Conversation
I'll note that the researchers are happy with the format of this csv |
Head comments to clarify usage.
Another comment, to clarify purpose.
@pbugni Can you please review this? I've just run it again against the prod systems, and added a few comments to the top to clarify purpose & usage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good! had a few suggestions, but no blockers
communication = entry['resource'] | ||
communication_id = communication.get('id') | ||
datetime = communication.get('sent') | ||
type = extract_type(communication) | ||
if type in ['isacc-comment', 'isacc-non-sms-message']: | ||
recipient_reference = communication.get('subject', {}).get('reference') | ||
else: | ||
recipient_reference = communication.get('recipient', [{}])[0].get('reference') | ||
if recipient_reference == None: | ||
recipient_reference = communication.get('sender', {}).get('reference') | ||
isacc_id = get_patient_isacc_id(recipient_reference, patient_cache) | ||
content = communication.get('payload', [{}])[0].get('contentString') | ||
if content: | ||
content = content.replace('\n', '\\n') | ||
sender = communication.get('sender', {}).get('reference') | ||
if sender == None and type == 'isacc-auto-sent-message': | ||
sender = 'system' | ||
note = communication.get('note', [{}])[0].get('text') | ||
if note: | ||
note = note.replace('\n', '\\n') | ||
|
||
writer.writerow([communication_id, datetime, recipient_reference, isacc_id, type, content, sender, note]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might make sense to move the Communication processing/extraction to a separate function (and return a row/list), so it's easier to keep track of the fields of interest
Co-authored-by: Ivan Cvitkovic <ivanc@uw.edu>
Co-authored-by: Ivan Cvitkovic <ivanc@uw.edu>
https://www.pivotaltracker.com/story/show/186631379 .