Skip to content
This repository has been archived by the owner on Mar 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #120 from rasanjanap/master
Browse files Browse the repository at this point in the history
Don't mege GSoC work on progress
  • Loading branch information
harsha89 committed Jul 6, 2016
2 parents 6896ef4 + 6f52082 commit 808bc9a
Show file tree
Hide file tree
Showing 34 changed files with 2,799 additions and 6 deletions.
Expand Up @@ -246,5 +246,8 @@ public final class FHIRConstants {

//Global Property Names
public static final String CONCEPTS_CONVERTABLE_TO_CONDITIONS_STORED_AS_OBS = "fhir.concepts.conditions";
//module id or name
public static final String MODULE_ID = "fhir";
public static final String URI_PREFIX_GLOBAL_PROPERTY_NAME = MODULE_ID + ".uriPrefix";

}
6 changes: 5 additions & 1 deletion omod/pom.xml
Expand Up @@ -101,7 +101,11 @@
<version>0.1</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
@@ -0,0 +1,53 @@
/*
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.fhir.filter;

import org.openmrs.module.fhir.util.FHIROmodConstants;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class SwaggerForwardingFilter implements Filter {

private String openmrsPath;

@Override
public void init(FilterConfig fc) throws ServletException {
openmrsPath = fc.getServletContext().getContextPath();
}

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
String requestURI = request.getRequestURI();

if (requestURI.startsWith(openmrsPath + FHIROmodConstants.OPENMRS_FHIR_SWAGGER_SHORT_PATH)) {
String newURI = requestURI.replace(FHIROmodConstants.OPENMRS_FHIR_SWAGGER_LONG_PATH, FHIROmodConstants.OPENMRS_FHIR_SWAGGER_ORG_PATH);
req.getRequestDispatcher(newURI).forward(req, res);
} else {
chain.doFilter(req, res);
}
}

@Override
public void destroy() {
}

}
Expand Up @@ -56,7 +56,7 @@ public Class<? extends IResource> getResourceType() {
*
* @param theId The read operation takes one parameter, which must be of type IdDt and must be
* annotated with the "@Read.IdParam" annotation.
* @return Returns a resource matching this identifier, or null if none exists.
* @return Returns a resource matching this identifier, or nu ll if none exists.
*/
@Read()
public Encounter getResourceById(@IdParam IdDt theId) {
Expand Down Expand Up @@ -115,7 +115,7 @@ public List<Encounter> searchEncountersByIdAndPartOf(@RequiredParam(name = Encou
* @param encounterId if of the encounter
* @return bundle
*/
@Operation(name = "$everything")
@Operation(name = "$everything", type = Encounter.class)
public Bundle encounterInstanceOperation(@IdParam IdDt encounterId) {
return encounterResource.getEncounterOperationsById(encounterId);
}
Expand Down
Expand Up @@ -158,7 +158,7 @@ public List<Patient> searchPatientsByProvider(@RequiredParam(name = Patient.SP_C
* @param patientId if of the patient
* @return bundle
*/
@Operation(name = "$everything")
@Operation(name = "$everything", type = Patient.class)
public Bundle patientInstanceOperation(@IdParam IdDt patientId) {
return patientResource.getPatientOperationsById(patientId);
}
Expand Down
Expand Up @@ -43,7 +43,7 @@ public List<Patient> searchByUniqueId(TokenParam id) {
return patientService.searchPatientsById(id.getValue());
}

//search by patient identifier. ex: GET [base-url]/Patient?identifier=http://acme.org/patient|2345
//search by patient identifier. ex: GET_DESCRIPTION [base-url]/Patient?identifier=http://acme.org/patient|2345
//returns a bundle of patients
public List<Patient> searchByIdentifier(TokenParam identifier) {
org.openmrs.module.fhir.api.PatientService patientService = Context.getService(
Expand Down
Expand Up @@ -41,7 +41,7 @@ public List<Practitioner> searchByUniqueId(TokenParam id) {
return patientService.searchPractitionersById(id.getValue());
}

//search by patient identifier. ex: GET [base-url]/Practitioner?identifier=12345
//search by patient identifier. ex: GET_DESCRIPTION [base-url]/Practitioner?identifier=12345
//returns a bundle of practitioners
public List<Practitioner> searchByIdentifier(TokenParam identifier) {
org.openmrs.module.fhir.api.PractitionerService patientService = Context
Expand Down
@@ -0,0 +1,46 @@
/*
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.fhir.server;

import ca.uhn.fhir.model.dstu2.resource.Conformance;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.provider.dstu2.ServerConformanceProvider;

public class ConformanceProvider {

private static Conformance conformance = null;
private static RestfulServer restfulServer;

public static void setConformance(Conformance conformanceStatement) {
conformance = conformanceStatement;
}

public static Conformance getConformance() {
if(conformance == null) {
ServerConformanceProvider confProvider = (ServerConformanceProvider) restfulServer.getServerConformanceProvider();
conformance = confProvider.getServerConformance(null);
return conformance;
} else {
return conformance;
}
}

public static RestfulServer getRestfulServer() {
return restfulServer;
}

public void setRestfulServer(RestfulServer restfulServer) {
this.restfulServer = restfulServer;
}
}
Expand Up @@ -18,6 +18,8 @@

import javax.servlet.ServletException;

import ca.uhn.fhir.model.dstu2.resource.Conformance;
import ca.uhn.fhir.rest.server.provider.dstu2.ServerConformanceProvider;
import org.openmrs.module.fhir.addressstrategy.OpenMRSFHIRRequestAddressStrategy;
import org.openmrs.module.fhir.api.util.FHIRUtils;
import org.openmrs.module.fhir.providers.RestfulAllergyIntoleranceResourceProvider;
Expand Down Expand Up @@ -85,6 +87,10 @@ protected void initialize() throws ServletException {
loggingInterceptor.setLoggerName("test.accesslog");
loggingInterceptor
.setMessageFormat("Source[${remoteAddr}] Operation[${operationType} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}]");
ServerConformanceProvider sc = new ServerConformanceProvider(this);
this.setServerConformanceProvider(sc);
ConformanceProvider provider = new ConformanceProvider();
provider.setRestfulServer(this);
}

protected String getRequestPath(String requestFullPath, String servletContextPath, String servletPath) {
Expand Down

0 comments on commit 808bc9a

Please sign in to comment.