Skip to content

Commit

Permalink
Feature : Changes to accomodate FHIR intergration
Browse files Browse the repository at this point in the history
  - Assessment,Enrollment,User and Site data transfer to FHIR adapter
  - RabbitMQ intergration
  - Language Translation changes
  • Loading branch information
hemavardhiniideas2it authored and Marimuthui2i committed May 16, 2024
1 parent a452733 commit fec7b75
Show file tree
Hide file tree
Showing 27 changed files with 1,159 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ public SuccessResponse<County> addCounty(@Valid @RequestBody CountyDTO countyDto
* </p>
*
* @param id The ID for which the county is being searched is given
* @return {@link SuccessResponse<County>} Returns a success message and status with the retrieved county
* @return {@link County} Returns a success message and status with the retrieved county
*/
@GetMapping("/county/get/{id}")
public SuccessResponse<County> getCountyById(@PathVariable(value = Constants.ID) long id) {
public County getCountyById(@PathVariable(value = Constants.ID) long id) {
Logger.logInfo("Get a county by ID");
return new SuccessResponse<>(SuccessCode.GET_COUNTY, dataService.getCountyById(id), HttpStatus.OK);
return dataService.getCountyById(id);
}

/**
Expand Down Expand Up @@ -216,13 +216,12 @@ public SuccessResponse<Subcounty> updateSubCountry(@Valid @RequestBody SubCounty
* </p>
*
* @param subCountyId The ID for which the sub county is being searched is given
* @return {@link SuccessResponse<Subcounty>} Returns a success message and status with the retrieved sub county
* @return {@link Subcounty} Returns a success message and status with the retrieved sub county
*/
@GetMapping("/subcounty/{id}")
public SuccessResponse<Subcounty> getSubCountyById(@PathVariable(value = Constants.ID) long subCountyId) {
public Subcounty getSubCountyById(@PathVariable(value = Constants.ID) long subCountyId) {
Logger.logInfo("Getting a list of County based on Country");
return new SuccessResponse<>(SuccessCode.GET_SUB_COUNTY, dataService.getSubCountyById(subCountyId),
HttpStatus.OK);
return dataService.getSubCountyById(subCountyId);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ void testGetCountyById() {
when(dataService.getCountyById(TestConstants.ONE)).thenReturn(county);

//then
SuccessResponse<County> actualCounty = dataController.getCountyById(TestConstants.ONE);
County actualCounty = dataController.getCountyById(TestConstants.ONE);
assertNotNull(actualCounty);
assertEquals(HttpStatus.OK, actualCounty.getStatusCode());
assertEquals(county, actualCounty);
}

@Test
Expand Down Expand Up @@ -229,9 +229,9 @@ void testGetSubCountyById() {
when(dataService.getSubCountyById(TestConstants.ONE)).thenReturn(subcounty);

//then
SuccessResponse<Subcounty> actualSubCounty = dataController.getSubCountyById(TestConstants.ONE);
Subcounty actualSubCounty = dataController.getSubCountyById(TestConstants.ONE);
assertNotNull(actualSubCounty);
assertEquals(HttpStatus.OK, actualSubCounty.getStatusCode());
assertEquals(subcounty, actualSubCounty);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.mdtlabs.coreplatform.common;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.mdtlabs.coreplatform.common.model.dto.spice.CultureDTO;
import com.mdtlabs.coreplatform.common.model.entity.spice.Comorbidity;
import com.mdtlabs.coreplatform.common.model.entity.spice.Complaints;
Expand All @@ -20,12 +26,6 @@
import com.mdtlabs.coreplatform.common.model.entity.spice.SideMenu;
import com.mdtlabs.coreplatform.common.model.entity.spice.Symptom;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* <p>
* To define the common static parameter used all over the application.
Expand Down Expand Up @@ -552,6 +552,13 @@ public final class Constants {
public static final String LAT = "lat";
public static final String LON = "lon";
public static final String BROWSER = "browser";
public static final String SITE_DATA = "Site_Data";
public static final String ORGANIZATION_LOGGER = "In OrganizationServiceImpl, setAndSendFhirSiteRequest :: ";
public static final String OBJECT_TO_STRING_LOGGER = "ERROR Converting from Object to String :: ";
public static final String RABBIT_MQ_LOGGER = "ERROR Connecting to RabbitMQ Queue :: ";
public static final String ERROR_LOGGER = "ERROR in setAndSendFhirSiteRequest :: ";
public static final String USER_LOGGER = "In UserServiceImpl, setAndSendFhirUserRequest :: ";
public static final String FHIR_USER_DATA = "User_Data";
public static List<Complaints> COMPLAINTS = new ArrayList<>();
public static List<NutritionLifestyle> NUTRITION_LIFESTYLES = new ArrayList<>();
public static List<PhysicalExamination> PHYSICAL_EXAMINATIONS = new ArrayList<>();
Expand All @@ -574,6 +581,13 @@ public final class Constants {
public static List<CultureDTO> CULTURE_LIST = new ArrayList<>();
public static List<FrequencyType> FREQUENCY_TYPE = new ArrayList<>();
public static final String SPACE_COMMA_SPACE_SPLIT_PATTERN = "\\s*,\\s*";
public static final String SHA_256 = "SHA-256";
public static final String NO_SUCH_ALGORITHM = "No such algorithm Exception occurred : \n";
public static final String TYPE_NOT_NULL_MESSAGE = "Type should not be null";
public static final String ENROLLMENT_DATA = "Enrollment_Data";
public static final String DEDUPLICATION_ID = "deduplicationId";
public static final String BODY = "body";
public static final String ASSESSMENT_DATA = "Assessment_Data";

private Constants() {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mdtlabs.coreplatform.common.model.dto.fhir;

import com.mdtlabs.coreplatform.common.model.entity.spice.*;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.List;

@Data
public class FhirAssessmentRequestDto {
private @NotNull(
message = "Type should not be null"
) String type;
private BpLog bpLog;
private GlucoseLog glucoseLog;
private MentalHealth mentalHealth;
private List<PatientSymptom> patientSymptomList;
private PatientPregnancyDetails patientPregnancyDetails;
private RedRiskNotification redRiskNotification;
private List<PatientMedicalCompliance> patientMedicalComplianceList;
private PatientAssessment patientAssessment;
private PatientTracker patientTracker;
private Long createdBy;
private Long updatedBy;
private Long patientTrackId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.mdtlabs.coreplatform.common.model.dto.fhir;

import com.mdtlabs.coreplatform.common.Constants;
import com.mdtlabs.coreplatform.common.model.entity.spice.BpLog;
import com.mdtlabs.coreplatform.common.model.entity.spice.GlucoseLog;
import com.mdtlabs.coreplatform.common.model.entity.spice.Patient;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
* <p>
* This class is an Request DTO class for FhirEnrollmentRequest.
* </p>
*
* @author Yogeshwaran M created on 17 Nov 2023
*/
@Data
public class FhirEnrollmentRequestDto {

@NotNull(message = Constants.TYPE_NOT_NULL_MESSAGE)
private String type;

private Long patientTrackId;

private Patient patient;

private BpLog bpLog;

private GlucoseLog glucoseLog;

private Long createdBy;

private Long updatedBy;

private Date createdAt;

private Date updatedAt;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.mdtlabs.coreplatform.common.model.dto.fhir;

import javax.validation.constraints.NotNull;

import lombok.Data;

@Data
public class FhirSiteRequestDTO {
private @NotNull(
message = "Type should not be null"
) String type;

private Long id;

private String name;

private String addressType;

private String addressUse;

private String address1;

private String address2;

private String latitude;

private String longitude;

private String city;

private String phoneNumber;

private Float workingHours;

private String postalCode;

private String siteType;

private Long countryId;

private Long countyId;

private Long subCountyId;

private String mflCode;

private boolean isActive;

private String countryName;

private String subCountyName;

private String countyName;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mdtlabs.coreplatform.common.model.dto.fhir;

import java.util.List;

import javax.validation.constraints.NotNull;

import lombok.Data;

import com.mdtlabs.coreplatform.common.model.entity.User;

@Data
public class FhirUserRequestDTO {
private @NotNull(
message = "Type should not be null"
) String type;
private List<User> users;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.mdtlabs.coreplatform.common.util;


import com.mdtlabs.coreplatform.common.logger.Logger;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import com.mdtlabs.coreplatform.common.Constants;

/**
* <p>
* Utility class for generating unique hash-based codes from input strings.
* </p>
*
* @author Yogeshwaran M created on Nov 17, 2023
*/
public class UniqueCodeGenerator {

private static final Map<String, String> stringToCodeMap = new HashMap<>();

private UniqueCodeGenerator() {
// Private constructor to prevent instantiation
}

/**
* Generates a unique hash-based code for the given input string.
*
* @param input The input string for which a unique code is to be generated.
* @return A unique hash-based code generated from the input string, or null if an algorithm is unavailable.
* @author Yogeshwaran M created on Nov 17, 2023
*/
public static String generateUniqueCode(String input) {
if (stringToCodeMap.containsKey(input)) {
return stringToCodeMap.get(input);
}

try {
MessageDigest digest = MessageDigest.getInstance(Constants.SHA_256);
byte[] encodedHash = digest.digest(input.getBytes());
String generatedCode = bytesToHex(encodedHash);
stringToCodeMap.put(input, generatedCode);
return generatedCode;
} catch (NoSuchAlgorithmException e) {
Logger.logError(Constants.NO_SUCH_ALGORITHM, e);
return null;
}
}

/**
* Converts a byte array to a hexadecimal representation.
*
* @param hash The byte array to be converted.
* @return The hexadecimal representation of the byte array.
* @author Yogeshwaran M created on Nov 17, 2023
*/
private static String bytesToHex(byte[] hash) {
StringBuilder hexString = new StringBuilder();
for (byte b : hash) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
}
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ services:
- EMAIL_APP_URL=${EMAIL_APP_URL}
- CFR_EMAIL_APP_URL=${CFR_EMAIL_APP_URL}
- SENDGRID_API_KEY=${SENDGRID_API_KEY}
- ENABLE_FHIR=${ENABLE_FHIR}
- RABBITMQ_QUEUE_NAME=${RABBITMQ_QUEUE_NAME}
- RABBITMQ_EXCHANGE_NAME=${RABBITMQ_EXCHANGE_NAME}
- RABBITMQ_ROUTING_KEY_NAME=${RABBITMQ_ROUTING_KEY_NAME}
- RABBITMQ_HOST=${RABBITMQ_HOST}
- RABBITMQ_PORT=${RABBITMQ_PORT}
- RABBITMQ_USERNAME=${RABBITMQ_USERNAME}
- RABBITMQ_PASSWORD=${RABBITMQ_PASSWORD}
volumes:
- ${PROJECT_PATH}/log:/log
networks:
Expand Down Expand Up @@ -170,6 +178,14 @@ services:
- ACCESS_NAME_MINIO=${ACCESS_NAME_MINIO}
- ACCESS_SECRET_MINIO=${ACCESS_SECRET_MINIO}
- BUCKET_NAME_MINIO=${BUCKET_NAME_MINIO}
- RABBITMQ_QUEUE_NAME=${RABBITMQ_QUEUE_NAME}
- RABBITMQ_EXCHANGE_NAME=${RABBITMQ_EXCHANGE_NAME}
- RABBITMQ_ROUTING_KEY_NAME=${RABBITMQ_ROUTING_KEY_NAME}
- RABBITMQ_HOST=${RABBITMQ_HOST}
- RABBITMQ_PORT=${RABBITMQ_PORT}
- RABBITMQ_USERNAME=${RABBITMQ_USERNAME}
- RABBITMQ_PASSWORD=${RABBITMQ_PASSWORD}
- ENABLE_FHIR=${ENABLE_FHIR}
networks:
- spice-app-db-network

Expand Down
10 changes: 9 additions & 1 deletion env.example
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ MAIL_PASSWORD=
MAIL_USER=
SENDGRID_API_KEY=
APP_VERSION=
EMAIL_APP_URL=
EMAIL_APP_URL=
RABBITMQ_QUEUE_NAME=
RABBITMQ_EXCHANGE_NAME=
RABBITMQ_ROUTING_KEY_NAME=
RABBITMQ_HOST=
RABBITMQ_PORT=
RABBITMQ_USERNAME=
RABBITMQ_PASSWORD=
ENABLE_FHIR=
11 changes: 11 additions & 0 deletions spice-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@
<artifactId>minio</artifactId>
<version>8.5.5</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down
Loading

0 comments on commit fec7b75

Please sign in to comment.