Skip to content

Commit

Permalink
Merge pull request #908 from Shreeja-dev/745-csv-validate-new
Browse files Browse the repository at this point in the history
fix : update source and origin in fhir table#745
  • Loading branch information
ratheesh-kr authored Dec 18, 2024
2 parents 81a96fe + 93aa527 commit 7e98854
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ private void saveScreeningGroup(final String groupInteractionId, final HttpServl
initRIHR.setContentType(MimeTypeUtils.APPLICATION_JSON_VALUE);
initRIHR.setCsvZipFileName(file.getOriginalFilename());
initRIHR.setSourceHubInteractionId(interactionId);
final InetAddress localHost = InetAddress.getLocalHost();
final String ipAddress = localHost.getHostAddress();
initRIHR.setClientIpAddress(ipAddress);
initRIHR.setUserAgent(request.getHeader("User-Agent"));
for (final FileDetail fileDetail : fileDetailList) {
switch (fileDetail.fileType()) {
case FileType.DEMOGRAPHIC_DATA -> {
Expand Down Expand Up @@ -384,7 +388,8 @@ private void saveValidationResults(final Map<String, Object> validationResults,
final var initRIHR = new RegisterInteractionHttpRequest();
try {
initRIHR.setInteractionId(groupInteractionId);
initRIHR.setGroupHubInteractionId(masterInteractionId);
initRIHR.setGroupHubInteractionId(groupInteractionId);
initRIHR.setSourceHubInteractionId(masterInteractionId);
initRIHR.setInteractionKey(request.getRequestURI());
initRIHR.setNature((JsonNode) Configuration.objectMapper.valueToTree(
Map.of("nature", "CSV Validation Result", "tenant_id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.techbd.model.csv.QeAdminData;
import org.techbd.model.csv.ScreeningObservationData;
import org.techbd.model.csv.ScreeningProfileData;
import org.techbd.service.constants.SourceType;
import org.techbd.service.converters.csv.CsvToFhirConverter;
import org.techbd.service.http.hub.prime.api.FHIRService;
import org.techbd.udi.UdiPrimeJpaConfig;
Expand Down Expand Up @@ -134,7 +135,7 @@ private void saveConvertedFHIR(boolean isValid, String masterInteractionId, Stri
initRIHR.setCreatedAt(forwardedAt);
initRIHR.setCreatedBy(CsvService.class.getName());
initRIHR.setFromState(isValid ? "VALIDATION SUCCESS" : "VALIDATION FAILED");
initRIHR.setFromState(isPayloadInstanceOfBundle(payload) ? "CONVERTED_TO_FHIR" : "FHIR_CONVERSION_FAILED");
initRIHR.setToState(isPayloadInstanceOfBundle(payload) ? "CONVERTED_TO_FHIR" : "FHIR_CONVERSION_FAILED");
final var provenance = "%s.saveConvertedFHIR".formatted(CsvBundleProcessorService.class.getName());
initRIHR.setProvenance(provenance);
initRIHR.setCsvGroupId(groupKey);
Expand Down Expand Up @@ -246,7 +247,7 @@ private List<Object> processScreeningProfileData(String groupKey,
results.add(fhirService.processBundle(
bundle, tenantId, null, null, null, null, null,
Boolean.toString(false), false,
false, false, request, response, null, true, null,interactionId,groupInteractionId,masterInteractionId));
false, false, request, response, null, true, null,interactionId,groupInteractionId,masterInteractionId,SourceType.CSV.name()));
} else {
results.add(createOperationOutcomeForError(masterInteractionId, interactionId,
profile.getPatientMrIdValue(), new Exception("Bundle not created")));
Expand Down
5 changes: 3 additions & 2 deletions hub-prime/src/main/java/org/techbd/service/CsvService.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.web.multipart.MultipartFile;
import org.techbd.conf.Configuration;
import org.techbd.orchestrate.csv.CsvOrchestrationEngine;
import org.techbd.service.constants.Origin;
import org.techbd.service.http.Interactions;
import org.techbd.service.http.InteractionsFilter;
import org.techbd.udi.UdiPrimeJpaConfig;
Expand Down Expand Up @@ -83,7 +84,7 @@ private void saveArchiveInteraction(final org.jooq.Configuration jooqCfg, final
final var forwardedAt = OffsetDateTime.now();
final var initRIHR = new RegisterInteractionHttpRequest();
try {
initRIHR.setOrigin("http");
initRIHR.setOrigin(Origin.HTTP.name());
initRIHR.setInteractionId(interactionId);
initRIHR.setInteractionKey(request.getRequestURI());
initRIHR.setNature((JsonNode) Configuration.objectMapper.valueToTree(
Expand All @@ -94,7 +95,7 @@ private void saveArchiveInteraction(final org.jooq.Configuration jooqCfg, final
initRIHR.setCsvZipFileName(file.getOriginalFilename());
initRIHR.setCreatedAt(forwardedAt);
final InetAddress localHost = InetAddress.getLocalHost();
final String ipAddress = localHost.getHostAddress();
final String ipAddress = localHost.getHostAddress();
initRIHR.setClientIpAddress(ipAddress);
initRIHR.setUserAgent(request.getHeader("User-Agent"));
initRIHR.setCreatedBy(CsvService.class.getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.techbd.service.constants;

public enum Origin {
HTTP,
SFTP

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.techbd.service.constants;

public enum SourceType {
FHIR,
CSV,
HL7
}
Loading

0 comments on commit 7e98854

Please sign in to comment.