Skip to content

Instantly share code, notes, and snippets.

@sdumitriu
Last active December 5, 2016 16:24
Show Gist options
  • Save sdumitriu/4e00a842c15b6ed7cc30 to your computer and use it in GitHub Desktop.
Save sdumitriu/4e00a842c15b6ed7cc30 to your computer and use it in GitHub Desktop.
PhenoTips - Update visibility for all patient records

To set or update the visibility for all patient records, including the template used for future patients, open /bin/edit/Sandbox/UpdateVisibility in a browser while logged in with an administrative account, paste the following snippet, and press Preview.

WARNING: Pressing Preview doesn't preview the changes, it will actually modify the permissions!

Things you can adjust:

  • the target visibility, at line 2 replace private with the desired value (hidden, private, matchable, public, open)
  • skip the patient template by replacing the query at line 3 with 'from doc.object(PhenoTips.PatientClass) as p where doc.name <> ''PatientTemplate'''
  • only include records of a certain user by replacing the query at line 3 with 'from doc.object(PhenoTips.PatientClass) as p, doc.object(PhenoTips.OwnerClass) as o where o.owner = ''xwiki:XWiki.username'''
  • only include records of a certain workgroup by replacing the query at line 3 with 'from doc.object(PhenoTips.PatientClass) as p, doc.object(PhenoTips.OwnerClass) as o where o.owner = ''xwiki:Groups.groupname'''
  • modify a specific set of patient records by specifying it manually: #foreach ($i in ['P0000001', 'P0000005', 'P0000042'])
{{velocity}}
#set ($visibility = $services.permissions.resolveVisibility('private'))
#foreach ($i in $services.query.xwql('from doc.object(PhenoTips.PatientClass) as p').execute())
$!services.permissions.getPatientAccess($services.patients.getPatientById($i)).setVisibility($visibility)
#end
{{/velocity}}
@jmenbo
Copy link

jmenbo commented Aug 10, 2015

Hey sdumitriu, is there a similar script to change the ownership of a batch of records?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment