Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
334 changes: 231 additions & 103 deletions src/hooks/rems.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,112 +7,227 @@ import { Link } from '../cards/Card';
import config from '../config';
import { hydrate } from './Prefetch/hydrator/PrefetchHydrator';

interface CardRule {
links: Link[];
summary?: string;
}
const CARD_DETAILS = 'Documentation Required, please complete form via Smart App link.';
// TODO: this codemap should be replaced with a system similar to original CRD's questionnaire package operation
// the app doesn't necessarily have to use CQL for this.
const codeMap: { [key: string]: Link[] } = {
const codeMap: { [key: string]: CardRule[] } = {
'2183126': [
{
label: 'Documentation Requirements',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Turalio_2020_08_04_REMS_Full.pdf'
)
},
{
label: 'Medication Guide',
type: 'absolute',
url: new URL(
'https://daiichisankyo.us/prescribing-information-portlet/getPIContent?productName=Turalio_Med&inline=true'
)
},
{
label: 'Patient Guide',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Turalio_2020_12_16_Patient_Guide.pdf'
)
},
{
label: 'Patient Status Update Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TuralioRemsPatientStatus',
type: 'smart',
url: new URL(config.smart.endpoint)
links: [
{
label: 'Documentation Requirements',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Turalio_2020_08_04_REMS_Full.pdf'
)
},
{
label: 'Medication Guide',
type: 'absolute',
url: new URL(
'https://daiichisankyo.us/prescribing-information-portlet/getPIContent?productName=Turalio_Med&inline=true'
)
},
{
label: 'Patient Guide',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Turalio_2020_12_16_Patient_Guide.pdf'
)
},
{
label: 'Patient Status Update Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TuralioRemsPatientStatus',
type: 'smart',
url: new URL(config.smart.endpoint)
},
{
label: 'Patient Enrollment Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TuralioRemsPatientEnrollment',
type: 'smart',
url: new URL(config.smart.endpoint)
}
]
},
{
label: 'Patient Enrollment Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TuralioRemsPatientEnrollment',
type: 'smart',
url: new URL(config.smart.endpoint)
links: [
{
label: 'Documentation Requirements',
type: 'absolute',
url: new URL(
'https://daiichisankyo.us/prescribing-information-portlet/getPIContent?productName=Turalio&inline=true'
)
},
{
label: 'Program Overview',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Turalio_2020_12_16_Program_Overview.pdf'
)
},
{
label: 'Prescriber Training',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Turalio_2020_12_16_Prescriber_Training.pdf'
)
},
{
label: 'Prescriber Enrollment Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TuralioPrescriberEnrollmentForm',
type: 'smart',
url: new URL(config.smart.endpoint)
},
{
label: 'Prescriber Knowledge Assessment',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TuralioPrescriberKnowledgeAssessment',
type: 'smart',
url: new URL(config.smart.endpoint)
}
],
summary: 'Prescriber Forms'
}
],
'6064': [
{
label: 'Documentation Requirements',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_REMS_Document.pdf'
)
},
{
label: 'Fact Sheet',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_Fact_Sheet.pdf'
)
},
{
label: 'Guide For Patients Who Can Get Pregnant',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_Guide_for_Patients_Who_Can_Get_pregnant.pdf'
)
},
{
label: 'Contraceptive Counseling Guide',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_Contraception_Counseling_Guide.pdf'
)
links: [
{
label: 'Documentation Requirements',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_REMS_Document.pdf'
)
},
{
label: 'Fact Sheet',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_Fact_Sheet.pdf'
)
},
{
label: 'Guide For Patients Who Can Get Pregnant',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_Guide_for_Patients_Who_Can_Get_pregnant.pdf'
)
},
{
label: 'Contraceptive Counseling Guide',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_Contraception_Counseling_Guide.pdf'
)
},
{
label: 'Patient Enrollment Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/IPledgeRemsPatientEnrollment',
type: 'smart',
url: new URL(config.smart.endpoint)
}
]
},
{
label: 'Patient Enrollment Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/IPledgeRemsPatientEnrollment',
type: 'smart',
url: new URL(config.smart.endpoint)
links: [
{
label: 'Prescriber Guide',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_Prescriber_Guide.pdf'
)
},
{
label: 'Prescriber Comprehension',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/Isotretinoin_2021_10_8_Comprehension_Questions.pdf'
)
},
{
label: 'Prescriber Enrollment Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/IPledgeRemsPrescriberEnrollmentForm',
type: 'smart',
url: new URL(config.smart.endpoint)
}
],
summary: 'Prescriber Forms'
}
],
'1237051': [
{
label: 'Documentation Requirements',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/TIRF_2022_08_17_REMS_Document.pdf'
)
},
{
label: 'Patient Counseling Guide',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/TIRF_2022_08_17_Patient_Counseling_Guide.pdf'
)
},
{
label: 'Patient FAQ',
type: 'absolute',
url: new URL(
'https://tirfstorageproduction.blob.core.windows.net/tirf-public/tirf-patientfaq-frequently-asked-questions.pdf?skoid=417a7522-f809-43c4-b6a8-6b192d44b69e&sktid=59fc620e-de8c-4745-abcc-18182d1bf20e&skt=2022-09-20T19%3A06%3A21Z&ske=2022-09-26T19%3A11%3A21Z&sks=b&skv=2020-04-08&sv=2020-04-08&st=2021-03-21T21%3A27%3A00Z&se=2031-03-21T23%3A59%3A59Z&sr=b&sp=rc&sig=owSGAoUBZuCtsLE41F2XC3o12x%2BG%2Bt5ogykOIt796es%3D'
)
links: [
{
label: 'Documentation Requirements',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/TIRF_2022_08_17_REMS_Document.pdf'
)
},
{
label: 'Patient Counseling Guide',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/TIRF_2022_08_17_Patient_Counseling_Guide.pdf'
)
},
{
label: 'Patient FAQ',
type: 'absolute',
url: new URL(
'https://tirfstorageproduction.blob.core.windows.net/tirf-public/tirf-patientfaq-frequently-asked-questions.pdf?skoid=417a7522-f809-43c4-b6a8-6b192d44b69e&sktid=59fc620e-de8c-4745-abcc-18182d1bf20e&skt=2022-09-20T19%3A06%3A21Z&ske=2022-09-26T19%3A11%3A21Z&sks=b&skv=2020-04-08&sv=2020-04-08&st=2021-03-21T21%3A27%3A00Z&se=2031-03-21T23%3A59%3A59Z&sr=b&sp=rc&sig=owSGAoUBZuCtsLE41F2XC3o12x%2BG%2Bt5ogykOIt796es%3D'
)
},
{
label: 'Patient Enrollment Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TIRFRemsPatientEnrollment',
type: 'smart',
url: new URL(config.smart.endpoint)
}
]
},
{
label: 'Patient Enrollment Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TIRFRemsPatientEnrollment',
type: 'smart',
url: new URL(config.smart.endpoint)
links: [
{
label: 'Prescriber Education',
type: 'absolute',
url: new URL(
'https://www.accessdata.fda.gov/drugsatfda_docs/rems/TIRF_2022_08_17_Prescriber_Education.pdf'
)
},
{
label: 'Prescriber FAQ',
type: 'absolute',
url: new URL(
'https://tirfstorageproduction.blob.core.windows.net/tirf-public/tirf-prfaq-frequently-asked-questions.pdf?skoid=417a7522-f809-43c4-b6a8-6b192d44b69e&sktid=59fc620e-de8c-4745-abcc-18182d1bf20e&skt=2022-09-20T19%3A06%3A53Z&ske=2022-09-26T19%3A11%3A53Z&sks=b&skv=2020-04-08&sv=2020-04-08&st=2021-03-21T21%3A35%3A43Z&se=2031-03-21T23%3A59%3A59Z&sr=b&sp=rc&sig=fqtDzsm7qi1G8MKau210Y3gNet%2Fi20zw2EThKODdEUM%3D'
)
},
{
label: 'Prescriber Enrollment Form',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TIRFPrescriberEnrollmentForm',
type: 'smart',
url: new URL(config.smart.endpoint)
},
{
label: 'Prescriber Knowledge Assessment',
appContext:
'questionnaire=http://localhost:8090/4_0_0/Questionnaire/TIRFPrescriberKnowledgeAssessment',
type: 'smart',
url: new URL(config.smart.endpoint)
}
],
summary: 'Prescriber Forms'
}
]
};
Expand Down Expand Up @@ -172,6 +287,10 @@ const handler = (req: TypedRequestBody, res: any) => {
console.log(' Practitioner: ' + practitioner?.id + ' NPI: ' + npi);
console.log(' Patient: ' + patient?.id);

console.log(' MedicationRequest: ' + prefetchRequest?.id);
console.log(' Practitioner: ' + practitioner?.id + ' NPI: ' + npi);
console.log(' Patient: ' + patient?.id);

// verify a MedicationRequest was sent
if (contextRequest && contextRequest.resourceType !== 'MedicationRequest') {
res.json(buildErrorCard('DraftOrders does not contain a MedicationRequest'));
Expand Down Expand Up @@ -210,23 +329,32 @@ const handler = (req: TypedRequestBody, res: any) => {
return e.code === medicationCode.code && e.system === medicationCode.system;
});
if (returnCard) {
const card = new Card(medicationCode.display || 'Rems', CARD_DETAILS, source, 'info');
const links = codeMap[medicationCode.code];
links.forEach(e => {
if (e.type == 'absolute') {
// no construction needed
card.addLink(e);
} else {
// link is SMART
// TODO: smart links should be built with discovered questionnaires, not hard coded ones
e.appContext = `${e.appContext}&order=${JSON.stringify(contextRequest)}&coverage=${
contextRequest.insurance?.[0].reference
}`;
card.addLink(e);
}
});
const cardArray: Card[] = [];
const codeRule = codeMap[medicationCode.code];
for (const rule of codeRule) {
const card = new Card(
rule.summary || medicationCode.display || 'Rems',
CARD_DETAILS,
source,
'info'
);
rule.links.forEach(e => {
if (e.type == 'absolute') {
// no construction needed
card.addLink(e);
} else {
// link is SMART
// TODO: smart links should be built with discovered questionnaires, not hard coded ones
e.appContext = `${e.appContext}&order=${JSON.stringify(contextRequest)}&coverage=${
contextRequest.insurance?.[0].reference
}`;
card.addLink(e);
}
});
cardArray.push(card);
}
res.json({
cards: [card]
cards: cardArray
});
} else {
res.json(buildErrorCard('Unsupported code'));
Expand Down