rtpb

package
v0.1.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rtpb answers NCPDP Real-Time Prescription Benefit requests from a formulary: what a drug will cost this member at this pharmacy, whether it needs a prior authorization or a step first, and which alternatives cost less.

CMS-0062-P proposes RTPB for impacted payers from 1 October 2027. The XML is NCPDP RTPB v13 (PBv13). NCPDP's schema is licensed, so element names and order follow the public Surescripts RTPB examples and NCPDP's public RTPB Implementation Recommendations (coverage restriction codes and the coverage status each maps to); a response is not checked against the XSD here, and a network certification is where that happens.

Index

Constants

View Source
const (
	RestrictionPriorAuth      = "75"  // Prior Authorization Required
	RestrictionPlanLimits     = "76"  // Plan Limitations Exceeded
	RestrictionNotCovered     = "70"  // Product/Service Not Covered - Plan/Benefit Exclusion
	RestrictionStepTherapy    = "608" // Step Therapy, Alternate Drug Therapy Required Prior To Use Of Submitted Product
	RestrictionDaysSupply     = "7X"  // Days Supply Exceeds Plan Limitation
	RestrictionPAOnFile       = "AB8" // Prior Authorization Approval on File
	StatusCovered             = "CC"
	StatusCoveredRestrictions = "CR"
	StatusNotCovered          = "NC"
)

Coverage restriction codes (NCPDP ECL, F12-Y8), and the coverage status each maps to (F13-YA) by NCPDP's RTPB Implementation Recommendations.

View Source
const (
	RejectCardholder = "52" // Non-Matched Cardholder ID
	RejectProduct    = "54" // Non-Matched Product/Service ID Number
	RejectQuantity   = "E7" // M/I Quantity Dispensed
	RejectDaysSupply = "19" // M/I Days Supply
)

Reject codes (NCPDP Telecom 511-FB) for a request that cannot be priced at all.

View Source
const Version = "PBv13"

Version is the RTPB version this package reads and writes.

Variables

This section is empty.

Functions

func Respond

func Respond(req *Request, a Answer, payerID string, now time.Time) []byte

Respond writes the RTPBResponse to a request.

Types

type Answer

type Answer struct {
	Processed    bool     `json:"processed"`
	Reject       string   `json:"reject,omitempty"`
	Note         string   `json:"note"`
	Plan         string   `json:"plan,omitempty"`
	Requested    *Priced  `json:"requested,omitempty"`
	Alternatives []Priced `json:"alternatives,omitempty"`
}

Answer is what the formulary says about one request, before it is written as XML: for the GUI and for tests.

type Header struct {
	To                 Party  `xml:"To"`
	From               Party  `xml:"From"`
	MessageID          string `xml:"MessageID"`
	RelatesToMessageID string `xml:"RelatesToMessageID,omitempty"`
	SentTime           string `xml:"SentTime"`
}

Header is the RTPB header.

type ID

type ID struct {
	Identification string `xml:"Identification"`
	Qualifier      string `xml:"Qualifier"`
}

ID is an identification with its qualifier.

type Options

type Options struct {
	// Member finds a member's plan id in the FHIR store, or "".
	Member func(id string) string
	// PAOnFile says whether the member has an approved prior authorization for the drug (RxNorm) in force.
	PAOnFile func(member, rxnorm string) bool
}

Options are what answering needs besides the formulary.

func (Options) Answer

func (o Options) Answer(f *formulary.File, req *RequestBody) Answer

Answer prices a request.

type Party

type Party struct {
	Primary   ID  `xml:"Primary"`
	Secondary *ID `xml:"Secondary,omitempty"`
	Tertiary  *ID `xml:"Tertiary,omitempty"`
}

Party is a To or From.

type Pharmacy

type Pharmacy struct {
	PharmacyType   string `xml:"PharmacyType,omitempty"`
	Identification struct {
		NCPDPID string `xml:"NCPDPID,omitempty"`
		NPI     string `xml:"NPI,omitempty"`
	} `xml:"Identification"`
	BusinessName string `xml:"BusinessName,omitempty"`
}

Pharmacy is where the prescription would be filled.

type Priced

type Priced struct {
	NDC          string   `json:"ndc"`
	RxNorm       string   `json:"rxnorm"`
	Description  string   `json:"description"`
	Tier         string   `json:"tier"`
	Status       string   `json:"coverageStatus"`
	Formulary    string   `json:"formularyStatus"`
	Restrictions []string `json:"restrictions,omitempty"`
	// PatientPays is the member's estimated share in dollars; nil when it cannot be stated (a coinsurance without a cost).
	PatientPays *float64 `json:"patientPays,omitempty"`
	PlanCost    *float64 `json:"planCost,omitempty"`
	Message     string   `json:"message"`
	Quantity    string   `json:"quantity"`
	Unit        string   `json:"unit"`
	Days        int      `json:"days"`
	Benefit     string   `json:"benefit"`
}

Priced is one drug's coverage and cost.

type Product

type Product struct {
	DrugCoded struct {
		NDC string `xml:"NDC"`
	} `xml:"DrugCoded"`
}

Product names a drug by NDC.

type Quantity

type Quantity struct {
	Value                 string `xml:"Value"`
	CodeListQualifier     string `xml:"CodeListQualifier"`
	QuantityUnitOfMeasure struct {
		Code string `xml:"Code"`
	} `xml:"QuantityUnitOfMeasure"`
}

Quantity is an amount and its unit.

type Request

type Request struct {
	XMLName xml.Name `xml:"Message"`
	Header  Header   `xml:"RTPBHeader"`
	Body    struct {
		Request *RequestBody `xml:"RTPBRequest"`
	} `xml:"RTPBBody"`
}

Request is an RTPBRequest message, as much of it as answering needs.

func Parse

func Parse(raw []byte) (*Request, error)

Parse reads an RTPBRequest.

type RequestBody

type RequestBody struct {
	Patient struct {
		Name struct {
			LastName  string `xml:"LastName"`
			FirstName string `xml:"FirstName"`
		} `xml:"Name"`
		DateOfBirth   string `xml:"DateOfBirth"`
		StateProvince string `xml:"StateProvince"`
		PostalCode    string `xml:"PostalCode"`
	} `xml:"Patient"`
	BenefitsCoordination struct {
		PBMMemberID string `xml:"PBMMemberID"`
		GroupID     string `xml:"GroupID"`
	} `xml:"BenefitsCoordination"`
	RequestedProduct struct {
		Product    Product   `xml:"Product"`
		Quantity   *Quantity `xml:"Quantity"`
		DaysSupply string    `xml:"DaysSupply"`
		Diagnosis  []struct {
			Code      string `xml:"Code"`
			Qualifier string `xml:"Qualifier"`
		} `xml:"Diagnosis"`
	} `xml:"RequestedProduct"`
	Prescriber struct {
		Identification struct {
			NPI string `xml:"NPI"`
		} `xml:"Identification"`
	} `xml:"Prescriber"`
	Pharmacy *Pharmacy `xml:"Pharmacy"`
}

RequestBody is the RTPBRequest.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL