Skip to content

Commit

Permalink
Merge pull request #17 from mcode/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
smalho01 authored May 20, 2024
2 parents b0fe208 + 58bee0a commit 83c2fb8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
31 changes: 31 additions & 0 deletions resources/EncounterStart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import CdsHook from './CdsHook';
import { EncounterStartContext, EncounterStartHook, SupportedHooks } from './HookTypes';

export default class EncounterStart extends CdsHook {
patientId: string;
userId: string;
encounterId: string;

constructor(patientId: string, userId: string, encounterId: string) {
super(SupportedHooks.ENCOUNTER_START);
this.patientId = patientId;
this.userId = userId;
this.encounterId = encounterId;
}

generate(): EncounterStartHook {
return {
hook: this.hookType,
hookInstance: this.hookInstance,
context: this.generateContext(),
prefetch: {}
};
}
generateContext(): EncounterStartContext {
return {
userId: this.userId,
patientId: this.patientId,
encounterId: this.encounterId
};
}
}
19 changes: 18 additions & 1 deletion resources/HookTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Bundle, FhirResource, Patient, Practitioner } from 'fhir/r4';
export enum SupportedHooks {
ORDER_SIGN = 'order-sign',
ORDER_SELECT = 'order-select',
PATIENT_VIEW = 'patient-view'
PATIENT_VIEW = 'patient-view',
ENCOUNTER_START = 'encounter-start'
}

export interface FhirAuthorization {
Expand Down Expand Up @@ -41,6 +42,12 @@ export interface PatientViewPrefetch extends HookPrefetch {
medicationRequests?: Bundle;
}

export interface EncounterStartPrefetch extends HookPrefetch {
practitioner?: Practitioner;
patient?: Patient;
medicationRequests?: Bundle;
}

export interface Hook {
hook: SupportedHooks;
hookInstance: string;
Expand All @@ -64,6 +71,11 @@ export interface OrderSelectContext extends HookContext {
// https://cds-hooks.org/hooks/patient-view/#context
export type PatientViewContext = HookContext;

// https://cds-hooks.org/hooks/encounter-start/#context
export interface EncounterStartContext extends HookContext {
encounterId: string;
}

// https://cds-hooks.hl7.org/1.0/#calling-a-cds-service
export interface OrderSignHook extends Hook {
context: OrderSignContext;
Expand All @@ -80,6 +92,11 @@ export interface PatientViewHook extends Hook {
prefetch?: PatientViewPrefetch;
}

export interface EncounterStartHook extends Hook {
context: EncounterStartContext;
prefetch?: EncounterStartPrefetch;
}

export interface Coding {
/**
* The code for what is being represented
Expand Down

0 comments on commit 83c2fb8

Please sign in to comment.