The equation of state is always written with density and temperature as independent variables, because they are easy to measure and for historical reasons. If you want to define your state using p and h, then you will have to find d and T such that the p and h calculated from the EoS match the p and h you specified. In other words, you have a forward part f=f(d,T) which is more or less straihgt forward to implement, and then you need some root finding algorithms. The only way around that is to use tables and splines.
The good news is that CoolProp does all three, the EoS, the root finding and also tables+splines.