Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public ElrReportsController(RawElrService rawELRService,
description = "To use batch job(1) or RTI(2)",
required = false,
schema = @Schema(type = "string")),
@Parameter(in = ParameterIn.HEADER,
name = "dataSource",
description = "Data origin, for example if data originated from Rhapsody - Rhapsody can be specified for the value. The default value is API",
required = false,
schema = @Schema(type = "string")),
@Parameter(in = ParameterIn.HEADER,
name = "customMapper",
description = "The optional custom mapper field that find and replaces the text in the ELR message." +
Expand All @@ -83,6 +88,7 @@ public ElrReportsController(RawElrService rawELRService,
@PostMapping(consumes = MediaType.TEXT_PLAIN_VALUE, path = "/api/elrs")
public ResponseEntity<String> save(@RequestBody final String payload, @RequestHeader("msgType") String type,
@RequestHeader(name = "version", defaultValue = "1") String version,
@RequestHeader(name = "dataSource", defaultValue = "API") String dataSource,
@RequestHeader(name="customMapper", defaultValue = "") String customMapper) throws KafkaProducerException {
if (type.isEmpty()) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Required headers should not be null");
Expand All @@ -91,6 +97,7 @@ public ResponseEntity<String> save(@RequestBody final String payload, @RequestHe
}

RawElrDto rawElrDto = new RawElrDto();
rawElrDto.setDataSource(dataSource);
customMetricsBuilder.incrementMessagesProcessed();

if (type.equalsIgnoreCase(HL7_ELR)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class RawElrDto {
private String type;
private String payload;
private String version;
private String dataSource;
private Boolean validationActive = false;
private String customMapper;
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ private List<RawElrModel> createRawElrModelsForBatch(List<String> hl7Messages,Ra
for(String hl7Message : hl7Messages) {
RawElrModel rawElrModel=convert(rawElrDto);
rawElrModel.setPayload(hl7Message);
rawElrModel.setDataSource(rawElrDto.getDataSource());
rawElrModels.add(rawElrModel);
}
return rawElrModels;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package gov.cdc.dataingestion.report.repository.model;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import java.sql.Timestamp;

@Entity
@Table(name = "elr_raw")
@Getter
@Setter
/**
1118 - require constructor complaint
125 - comment complaint
Expand All @@ -26,6 +30,9 @@ public class RawElrModel {
private String type;
private String payload;

@Column(name = "data_source")
private String dataSource;

@Column(name = "version")
private String version;

Expand All @@ -41,67 +48,4 @@ public class RawElrModel {
@Column(name = "updated_by")
private String updatedBy;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getPayload() {
return payload;
}

public void setPayload(String payload) {
this.payload = payload;
}

public Timestamp getCreatedOn() {
return createdOn;
}

public void setCreatedOn(Timestamp createdOn) {
this.createdOn = createdOn;
}

public Timestamp getUpdatedOn() {
return updatedOn;
}

public void setUpdatedOn(Timestamp updatedOn) {
this.updatedOn = updatedOn;
}

public String getCreatedBy() {
return createdBy;
}

public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}

public String getUpdatedBy() {
return updatedBy;
}

public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class RawMessageStatus {
private String rawMessageId;
// private String rawPayload;
private String dataSource;
private String rawCreatedBy;
private String rawCreatedOn;
private String rawPipeLineStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public List<MessageStatus> getMessageStatus(String rawMessageID) {
msgStatus.getRawInfo().setRawCreatedBy(rawMessageData.get().getCreatedBy());
msgStatus.getRawInfo().setRawCreatedOn(TimeStampHelper.convertTimestampToString(rawMessageData.get().getCreatedOn()));
msgStatus.getRawInfo().setRawPipeLineStatus(MSG_STATUS_SUCCESS);
msgStatus.getRawInfo().setDataSource(rawMessageData.get().getDataSource());

if (rawMessageData.get().getType().equalsIgnoreCase(HL7_ELR)) {
Optional<ValidatedELRModel> validatedMessageData = iValidatedELRRepository.findByRawId(msgStatus.getRawInfo().getRawMessageId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ databaseChangeLog:
changes:
- sqlFile:
path: db/dataingest/tables/di-service-003.sql
splitStatements: false
- changeSet:
id: 5
author: liquibase
runOnChange: true
changes:
- sqlFile:
path: db/dataingest/tables/di-service-004.sql
splitStatements: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
USE NBS_DataIngest;
GO

IF NOT EXISTS (
SELECT 1
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'elr_raw'
AND COLUMN_NAME = 'data_source'
)
BEGIN
ALTER TABLE elr_raw
ADD data_source NVARCHAR(255) NULL;
END
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void testSave_HL7_ELR_Type() throws KafkaProducerException {

when(rawELRService.submissionElr(any(RawElrDto.class))).thenReturn(expectedResponse);

ResponseEntity<String> response = elrReportsController.save(payload, type, version,"");
ResponseEntity<String> response = elrReportsController.save(payload, type, version,"", "");

assertEquals(HttpStatus.OK, response.getStatusCode());
assertEquals(expectedResponse, response.getBody());
Expand All @@ -74,7 +74,7 @@ void testSave_XML_ELR_Type() throws KafkaProducerException {

when(rawELRService.submissionElrXml(any(RawElrDto.class))).thenReturn(expectedResponse);

ResponseEntity<String> response = elrReportsController.save(payload, type, version,"");
ResponseEntity<String> response = elrReportsController.save(payload, type, version,"", "");

assertEquals(HttpStatus.OK, response.getStatusCode());
assertEquals(expectedResponse, response.getBody());
Expand All @@ -88,7 +88,7 @@ void testSave_Invalid_Type() {
String version = "1";

assertThrows(ResponseStatusException.class, () ->
elrReportsController.save(payload, type, version,""));
elrReportsController.save(payload, type, version,"", ""));
}

@Test
Expand All @@ -98,7 +98,7 @@ void testSave_Missing_Type() {
String version = "1";

assertThrows(ResponseStatusException.class, () ->
elrReportsController.save(payload, type, version,""));
elrReportsController.save(payload, type, version,"", ""));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void testSaveHL7Message() throws Exception {
String messageType = "HL7";
mockMvc.perform(MockMvcRequestBuilders.post("/api/elrs")
.header("msgType", messageType)
.header("dataSource", "API")
.contentType("text/plain")
.content(hl7Payload)
.with(SecurityMockMvcRequestPostProcessors.jwt()))
Expand All @@ -53,6 +54,7 @@ void testSaveHL7Message() throws Exception {
rawElrDto.setValidationActive(true);
rawElrDto.setVersion("1");
rawElrDto.setCustomMapper("");
rawElrDto.setDataSource("API");
verify(rawELRService).submissionElr(rawElrDto);

}
Expand All @@ -63,6 +65,7 @@ void testSaveElrXmlMessage() throws Exception {
String messageType = "HL7-XML";
mockMvc.perform(MockMvcRequestBuilders.post("/api/elrs")
.header("msgType", messageType)
.header("dataSource", "API")
.contentType("text/plain")
.content(xmlPayload)
.with(SecurityMockMvcRequestPostProcessors.jwt()))
Expand All @@ -74,6 +77,7 @@ void testSaveElrXmlMessage() throws Exception {
rawElrDto.setValidationActive(true);
rawElrDto.setVersion("1");
rawElrDto.setCustomMapper(null);
rawElrDto.setDataSource("API");

verify(rawELRService).submissionElrXml(rawElrDto);
}
Expand Down
Loading