Iterating over a paged fhir response - dstu2-fhir

I've ran a query on a hapi fhir database which has returned a paged result back to me. I'm using hapi base in java to actually do the search, as per the documentation here: http://hapifhir.io/doc_rest_client.html
Bundle bundle = client.search().forResource(Basic.class).returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).execute();
do {
for (Entry entry: bundle.getEntry())
System.out.println(entry.getFullUrl());
if (bundle.getLink(Bundle.LINK_NEXT) != null)
bundle = client.loadPage().next(bundle).execute();
else
bundle = null;
}
while (bundle != null);
The code runs as far as getting the first bundle, and prints out the urls as expected, however when it tries to execute the next bundle, I get a ConnectionException 'Connection refused: connect'.
The server still appears to be responsive however as I can rerun my program and have the exact same result returned.
Any idea why the connection would be being refused? I get a similar issue when I try to run it manually from postman.

What you're doing certainly looks correct. If you perform a search manually (say, using a browser or postman or whatever) what does the next link look like? And does it work if you use that link directly in a browser too?
For example, if I run the CLI locally on my machine, and execute a search I see the following in the response:
"link": [
{
"relation": "self",
"url": "http://localhost:8080/baseDstu3/_history"
},
{
"relation": "next",
"url": "http://localhost:8080/baseDstu3?_getpages=d8454866-624d-4bb3-b7a0-0858e4870e7e&_getpagesoffset=10&_count=10&_pretty=true&_bundletype=history"
}
],
If I plug the next link (http://localhost:8080/baseDstu3?_getpages=d8454866-624d-4bb3-b7a0-0858e4870e7e&_getpagesoffset=10&_count=10&_pretty=true&_bundletype=history) into a browser, I get the next page.
Can you try this and see how it goes?

Just in case anyone stumbles across this. I had some sort of redirection going on (setup by another member of my team). Essentially my base url was localhost:8080, but the next address was returning as localhost:1080 (which I don't entirely understand why).
He changed a config in the server to make it not redirect.

Related

Angular Service Worker stuck in Safari after logout

We have a WebApp developed with Angular 14. It is deployed on Azure Blob Storage (static website).
Authentification is done with the msal library for javascript. Azure AD B2C is used as identity provider.
When we logout we call msalService.logoutRedirect() which works fine for all devices except for iPhones using the Safari browser. On iPhone/Safari it sometimes gets stuck (mostly when we had the phone locked for a few minutes first). Safari then displays a "neverending" network request - but I am convinced that the actual problem is some code in the service worker, as Safari gets completely frozen and you cannot even enter anything in the Console.
We are using Angular Service Worker to provide a PWA and everything is working fine if we serve the app without Service Workers.
I tried to take a look at ngsw/state (which usually works) but as soon as the bug occurs, this site is not reachable (I assume because Safari is stuck).
For me this looks like the service worker code is stuck in some loop (there are no errors shown in the console). When I then manually try to reload the page we get the following errors in the console: .
How can I find out what causes the problem here? I tried to debug the ngsw-worker.js file but it's almost 2k lines, so it's not that easy. Is there any simpler way to debug it?
Update:
This is how the ngsw-config.json looks like:
{
"$schema": "./node_modules/#angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/manifest.webmanifest",
"/*.css",
"/*.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
]
}
We are using google-fonts and fetch it from fonts.googleapis.com.
When we logout and the bug occurs the browser displays that it tries to load the google fonts - it is stuck there. Is it possible that it somehow thinks the google-fonts file should be in cache and it tries to fetch it but since it isn't there, it loads endlessly?
Update: I found a forum post that sounds very similar to the problem we have, unfortunately, it seems they never found a solution: apple forum
You could try to clone the msal library and change the code in the navigation client to always use replace instead of assign. Could be worth a shot since it helped me in the react oidc library i used.

Zerocode: Set system property in host configuration file

Configuration:
zerocode-tdd.1.3.2
${host}
At runtime, system property set with -D java option. All is well.
Problem / What I Need:
At unit test time, system property not set, and host not resolved.
App uses Junit and Zerocode, would like to simply configure Zerocode to set the system property.
Example:
host.properties
web.application.endpoint.host:${host}
web.application.endpoint.port=
web.application.endpoint.context=
More Info:
Requirement is for configuration only. Can't introduce new Java code, or entries into IDE.
Any help out there? Any ideas are appreciated.
This feature is available in zerocode version 1.3.9 and higher.
Please use the place holder like ${SYSTEM.PROP:host} e.g. ${SYSTEM.PROPERTY:java.vendor} resolves to Oracle Corporation or Azul Systems, Inc.
Example link:
https://github.com/authorjapps/zerocode/blob/master/README.md#general-place-holders
Found a solution, but not sure if this is the correct way to do so.
Step 1: Create a config file and load system properties.
Config.java
public class Config {
public Map<String, Object> readProperties(String optionalString) {
Map<String, Object> propertiesMap = new HashMap<>();
final String host = System.getProperty("host");
propertiesMap.put("host", host);
return propertiesMap;
}
}
Step 2: Add a step (before other steps) to use the loaded properties in the .json file.
test.json
{
"scenarioName": "Test ...",
"steps": [
{
"name": "config",
"url": "com.test.Config",
"operation": "readProperties",
"request": "",
"assertions": {}
}
]
}
Step 3: Use loaded property in step config
test.json
{
"scenarioName": "Test ...",
"steps": [
{
"name": "config",
"url": "com.test.Config",
"operation": "readProperties",
"request": "",
"assertions": {}
},
{
"name": "test",
"url": "${$.config.response.host}/test/xxx",
"operation": "GET",
"request": {},
"assertions": {
"status": 200
}
}
]
}
That's it, although it is working but I am looking for better approach.
Some possible options I am trying are:
Common step for load/config (in one place)
Directly using properties as {host} in json files
Custom client
Again any help/ideas are appreciated.
My question is why are you trying to access the actual host/port? Sorry for the long answer but bear with me. I think there is an easier way to achieve what you are attempting. I find its best to think about zerocode usage in two ways,
live integration tests (which is what I think your trying to do) [meaning this calls a live endpoint / service], or
what I refer to as a thintegration test (an integration test but using a mock endpoint / service).
Thinking about it this way gives you the opportunity for two different metrics,
when using the mock endpoint / service how performant / resilient is my code, and
when using live integration tests what is the rough real life performance (expect a bit slower than external load test due to data setup / test setup).
This lets you evaluate both yourself and your partner service.
So outside of the evaluation above why would you want to build a thintegration test? The real value in doing this is you still make it all the way through your code like you would in an integration test but you control the result of said test like you would in a standard unit test. Additionally since you control the result of the test this may improve build time test stability vs a live api.
Obviously it seems you already know how to setup an integration test so I'll assume you're good to go there but what about the thintegration tests?
To setup a thintegration test you really have two options,
use postman mock server (https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/setting-up-mock/)
a. more work to setup
b. external config to maintain
c. monthly api call limits
use WireMock (http://wiremock.org/)
a. lives with your code
b. all local so no limits
If you already have integration tests you can copy them to a new file and make the updates or just convert your existing.
**** To address your specific question ****
When using WireMock you can setup a dynamic local server url with dynamic port using the following.
protected String urlWithPort;
#Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort().dynamicHttpsPort());
protected String getUriWithPort() {
return "http://localhost:" + wireMockRule.port();
}
Note: The above was tested using WireMock version 2.27.1 and ZeroCode 1.3.27
Hope that helps you answer how to dynamically get a server/port for your tests.

here api request error --- Invalid credentials

I have a 90-day trial and I am registered at (Evaluation 2018-06-29).
But when I request with my correct copied app id and app code I get the below error.
{
"response": {
"_type": "ns2:RoutingServiceErrorType",
"type": "PermissionError",
"subtype": "InvalidCredentials",
"details": "This is not a valid app_id and app_code pair. Please verify that the values are not swapped between the app_id and app_code and the values provisioned by HERE (either by your customer representative or via http://developer.here.com/myapps) were copied correctly into the request.",
"metaInfo": {
"timestamp": "2018-08-15T18:52:35Z",
"mapVersion": "8.30.86.153",
"moduleVersion": "7.2.201832-36299",
"interfaceVersion": "2.6.34"
}
}
}
Can anyone help, especially someone from here api developer support team?
Go into your account projects and add a new project explicitly for the Freemium plan. Then you should be able to generate a new JavaScript/REST App ID and App Code. If you are using one of the mobile SDKs you would generate a new id / code there as well.
(1) Copy and Paste
I'm not certain this is what may be happening for you, but one of my codes had a leading underscore and it was very easy to copy and paste it incorrectly into my source code.
(2) Domain Protection
Also make sure that if you checked "Secure app credentials against a specific domain" that you are calling the routing service from the same domain.
(3) Shell Interpolation
Without more detail about how you are making the calls to the routing service (curl, postman, javascript, ios, android, etc.) it may also indicate where to offer advice.
For example, if you are using curl make sure your parameters have surrounding quotes as & will be interpreted by a shell such that ?app_id=your-app-id&app_code=your-app-code is not interpreted properly. That could generate the response you saw as the shell took your app_code parameter away before curl could make the request only passing the app_id.

Actions on Google responds with "Sorry, I didn't get any response."

I am following this code lab Facts about You: Build a conversational app for the Google Assistant
I had it working once but must have done something wrong because now all. To be 100% clear i have deleted everything on my pc downloaded the code from Git again deleted the project in actions console deleted the project in api.ai. This is the result of a completely new install. I have not changed anything in the code lab.
"Sorry, I didn't get any response."
The request apears to be sending corectly
From actions test:
{
"conversationToken": "CiZDIzU5Ym...",
"debugLevel": 1,
"inputType": "KEYBOARD",
"locale": "en-US",
"mockLocation": {
"city": "Mountain View",
"coordinates": {
"latitude": 37.421980615353675,
"longitude": -122.08419799804688
},
"formattedAddress": "Googleplex, Mountain View, CA 94043, United States",
"zipCode": "94043"
},
"query": "tell me about cats",
"surface": "GOOGLE_HOME"
}
Received in fire-base
[{"name":"actions.capability.AUDIO_OUTPUT"}]},"inputs":[{"rawInputs":[{"query":"tell me about cats","inputType":"VOICE"}],"arguments":[{"rawText":"tell me about cats","textValue":"tell me about cats","name":"text"}],"intent":"actions.intent.TEXT"}],"user":{"locale":"en-US","userId":"AETml1RzwqyijfbawqjZkRSXz-P1"},"device":{},"conversation":{"conversationId":"1504878811393","type":"ACTIVE","conversationToken":"[\"_actions_on_google_\",\"choose_fact-followup\"]"}}},"id":"3b97e239-346f-49a2-a106-96cfb6f69e92","timestamp":"2017-09-08T13:58:29.99Z","lang":"en","result":{"source":"agent","resolvedQuery":"tell me about cats","speech":"","action":"tell.cat.fact","actionIncomplete":false,"parameters":{},"contexts":[{"name":"_actions_on_google_","parameters":{"category.original":"headquarters","category":"headquarters","facts":{"content":{"headquarters":["Google has over 10 fitness facilities in its main campus."],"history":["Google was founded in 1998.","Google was founded by Larry Page and Sergey Brin.","Google went public in 2004.","Google has more than 70 offices in more than 40 countries."]}}},"lifespan":98},{"name":"actions_capability_audio_output","parameters":{},"lifespan":0},{"name":"google_assistant_input_type_voice","parameters":{},"lifespan":0},{"name":"choose_cats-followup","parameters":{},"lifespan":2}],"metadata":{"intentId":"14df3938-3776-477c-811c-d1758ecd15cb","webhookUsed":"true","webhookForSlotFillingUsed":"false","nluResponseTime":19,"intentName":"choose_cats"},"fulfillment":{"speech":"","messages":[{"type":0,"speech":""}]},"score":1},"status":{"code":200,"errorType":"success"},"sessionId":"1504878811393"}
Response returned to actions
{
"audioResponse": "//NExAARAA...",
"conversationToken": "CiZDIzU5Ym...",
"expectUserResponse": true,
"response": "Sorry, I didn't get any response.",
"visualResponse": {
"visualElements": []
}
}
I must be missing something. Firebase is receiving the request its just not responding correctly.
training image
That error on appears if your web hook doesn't provide a response to the assistant. The cloud function has been triggered or has timed out and not returned the JSON back to assistant to parse. Check to see what the output of the cloud function is and check it against the API.AI web hook format here https://developers.google.com/actions/reference/v1/apiai-webhook
It should look something like this:
{
"speech": "...", // ASCII characters only
"displayText": "...",
"data": {
"google": {
"expect_user_response": true,
"is_ssml": true,
"permissions_request": {
"opt_context": "...",
"permissions": [
"NAME",
"DEVICE_COARSE_LOCATION",
"DEVICE_PRECISE_LOCATION"
]
}
}
},
"contextOut": [...],
}
I think this is something on the Google's end. My application have been running on production for more than a week. Based on the logs everything was fine till 6 hours ago but since that the users don't get any answer back.
If I request on the API.AI the response is okay so it's not the firebase/fullfillment causing the issue.
Checked other applications some had the same problem some had no problem at all. Not sure what we can do here.
Errors like this are usually caused by a syntax error or other problem in your Firebase Function after you've updated it. There are a few good approaches to diagnosing problems like this:
Check the Firebase function log. If there is an error, it will almost certainly show up here.
From the command line you can use firebase functions:log to see the most recent logging messages. You can also use the console to view the logs by going to console.firebase.com, selecting the project, selecting Functions, and then the Logs tab.
If there isn't an error, it becomes more of a logic problem. Adding your own logs via console.log(), console.info(), or console.error()
Many times the logs will indicate the function is timing out after 60 seconds when you think you're returning things by then. Make sure you are completing any callbacks and calling assistant.ask() or assistant.tell() (or one of their cousins) to make sure they're being called.
After posting a question on the Google+ actions group. I got a response back from Google.
Actions Bug There is currently a bug in the Actions Platform that
might result in unexpected error messages when running your apps.
We are currently testing a fix and hope to have that rolled out soon.
As of 10 minutes ago it is working again. The code was correct all along.

