diff --git a/Dockerfile b/Dockerfile index 5d95d777..65a33f63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,10 @@ -FROM centos:6.6 +FROM centos -ENV JAVA_VERSION_MAJOR=8 \ - JAVA_VERSION_MINOR=171 \ - JAVA_VERSION_BUILD=11 \ - JAVA_URL_HASH=512cd62ec5174c3487ac17c61aaa89e8 +RUN cd /etc/yum.repos.d/ +RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* +RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* -RUN yum install -y wget && \ - wget -q --no-cookies --no-check-certificate \ - --header 'Cookie:oraclelicense=accept-securebackup-cookie' \ - "http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_URL_HASH}/jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.rpm" && \ - yum install -y jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.rpm && rm -f jre-*.rpm && yum clean all +RUN yum install java-1.8.0-openjdk -y COPY shr/build/distributions/shr-*.noarch.rpm /tmp/shr.rpm RUN yum install -y /tmp/shr.rpm && rm -f /tmp/shr.rpm && yum clean all diff --git a/env/local.properties b/env/local.properties index e58a83f5..cb7af635 100644 --- a/env/local.properties +++ b/env/local.properties @@ -4,7 +4,7 @@ TR_PASSWORD=Admin123 CASSANDRA_KEYSPACE=freeshr CASSANDRA_VERSION=2 CQL_VERSION=3.1.1 -CASSANDRA_HOST=192.168.33.10 +CASSANDRA_HOST=localhost CASSANDRA_PORT=9042 CASSANDRA_USER=cassandra CASSANDRA_PASSWORD=cassandra @@ -12,12 +12,12 @@ CASSANDRA_TIMEOUT=60000 CASSANDRA_MIGRATIONS_PATH=org/freeshr/cassandra/migrations REST_POOL_SIZE=20 BDSHR_PORT=8082 -FACILITY_REGISTRY_URL=http://hrmtest.dghs.gov.bd/api/1.0/facilities/ -PROVIDER_REGISTRY_URL=http://hrmtest.dghs.gov.bd/api/1.0/providers/ +FACILITY_REGISTRY_URL=http://localhost:8084/api/1.0/facilities/ +PROVIDER_REGISTRY_URL=http://localhost:8084/api/1.0/providers/ ENCOUNTER_FETCH_LIMIT=20 SERVER_CONNECTION_TIMEOUT=10000 -TR_SERVER_BASE_URL=http://172.18.46.56:9080 -IDENTITY_SERVER_BASE_URL=http://172.18.46.55:8084/token/ +TR_SERVER_BASE_URL=http://localhost:9080 +IDENTITY_SERVER_BASE_URL=http://localhost:8084/token/ SHR_LOG_LEVEL=INFO VALIDATION_ZIP_PATH= FACILITY_CACHE_TTL_SECONDS=864000 @@ -26,6 +26,6 @@ IDP_AUTH_TOKEN=c6e6fd3a26313eb250e1019519af33e743808f5bb50428ae5423b8ee278e6fa5 SHR_VERSION=v2 IS_LATEST_SHR=true LOCAL_CACHE_TTL=86400 -MCI_SERVER_URL=http://172.18.46.56:8081 +MCI_SERVER_URL=http://localhost:8081 FHIR_DOCUMENT_SCHEMA_VERSION=v3 IDENTITY_CACHE_TTL=120 diff --git a/shr/src/main/java/org/freeshr/application/fhir/EncounterBundle.java b/shr/src/main/java/org/freeshr/application/fhir/EncounterBundle.java index 27542381..c6f058f0 100644 --- a/shr/src/main/java/org/freeshr/application/fhir/EncounterBundle.java +++ b/shr/src/main/java/org/freeshr/application/fhir/EncounterBundle.java @@ -1,13 +1,13 @@ package org.freeshr.application.fhir; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import org.eclipse.persistence.oxm.annotations.XmlCDATA; import org.freeshr.domain.model.Requester; import org.freeshr.utils.Confidentiality; import org.freeshr.utils.DateUtil; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; @@ -28,6 +28,15 @@ public class EncounterBundle { private Date updatedAt; private UUID updatedEventReference; private UUID receivedEventReference; + private String contentType; + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } @JsonProperty("id") @XmlElement(name = "id") @@ -63,7 +72,6 @@ public String getContent() { public Date getReceivedAt() { return receivedAt; } - @JsonIgnore @XmlTransient public EncounterContent getEncounterContent() { @@ -137,6 +145,10 @@ public void setContentVersion(int contentVersion) { this.contentVersion = contentVersion; } + public void setContent(String content) { + this.encounterContent = new EncounterContent(content); + } + public void setEncounterConfidentiality(Confidentiality encounterConfidentiality) { this.encounterConfidentiality = encounterConfidentiality; } diff --git a/shr/src/main/java/org/freeshr/interfaces/encounter/ws/PatientEncounterController.java b/shr/src/main/java/org/freeshr/interfaces/encounter/ws/PatientEncounterController.java index f7e3a744..62128422 100644 --- a/shr/src/main/java/org/freeshr/interfaces/encounter/ws/PatientEncounterController.java +++ b/shr/src/main/java/org/freeshr/interfaces/encounter/ws/PatientEncounterController.java @@ -17,6 +17,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.async.DeferredResult; @@ -53,20 +55,28 @@ public PatientEncounterController(PatientEncounterService patientEncounterServic } @PreAuthorize("hasAnyRole('ROLE_SHR_FACILITY', 'ROLE_SHR_PROVIDER')") - @RequestMapping(value = "/{healthId}/encounters", method = RequestMethod.POST) + @RequestMapping(value = "/{healthId}/encounters", method = RequestMethod.POST, + consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_ATOM_XML_VALUE}) public DeferredResult create( @PathVariable String healthId, - @RequestBody EncounterBundle encounterBundle) throws ExecutionException, InterruptedException { + @RequestBody EncounterBundle encounterBundle, + @RequestHeader(HttpHeaders.CONTENT_TYPE) String contentType) + throws ExecutionException, InterruptedException { UserInfo userInfo = getUserInfo(); logAccessDetails(userInfo, String.format("Create encounter request for patient (healthId) %s", healthId)); final DeferredResult deferredResult = new DeferredResult<>(); + if (contentType.equals(MediaType.APPLICATION_JSON_VALUE)) { + encounterBundle.setContentType("json"); + } else { + encounterBundle.setContentType("xml"); + } + try { logger.info(String.format("Create encounter for patient (healthId) %s", healthId)); encounterBundle.setHealthId(healthId); Observable encounterResponse = patientEncounterService.ensureCreated(encounterBundle, userInfo); - encounterResponse.subscribe(encounterSaveSuccessCallback(deferredResult), errorCallback(deferredResult)); } catch (Exception e) { logger.error(e.getMessage()); diff --git a/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java b/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java index 6616a6af..ef53f667 100644 --- a/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java +++ b/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java @@ -3,6 +3,7 @@ import org.freeshr.application.fhir.EncounterBundle; import org.freeshr.utils.FhirFeedUtil; import org.hl7.fhir.dstu3.model.Bundle; +import java.util.Optional; public class EncounterValidationContext { private EncounterBundle encounterBundle; @@ -48,7 +49,10 @@ public String extract() { public Bundle getBundle() { if (bundle != null) return bundle; - bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), "xml"); + + String type = Optional.ofNullable(encounterBundle.getContentType()).orElse("xml"); + bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), type); + return bundle; } }