Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Practitioner Details Endpoint #24

Merged
merged 6 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,21 @@
<dependency>
<groupId>org.smartregister</groupId>
<artifactId>hapi-fhir-keycloak</artifactId>
<version>0.0.3-SNAPSHOT</version>
<version>0.0.6-SNAPSHOT</version>
</dependency>

<!-- This dependency holds all the code extensions that OpenSRP will build on top of Hapi-Fhir-->
<dependency>
<groupId>org.smartregister.hapi-fhir-opensrp-extensions</groupId>
<artifactId>location</artifactId>
<version>0.0.3-SNAPSHOT</version>
<version>0.0.4-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.smartregister.hapi-fhir-opensrp-extensions</groupId>
<artifactId>practitioner</artifactId>
<version>0.0.4-SNAPSHOT</version>
</dependency>

<!-- HAPI-FHIR uses Logback for logging support. The logback library is included automatically by Maven as a part of the hapi-fhir-base dependency, but you also need to include a logging library. Logback
is used here, but log4j would also be fine. -->
Expand Down
37 changes: 34 additions & 3 deletions src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package ca.uhn.fhir.jpa.starter;

import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import org.hl7.fhir.r4.model.Location;
import org.smartregister.extension.model.*;
import org.hl7.fhir.r4.model.*;
import org.smartregister.extension.rest.LocationHierarchyResourceProvider;
import org.smartregister.extension.rest.PractitionerDetailsResourceProvider;
import org.smartregister.model.location.*;
import org.smartregister.model.practitioner.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;

import javax.servlet.ServletException;
import static org.smartregister.extension.utils.Constants.LOCATION;
import static org.smartregister.utils.Constants.LOCATION;

@Import(AppProperties.class)
public class JpaRestfulServer extends BaseJpaRestfulServer {
Expand All @@ -28,6 +30,7 @@ protected void initialize() throws ServletException {

// Add your own customization here
registerLocationHierarchyTypes();
registerPracitionerDetailsTypes();
}

private void registerLocationHierarchyTypes() {
Expand All @@ -45,4 +48,32 @@ private void registerLocationHierarchyTypes() {
getFhirContext().registerCustomType(ChildTreeNode.class);
}


private void registerPracitionerDetailsTypes() {
IFhirResourceDao<Practitioner> practitionerIFhirResourceDao = daoRegistry.getResourceDao("Practitioner");
IFhirResourceDao<PractitionerRole> practitionerRoleIFhirResourceDao = daoRegistry.getResourceDao("PractitionerRole");
IFhirResourceDao<CareTeam> careTeamIFhirResourceDao = daoRegistry.getResourceDao("CareTeam");
IFhirResourceDao<OrganizationAffiliation> organizationAffiliationIFhirResourceDao = daoRegistry.getResourceDao("OrganizationAffiliation");
IFhirResourceDao<Organization> organizationIFhirResourceDao = daoRegistry.getResourceDao("Organization");
IFhirResourceDao<Location> locationIFhirResourceDao = daoRegistry.getResourceDao(LOCATION);
rehammuzzamil marked this conversation as resolved.
Show resolved Hide resolved
LocationHierarchyResourceProvider locationHierarchyResourceProvider = new LocationHierarchyResourceProvider();
locationHierarchyResourceProvider.setLocationIFhirResourceDao(locationIFhirResourceDao);
PractitionerDetailsResourceProvider practitionerDetailsResourceProvider = new PractitionerDetailsResourceProvider();
practitionerDetailsResourceProvider.setPractitionerIFhirResourceDao(practitionerIFhirResourceDao);
practitionerDetailsResourceProvider.setPractitionerRoleIFhirResourceDao(practitionerRoleIFhirResourceDao);
practitionerDetailsResourceProvider.setCareTeamIFhirResourceDao(careTeamIFhirResourceDao);
practitionerDetailsResourceProvider.setOrganizationAffiliationIFhirResourceDao(organizationAffiliationIFhirResourceDao);
practitionerDetailsResourceProvider.setLocationHierarchyResourceProvider(locationHierarchyResourceProvider);
practitionerDetailsResourceProvider.setOrganizationIFhirResourceDao(organizationIFhirResourceDao);
practitionerDetailsResourceProvider.setLocationIFhirResourceDao(locationIFhirResourceDao);

registerProvider(practitionerDetailsResourceProvider);
getFhirContext().registerCustomType(PractitionerDetails.class);
getFhirContext().registerCustomType(KeycloakUserDetails.class);
getFhirContext().registerCustomType(UserBioData.class);
getFhirContext().registerCustomType(FhirPractitionerDetails.class);
getFhirContext().registerCustomType(FhirCareTeamExtension.class);
getFhirContext().registerCustomType(FhirOrganizationExtension.class);
}

}