import { AsyncPostResponse, D2ApiResponse } from "./common"; import { D2ApiGeneric } from "./d2Api"; import { Pager } from "./model"; import { Selector, SelectedPick } from "."; import { Preset, FieldPresets, Id } from "../schemas"; import { D2Relationship, D2RelationshipSchema } from "../2.40"; export declare class Events { d2Api: D2ApiGeneric; constructor(d2Api: D2ApiGeneric); get(params: EventsGetRequest): D2ApiResponse>; getAll(params: EventsGetRequest): D2ApiResponse>; post(params: EventsPostParams, request: EventsPostRequest): D2ApiResponse; postAsync(params: EventsPostParams, request: EventsPostRequest): D2ApiResponse>; } export interface D2EventSchema { name: "D2Event"; model: D2Event; fields: D2Event & { dataValues: D2EventDataValueSchema[]; relationships: D2RelationshipSchema[]; }; fieldPresets: { $all: Preset; $identifiable: Preset; $nameable: Preset; $persisted: Preset; $owner: Preset; }; } export interface D2EventDataValueSchema { name: "D2DataValue"; model: DataValue; fields: DataValue; fieldPresets: { $all: Preset; $identifiable: Preset; $nameable: Preset; $persisted: Preset; $owner: Preset; }; } declare type D2EventFields = Selector; declare type GetEvent = SelectedPick; export declare type EventStatus = "ACTIVE" | "COMPLETED" | "VISITED" | "SCHEDULE" | "OVERDUE" | "SKIPPED"; export interface D2EventToPost { event?: string; orgUnit: string; program: string; status: EventStatus; eventDate: string; coordinate?: { latitude: number; longitude: number; }; attributeOptionCombo?: string; trackedEntityInstance?: string; programStage?: string; dataValues: Array<{ dataElement: string; value: string | number | boolean; }>; } export interface EventsPostRequest { events: D2EventToPost[]; } export declare type EventsPostParams = Partial<{ idScheme: IdScheme; dataElementIdScheme: IdScheme; orgUnitIdScheme: IdScheme; eventIdScheme: IdScheme; preheatCache: boolean; skipExistingCheck: boolean; payloadFormat: "json" | "xml" | "csv"; async: boolean; dryRun: boolean; strategy: "CREATE" | "UPDATE" | "CREATE_AND_UPDATE" | "DELETE"; }>; export declare type IdScheme = string; export interface EventsPostResponse { responseType: "ImportSummaries"; status: "ERROR" | "SUCCESS" | "WARNING"; imported: number; updated: number; deleted: number; ignored: number; total: number; importOptions: object; importSummaries?: Array<{ responseType: "ImportSummary"; status: "ERROR" | "WARNING"; reference?: string; description: string; importOptions: object; conflicts: Array<{ object: string; value: string; }>; importCount: { imported: number; updated: number; ignored: number; deleted: number; }; } | { responseType: "ImportSummary"; status: "SUCCESS"; reference: string; href: string; importOptions: object; importCount: { imported: number; updated: number; ignored: number; deleted: number; }; }>; } export declare type EventsGetRequestFilters = EventsGetRequest; export interface EventsGetRequest { fields: Fields; program?: string; orgUnit?: string; event?: string; programStage?: string; programStatus?: "ACTIVE" | "COMPLETED" | "CANCELLED"; followUp?: boolean; trackedEntityInstance?: string; ouMode?: "SELECTED" | "CHILDREN" | "DESCENDANTS"; startDate?: string; endDate?: string; status?: "ACTIVE" | "COMPLETED" | "VISITED" | "SCHEDULE" | "OVERDUE" | "SKIPPED"; lastUpdated?: string; lastUpdatedStartDate?: string; lastUpdatedEndDate?: string; lastUpdatedDuration?: string; skipMeta?: boolean; page?: number; pageSize?: number; totalPages?: boolean; skipPaging?: boolean; dataElementIdScheme?: IdScheme; categoryOptionComboIdScheme?: IdScheme; orgUnitIdScheme?: IdScheme; programIdScheme?: IdScheme; programStageIdScheme?: IdScheme; idScheme?: IdScheme; order?: string; skipEventId?: boolean; attributeCc?: string; attributeCos?: string; async?: boolean; includeDeleted?: boolean; assignedUserMode?: boolean; assignedUser?: string; filter?: string; } export interface EventsGetResponse { events: GetEvent[]; } export interface PaginatedEventsGetResponse extends EventsGetResponse { pager: Pager; } export interface D2Event { attributeCategoryOptions: string; attributeOptionCombo: Id; created: DateString; createdByUserInfo?: UserInfo; coordinate?: { latitude: number; longitude: number; }; dataValues: DataValue[]; deleted: boolean; dueDate: DateString; enrollment?: Id; enrollmentStatus?: "ACTIVE" | "COMPLETED" | "CANCELLED"; event: Id; eventDate: DateString; followup?: boolean; href: string; lastUpdated: DateString; lastUpdatedByUserInfo?: UserInfo; notes?: string; orgUnit: Id; orgUnitName: string; program: Id; programStage: Id; programType: "WITH_REGISTRATION" | "WITHOUT_REGISTRATION"; relationships?: D2Relationship[]; status: EventStatus; storedBy: Username; trackedEntityInstance?: Id; } declare type DateString = string; declare type Username = string; export interface UserInfo { uid: Id; username: string; firstName: string; surname: string; } export interface DataValue { lastUpdated: string; storedBy: string; created: string; dataElement: string; value: string; providedElsewhere: boolean; } export {};