From b659dc8331dcb4cd00719eff3aa5cbb2edc09cf3 Mon Sep 17 00:00:00 2001 From: Atiquzzaman Date: Mon, 2 Jan 2023 19:01:33 +0600 Subject: [PATCH 1/5] Docker build change, Bug fix --- Dockerfile | 15 +++++---------- env/local.properties | 12 ++++++------ .../freeshr/application/fhir/EncounterBundle.java | 4 ++++ 3 files changed, 15 insertions(+), 16 deletions(-) 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..8cd728d0 100644 --- a/shr/src/main/java/org/freeshr/application/fhir/EncounterBundle.java +++ b/shr/src/main/java/org/freeshr/application/fhir/EncounterBundle.java @@ -137,6 +137,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; } From bd52eca877c981efcf5447fcb31f29527c16c6f1 Mon Sep 17 00:00:00 2001 From: Samim Hossain Date: Tue, 7 Mar 2023 15:53:52 +0600 Subject: [PATCH 2/5] Encounter content improved to allow json data --- .../freeshr/application/fhir/EncounterBundle.java | 13 ++++++++++++- .../encounter/ws/PatientEncounterController.java | 9 +++++---- .../validations/EncounterValidationContext.java | 9 ++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) 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 8cd728d0..8341d8bd 100644 --- a/shr/src/main/java/org/freeshr/application/fhir/EncounterBundle.java +++ b/shr/src/main/java/org/freeshr/application/fhir/EncounterBundle.java @@ -1,16 +1,19 @@ package org.freeshr.application.fhir; +import com.fasterxml.jackson.annotation.JsonFormat; 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 org.springframework.http.MediaType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; +import javax.xml.bind.annotation.XmlRootElement; import java.util.Date; import java.util.UUID; @@ -28,6 +31,15 @@ public class EncounterBundle { private Date updatedAt; private UUID updatedEventReference; private UUID receivedEventReference; + private String contentType = MediaType.APPLICATION_XML_VALUE; + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } @JsonProperty("id") @XmlElement(name = "id") @@ -63,7 +75,6 @@ public String getContent() { public Date getReceivedAt() { return receivedAt; } - @JsonIgnore @XmlTransient public EncounterContent getEncounterContent() { 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..a3d84c60 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,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +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; @@ -24,6 +25,7 @@ import rx.functions.Action1; import javax.servlet.http.HttpServletRequest; +import java.awt.*; import java.io.UnsupportedEncodingException; import java.util.Date; import java.util.List; @@ -53,20 +55,19 @@ 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_XML_VALUE}) public DeferredResult create( @PathVariable String healthId, - @RequestBody EncounterBundle encounterBundle) throws ExecutionException, InterruptedException { + @RequestBody EncounterBundle encounterBundle, HttpServletRequest request) throws ExecutionException, InterruptedException { UserInfo userInfo = getUserInfo(); logAccessDetails(userInfo, String.format("Create encounter request for patient (healthId) %s", healthId)); final DeferredResult deferredResult = new DeferredResult<>(); - + encounterBundle.setContentType(request.getHeader("Content-Type")); 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..b5c26ca5 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 org.springframework.http.MediaType; public class EncounterValidationContext { private EncounterBundle encounterBundle; @@ -48,7 +49,13 @@ public String extract() { public Bundle getBundle() { if (bundle != null) return bundle; - bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), "xml"); + + if(encounterBundle.getContentType().contains(MediaType.APPLICATION_JSON_VALUE)){ + bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), "json"); + }else { + bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), "xml"); + } + return bundle; } } From 2e8eadd3efff19e4720667a28e3a2fb6c96cde5b Mon Sep 17 00:00:00 2001 From: Samim Hossain Date: Tue, 7 Mar 2023 18:03:29 +0600 Subject: [PATCH 3/5] Encounter content improved to allow json data --- .../org/freeshr/validations/EncounterValidationContext.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java b/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java index b5c26ca5..4d90cd5d 100644 --- a/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java +++ b/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java @@ -50,9 +50,9 @@ public String extract() { public Bundle getBundle() { if (bundle != null) return bundle; - if(encounterBundle.getContentType().contains(MediaType.APPLICATION_JSON_VALUE)){ + if (encounterBundle.getContentType().contains(MediaType.APPLICATION_JSON_VALUE)) { bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), "json"); - }else { + } else { bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), "xml"); } From b5c9b14a5e90e20b22e401c0a2f23e402b743707 Mon Sep 17 00:00:00 2001 From: Samim Hossain Date: Thu, 9 Mar 2023 16:29:34 +0600 Subject: [PATCH 4/5] Encounter content improved to allow json data updated efficiently --- .../freeshr/application/fhir/EncounterBundle.java | 7 ++----- .../encounter/ws/PatientEncounterController.java | 14 +++++++++++--- .../validations/EncounterValidationContext.java | 9 +++------ 3 files changed, 16 insertions(+), 14 deletions(-) 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 8341d8bd..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,19 +1,16 @@ package org.freeshr.application.fhir; -import com.fasterxml.jackson.annotation.JsonFormat; + 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 org.springframework.http.MediaType; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; -import javax.xml.bind.annotation.XmlRootElement; import java.util.Date; import java.util.UUID; @@ -31,7 +28,7 @@ public class EncounterBundle { private Date updatedAt; private UUID updatedEventReference; private UUID receivedEventReference; - private String contentType = MediaType.APPLICATION_XML_VALUE; + private String contentType; public String getContentType() { return contentType; 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 a3d84c60..5d57f00b 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,7 @@ 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.*; @@ -25,7 +26,6 @@ import rx.functions.Action1; import javax.servlet.http.HttpServletRequest; -import java.awt.*; import java.io.UnsupportedEncodingException; import java.util.Date; import java.util.List; @@ -58,11 +58,19 @@ public PatientEncounterController(PatientEncounterService patientEncounterServic @RequestMapping(value = "/{healthId}/encounters", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}) public DeferredResult create( @PathVariable String healthId, - @RequestBody EncounterBundle encounterBundle, HttpServletRequest request) 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<>(); - encounterBundle.setContentType(request.getHeader("Content-Type")); + + 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); diff --git a/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java b/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java index 4d90cd5d..ef53f667 100644 --- a/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java +++ b/shr/src/main/java/org/freeshr/validations/EncounterValidationContext.java @@ -3,7 +3,7 @@ import org.freeshr.application.fhir.EncounterBundle; import org.freeshr.utils.FhirFeedUtil; import org.hl7.fhir.dstu3.model.Bundle; -import org.springframework.http.MediaType; +import java.util.Optional; public class EncounterValidationContext { private EncounterBundle encounterBundle; @@ -50,11 +50,8 @@ public String extract() { public Bundle getBundle() { if (bundle != null) return bundle; - if (encounterBundle.getContentType().contains(MediaType.APPLICATION_JSON_VALUE)) { - bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), "json"); - } else { - bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), "xml"); - } + String type = Optional.ofNullable(encounterBundle.getContentType()).orElse("xml"); + bundle = fhirFeedUtil.parseBundle(encounterBundle.getContent(), type); return bundle; } From 655aa5f9814f8263b115819ae0fca5a94b59b045 Mon Sep 17 00:00:00 2001 From: Atiquzzaman Date: Sun, 12 Mar 2023 14:00:36 +0600 Subject: [PATCH 5/5] Allowed atom media type --- .../interfaces/encounter/ws/PatientEncounterController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 5d57f00b..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 @@ -55,7 +55,8 @@ public PatientEncounterController(PatientEncounterService patientEncounterServic } @PreAuthorize("hasAnyRole('ROLE_SHR_FACILITY', 'ROLE_SHR_PROVIDER')") - @RequestMapping(value = "/{healthId}/encounters", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}) + @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,