Page History
...
| Code Block |
|---|
constructor(
private napSDK: NapAngularService,
private appointmentService: AppointmentService,
private authService: AuthService
) {
const napMsg: NAPMessage = {
date: new Date().toISOString(),
id: UUID(),
event: {
type: NAPEventCatalogue.v1.PatientOpen,
},
};
this.napSDK.sendMessage(napMsg);
}
public currentPatient$: Observable<NAPPatientInfo | undefined> = this.napSDK.incomming$.pipe(
filterEvent(NAPEventCatalogue.v1.PatientOpen),
map(message => FHIRValueGetter.getPatientInfo(message))
); |
Session-Error
I appointment service (src/app/service/appointment.service.ts) vises et eksempel på fejlhåndtering som skal gå igennem NAP SDK'et.
createNapErrorMessage() opbygger en besked med typen SessionError, som indikere der er sket Session-error sendes, hvis der sker en uventet fejl i projektet skal dette projektet og som skal sendes til værtssystemet og vice versa. Et eksempel på dette findes i appointment-service:
Fejlen bliver sendt hvis kaldet til getAppointments() fejler.
| Code Block |
|---|
private appointmentEndPoint$ = this.configurationService.fetch(
config => config.appointmentsEndpoint
);
private serverUrl = this.configurationService.fetch(config => config.serverUrl);
private createNapErrorMessage(error: GenericAppError): NAPMessage {
return {
date: new Date().toISOString(),
id: UUID(),
event: {
type: NAPEventCatalogue.v1.SessionError,
context: [
{
resource: {
resourceType: FHIRValueSetter.FHIRResourceType.Basic,
code: {
coding: [
{
code: NAPEventCatalogue.v1.SessionError,
system: FHIRValueSetter.FHIRSystem.NAP,
},
],
},
identifier: [
{
system: FHIRValueSetter.FHIRIdentifierSystem.NAPErrorMessage,
value: error.innerError?.message ? error.innerError?.message : '',
},
{
system: FHIRValueSetter.FHIRIdentifierSystem.NAPErrorDescription,
value: error.errorMessage,
},
],
},
},
],
}
}
}
public getAppointments(patientIdentifier: string | undefined): Observable<any[] | undefined> {
return combineLatest(
[
this.serverUrl,
this.appointmentEndPoint$,
this.serviceActivator
]
).pipe(
switchMap(([serverUrl, endpointPath, _]) => this.http.get<any[]>(serverUrl + endpointPath + '/' + patientIdentifier)),
catchError(error => {
this.errorService.postError(error);
this.napSDK.sendMessage(this.createNapErrorMessage(error)); // indicate to the host that something went wrong
return of(undefined);
}),
);
} |
...