Help me please!
[GET] http://fhir.hl7fundamentals.org/r4/ServiceRequest?encounter:Encounter.participant.identifier=teste-brasil-v1|123abc456
The result is 1
[GET] http://fhir.hl7fundamentals.org/r4/ServiceRequest?encounter:Encounter.participant.practitioner.identifier=teste-brasil-v1|123abc456
The result is 2
I would like to put both parameters in the same url, but with the "or" operator, something like:
...? encounter:Encounter.participant.identifier=teste-brasil-v1|123abc456 or encounter:Encounter.participant.practitioner.identifier=teste-brasil-v1|123abc456
Objective is in a single url to obtain the result of 2 records
You can't do it with a standard RESTful search. You'd have to use _filter which gives you the ability to 'or' parameters together. With REST, you can only do 'or' with the values for a single criteria. For example, you could search for encounters that have participants with identifier A or B (by separating the values you want to match on with ',').
Be aware that _filter isn't widely supported, so it may not be available on the server you're using.
Another option is to execute two separate queries, but send them in a batch so you only have to make one call. You'll end up with two result sets, and you'll have to page them independently, but it does let you get away with a single call.
The Bitwise OR ( | ) returns a 1 in each bit position for which the corresponding bits of either or both operands are 1s
The Logical OR ( || ) returns true if and only if one or more of its operands is true the first true operand is returned or false if all operands are false
const a = 5; // 00000000000000000000000000000101
const b = 3; // 00000000000000000000000000000011
console.log(a | b); // 00000000000000000000000000000111
// expected output: 7
const a = 3;
const b = -2;
console.log(a > 0 || b > 0);
// expected output: true
Related
I have a data column of strings containing a lead status. I only want to count if the lead is qualified or nurture. I have this expression:
Is Qualified = If('Lead'[Status] = OR("Qualified", "Nurture"),1,0)
But I am getting this error:
DAX comparison operations do not support comparing values of type Text
with values of type True/False. Consider using the VALUE or FORMAT
function to convert one of the values.
I'm new with DAX and haven't been able to fix this one. Any help would be great, thanks.
OR() returns a boolean value. I assume 'Lead'[Status] is a text field, in which we will find some strings with the values "Qualified" or "Nurture". If this is the case you want to do the following:
IsQualified =
IF(
'Lead'[Status] = "Qualified"
|| 'Lead'[Status] = "Nurture"
,1
0
)
This is performing two tests, and combining them with a logical or ( || - the double pipe is DAX's or operator ).
This question already has answers here:
Passing lists from one function to another in Swift
(2 answers)
Closed 7 years ago.
I am getting a Binary operator '/' cannot be applied to two (Int) operands error when I put the following code in a Swift playground in Xcode.
func sumOf(numbers: Int...) -> Int {
var sum = 0
for number in numbers {
sum += number
}
return sum
}
sumOf()
sumOf(42, 597, 12)
The above was a function calculating the total sum of any numbers.
Below is a function calculating the average of the numbers. The function is calling the sumOf() function from within itself.
func avg(numbers: Int...) -> Float {
var avg:Float = ( sumOf(numbers) ) / ( numbers.count ) //Binary operator '/' cannot be applied to two (Int) operands
return avg
}
avg(1, 2, 3);
Note: I have looked everywhere in stack exchange for the answer, but the questions all are different from mine because mine is involving two Ints, the same type and not different two different types.
I would like it if someone could help me to solve the problem which I have.
Despite the error message it seems that you cannot forward the sequence (...) operator. A single call of sumOf(numbers) within the agv() function gives an error cannot invoke sumOf with an argument of type ((Int))
The error is telling you what to do. If you refer to https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_operators.html
/ Division.
A binary arithmetic operator that divides the number to its left by the number to its right.
Class of operands: integer, real
Class of result: real
The second argument has to be real. Convert it like so. I don't use xcode, but I think my syntax is correct.
var avg:Float = ( sumOf(numbers) ) / Float( numbers.count )
Since semicolons are apparently optional in Rust, why, if I do this:
fn fn1() -> i32 {
let a = 1
let b = 2
3
}
I get the error:
error: expected one of `.`, `;`, `?`, or an operator, found `let`
--> src/main.rs:3:9
|
2 | let a = 1
| - expected one of `.`, `;`, `?`, or an operator here
3 | let b = 2
| ^^^ unexpected token
They're not optional. Semicolons modify the behaviour of an expression statement so it should be a conscious decision whether you use them or not for a line of code.
Almost everything in Rust is an expression. An expression is something that returns a value. If you put a semicolon you are suppressing the result of this expression, which in most cases is what you want.
On the other hand, this means that if you end your function with an expression without a semicolon, the result of this last expression will be returned. The same can be applied for a block in a match statement.
You can use expressions without semicolons anywhere else a value is expected.
For example:
let a = {
let inner = 2;
inner * inner
};
Here the expression inner * inner does not end with a semicolon, so its value is not suppressed. Since it is the last expression in the block, its value will be returned and assigned to a. If you put a semicolon on this same line, the value of inner * inner won't be returned.
In your specific case, not suppressing the value of your let statement doesn't make sense, and the compiler is rightly giving you an error for it. In fact, let is not an expression.
Semicolons are generally not optional, but there are a few situations where they are. Namely after control expressions like for, if/else, match, etc.
fn main() {
let a: u32 = 5;
if 5 == a {
println!("Hello!");
}
if 5 == a {
println!("Hello!");
};
for x in "World".chars() {
println!("{}", x);
}
for x in "World".chars() {
println!("{}", x);
};
}
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1bf94760dccae285a2bdc9c44e8f658a
(There are situations where you do need to have or not have semicolons for these statements. If you're returning the value from within you can't have a semicolon, and if you're setting a variable to be the value from within you'll need a semicolon.)
Is there any algorithm that can find the sign of an arbitrary symbolic algebraic expression given in a "Tree - Form"?
I know that a general algorithm doesn't exist because the zero recognizion problem is undecidable for an arbitrary expression, but how should I approach the problem of finding the sign of an expression?
(how is this done in computer algebra?)
For example: sign(sqrt(2)-1) = ?
Evaluate the function value
You need function evaluator engine for that (it is not that hard to code) there is no way to evaluate sign only if you want to support +,- operations !!! All my function evaluators works like this:
compile the source text of the function
First create supported functions table (id,num of operands,name,pointer to function) like:
+,-,*,/,sin,cos,....
These will be the building blocks to any supported expression you need to evaluate. Do not forget to code all functions in your code too. Handle brackets (,) also as functions (push,pop). Group your functions by number of operands so +,- are with 1 and 2 operands (two different functions each !!!).
Now from expression extract:
variable names
constant names and values
number values
Into some kind of table/list:
variables[](id,name,value)
constants[](id,name,value)
numbers [](id, ,value)
And now finally construct compiled function string. My strings are set of two int's. First is type (which table to use) and second is id (index in table).
for example expression:
sign(sqrt(2)-1)
types:
id type
0 function
1 number
2 constant
3 variable
functions:
id name pointer
0 '(' ???
1 ')' ???
2 '+' ???
3 '-' ???
4 '*' ???
5 '/' ???
6 'sqrt' ???
7 'sign' ???
There are no variables or constants. The numbers are:
id value
0 2
1 1
compiled string:
type id
0 7 // sign(1 operand)
0 6 // sqrt(1 operand)
1 0 // 2
0 3 // - (2 operands)
1 1 // 1
After compilation you need to interpret the string and evaluate it's value.
init variables
op1=0`,`op2=0, // set all operands to zero (number depends on supported functions usually 2)
opn=0 // actual operands number
fx=none // actual function (for example none=-1)
fxn=0 // actual function operands number
read first record of compiled string
if it is value (number,constant,variable) set appropriate op? value with it and increment operand counter opn++.
if it is function set fx,fxn code with it
if opn == fxn
You reached needed operand count so execute function fx and init next function
op1=fxtab[fx].pointer(op1,op2,...)
fx=none,fxn=1
opn=1 (some spec functions can return more operands, then set op1,op2,.. opn=...)
if not end of string goto #2 but with next string record
at the end op1 should hold your output value
some example functions (C++ implementation):
double sign(double op1)
{
if (op1>0.0) return +1.0;
if (op1<0.0) return -1.0;
return 0.0;
}
double sqrt1(double op1) { return sqrt(op1); }
double plus1(double op1) { return op1; }
double minus1(double op1) { return -op1; }
double plus2(double op1,double op2) { return op1+op2; }
double minus2(double op1,double op2) { return op1-op2; }
[Notes]
You have to handle special cases like function = "";. Also beware spacing, case sensitivity because any error in compilation invalidates the result.
Speed is not a big issue this is interpreting-evaluation not numerical solution. All operations are called the same times as you would do on the paper.
You should also handle mathematic errors (overflows,invalid operands,NaN,Inf ...)
I usually group functions with the same number of operands to own type to simplify things
I am trying to run a granger causality test on two currency pairs but I seem to get this error message in Shell whenever I try and test it. Can anyone please advise?
I am very new to programming and need this to run an analysis for my project. In shell, I am putting -
import ats15
ats15.grangertest('EURUSD', 'EURGBP', 8)
What is going wrong? I have copied the script below.
Thanks in advance.
Heading ##def grangertest(Y,X,maxlag):
"""
Performs a Granger causality test on variables (vectors) Y and X.
The null hypothese is: Does X cause Y ?
Returned value: pvalue, F, df1, df2
"""
# Create linear model involving Y lags only.
n = len(Y)
if n != len(X):
raise ValueError, "grangertest: incompatible Y,X vectors"
M = [ [0] * maxlag for i in range(n-maxlag)]
for i in range(maxlag, n):
for j in range(1, maxlag+1):
M[i-maxlag][j-1] = Y[i-j]
fit = ols(M, Y[maxlag:])
RSSr = fit.RSS
# Create linear model including X lags.
for i in range(maxlag, n):
xlagged = [X[i-j] for j in range(1, maxlag+1)]
M[i-maxlag].extend(xlagged)
fit = ols(M, Y[maxlag:])
RSSu = fit.RSS
df1 = maxlag
df2 = n - 2 * maxlag - 1
F = ((RSSr - RSSu)/df1)/(RSSu/df2)
pvalue = 1.0 - stats.f.cdf(F,df1,df2)
return pvalue, F, df1, df2, RSSr, RSSu
You didn't post the full traceback, but this error message:
TypeError: unsupported operand type(s) for -: 'str' and 'int'
means what it says. There's an operand - -- the subtraction operator -- and it doesn't know how to handle subtracting an integer from a string. Why would strings be involved? Well, you're calling the function with:
ats15.grangertest('EURUSD', 'EURGBP', 8)
and so you're giving grangertest two strings and an integer. But it seems like grangertest expects
def grangertest(Y,X,maxlag):
two sequences (lists, arrays, whatever) of numbers to use as Y and X, not strings. If EURUSD and EURGBP are names you've given to lists beforehand, then you don't need the quotes:
ats15.grangertest(EURUSD, EURGBP, 8)
but if not, then you should pass grangertest the lists under whatever name you've called them.
The input to the grangertest function must be two lists of numbers. grangertest doesn't know anything about currencies, so passing it currency strings won't work.
You have to fetch the exchange rate data somehow so that you can pass it to grangertest. If EURUSD and EURGBP are variables, then you don't put quotes around them when you pass them to a function (e.g. ats15.grangertest(EURUSD, EURGBP, 8)).