There’s the WordPress meta API for retrieving meta values from the wp_postmeta table, but the API doesn’t provide a function for retrieving the post ID (post_id value), but you can use custom SQL as in your code.
However, $wpdb->get_col() returns an array of values (upon success), so that’s why you get the “Array” when you do echo $get_values;.
So you can either do something like this:
$post_ids = $wpdb->get_col( $prepare_guery ); // returns an array of IDs on success
$post_id = $post_ids[0]; // simplified - assuming that $post_ids[0] is actually set
var_dump( $post_ids ); // for testing
Or (a simpler option) if you want to retrieve just a single value, you should use $wpdb->get_var():
$post_id = $wpdb->get_var( $prepare_guery ); // returns a string (an ID) on success
Additional Notes
$prepare_guery = $wpdb->prepare( "SELECT post_id FROM $tbl WHERE meta_key ='patientid' AND meta_value LIKE $thevalue", $meta_value );
should be:
$prepare_guery = $wpdb->prepare( "SELECT post_id FROM $tbl WHERE meta_key ='patientid' AND meta_value LIKE %s", $wpdb->esc_like( $thevalue ) );
I.e. Note the %s (placeholder) and I also use $wpdb->esc_like(). I also realized that the $meta_value is not defined in your code, hence I changed that (in the above code) to $thevalue.
And in the previous revisions, I misspelled the $prepare_guery as $prepare_query… or did you mean $prepare_query ?