protected ObjectElement getObjectElement ( IResource resource , SecurityEventObjectLifecycleEnum lifecycle , byte [ ] query ) throws InstantiationException , IllegalAccessException { String resourceType = resource . getResourceName ( ) ; if ( myAuditableResources . containsKey ( resourceType ) ) { log . debug ( "Found auditable resource of type: " + resourceType ) ; @ SuppressWarnings ( "unchecked" ) IResourceAuditor < IResource > auditableResource = ( IResourceAuditor < IResource > ) myAuditableResources . get ( resourceType ) . newInstance ( ) ; auditableResource . setResource ( resource ) ; if ( auditableResource . isAuditable ( ) ) { ObjectElement object = new ObjectElement ( ) ; object . setReference ( new ResourceReferenceDt ( resource . getId ( ) ) ) ; object . setLifecycle ( lifecycle ) ; object . setQuery ( query ) ; object . setName ( auditableResource . getName ( ) ) ; object . setIdentifier ( ( IdentifierDt ) auditableResource . getIdentifier ( ) ) ; object . setType ( auditableResource . getType ( ) ) ; object . setDescription ( auditableResource . getDescription ( ) ) ; Map < String , String > detailMap = auditableResource . getDetail ( ) ; if ( detailMap != null && ! detailMap . isEmpty ( ) ) { List < ObjectDetail > details = new ArrayList < SecurityEvent . ObjectDetail > ( ) ; for ( Entry < String , String > entry : detailMap . entrySet ( ) ) { ObjectDetail detail = makeObjectDetail ( entry . getKey ( ) , entry . getValue ( ) ) ; details . add ( detail ) ; } object . setDetail ( details ) ; } if ( auditableResource . getSensitivity ( ) != null ) { CodingDt coding = object . getSensitivity ( ) . addCoding ( ) ; coding . setSystem ( auditableResource . getSensitivity ( ) . getSystemElement ( ) . getValue ( ) ) ; coding . setCode ( auditableResource . getSensitivity ( ) . getCodeElement ( ) . getValue ( ) ) ; coding . setDisplay ( auditableResource . getSensitivity ( ) . getDisplayElement ( ) . getValue ( ) ) ; } return object ; } else { log . debug ( "Resource is not auditable" ) ; } } else { log . debug ( "No auditor configured for resource type " + resourceType ) ; } return null ; // not something we care to audit }
If the resource is considered an auditable resource containing PHI create an ObjectElement otherwise return null