npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@integraciones_doc24/sdk

v1.15.10

Published

Node.JS library for accessing doc24 api

Downloads

477

Readme

@integraciones_doc24/sdk

Node.JS library for accessing doc24 api

Installation

npm i @integraciones_doc24/sdk

Usage

import {doc24Sdk} from '@integraciones_doc24/sdk';

const getBaseSdk = () =>
  doc24Sdk({
    url: 'https://tapi.doc24.com.ar/ws/sdk',
    credentials: {
      iss: 'myissuer',
      key: 'mysecret',
    },
  });

const getSpecialities = async (user) => {
  const baseSdk = await getBaseSdk();

  const userSdk = await baseSdk.getUserInstance(user);

  return await userSdk.getSpecialties('instant', 'ES');
};

const getRequestHandler = async () => {
  const baseSdk = await getBaseSdk();
  return baseSdk.getRequestHandler({
    credentials: {
      iss: 'doc24issuer',
      key: 'doc24secret',
    },
    baseAddress: 'http://myaddress.com/route/to/webhook',
    eventHandlers: {
      onAppointmentStatusChange: ({id, status, changeDate}) => {
        console.log({id, status, changeDate});
      },
      onConsultationStatusChange: ({
        id,
        invitationId,
        status,
        changeDate,
        vcToken,
      }) => {
        console.log({id, invitationId, status, changeDate, vcToken});
      },
      onInvitationStatusChange: ({id, status, changeDate}) => {
        console.log({id, status, changeDate});
      },
      onChatUpdate: ({id, status, patientId, professionalId, date}) => {
        console.log({id, status, patientId, professionalId, date});
      },
    },
  });
};

The library exports the function doc24Sdk. It takes one parameters of type SdkParams, and returns a BaseSdk. It also returns an extra getRequestHandler function that takes a RequestHandlerParams

type SdkCredentials = {
  iss: string;
  key: string;
};
type SdkParams = {
  url: string;
  credentials: SdkCredentials;
};
export type BaseSdk = {
  declareUser: (params: DeclareUserParams) => Promise<DeclareUserResponse>;
  getUserId: (user: User) => Promise<number>;
  getUserInstance: (user: User | number) => Promise<UserSdk>;
  getProfessional: (professionalId: number) => Promise<Professional>;
  getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
  enroll: (params: EnrollmentParams) => Promise<void>;
  getCoverageInfo: (identificationValue: string) => Promise<CoverageInfo>;
  sendVerificationCode: (params: SendVerificationCodeParams) => Promise<void>;
  getDiagnosticaHistory: (
    patient: DiagnosticaPatientFilter,
    from: Date,
    to: Date,
  ) => Promise<DiagnosticaHistoryAppointment[]>;
  getDiagnosticaDeepLink: (
    kiosk: string,
    user: DiagnosticaUser,
    patient: DiagnosticaPatient,
  ) => Promise<DiagnosticaDeepLinkResponse>;
  getDiagnosticaAccess: (
    kiosk: string,
    user: DiagnosticaUser,
    patient: DiagnosticaPatient,
  ) => Promise<void>;
  externalLogin: (
    params: ExternalLoginParams,
  ) => Promise<ExternalLoginResponse>;
  preExternalEnrollment: (params: PreExternalEnrollmentParams) => Promise<void>;
  externalEnrollment: (
    params: ExternalEnrollmentParams,
  ) => Promise<ExternalLoginResponse>;
  sendExternalVerificationCode: (
    params: SendExternalVerificationCodeParams,
  ) => Promise<void>;
  verifyExternalVerificationCode: (
    params: VerifyExternalVerificationCodeParams,
  ) => Promise<any>;
  externalResetPassword: (params: ExternalResetPasswordParams) => Promise<any>;
  getExternalStudiesHistoryLink: (
    patient: ExternalPatient,
  ) => Promise<string | null>;
  getExternalAppointmentsLink: (
    identificationValue: string,
    birthdate: Date,
  ) => Promise<string | null>;
  getExternalAppointments: () => Promise<ExternalAppointment[]>;
  cancelExternalAppointment: (
    appointmentId: ExternalAppointment,
  ) => Promise<void>;
};

type RequestHandlerParams = {
  // Credentials that doc24 should use when singing the jwt
  credentials: SdkCredentials;
  eventHandlers: Webhook.Events;
  // Address in which doc24 should send the requests
  baseAddress: string;
};

getRequestHandler should be called only once, and takes care of managing the webhook that receives events from doc24.

Express example

const handler = await getRequestHandler();
app.all('/doc24', async (req, res) => {
  const response = await handler({
    headers: req.headers,
    body: req.body,
    query: req.query,
  });

  res.status(response.status.code).json(response.data);
});

UserSdk

Most of the methods need a user specified, so getUserInstance returns an instance of UserSdk with them.

export type UserSdk = {
  declarePatient: (
    params: DeclarePatientParams,
  ) => Promise<DeclarePatientResponse>;
  getPatientId: (patient: Patient) => Promise<number>;
  deletePatient: (patientId: number) => Promise<void>;
  getSpecialties: (
    mode: SpecialtyMode,
    language: string,
  ) => Promise<Specialty[]>;
  getScheduleDates: (
    patientId: number,
    filter?: ScheduleAvailabilityFilter,
  ) => Promise<Date[]>;
  getSchedule: (
    patientId: number,
    specialtyId: number,
    filter?: ScheduleFilter,
  ) => Promise<AvailableAppointment[]>;
  getAppointment: (appointmentId: number) => Promise<Appointment>;
  getAppointmentByVcToken: (vcToken: string) => Promise<Appointment>;
  scheduleVideoVisit: (params: ScheduleParameters) => Promise<string>;
  cancelVideoVisit: (vcToken: string) => Promise<void>;
  getVideoVisit: (vcToken: string, patientId: number) => Promise<VideoVisit>;
  getVideoVisitDetails: (vcId: number) => Promise<VideoVisitDetails>;
  getVideoVisitLink: (
    vcToken: string,
    patientId: number,
  ) => Promise<string | null>;
  getPatientVideoVisitHistory: (
    patientId: number,
  ) => Promise<HistoricalVideoVisit[]>;
  getActiveVideoVisits: () => Promise<ActiveVideoVisitData[]>;
  getAvailableChatrooms: (
    patientId: number,
    specialtyId: number,
    filter: ChatroomAvailabilityFilter,
  ) => Promise<AvailableChatroom[]>;
  createNewChat: (chatParameters: ChatParameters) => Promise<number>;
  getPatientChats: (patientId: number) => Promise<ChatDetails[]>;
  getChatPosts: (chatId: number) => Promise<ChatPost[]>;
  cancelChat: (chatId: number) => Promise<void>;
  sendChatMessage: (chatId: number, message: string) => Promise<number>;
  userId: number;
};