import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectString as __expectString , expectUnion as __expectUnion , parseEpochTimestamp as __parseEpochTimestamp , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , HeaderBag as __HeaderBag , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { v4 as generateIdempotencyToken } from "uuid" ; import { CreateFHIRDatastoreCommandInput , CreateFHIRDatastoreCommandOutput , } from "../commands/CreateFHIRDatastoreCommand" ; import { DeleteFHIRDatastoreCommandInput , DeleteFHIRDatastoreCommandOutput , } from "../commands/DeleteFHIRDatastoreCommand" ; import { DescribeFHIRDatastoreCommandInput , DescribeFHIRDatastoreCommandOutput , } from "../commands/DescribeFHIRDatastoreCommand" ; import { DescribeFHIRExportJobCommandInput , DescribeFHIRExportJobCommandOutput , } from "../commands/DescribeFHIRExportJobCommand" ; import { DescribeFHIRImportJobCommandInput , DescribeFHIRImportJobCommandOutput , } from "../commands/DescribeFHIRImportJobCommand" ; import { ListFHIRDatastoresCommandInput , ListFHIRDatastoresCommandOutput } from "../commands/ListFHIRDatastoresCommand" ; import { ListFHIRExportJobsCommandInput , ListFHIRExportJobsCommandOutput } from "../commands/ListFHIRExportJobsCommand" ; import { ListFHIRImportJobsCommandInput , ListFHIRImportJobsCommandOutput } from "../commands/ListFHIRImportJobsCommand" ; import { ListTagsForResourceCommandInput , ListTagsForResourceCommandOutput , } from "../commands/ListTagsForResourceCommand" ; import { StartFHIRExportJobCommandInput , StartFHIRExportJobCommandOutput } from "../commands/StartFHIRExportJobCommand" ; import { StartFHIRImportJobCommandInput , StartFHIRImportJobCommandOutput } from "../commands/StartFHIRImportJobCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { AccessDeniedException , ConflictException , CreateFHIRDatastoreRequest , CreateFHIRDatastoreResponse , DatastoreFilter , DatastoreProperties , DeleteFHIRDatastoreRequest , DeleteFHIRDatastoreResponse , DescribeFHIRDatastoreRequest , DescribeFHIRDatastoreResponse , DescribeFHIRExportJobRequest , DescribeFHIRExportJobResponse , DescribeFHIRImportJobRequest , DescribeFHIRImportJobResponse , ExportJobProperties , ImportJobProperties , InputDataConfig , InternalServerException , KmsEncryptionConfig , ListFHIRDatastoresRequest , ListFHIRDatastoresResponse , ListFHIRExportJobsRequest , ListFHIRExportJobsResponse , ListFHIRImportJobsRequest , ListFHIRImportJobsResponse , ListTagsForResourceRequest , ListTagsForResourceResponse , OutputDataConfig , PreloadDataConfig , ResourceNotFoundException , S3Configuration , SseConfiguration , StartFHIRExportJobRequest , StartFHIRExportJobResponse , StartFHIRImportJobRequest , StartFHIRImportJobResponse , Tag , TagResourceRequest , TagResourceResponse , ThrottlingException , UntagResourceRequest , UntagResourceResponse , ValidationException , } from "../models/models_0" ; export const serializeAws_json1_0CreateFHIRDatastoreCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.CreateFHIRDatastore" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0CreateFHIRDatastoreRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0DeleteFHIRDatastoreCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.DeleteFHIRDatastore" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0DeleteFHIRDatastoreRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0DescribeFHIRDatastoreCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.DescribeFHIRDatastore" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0DescribeFHIRDatastoreRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0DescribeFHIRExportJobCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.DescribeFHIRExportJob" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0DescribeFHIRExportJobRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0DescribeFHIRImportJobCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.DescribeFHIRImportJob" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0DescribeFHIRImportJobRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0ListFHIRDatastoresCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.ListFHIRDatastores" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0ListFHIRDatastoresRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0ListFHIRExportJobsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.ListFHIRExportJobs" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0ListFHIRExportJobsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0ListFHIRImportJobsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.ListFHIRImportJobs" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0ListFHIRImportJobsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0ListTagsForResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.ListTagsForResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0ListTagsForResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0StartFHIRExportJobCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.StartFHIRExportJob" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0StartFHIRExportJobRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0StartFHIRImportJobCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.StartFHIRImportJob" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0StartFHIRImportJobRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0TagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.TagResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0TagResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0UntagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "HealthLake.UntagResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0UntagResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const deserializeAws_json1_0CreateFHIRDatastoreCommand = async ( output , context ) : Promise < CreateFHIRDatastoreCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0CreateFHIRDatastoreCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0CreateFHIRDatastoreResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0CreateFHIRDatastoreCommandError = async ( output , context ) : Promise < CreateFHIRDatastoreCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.healthlake#AccessDeniedException" : response = { ... ( await deserializeAws_json1_0AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0DeleteFHIRDatastoreCommand = async ( output , context ) : Promise < DeleteFHIRDatastoreCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0DeleteFHIRDatastoreCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0DeleteFHIRDatastoreResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0DeleteFHIRDatastoreCommandError = async ( output , context ) : Promise < DeleteFHIRDatastoreCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.healthlake#AccessDeniedException" : response = { ... ( await deserializeAws_json1_0AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.healthlake#ConflictException" : response = { ... ( await deserializeAws_json1_0ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0DescribeFHIRDatastoreCommand = async ( output , context ) : Promise < DescribeFHIRDatastoreCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0DescribeFHIRDatastoreCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0DescribeFHIRDatastoreResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0DescribeFHIRDatastoreCommandError = async ( output , context ) : Promise < DescribeFHIRDatastoreCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0DescribeFHIRExportJobCommand = async ( output , context ) : Promise < DescribeFHIRExportJobCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0DescribeFHIRExportJobCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0DescribeFHIRExportJobResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0DescribeFHIRExportJobCommandError = async ( output , context ) : Promise < DescribeFHIRExportJobCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0DescribeFHIRImportJobCommand = async ( output , context ) : Promise < DescribeFHIRImportJobCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0DescribeFHIRImportJobCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0DescribeFHIRImportJobResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0DescribeFHIRImportJobCommandError = async ( output , context ) : Promise < DescribeFHIRImportJobCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0ListFHIRDatastoresCommand = async ( output , context ) : Promise < ListFHIRDatastoresCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0ListFHIRDatastoresCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0ListFHIRDatastoresResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0ListFHIRDatastoresCommandError = async ( output , context ) : Promise < ListFHIRDatastoresCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0ListFHIRExportJobsCommand = async ( output , context ) : Promise < ListFHIRExportJobsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0ListFHIRExportJobsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0ListFHIRExportJobsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0ListFHIRExportJobsCommandError = async ( output , context ) : Promise < ListFHIRExportJobsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.healthlake#AccessDeniedException" : response = { ... ( await deserializeAws_json1_0AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0ListFHIRImportJobsCommand = async ( output , context ) : Promise < ListFHIRImportJobsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0ListFHIRImportJobsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0ListFHIRImportJobsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0ListFHIRImportJobsCommandError = async ( output , context ) : Promise < ListFHIRImportJobsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.healthlake#AccessDeniedException" : response = { ... ( await deserializeAws_json1_0AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0ListTagsForResourceCommand = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0ListTagsForResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0ListTagsForResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0ListTagsForResourceCommandError = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0StartFHIRExportJobCommand = async ( output , context ) : Promise < StartFHIRExportJobCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0StartFHIRExportJobCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0StartFHIRExportJobResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0StartFHIRExportJobCommandError = async ( output , context ) : Promise < StartFHIRExportJobCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.healthlake#AccessDeniedException" : response = { ... ( await deserializeAws_json1_0AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0StartFHIRImportJobCommand = async ( output , context ) : Promise < StartFHIRImportJobCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0StartFHIRImportJobCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0StartFHIRImportJobResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0StartFHIRImportJobCommandError = async ( output , context ) : Promise < StartFHIRImportJobCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.healthlake#AccessDeniedException" : response = { ... ( await deserializeAws_json1_0AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.healthlake#InternalServerException" : response = { ... ( await deserializeAws_json1_0InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.healthlake#ThrottlingException" : response = { ... ( await deserializeAws_json1_0ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0TagResourceCommand = async ( output , context ) : Promise < TagResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0TagResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0TagResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0TagResourceCommandError = async ( output , context ) : Promise < TagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0UntagResourceCommand = async ( output , context ) : Promise < UntagResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0UntagResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0UntagResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0UntagResourceCommandError = async ( output , context ) : Promise < UntagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.healthlake#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.healthlake#ValidationException" : response = { ... ( await deserializeAws_json1_0ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; const deserializeAws_json1_0AccessDeniedExceptionResponse = async ( parsedOutput , context ) : Promise < AccessDeniedException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0AccessDeniedException ( body , context ) ; const contents = { name : "AccessDeniedException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_0ConflictExceptionResponse = async ( parsedOutput , context ) : Promise < ConflictException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0ConflictException ( body , context ) ; const contents = { name : "ConflictException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_0InternalServerExceptionResponse = async ( parsedOutput , context ) : Promise < InternalServerException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0InternalServerException ( body , context ) ; const contents = { name : "InternalServerException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_0ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0ResourceNotFoundException ( body , context ) ; const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_0ThrottlingExceptionResponse = async ( parsedOutput , context ) : Promise < ThrottlingException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0ThrottlingException ( body , context ) ; const contents = { name : "ThrottlingException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_0ValidationExceptionResponse = async ( parsedOutput , context ) : Promise < ValidationException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0ValidationException ( body , context ) ; const contents = { name : "ValidationException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const serializeAws_json1_0CreateFHIRDatastoreRequest = ( input , context ) : any => { return { ClientToken : input . ClientToken ?? generateIdempotencyToken ( ) , ... ( input . DatastoreName !== undefined && input . DatastoreName !== null && { DatastoreName : input . DatastoreName } ) , ... ( input . DatastoreTypeVersion !== undefined && input . DatastoreTypeVersion !== null && { DatastoreTypeVersion : input . DatastoreTypeVersion } ) , ... ( input . PreloadDataConfig !== undefined && input . PreloadDataConfig !== null && { PreloadDataConfig : serializeAws_json1_0PreloadDataConfig ( input . PreloadDataConfig , context ) , } ) , ... ( input . SseConfiguration !== undefined && input . SseConfiguration !== null && { SseConfiguration : serializeAws_json1_0SseConfiguration ( input . SseConfiguration , context ) , } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_0TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_0DatastoreFilter = ( input , context ) : any => { return { ... ( input . CreatedAfter !== undefined && input . CreatedAfter !== null && { CreatedAfter : Math . round ( input . CreatedAfter . getTime ( ) / 1000 ) } ) , ... ( input . CreatedBefore !== undefined && input . CreatedBefore !== null && { CreatedBefore : Math . round ( input . CreatedBefore . getTime ( ) / 1000 ) } ) , ... ( input . DatastoreName !== undefined && input . DatastoreName !== null && { DatastoreName : input . DatastoreName } ) , ... ( input . DatastoreStatus !== undefined && input . DatastoreStatus !== null && { DatastoreStatus : input . DatastoreStatus } ) , } ; } ; const serializeAws_json1_0DeleteFHIRDatastoreRequest = ( input , context ) : any => { return { ... ( input . DatastoreId !== undefined && input . DatastoreId !== null && { DatastoreId : input . DatastoreId } ) , } ; } ; const serializeAws_json1_0DescribeFHIRDatastoreRequest = ( input , context ) : any => { return { ... ( input . DatastoreId !== undefined && input . DatastoreId !== null && { DatastoreId : input . DatastoreId } ) , } ; } ; const serializeAws_json1_0DescribeFHIRExportJobRequest = ( input , context ) : any => { return { ... ( input . DatastoreId !== undefined && input . DatastoreId !== null && { DatastoreId : input . DatastoreId } ) , ... ( input . JobId !== undefined && input . JobId !== null && { JobId : input . JobId } ) , } ; } ; const serializeAws_json1_0DescribeFHIRImportJobRequest = ( input , context ) : any => { return { ... ( input . DatastoreId !== undefined && input . DatastoreId !== null && { DatastoreId : input . DatastoreId } ) , ... ( input . JobId !== undefined && input . JobId !== null && { JobId : input . JobId } ) , } ; } ; const serializeAws_json1_0InputDataConfig = ( input , context ) : any => { return InputDataConfig . visit ( input , { S3Uri : ( value ) => ( { S3Uri : value } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_json1_0KmsEncryptionConfig = ( input , context ) : any => { return { ... ( input . CmkType !== undefined && input . CmkType !== null && { CmkType : input . CmkType } ) , ... ( input . KmsKeyId !== undefined && input . KmsKeyId !== null && { KmsKeyId : input . KmsKeyId } ) , } ; } ; const serializeAws_json1_0ListFHIRDatastoresRequest = ( input , context ) : any => { return { ... ( input . Filter !== undefined && input . Filter !== null && { Filter : serializeAws_json1_0DatastoreFilter ( input . Filter , context ) } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , } ; } ; const serializeAws_json1_0ListFHIRExportJobsRequest = ( input , context ) : any => { return { ... ( input . DatastoreId !== undefined && input . DatastoreId !== null && { DatastoreId : input . DatastoreId } ) , ... ( input . JobName !== undefined && input . JobName !== null && { JobName : input . JobName } ) , ... ( input . JobStatus !== undefined && input . JobStatus !== null && { JobStatus : input . JobStatus } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . SubmittedAfter !== undefined && input . SubmittedAfter !== null && { SubmittedAfter : Math . round ( input . SubmittedAfter . getTime ( ) / 1000 ) } ) , ... ( input . SubmittedBefore !== undefined && input . SubmittedBefore !== null && { SubmittedBefore : Math . round ( input . SubmittedBefore . getTime ( ) / 1000 ) } ) , } ; } ; const serializeAws_json1_0ListFHIRImportJobsRequest = ( input , context ) : any => { return { ... ( input . DatastoreId !== undefined && input . DatastoreId !== null && { DatastoreId : input . DatastoreId } ) , ... ( input . JobName !== undefined && input . JobName !== null && { JobName : input . JobName } ) , ... ( input . JobStatus !== undefined && input . JobStatus !== null && { JobStatus : input . JobStatus } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . SubmittedAfter !== undefined && input . SubmittedAfter !== null && { SubmittedAfter : Math . round ( input . SubmittedAfter . getTime ( ) / 1000 ) } ) , ... ( input . SubmittedBefore !== undefined && input . SubmittedBefore !== null && { SubmittedBefore : Math . round ( input . SubmittedBefore . getTime ( ) / 1000 ) } ) , } ; } ; const serializeAws_json1_0ListTagsForResourceRequest = ( input , context ) : any => { return { ... ( input . ResourceARN !== undefined && input . ResourceARN !== null && { ResourceARN : input . ResourceARN } ) , } ; } ; const serializeAws_json1_0OutputDataConfig = ( input , context ) : any => { return OutputDataConfig . visit ( input , { S3Configuration : ( value ) => ( { S3Configuration : serializeAws_json1_0S3Configuration ( value , context ) } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_json1_0PreloadDataConfig = ( input , context ) : any => { return { ... ( input . PreloadDataType !== undefined && input . PreloadDataType !== null && { PreloadDataType : input . PreloadDataType } ) , } ; } ; const serializeAws_json1_0S3Configuration = ( input , context ) : any => { return { ... ( input . KmsKeyId !== undefined && input . KmsKeyId !== null && { KmsKeyId : input . KmsKeyId } ) , ... ( input . S3Uri !== undefined && input . S3Uri !== null && { S3Uri : input . S3Uri } ) , } ; } ; const serializeAws_json1_0SseConfiguration = ( input , context ) : any => { return { ... ( input . KmsEncryptionConfig !== undefined && input . KmsEncryptionConfig !== null && { KmsEncryptionConfig : serializeAws_json1_0KmsEncryptionConfig ( input . KmsEncryptionConfig , context ) , } ) , } ; } ; const serializeAws_json1_0StartFHIRExportJobRequest = ( input , context ) : any => { return { ClientToken : input . ClientToken ?? generateIdempotencyToken ( ) , ... ( input . DataAccessRoleArn !== undefined && input . DataAccessRoleArn !== null && { DataAccessRoleArn : input . DataAccessRoleArn } ) , ... ( input . DatastoreId !== undefined && input . DatastoreId !== null && { DatastoreId : input . DatastoreId } ) , ... ( input . JobName !== undefined && input . JobName !== null && { JobName : input . JobName } ) , ... ( input . OutputDataConfig !== undefined && input . OutputDataConfig !== null && { OutputDataConfig : serializeAws_json1_0OutputDataConfig ( input . OutputDataConfig , context ) , } ) , } ; } ; const serializeAws_json1_0StartFHIRImportJobRequest = ( input , context ) : any => { return { ClientToken : input . ClientToken ?? generateIdempotencyToken ( ) , ... ( input . DataAccessRoleArn !== undefined && input . DataAccessRoleArn !== null && { DataAccessRoleArn : input . DataAccessRoleArn } ) , ... ( input . DatastoreId !== undefined && input . DatastoreId !== null && { DatastoreId : input . DatastoreId } ) , ... ( input . InputDataConfig !== undefined && input . InputDataConfig !== null && { InputDataConfig : serializeAws_json1_0InputDataConfig ( input . InputDataConfig , context ) , } ) , ... ( input . JobName !== undefined && input . JobName !== null && { JobName : input . JobName } ) , ... ( input . JobOutputDataConfig !== undefined && input . JobOutputDataConfig !== null && { JobOutputDataConfig : serializeAws_json1_0OutputDataConfig ( input . JobOutputDataConfig , context ) , } ) , } ; } ; const serializeAws_json1_0Tag = ( input , context ) : any => { return { ... ( input . Key !== undefined && input . Key !== null && { Key : input . Key } ) , ... ( input . Value !== undefined && input . Value !== null && { Value : input . Value } ) , } ; } ; const serializeAws_json1_0TagKeyList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_0TagList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_0Tag ( entry , context ) ; } ) ; } ; const serializeAws_json1_0TagResourceRequest = ( input , context ) : any => { return { ... ( input . ResourceARN !== undefined && input . ResourceARN !== null && { ResourceARN : input . ResourceARN } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_0TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_0UntagResourceRequest = ( input , context ) : any => { return { ... ( input . ResourceARN !== undefined && input . ResourceARN !== null && { ResourceARN : input . ResourceARN } ) , ... ( input . TagKeys !== undefined && input . TagKeys !== null && { TagKeys : serializeAws_json1_0TagKeyList ( input . TagKeys , context ) } ) , } ; } ; const deserializeAws_json1_0AccessDeniedException = ( output , context ) : AccessDeniedException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_0ConflictException = ( output , context ) : ConflictException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_0CreateFHIRDatastoreResponse = ( output , context ) : CreateFHIRDatastoreResponse => { return { DatastoreArn : __expectString ( output . DatastoreArn ) , DatastoreEndpoint : __expectString ( output . DatastoreEndpoint ) , DatastoreId : __expectString ( output . DatastoreId ) , DatastoreStatus : __expectString ( output . DatastoreStatus ) , } as any ; } ; const deserializeAws_json1_0DatastoreProperties = ( output , context ) : DatastoreProperties => { return { CreatedAt : output . CreatedAt !== undefined && output . CreatedAt !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreatedAt ) ) ) : undefined , DatastoreArn : __expectString ( output . DatastoreArn ) , DatastoreEndpoint : __expectString ( output . DatastoreEndpoint ) , DatastoreId : __expectString ( output . DatastoreId ) , DatastoreName : __expectString ( output . DatastoreName ) , DatastoreStatus : __expectString ( output . DatastoreStatus ) , DatastoreTypeVersion : __expectString ( output . DatastoreTypeVersion ) , PreloadDataConfig : output . PreloadDataConfig !== undefined && output . PreloadDataConfig !== null ? deserializeAws_json1_0PreloadDataConfig ( output . PreloadDataConfig , context ) : undefined , SseConfiguration : output . SseConfiguration !== undefined && output . SseConfiguration !== null ? deserializeAws_json1_0SseConfiguration ( output . SseConfiguration , context ) : undefined , } as any ; } ; const deserializeAws_json1_0DatastorePropertiesList = ( output , context ) : DatastoreProperties [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_0DatastoreProperties ( entry , context ) ; } ) ; } ; const deserializeAws_json1_0DeleteFHIRDatastoreResponse = ( output , context ) : DeleteFHIRDatastoreResponse => { return { DatastoreArn : __expectString ( output . DatastoreArn ) , DatastoreEndpoint : __expectString ( output . DatastoreEndpoint ) , DatastoreId : __expectString ( output . DatastoreId ) , DatastoreStatus : __expectString ( output . DatastoreStatus ) , } as any ; } ; const deserializeAws_json1_0DescribeFHIRDatastoreResponse = ( output , context ) : DescribeFHIRDatastoreResponse => { return { DatastoreProperties : output . DatastoreProperties !== undefined && output . DatastoreProperties !== null ? deserializeAws_json1_0DatastoreProperties ( output . DatastoreProperties , context ) : undefined , } as any ; } ; const deserializeAws_json1_0DescribeFHIRExportJobResponse = ( output , context ) : DescribeFHIRExportJobResponse => { return { ExportJobProperties : output . ExportJobProperties !== undefined && output . ExportJobProperties !== null ? deserializeAws_json1_0ExportJobProperties ( output . ExportJobProperties , context ) : undefined , } as any ; } ; const deserializeAws_json1_0DescribeFHIRImportJobResponse = ( output , context ) : DescribeFHIRImportJobResponse => { return { ImportJobProperties : output . ImportJobProperties !== undefined && output . ImportJobProperties !== null ? deserializeAws_json1_0ImportJobProperties ( output . ImportJobProperties , context ) : undefined , } as any ; } ; const deserializeAws_json1_0ExportJobProperties = ( output , context ) : ExportJobProperties => { return { DataAccessRoleArn : __expectString ( output . DataAccessRoleArn ) , DatastoreId : __expectString ( output . DatastoreId ) , EndTime : output . EndTime !== undefined && output . EndTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . EndTime ) ) ) : undefined , JobId : __expectString ( output . JobId ) , JobName : __expectString ( output . JobName ) , JobStatus : __expectString ( output . JobStatus ) , Message : __expectString ( output . Message ) , OutputDataConfig : output . OutputDataConfig !== undefined && output . OutputDataConfig !== null ? deserializeAws_json1_0OutputDataConfig ( __expectUnion ( output . OutputDataConfig ) , context ) : undefined , SubmitTime : output . SubmitTime !== undefined && output . SubmitTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . SubmitTime ) ) ) : undefined , } as any ; } ; const deserializeAws_json1_0ExportJobPropertiesList = ( output , context ) : ExportJobProperties [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_0ExportJobProperties ( entry , context ) ; } ) ; } ; const deserializeAws_json1_0ImportJobProperties = ( output , context ) : ImportJobProperties => { return { DataAccessRoleArn : __expectString ( output . DataAccessRoleArn ) , DatastoreId : __expectString ( output . DatastoreId ) , EndTime : output . EndTime !== undefined && output . EndTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . EndTime ) ) ) : undefined , InputDataConfig : output . InputDataConfig !== undefined && output . InputDataConfig !== null ? deserializeAws_json1_0InputDataConfig ( __expectUnion ( output . InputDataConfig ) , context ) : undefined , JobId : __expectString ( output . JobId ) , JobName : __expectString ( output . JobName ) , JobOutputDataConfig : output . JobOutputDataConfig !== undefined && output . JobOutputDataConfig !== null ? deserializeAws_json1_0OutputDataConfig ( __expectUnion ( output . JobOutputDataConfig ) , context ) : undefined , JobStatus : __expectString ( output . JobStatus ) , Message : __expectString ( output . Message ) , SubmitTime : output . SubmitTime !== undefined && output . SubmitTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . SubmitTime ) ) ) : undefined , } as any ; } ; const deserializeAws_json1_0ImportJobPropertiesList = ( output , context ) : ImportJobProperties [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_0ImportJobProperties ( entry , context ) ; } ) ; } ; const deserializeAws_json1_0InputDataConfig = ( output , context ) : InputDataConfig => { if ( __expectString ( output . S3Uri ) !== undefined ) { return { S3Uri : __expectString ( output . S3Uri ) as any } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_json1_0InternalServerException = ( output , context ) : InternalServerException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_0KmsEncryptionConfig = ( output , context ) : KmsEncryptionConfig => { return { CmkType : __expectString ( output . CmkType ) , KmsKeyId : __expectString ( output . KmsKeyId ) , } as any ; } ; const deserializeAws_json1_0ListFHIRDatastoresResponse = ( output , context ) : ListFHIRDatastoresResponse => { return { DatastorePropertiesList : output . DatastorePropertiesList !== undefined && output . DatastorePropertiesList !== null ? deserializeAws_json1_0DatastorePropertiesList ( output . DatastorePropertiesList , context ) : undefined , NextToken : __expectString ( output . NextToken ) , } as any ; } ; const deserializeAws_json1_0ListFHIRExportJobsResponse = ( output , context ) : ListFHIRExportJobsResponse => { return { ExportJobPropertiesList : output . ExportJobPropertiesList !== undefined && output . ExportJobPropertiesList !== null ? deserializeAws_json1_0ExportJobPropertiesList ( output . ExportJobPropertiesList , context ) : undefined , NextToken : __expectString ( output . NextToken ) , } as any ; } ; const deserializeAws_json1_0ListFHIRImportJobsResponse = ( output , context ) : ListFHIRImportJobsResponse => { return { ImportJobPropertiesList : output . ImportJobPropertiesList !== undefined && output . ImportJobPropertiesList !== null ? deserializeAws_json1_0ImportJobPropertiesList ( output . ImportJobPropertiesList , context ) : undefined , NextToken : __expectString ( output . NextToken ) , } as any ; } ; const deserializeAws_json1_0ListTagsForResourceResponse = ( output , context ) : ListTagsForResourceResponse => { return { Tags : output . Tags !== undefined && output . Tags !== null ? deserializeAws_json1_0TagList ( output . Tags , context ) : undefined , } as any ; } ; const deserializeAws_json1_0OutputDataConfig = ( output , context ) : OutputDataConfig => { if ( output . S3Configuration !== undefined && output . S3Configuration !== null ) { return { S3Configuration : deserializeAws_json1_0S3Configuration ( output . S3Configuration , context ) , } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_json1_0PreloadDataConfig = ( output , context ) : PreloadDataConfig => { return { PreloadDataType : __expectString ( output . PreloadDataType ) , } as any ; } ; const deserializeAws_json1_0ResourceNotFoundException = ( output , context ) : ResourceNotFoundException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_0S3Configuration = ( output , context ) : S3Configuration => { return { KmsKeyId : __expectString ( output . KmsKeyId ) , S3Uri : __expectString ( output . S3Uri ) , } as any ; } ; const deserializeAws_json1_0SseConfiguration = ( output , context ) : SseConfiguration => { return { KmsEncryptionConfig : output . KmsEncryptionConfig !== undefined && output . KmsEncryptionConfig !== null ? deserializeAws_json1_0KmsEncryptionConfig ( output . KmsEncryptionConfig , context ) : undefined , } as any ; } ; const deserializeAws_json1_0StartFHIRExportJobResponse = ( output , context ) : StartFHIRExportJobResponse => { return { DatastoreId : __expectString ( output . DatastoreId ) , JobId : __expectString ( output . JobId ) , JobStatus : __expectString ( output . JobStatus ) , } as any ; } ; const deserializeAws_json1_0StartFHIRImportJobResponse = ( output , context ) : StartFHIRImportJobResponse => { return { DatastoreId : __expectString ( output . DatastoreId ) , JobId : __expectString ( output . JobId ) , JobStatus : __expectString ( output . JobStatus ) , } as any ; } ; const deserializeAws_json1_0Tag = ( output , context ) : Tag => { return { Key : __expectString ( output . Key ) , Value : __expectString ( output . Value ) , } as any ; } ; const deserializeAws_json1_0TagList = ( output , context ) : Tag [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_0Tag ( entry , context ) ; } ) ; } ; const deserializeAws_json1_0TagResourceResponse = ( output , context ) : TagResourceResponse => { return { } as any ; } ; const deserializeAws_json1_0ThrottlingException = ( output , context ) : ThrottlingException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_0UntagResourceResponse = ( output , context ) : UntagResourceResponse => { return { } as any ; } ; const deserializeAws_json1_0ValidationException = ( output , context ) : ValidationException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeMetadata = ( output ) : __ResponseMetadata => ( { httpStatusCode : output . statusCode , requestId : output . headers [ "x-amzn-requestid" ] ?? output . headers [ "x-amzn-request-id" ] , extendedRequestId : output . headers [ "x-amz-id-2" ] , cfId : output . headers [ "x-amz-cf-id" ] , } ) ; const collectBody = ( streamBody = new Uint8Array ( ) , context ) : Promise < Uint8Array > => { if ( streamBody instanceof Uint8Array ) { return Promise . resolve ( streamBody ) ; } return context . streamCollector ( streamBody ) || Promise . resolve ( new Uint8Array ( ) ) ; } ; const collectBodyString = ( streamBody , context ) : Promise < string > => collectBody ( streamBody , context ) . then ( ( body ) => context . utf8Encoder ( body ) ) ; const buildHttpRpcRequest = async ( context , headers , path , resolvedHostname , body ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const contents = { protocol , hostname , port , method : "POST" , path : basePath . endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) + path : basePath + path , headers , } ; if ( resolvedHostname !== undefined ) { contents . hostname = resolvedHostname ; } if ( body !== undefined ) { contents . body = body ; } return new __HttpRequest ( contents ) ; } ; const parseBody = ( streamBody , context ) : any => collectBodyString ( streamBody , context ) . then ( ( encoded ) => { if ( encoded . length ) { return JSON . parse ( encoded ) ; } return { } ; } ) ; /**
 * Load an error code for the aws.rest-json-1.1 protocol.
 */ const loadRestJsonErrorCode = ( output , data ) : string => { const findKey = ( object , key ) => Object . keys ( object ) . find ( ( k ) => k . toLowerCase ( ) === key . toLowerCase ( ) ) ; const sanitizeErrorCode = ( rawValue ) : string => { let cleanValue = rawValue ; if ( cleanValue . indexOf ( ":" ) >= 0 ) { cleanValue = cleanValue . split ( ":" ) [ 0 ] ; } if ( cleanValue . indexOf ( "#" ) >= 0 ) { cleanValue = cleanValue . split ( "#" ) [ 1 ] ; } return cleanValue ; } ; const headerKey = findKey ( output . headers , "x-amzn-errortype" ) ; if ( headerKey !== undefined ) { return sanitizeErrorCode ( output . headers [ headerKey ] ) ; } if ( data . code !== undefined ) { return sanitizeErrorCode ( data . code ) ; } if ( data [ "__type" ] !== undefined ) { return sanitizeErrorCode ( data [ "__type" ] ) ; } return "" ; } ;