@@ -32,6 +32,7 @@ import type { MedplumStorageIdentifiers } from './types';
3232
3333type MedplumNotificationBackendOptions = {
3434 emailNotificationSubjectExtensionUrl ?: string ;
35+ identifier ?: string ;
3536} ;
3637
3738type StringFilterLookup = {
@@ -57,10 +58,18 @@ const IDENTIFIER_SYSTEMS = {
5758export class MedplumNotificationBackend < Config extends BaseNotificationTypeConfig > implements BaseNotificationBackend < Config > {
5859 private attachmentManager ?: BaseAttachmentManager ;
5960 private logger ?: BaseLogger ;
61+ private identifier : string ;
6062
6163 constructor ( private medplum : MedplumClient , private options : MedplumNotificationBackendOptions = {
6264 emailNotificationSubjectExtensionUrl : 'http://vintasend.com/fhir/StructureDefinition/email-notification-subject' ,
63- } ) { }
65+ identifier : 'default-medplum' ,
66+ } ) {
67+ this . identifier = options . identifier || 'default-medplum' ;
68+ }
69+
70+ getBackendIdentifier ( ) : string {
71+ return this . identifier ;
72+ }
6473
6574 /**
6675 * Inject attachment manager (called by VintaSend when both service and backend exist)
@@ -304,7 +313,9 @@ export class MedplumNotificationBackend<Config extends BaseNotificationTypeConfi
304313 . filter ( ( n ) : n is DatabaseNotification < Config > => 'userId' in n ) ;
305314 }
306315
307- async persistNotification ( notification : NotificationInput < Config > ) : Promise < DatabaseNotification < Config > > {
316+ async persistNotification (
317+ notification : Omit < Notification < Config > , 'id' > & { id ?: Config [ 'NotificationIdType' ] } ,
318+ ) : Promise < DatabaseNotification < Config > > {
308319 const notificationWithOptionalGitCommitSha = notification as NotificationInput < Config > & {
309320 gitCommitSha ?: string | null ;
310321 } ;
@@ -344,6 +355,7 @@ export class MedplumNotificationBackend<Config extends BaseNotificationTypeConfi
344355
345356 const communication : Communication = {
346357 resourceType : 'Communication' ,
358+ ...( notification . id ? { id : notification . id as string } : { } ) ,
347359 status : 'in-progress' ,
348360 sent : notification . sendAfter ?. toISOString ( ) ,
349361 topic : { text : notification . title || undefined } ,
@@ -705,7 +717,9 @@ export class MedplumNotificationBackend<Config extends BaseNotificationTypeConfi
705717 /* One-off notification methods */
706718
707719 async persistOneOffNotification (
708- notification : Omit < OneOffNotificationInput < Config > , 'id' > ,
720+ notification : Omit < OneOffNotificationInput < Config > , 'id' > & {
721+ id ?: Config [ 'NotificationIdType' ] ;
722+ } ,
709723 ) : Promise < DatabaseOneOffNotification < Config > > {
710724 const notificationWithOptionalGitCommitSha = notification as Omit <
711725 OneOffNotificationInput < Config > ,
@@ -749,6 +763,7 @@ export class MedplumNotificationBackend<Config extends BaseNotificationTypeConfi
749763
750764 const communication : Communication = {
751765 resourceType : 'Communication' ,
766+ ...( notification . id ? { id : notification . id as string } : { } ) ,
752767 status : 'in-progress' ,
753768 sent : notification . sendAfter ?. toISOString ( ) ,
754769 topic : { text : notification . title || undefined } ,
@@ -1691,7 +1706,7 @@ export class MedplumNotificationBackend<Config extends BaseNotificationTypeConfi
16911706}
16921707
16931708export class MedplumNotificationBackendFactory < Config extends BaseNotificationTypeConfig > {
1694- create ( medplum : MedplumClient ) {
1695- return new MedplumNotificationBackend < Config > ( medplum ) ;
1709+ create ( medplum : MedplumClient , options ?: MedplumNotificationBackendOptions ) {
1710+ return new MedplumNotificationBackend < Config > ( medplum , options ) ;
16961711 }
16971712}
0 commit comments