-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature : FHIR Adapter intergration changes and Sonar cloud security fix
1.Assessment,Enrollment,User and Site data transfer to FHIR adapter 2.RabbitMQ intergration 3.Language Translation changes 4.Added TestCase to all changes 5.Sonar security fix
- Loading branch information
1 parent
f449042
commit 94eef00
Showing
34 changed files
with
1,559 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...rc/main/java/com/mdtlabs/coreplatform/common/model/dto/fhir/FhirAssessmentRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
41 changes: 41 additions & 0 deletions
41
...rc/main/java/com/mdtlabs/coreplatform/common/model/dto/fhir/FhirEnrollmentRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
...vice/src/main/java/com/mdtlabs/coreplatform/common/model/dto/fhir/FhirSiteRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...vice/src/main/java/com/mdtlabs/coreplatform/common/model/dto/fhir/FhirUserRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
69 changes: 69 additions & 0 deletions
69
common-service/src/main/java/com/mdtlabs/coreplatform/common/util/UniqueCodeGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ice/src/test/java/com/mdtlabs/coreplatform/common/util/spice/UniqueCodeGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.mdtlabs.coreplatform.common.util.spice; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.mockito.junit.jupiter.MockitoSettings; | ||
import org.mockito.quality.Strictness; | ||
|
||
import com.mdtlabs.coreplatform.common.util.UniqueCodeGenerator; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
@MockitoSettings(strictness = Strictness.LENIENT) | ||
class UniqueCodeGeneratorTest { | ||
|
||
@InjectMocks | ||
private UniqueCodeGenerator uniqueCodeGenerator; | ||
@Test | ||
public void testGenerateUniqueCode() { | ||
String input = "test"; | ||
String uniqueCode = uniqueCodeGenerator.generateUniqueCode(input); | ||
assertNotNull(uniqueCode); | ||
|
||
// Test that the same code is returned for the same input | ||
String sameUniqueCode = UniqueCodeGenerator.generateUniqueCode(input); | ||
assertEquals(uniqueCode, sameUniqueCode); | ||
|
||
// Test that a different code is returned for a different input | ||
String differentUniqueCode = uniqueCodeGenerator.generateUniqueCode(input + "1"); | ||
assertNotNull(differentUniqueCode); | ||
Assertions.assertNotEquals(uniqueCode, differentUniqueCode); | ||
} | ||
} |
Oops, something went wrong.