How much does this Integer score? The Challenge
Given an integer, calculate its score as described below.
The score is calculated by raising each digit of the input Integer to the power n, where n denotes the index of the digit in Input (beginning with 1) when counted from left to right (the index of leftmost digit should be 1), and then summing them all together. If the original number happens to be prime, then add the largest digit of the input integer to the score, else subtract the smallest digit of the input integer from it.
Input
Your program should take an integer as input. You can take the input in whatever way you want to.
Output
Output the score of the input integer through whatever medium your programming language supports. Function return is also allowed.

Test Cases
 5328   -&gt;  (5^1)+(3^2)+(2^3)+(8^4)-2 = 4116
 3067   -&gt;  (3^1)+(0^2)+(6^3)+(7^4)+7 = 2627
 7      -&gt;  (7^1)+7                   = 14

Scoring
This is code-golf, so the shortest code in bytes wins!
Mathematica, 63 bytes

s+Max@If[PrimeQ[s=Tr[d^Range@Length[d=IntegerDigits@#]]],d,-d]&amp;


Pure function taking a positive integer as input and returning an integer. Directly performs the indicated computation, with all the long Mathematica command names that requires. Perhaps the one innovation is noticing that, if d is the list of digits of the input, then the last addition/subtraction is the same as adding Max[d] if the initial sum was prime, and adding Max[-d] if not.