@welshare/sdk
    Preparing search index...

    Function createDocumentReference

    • Create a DocumentReference for an uploaded file.

      This creates searchable metadata for a Binary resource. The DocumentReference links to the Binary via content.attachment.url using the format "binary/{id}".

      If no author is provided, the subject (patient) is used as the author.

      Returns {
          author?: {
              display?: string;
              id?: string;
              identifier?: { system?: string; value?: string };
              reference?: string;
              type?: string;
          }[];
          category?: {
              coding?: {
                  code?: string;
                  display?: string;
                  system: string;
                  userSelected?: boolean;
                  version?: string;
              }[];
              text?: string;
          }[];
          content: {
              attachment: {
                  contentType?: string;
                  creation?: string;
                  data?: string;
                  duration?: number;
                  frames?: number;
                  hash?: string;
                  height?: number;
                  id?: string;
                  language?: string;
                  pages?: number;
                  size?: number;
                  title?: string;
                  url?: string;
                  width?: number;
              };
              profile?: (
                  | {
                      valueCoding: {
                          code?: string;
                          display?: string;
                          system: string;
                          userSelected?: boolean;
                          version?: string;
                      };
                  }
                  | { valueUri: string }
              )[];
          }[];
          date?: string;
          description?: string;
          id: string;
          meta?: { lastUpdated?: string; profile?: string[]; versionId?: string };
          resourceType: "DocumentReference";
          securityLabel?: {
              coding?: {
                  code?: string;
                  display?: string;
                  system: string;
                  userSelected?: boolean;
                  version?: string;
              }[];
              text?: string;
          }[];
          status: string;
          subject?: {
              display?: string;
              id?: string;
              identifier?: { system?: string; value?: string };
              reference?: string;
              type?: string;
          };
          type?: {
              coding?: {
                  code?: string;
                  display?: string;
                  system: string;
                  userSelected?: boolean;
                  version?: string;
              }[];
              text?: string;
          };
      }

      • Optionalauthor?: {
            display?: string;
            id?: string;
            identifier?: { system?: string; value?: string };
            reference?: string;
            type?: string;
        }[]

        Who and/or what authored the document

      • Optionalcategory?: {
            coding?: {
                code?: string;
                display?: string;
                system: string;
                userSelected?: boolean;
                version?: string;
            }[];
            text?: string;
        }[]

        Categorization of document - use DOCUMENT_CATEGORY_CONCEPTS

      • content: {
            attachment: {
                contentType?: string;
                creation?: string;
                data?: string;
                duration?: number;
                frames?: number;
                hash?: string;
                height?: number;
                id?: string;
                language?: string;
                pages?: number;
                size?: number;
                title?: string;
                url?: string;
                width?: number;
            };
            profile?: (
                | {
                    valueCoding: {
                        code?: string;
                        display?: string;
                        system: string;
                        userSelected?: boolean;
                        version?: string;
                    };
                }
                | { valueUri: string }
            )[];
        }[]

        Document content - array of content elements. Each element has an attachment that references the Binary resource via url (e.g., "binary/{id}") and includes metadata like contentType, size, title.

      • Optionaldate?: string

        When this document reference was created

      • Optionaldescription?: string

        Human-readable description (title/summary)

      • id: string
      • Optionalmeta?: { lastUpdated?: string; profile?: string[]; versionId?: string }
      • resourceType: "DocumentReference"
      • OptionalsecurityLabel?: {
            coding?: {
                code?: string;
                display?: string;
                system: string;
                userSelected?: boolean;
                version?: string;
            }[];
            text?: string;
        }[]

        Document security labels

      • status: string

        Document status: current | superseded | entered-in-error

      • Optionalsubject?: {
            display?: string;
            id?: string;
            identifier?: { system?: string; value?: string };
            reference?: string;
            type?: string;
        }

        Who/what is the subject of the document (typically patient reference)

      • Optionaltype?: {
            coding?: {
                code?: string;
                display?: string;
                system: string;
                userSelected?: boolean;
                version?: string;
            }[];
            text?: string;
        }

        Kind of document (LOINC code) - use DOCUMENT_TYPE_CONCEPTS

      import {
      createDocumentReference,
      DOCUMENT_TYPE_CONCEPTS,
      DOCUMENT_CATEGORY_CONCEPTS,
      Fhir
      } from "@welshare/sdk";

      const docRef = createDocumentReference({
      binaryId: uploadResult.insertedUid,
      fileName: file.name,
      fileType: file.type,
      fileSize: file.size,
      subjectDid: userDid,
      author: authorDid, //optional
      description: "My photo",
      type: DOCUMENT_TYPE_CONCEPTS.PHOTO_DOCUMENT,
      category: [DOCUMENT_CATEGORY_CONCEPTS.PERSONAL],
      });