Page History
...
Code Block | ||
---|---|---|
| ||
import {filterEvents, NAPEventCatalogue} from 'nap-typescript-sdk'; nap.incomming$incoming$.pipe( filterEvents([ NAPEventCatalogue.v1.SessionOpen, NAPEventCatalogue.v1.SessionClose, ]) ) |
...
Code Block | ||
---|---|---|
| ||
NapAngularService { // attributter incomming$incoming$: Observable<NAPmessage> errors$: Observable<NAPError> outgoing$: Subject<NapMessage> sendMessage(message: NAPMessage):void subscribeToMessages(callback: (message: NAPMessage) => void): void } |
...
Code Block | ||
---|---|---|
| ||
import { NapAngularService } from 'nap-angular-sdk'; import { filterEvents, NAPEventCatalogue, NAPMessage } from 'nap-typescript-sdk'; import { v4 as UUID } from 'uuid'; export class MyComponent { // proxy for SAMLAssertion public session$: Observable<NAPMessage | undefined> = this.napSDK.incomming$incoming$.pipe( filterEvents([NAPEventCatalogue.v1.SessionOpen, NAPEventCatalogue.v1.SessionClose]) ); //inject the nap-angular-sdk service constructor(private napSK: NapAngularService) { // Construct an SessionOpen NAPMessage const napMsg: NAPMessage = { date: new Date().toISOString(), id: UUID(), event: { type: NAPEventCatalogue.v1.SessionOpen }, }; // Ask for the SAMLassertion in host this.napSDK.sendMessage(napMsg); } } |
...
Code Block | ||
---|---|---|
| ||
import { NapAngularService } from 'nap-angular-sdk'; import { filterEvents, NAPEventCatalogue, NAPMessage, FHIRValueSetter, FHIRValueGetter } from 'nap-typescript-sdk'; import { v4 as UUID } from 'uuid'; export class MyComponent { // proxy for currentPatient public currentPatient$: Observable<NAPPatientInfo | undefined> = this.napSDK.incomming$incoming$.pipe( filterEvent(NAPEventCatalogue.v1.PatientOpen), map((message) => FHIRValueGetter.getPatientInfo(message)) ); //inject the nap-angular-sdk service constructor(private napSK: NapAngularService) { // Construct an patient NAPMessage const napMsg: NAPMessage = { date: new Date().toISOString(), id: UUID(), event: { type: NAPEventCatalogue.v1.PatientOpen} }; this.napSDK.sendMessage(napMsg); // Ask for the patient context in host this.napSDK.sendMessage(napMsg); } // Something triggered a patientClose on the client site public patientClose(patient: NAPPatientInfo) { const napMsg: NAPMessage = { date: new Date().toISOstring(), id: UUID(), event: { type: NAPEventType.PatientClose, context: [{ resource: { resourceType: FHIRValueSetter.FHIRResourceType.Patient, code: { coding: [{ code: NAPEventCatalogue.v1.Close, system: FHIRSystem.NAP}] }, identifier: [{ system: FHIRSystem.CPR, value: patient.ssNo, }], name: [{ family: patient.familyName, given: [patient.familyName] }], meta: {profile: ['http://hl7.dk/fhir/core/StructureDefinition/dk-core-patient']}, }], } }; // Send the message this.napSDK.sendMessage(napMsg); } } |
...