@@ -28,15 +28,15 @@ export function formatInterPartnerFilename(
2828 sof : string ,
2929) : string {
3030 // Format: InterPartner~DatapultELRPivot~Simple-Report~AIMSPlatform~<SE>~<RE>~<Timestamp>~STOP~<SOF>
31- const uc = "DatapultELRPivot" ;
32- const sj = "Simple-Report" ;
33- const rj = "AIMSPlatform" ;
34- const se = env ; //sending environment we could potentially consolidate to one variable
35- const re = env ; //recieving environment
31+ const use_case = "DatapultELRPivot" ;
32+ const sending_jurisdiction = "Simple-Report" ;
33+ const receiving_jurisdiction = "AIMSPlatform" ;
34+ const sending_environment = env ;
35+ const receiving_environment = env ;
3636 const formattedTimestamp = formatTimestamp ( timestamp ) ;
3737 const stop = "STOP" ;
3838
39- return `InterPartner~${ uc } ~${ sj } ~${ rj } ~${ se } ~${ re } ~${ formattedTimestamp } ~${ stop } ~${ sof } ` ;
39+ return `InterPartner~${ use_case } ~${ sending_jurisdiction } ~${ receiving_jurisdiction } ~${ sending_environment } ~${ receiving_environment } ~${ formattedTimestamp } ~${ stop } ~${ sof } ` ;
4040}
4141
4242export function formatTimestamp ( date : Date ) : string {
@@ -139,7 +139,7 @@ export async function SendToAIMS(
139139
140140 // Parse messageID from HL7
141141 const messageId = hl7Message . messageId ;
142- const filename = hl7Message . filename || `hl7-message- ${ Date . now ( ) } .hl7` ;
142+ const filename = hl7Message . filename ;
143143 const objectKey = `${ ENV . AIMS_USER_ID } /SendTo/${ filename } ` ;
144144
145145 // Populate metadata following AIMS pattern
@@ -167,7 +167,17 @@ export async function SendToAIMS(
167167 // Track S3 dependency
168168 const startTime = Date . now ( ) ;
169169 try {
170- await client . send ( command ) ;
170+ const response = await client . send ( command ) ;
171+
172+ // Check if the response indicates success
173+ if (
174+ response . $metadata ?. httpStatusCode &&
175+ response . $metadata . httpStatusCode >= 400
176+ ) {
177+ throw new Error (
178+ `S3 upload failed with status ${ response . $metadata . httpStatusCode } ` ,
179+ ) ;
180+ }
171181
172182 telemetry . trackDependency ( {
173183 target : ENV . AIMS_OUTBOUND_ENDPOINT ,
0 commit comments