Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 6 additions & 6 deletions env/local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ 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
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
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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")
Expand Down Expand Up @@ -63,7 +72,6 @@ public String getContent() {
public Date getReceivedAt() {
return receivedAt;
}

@JsonIgnore
@XmlTransient
public EncounterContent getEncounterContent() {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<EncounterResponse> 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<EncounterResponse> 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> encounterResponse = patientEncounterService.ensureCreated(encounterBundle,
userInfo);

encounterResponse.subscribe(encounterSaveSuccessCallback(deferredResult), errorCallback(deferredResult));
} catch (Exception e) {
logger.error(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}