@medic/cht-datasource
    Preparing search index...

    Interface Datasource

    Operations for working with reports.

    interface Datasource {
        create: (input: ReportInput) => Promise<Report.v1.Report>;
        getByUuid: (uuid: string) => Promise<Nullable<Report.v1.Report>>;
        getByUuidWithLineage: (
            uuid: string,
        ) => Promise<Nullable<ReportWithLineage>>;
        getUuidsByFreetext: (qualifier: string) => AsyncGenerator<string, null>;
        getUuidsPageByFreetext: (
            qualifier: string,
            cursor?: Nullable<string>,
            limit?: number | `${number}`,
        ) => Promise<Page<string>>;
        update: <T extends Report.v1.Report | ReportWithLineage>(
            updated: T,
        ) => Promise<T>;
    }
    Index

    Properties

    create: (input: ReportInput) => Promise<Report.v1.Report>

    Creates a new report record.

    Type Declaration

    InvalidArgumentError if form is not provided or is not a supported form id

    InvalidArgumentError if contact is not provided or is not the identifier of a valid contact

    InvalidArgumentError if the provided reported_date is not in a valid format. Valid formats are 'YYYY-MM-DDTHH:mm:ssZ', 'YYYY-MM-DDTHH:mm:ss.SSSZ', or .

    getByUuid: (uuid: string) => Promise<Nullable<Report.v1.Report>>

    Returns a report by their UUID.

    Type Declaration

    InvalidArgumentError if no UUID is provided

    getByUuidWithLineage: (uuid: string) => Promise<Nullable<ReportWithLineage>>

    Returns a report by UUID along with the report's lineage information.

    Type Declaration

    InvalidArgumentError if no UUID is provided

    getUuidsByFreetext: (qualifier: string) => AsyncGenerator<string, null>

    Returns a generator for fetching all the contact identifiers for given qualifier.

    Type Declaration

      • (qualifier: string): AsyncGenerator<string, null>
      • Parameters

        • qualifier: string

          the limiter defining which identifiers to return

        Returns AsyncGenerator<string, null>

        a generator for fetching all report identifiers that match the given qualifier

    InvalidArgumentError if no qualifier is provided or if the qualifier is invalid

    getUuidsPageByFreetext: (
        qualifier: string,
        cursor?: Nullable<string>,
        limit?: number | `${number}`,
    ) => Promise<Page<string>>

    Returns a paged array of report identifiers from the given data context.

    Type Declaration

      • (
            qualifier: string,
            cursor?: Nullable<string>,
            limit?: number | `${number}`,
        ): Promise<Page<string>>
      • Parameters

        • qualifier: string

          the limiter defining which identifiers to return

        • Optionalcursor: Nullable<string>

          the token identifying which page to retrieve. A null value indicates the first page should be returned. Subsequent pages can be retrieved by providing the cursor returned with the previous page.

        • Optionallimit: number | `${number}`

          the maximum number of identifiers to return. Default is 10000.

        Returns Promise<Page<string>>

        a page of report identifiers for the provided specification

    InvalidArgumentError if no qualifier is provided or if the qualifier is invalid

    InvalidArgumentError if the provided limit value is <=0

    InvalidArgumentError if the provided cursor is not a valid page token or null

    update: <T extends Report.v1.Report | ReportWithLineage>(
        updated: T,
    ) => Promise<T>

    Updates an existing report to have the provided data.

    Type Declaration

      • <T extends Report.v1.Report | ReportWithLineage>(updated: T): Promise<T>
      • Type Parameters

        Parameters

        • updated: T

          the updated report data. The complete data for the report must be provided. Existing fields not included in the updated data will be removed from the report. If the provided parent/patient/place lineage is hydrated (e.g. for a v1.ReportWithLineage), the lineage will be properly dehydrated before being stored.

        Returns Promise<T>

        the updated report with the new _rev value

    InvalidArgumentError if _id is not provided

    ResourceNotFoundError if _id does not identify an existing report

    InvalidArgumentError if _rev is not provided or does not match the report's current _rev value

    InvalidArgumentError if form is not provided or is not a supported form id

    InvalidArgumentError if contact is not provided or is not a valid contact

    InvalidArgumentError if any of the following read-only properties are changed: reported_date, type