-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from onaio/flatten_location_hierarchy
Flatten the LocationHierarchy endpoint response
- Loading branch information
Showing
14 changed files
with
288 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 4 additions & 31 deletions
35
plugins/src/main/java/org/smartregister/fhir/gateway/plugins/BaseEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,11 @@ | ||
package org.smartregister.fhir.gateway.plugins; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import javax.servlet.http.HttpServlet; | ||
|
||
import org.hl7.fhir.r4.model.Bundle; | ||
import org.hl7.fhir.r4.model.Resource; | ||
import ca.uhn.fhir.context.FhirContext; | ||
import ca.uhn.fhir.parser.IParser; | ||
|
||
public abstract class BaseEndpoint extends HttpServlet { | ||
public Bundle createBundle(List<Resource> resourceList) { | ||
Bundle responseBundle = new Bundle(); | ||
List<Bundle.BundleEntryComponent> bundleEntryComponentList = new ArrayList<>(); | ||
|
||
for (Resource resource : resourceList) { | ||
bundleEntryComponentList.add(new Bundle.BundleEntryComponent().setResource(resource)); | ||
} | ||
|
||
responseBundle.setEntry(bundleEntryComponentList); | ||
responseBundle.setTotal(bundleEntryComponentList.size()); | ||
return responseBundle; | ||
} | ||
|
||
public Bundle createEmptyBundle(String requestURL) { | ||
Bundle responseBundle = new Bundle(); | ||
responseBundle.setId(UUID.randomUUID().toString()); | ||
Bundle.BundleLinkComponent linkComponent = new Bundle.BundleLinkComponent(); | ||
linkComponent.setRelation(Bundle.LINK_SELF); | ||
linkComponent.setUrl(requestURL); | ||
responseBundle.setLink(Collections.singletonList(linkComponent)); | ||
responseBundle.setType(Bundle.BundleType.SEARCHSET); | ||
responseBundle.setTotal(0); | ||
return responseBundle; | ||
} | ||
protected final FhirContext fhirR4Context = FhirContext.forR4(); | ||
protected final IParser fhirR4JsonParser = fhirR4Context.newJsonParser().setPrettyPrint(true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.