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

New script to report isacc Communication resources as a CSV, per #35

Merged
merged 8 commits into from
Jun 5, 2024

Conversation

mcjustin
Copy link
Member

@mcjustin mcjustin commented Jan 9, 2024

@mcjustin mcjustin marked this pull request as draft January 9, 2024 21:26
@mcjustin mcjustin requested review from pbugni and ivan-c January 10, 2024 01:25
@mcjustin mcjustin requested a review from Filienko January 19, 2024 17:29
@mcjustin
Copy link
Member Author

I'll note that the researchers are happy with the format of this csv

@mcjustin mcjustin marked this pull request as ready for review January 19, 2024 17:30
Head comments to clarify usage.
Another comment, to clarify purpose.
@mcjustin
Copy link
Member Author

@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.

@mcjustin
Copy link
Member Author

@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.

@ivan-c @pbugni can you please review this? Otherwise I'll just merge it in, since it worked for it's initial purpose.

Copy link
Member

@ivan-c ivan-c left a 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

utils/communication_report.py Show resolved Hide resolved
utils/communication_report.py Show resolved Hide resolved
utils/communication_report.py Outdated Show resolved Hide resolved
Comment on lines +95 to +116
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])
Copy link
Member

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

utils/communication_report.py Show resolved Hide resolved
mcjustin and others added 2 commits May 29, 2024 15:18
Co-authored-by: Ivan Cvitkovic <ivanc@uw.edu>
Co-authored-by: Ivan Cvitkovic <ivanc@uw.edu>
@mcjustin mcjustin merged commit aecf5de into main Jun 5, 2024
@mcjustin mcjustin deleted the communication-report-script branch June 5, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants