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

ATT-53: Add privileges for attachments #65

Merged
merged 3 commits into from
Aug 19, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,10 @@ public static enum ContentFamily {
public static final String REPRESENTATION_OBS = "(uuid:ref,comment:ref,obsDatetime:ref)";

public static final String REPRESENTATION_VISIT = "(uuid:ref,stopDatetime:ref)";

/**
* PRIVILEGES
*/
public static final String CREATE_ATTACHMENTS = "Create Attachments";
public static final String VIEW_ATTACHMENTS = "View Attachments";
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import org.openmrs.Encounter;
import org.openmrs.Patient;
import org.openmrs.Visit;
import org.openmrs.annotation.Authorized;
import org.openmrs.api.APIException;
import org.openmrs.module.attachments.obs.Attachment;
import org.openmrs.module.attachments.AttachmentsConstants;

public interface AttachmentsService {

Expand All @@ -18,6 +20,7 @@ public interface AttachmentsService {
* voided ones or not.
* @throws APIException if non-complex obs are mistakenly returned
*/
@Authorized(AttachmentsConstants.VIEW_ATTACHMENTS)
List<Attachment> getAttachments(Patient patient, boolean includeVoided);

/**
Expand All @@ -29,6 +32,7 @@ public interface AttachmentsService {
* include attachments that are not associated with any visits or encounters.
* @throws APIException if non-complex obs are mistakenly returned
*/
@Authorized(AttachmentsConstants.VIEW_ATTACHMENTS)
List<Attachment> getAttachments(Patient patient, boolean includeEncounterless, boolean includeVoided);

/**
Expand All @@ -38,6 +42,7 @@ public interface AttachmentsService {
* voided ones or not.
* @throws APIException if non-complex obs are mistakenly returned
*/
@Authorized(AttachmentsConstants.VIEW_ATTACHMENTS)
List<Attachment> getEncounterlessAttachments(Patient patient, boolean includeVoided);

/**
Expand All @@ -48,6 +53,7 @@ public interface AttachmentsService {
* voided ones or not.
* @throws APIException if non-complex obs are mistakenly returned
*/
@Authorized(AttachmentsConstants.VIEW_ATTACHMENTS)
List<Attachment> getAttachments(Patient patient, Encounter encounter, boolean includeVoided);

/**
Expand All @@ -58,7 +64,9 @@ public interface AttachmentsService {
* voided ones or not.
* @throws APIException if non-complex obs are mistakenly returned
*/
@Authorized(AttachmentsConstants.VIEW_ATTACHMENTS)
List<Attachment> getAttachments(Patient patient, Visit visit, boolean includeVoided);

@Authorized(AttachmentsConstants.CREATE_ATTACHMENTS)
Attachment save(Attachment attachment, String reason);
}
9 changes: 9 additions & 0 deletions omod/src/main/resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,13 @@
<description>Allowed to access the main attachments page</description>
</privilege>

<privilege>
<name>Create Attachment</name>
<description>Allowed to create attachments</description>
</privilege>

<privilege>
<name>View Attachments</name>
<description>Allowed to view attachments</description>
</privilege>
</module>
Loading