@welshare/sdk
    Preparing search index...

    Function createDocumentReferenceFromBinary

    • Create a DocumentReference from an existing BinaryFileSubmission.

      Convenience function that extracts file metadata from the Binary record. If no author is provided, the subject is used as the author.

      Parameters

      • binary: {
            controller_did: string;
            encryption_key: string;
            file_name: string;
            file_size: number;
            file_type: string;
            reference: string;
            url: string;
        } & { _id: string }
        • controller_did: string
        • encryption_key: string
        • file_name: string
        • file_size: number
        • file_type: string
        • reference: string

          Not part of official FHIR Binary spec. Used for legacy questionnaire attachment references. For new implementations, create a DocumentReference resource that links to this Binary via content.attachment.url.

        • url: string
        • _id: string
      • options: CreateDocumentReferenceFromBinaryParams

      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

      const docRef = createDocumentReferenceFromBinary(
      binaryRecord,
      {
      subjectDid: userDid,
      author: applicationId,
      type: DOCUMENT_TYPE_CONCEPTS.CONSENT_DOCUMENT,
      }
      );