Apple App Site association not working

App Search API Validation Tool of "Apple" is not validating my domain.
https://search.developer.apple.com/appsearch-validation-tool
I am using universal links but "Link to Application" is showing me "Error".(http://www.awesomescreenshot.com/image/1719847/330979a43c4c6b2766da1e703447ee04)
Here is my "apple-app-site-association" file code.
{"applinks": {"apps": [],"details": {"XXXXXXXXXX.com.streatmanagement.threadshare": {"paths": ["*"]}}}}
Can someone please solve my query or send the sample of "apple-app-site-association" valid code?
Apple's API validation tool compares your website's association file to a store listing. If your app is not yet publicly available the error you listed will be displayed.
Your apple-app-site-association has a small typo where you specify the details (it should be an array). I also assume you're replacing the XXXX's with your app ID.
{
"applinks": {
"apps": [],
"details": [
{
"appID": "APPID.BUNDLEID",
"paths": [ "*" ]
}
]
}
}
Even if you get this error from Apple's validation tool, you can test Universal links. If your Universal Link does not work on your test device you need to inspect the device logs when you fresh install it and make sure your apple-app-site-association is available at the root of your site via https with no redirects. Sometimes there is issue if the content-type is not application/json (but the file name should remain exactly apple-app-site-association).

Resources