@medplum/scriptsure-react 5.1.26 → 5.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/cjs/index.d.ts +127 -3
- package/dist/esm/index.d.ts +127 -3
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +3 -3
- package/package.json +8 -8
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};__export(index_exports,{MEDPLUM_BOT_SYSTEM:()=>MEDPLUM_BOT_SYSTEM,SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT:()=>SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT,SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES:()=>SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES,SCRIPTSURE_DRUG_SEARCH_BOT:()=>SCRIPTSURE_DRUG_SEARCH_BOT,SCRIPTSURE_GENERIC_NAME_EXTENSION:()=>SCRIPTSURE_GENERIC_NAME_EXTENSION,SCRIPTSURE_IFRAME_BOT:()=>SCRIPTSURE_IFRAME_BOT,SCRIPTSURE_IFRAME_URL_EXTENSION:()=>SCRIPTSURE_IFRAME_URL_EXTENSION,SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS:()=>SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS,SCRIPTSURE_NAME_TYPE_EXTENSION:()=>SCRIPTSURE_NAME_TYPE_EXTENSION,SCRIPTSURE_ORDERSET_ID_SYSTEM:()=>SCRIPTSURE_ORDERSET_ID_SYSTEM,SCRIPTSURE_ORDER_MEDICATION_BOT:()=>SCRIPTSURE_ORDER_MEDICATION_BOT,SCRIPTSURE_ORDER_SET_BOT:()=>SCRIPTSURE_ORDER_SET_BOT,SCRIPTSURE_PATIENT_ID_SYSTEM:()=>SCRIPTSURE_PATIENT_ID_SYSTEM,SCRIPTSURE_PATIENT_SYNC_BOT:()=>SCRIPTSURE_PATIENT_SYNC_BOT,SCRIPTSURE_PENDING_ORDER_ID_SYSTEM:()=>SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION:()=>SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS:()=>SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS,SCRIPTSURE_ROUTED_MED_ID_SYSTEM:()=>SCRIPTSURE_ROUTED_MED_ID_SYSTEM,SCRIPTSURE_SEARCH_PHARMACY_BOT:()=>SCRIPTSURE_SEARCH_PHARMACY_BOT,SCRIPTSURE_SIG_EXTENSION:()=>SCRIPTSURE_SIG_EXTENSION,SCRIPTSURE_SYSTEM:()=>SCRIPTSURE_SYSTEM,loadScriptSureQuantityQualifiers:()=>loadScriptSureQuantityQualifiers,useScriptSureIFrame:()=>useScriptSureIFrame,useScriptSureOrderMedication:()=>useScriptSureOrderMedication,useScriptSureOrderSet:()=>useScriptSureOrderSet,useScriptSurePharmacySearch:()=>useScriptSurePharmacySearch});module.exports=__toCommonJS(index_exports);var MEDPLUM_BOT_SYSTEM="https://www.medplum.com/bots",SCRIPTSURE_DRUG_SEARCH_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-drug-search-bot"},SCRIPTSURE_ORDER_MEDICATION_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-order-medication-bot"},SCRIPTSURE_ROUTED_MED_ID_SYSTEM="https://scriptsure.com/routed-med-id",SCRIPTSURE_PENDING_ORDER_ID_SYSTEM="https://scriptsure.com/pending-order-id",SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION="https://scriptsure.com/pending-order-status",SCRIPTSURE_IFRAME_URL_EXTENSION="https://scriptsure.com/iframe-url",SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS={pendingOrderIdSystem:SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,pendingOrderStatusUrl:SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,iframeUrlExtension:SCRIPTSURE_IFRAME_URL_EXTENSION},SCRIPTSURE_IFRAME_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-iframe-bot"},SCRIPTSURE_PATIENT_SYNC_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-patient-sync-bot"},SCRIPTSURE_ORDER_SET_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-order-set-bot"},SCRIPTSURE_ORDERSET_ID_SYSTEM="https://spa.scriptsure.com/orderset-id",SCRIPTSURE_SEARCH_PHARMACY_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-search-pharmacy-bot"},SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-add-patient-pharmacy-bot"},SCRIPTSURE_PATIENT_ID_SYSTEM="https://scriptsure.com/patient-id",SCRIPTSURE_SYSTEM="https://scriptsure.com",SCRIPTSURE_SIG_EXTENSION=`${SCRIPTSURE_SYSTEM}/sig`,SCRIPTSURE_NAME_TYPE_EXTENSION=`${SCRIPTSURE_SYSTEM}/name-type`,SCRIPTSURE_GENERIC_NAME_EXTENSION=`${SCRIPTSURE_SYSTEM}/generic-name`;var import_core=require("@medplum/core");function parametersToQuantityQualifiers(params){let rows=[];for(let p of params.parameter??[]){if(p.name!=="quantityQualifier"||!p.part)continue;let code=p.part.find(part=>part.name==="code")?.valueString,label=p.part.find(part=>part.name==="label")?.valueString;typeof code=="string"&&typeof label=="string"&&rows.push({code,label})}return rows}async function loadScriptSureQuantityQualifiers(medplum){let url=medplum.fhirUrl("Medication","$drug-quantity-qualifiers"),body=(0,import_core.medicationSearchParamsToParameters)({quantityQualifiers:!0}),response=await medplum.post(url,body);return(0,import_core.isResource)(response,"Parameters")?parametersToQuantityQualifiers(response):[]}var SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS=[{value:"Retail",label:"Retail"},{value:"MailOrder",label:"Mail order"},{value:"TwentyFourHourStore",label:"24-hour"},{value:"LongTermCare",label:"Long-term care"},{value:"Specialty",label:"Specialty"},{value:"SupportsDigitalSignature",label:"Digital signature"},{value:"FaxPharmacySurescripts",label:"Fax (Surescripts)"}],SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES=["Retail"];var import_react_hooks=require("@medplum/react-hooks");function useScriptSureIFrame(options){return(0,import_react_hooks.useMedicationIFrame)(SCRIPTSURE_PATIENT_SYNC_BOT,SCRIPTSURE_IFRAME_BOT,options)}var import_react_hooks2=require("@medplum/react-hooks");function useScriptSureOrderMedication(){return(0,import_react_hooks2.useMedicationOrder)()}var import_react_hooks3=require("@medplum/react-hooks");function useScriptSureOrderSet(options){return(0,import_react_hooks3.useMedicationOrderSet)({patientId:options.patientId,planDefinitionId:options.planDefinitionId,vendorOrderSetId:options.scriptSureOrdersetId,appId:options.appId})}var import_react_hooks4=require("@medplum/react-hooks");function useScriptSurePharmacySearch(){return(0,import_react_hooks4.usePharmacySearch)(SCRIPTSURE_SEARCH_PHARMACY_BOT,SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT)}
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};__export(index_exports,{MEDPLUM_BOT_SYSTEM:()=>MEDPLUM_BOT_SYSTEM,SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT:()=>SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT,SCRIPTSURE_BUSINESS_UNIT_ID_SYSTEM:()=>SCRIPTSURE_BUSINESS_UNIT_ID_SYSTEM,SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES:()=>SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES,SCRIPTSURE_DRUG_SEARCH_BOT:()=>SCRIPTSURE_DRUG_SEARCH_BOT,SCRIPTSURE_GCN_SEQNO_SYSTEM:()=>SCRIPTSURE_GCN_SEQNO_SYSTEM,SCRIPTSURE_GENERIC_NAME_EXTENSION:()=>SCRIPTSURE_GENERIC_NAME_EXTENSION,SCRIPTSURE_IFRAME_BOT:()=>SCRIPTSURE_IFRAME_BOT,SCRIPTSURE_IFRAME_URL_EXTENSION:()=>SCRIPTSURE_IFRAME_URL_EXTENSION,SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS:()=>SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS,SCRIPTSURE_MESSAGE_ID_SYSTEM:()=>SCRIPTSURE_MESSAGE_ID_SYSTEM,SCRIPTSURE_NAME_TYPE_EXTENSION:()=>SCRIPTSURE_NAME_TYPE_EXTENSION,SCRIPTSURE_ORDERSET_ID_SYSTEM:()=>SCRIPTSURE_ORDERSET_ID_SYSTEM,SCRIPTSURE_ORDER_MEDICATION_BOT:()=>SCRIPTSURE_ORDER_MEDICATION_BOT,SCRIPTSURE_ORDER_SET_BOT:()=>SCRIPTSURE_ORDER_SET_BOT,SCRIPTSURE_ORGANIZATION_TYPE_SYSTEM:()=>SCRIPTSURE_ORGANIZATION_TYPE_SYSTEM,SCRIPTSURE_PATIENT_ID_SYSTEM:()=>SCRIPTSURE_PATIENT_ID_SYSTEM,SCRIPTSURE_PATIENT_SYNC_BOT:()=>SCRIPTSURE_PATIENT_SYNC_BOT,SCRIPTSURE_PENDING_ORDER_ID_SYSTEM:()=>SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION:()=>SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,SCRIPTSURE_PENDING_ORDER_STATUS_IN_CART:()=>SCRIPTSURE_PENDING_ORDER_STATUS_IN_CART,SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS:()=>SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS,SCRIPTSURE_PRACTICE_ID_SYSTEM:()=>SCRIPTSURE_PRACTICE_ID_SYSTEM,SCRIPTSURE_ROUTED_MED_ID_SYSTEM:()=>SCRIPTSURE_ROUTED_MED_ID_SYSTEM,SCRIPTSURE_SEARCH_PHARMACY_BOT:()=>SCRIPTSURE_SEARCH_PHARMACY_BOT,SCRIPTSURE_SIG_EXTENSION:()=>SCRIPTSURE_SIG_EXTENSION,SCRIPTSURE_SYSTEM:()=>SCRIPTSURE_SYSTEM,ScriptSurePracticeProvider:()=>ScriptSurePracticeProvider,loadScriptSureQuantityQualifiers:()=>loadScriptSureQuantityQualifiers,useScriptSureCart:()=>useScriptSureCart,useScriptSureIFrame:()=>useScriptSureIFrame,useScriptSureOrderMedication:()=>useScriptSureOrderMedication,useScriptSureOrderSet:()=>useScriptSureOrderSet,useScriptSurePharmacySearch:()=>useScriptSurePharmacySearch,useScriptSurePractice:()=>useScriptSurePractice});module.exports=__toCommonJS(index_exports);var MEDPLUM_BOT_SYSTEM="https://www.medplum.com/bots",SCRIPTSURE_DRUG_SEARCH_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-drug-search-bot"},SCRIPTSURE_ORDER_MEDICATION_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-order-medication-bot"},SCRIPTSURE_ROUTED_MED_ID_SYSTEM="https://scriptsure.com/routed-med-id",SCRIPTSURE_GCN_SEQNO_SYSTEM="https://scriptsure.com/gcn-seqno",SCRIPTSURE_PENDING_ORDER_ID_SYSTEM="https://scriptsure.com/pending-order-id",SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION="https://scriptsure.com/pending-order-status",SCRIPTSURE_PENDING_ORDER_STATUS_IN_CART="in-cart",SCRIPTSURE_IFRAME_URL_EXTENSION="https://scriptsure.com/iframe-url",SCRIPTSURE_MESSAGE_ID_SYSTEM="https://scriptsure.com/message-id",SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS={pendingOrderIdSystem:SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,pendingOrderStatusUrl:SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,iframeUrlExtension:SCRIPTSURE_IFRAME_URL_EXTENSION,messageIdSystem:SCRIPTSURE_MESSAGE_ID_SYSTEM},SCRIPTSURE_IFRAME_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-iframe-bot"},SCRIPTSURE_PATIENT_SYNC_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-patient-sync-bot"},SCRIPTSURE_ORDER_SET_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-order-set-bot"},SCRIPTSURE_ORDERSET_ID_SYSTEM="https://spa.scriptsure.com/orderset-id",SCRIPTSURE_SEARCH_PHARMACY_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-search-pharmacy-bot"},SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-add-patient-pharmacy-bot"},SCRIPTSURE_PATIENT_ID_SYSTEM="https://scriptsure.com/patient-id",SCRIPTSURE_PRACTICE_ID_SYSTEM="https://scriptsure.com/practice-id",SCRIPTSURE_BUSINESS_UNIT_ID_SYSTEM="https://scriptsure.com/business-unit-id",SCRIPTSURE_ORGANIZATION_TYPE_SYSTEM="https://scriptsure.com/organization-type",SCRIPTSURE_SYSTEM="https://scriptsure.com",SCRIPTSURE_SIG_EXTENSION=`${SCRIPTSURE_SYSTEM}/sig`,SCRIPTSURE_NAME_TYPE_EXTENSION=`${SCRIPTSURE_SYSTEM}/name-type`,SCRIPTSURE_GENERIC_NAME_EXTENSION=`${SCRIPTSURE_SYSTEM}/generic-name`;var import_core=require("@medplum/core");function parametersToQuantityQualifiers(params){let rows=[];for(let p of params.parameter??[]){if(p.name!=="quantityQualifier"||!p.part)continue;let code=p.part.find(part=>part.name==="code")?.valueString,label=p.part.find(part=>part.name==="label")?.valueString;typeof code=="string"&&typeof label=="string"&&rows.push({code,label})}return rows}async function loadScriptSureQuantityQualifiers(medplum){let url=medplum.fhirUrl("Medication","$drug-quantity-qualifiers"),body=(0,import_core.medicationSearchParamsToParameters)({quantityQualifiers:!0}),response=await medplum.post(url,body);return(0,import_core.isResource)(response,"Parameters")?parametersToQuantityQualifiers(response):[]}var SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS=[{value:"Retail",label:"Retail"},{value:"MailOrder",label:"Mail order"},{value:"TwentyFourHourStore",label:"24-hour"},{value:"LongTermCare",label:"Long-term care"},{value:"Specialty",label:"Specialty"},{value:"SupportsDigitalSignature",label:"Digital signature"},{value:"FaxPharmacySurescripts",label:"Fax (Surescripts)"}],SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES=["Retail"];var import_react_hooks=require("@medplum/react-hooks");function useScriptSureCart(){return(0,import_react_hooks.useMedicationCart)()}var import_react_hooks2=require("@medplum/react-hooks");function useScriptSureIFrame(options){return(0,import_react_hooks2.useMedicationIFrame)(SCRIPTSURE_PATIENT_SYNC_BOT,SCRIPTSURE_IFRAME_BOT,options)}var import_react_hooks3=require("@medplum/react-hooks");function useScriptSureOrderMedication(){return(0,import_react_hooks3.useMedicationOrder)()}var import_react_hooks4=require("@medplum/react-hooks");function useScriptSureOrderSet(options){return(0,import_react_hooks4.useMedicationOrderSet)({patientId:options.patientId,planDefinitionId:options.planDefinitionId,vendorOrderSetId:options.scriptSureOrdersetId,appId:options.appId,organization:options.organization})}var import_react_hooks5=require("@medplum/react-hooks");function useScriptSurePharmacySearch(){return(0,import_react_hooks5.usePharmacySearch)(SCRIPTSURE_SEARCH_PHARMACY_BOT,SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT)}var import_core2=require("@medplum/core"),import_react_hooks6=require("@medplum/react-hooks"),import_react=require("react");var import_jsx_runtime=require("react/jsx-runtime"),STORAGE_KEY="medplum.scriptsure.selectedPracticeOrganization",ScriptSurePracticeContext=(0,import_react.createContext)({practices:[],selectedOrganizationId:void 0,selectedOrganization:void 0,setSelectedOrganizationId:()=>{},loading:!1});function addOrganizationReference(refs,reference){reference?.startsWith("Organization/")&&refs.add(reference)}function hasPracticeIdentifier(org){return!!(0,import_core2.getIdentifier)(org,SCRIPTSURE_PRACTICE_ID_SYSTEM)}function resolvePractitionerId(profile){if(profile?.resourceType==="Practitioner")return profile.id;if(profile?.resourceType==="PractitionerRole")return(0,import_core2.resolveId)(profile.practitioner)}function ScriptSurePracticeProvider(props){let medplum=(0,import_react_hooks6.useMedplum)(),[practices,setPractices]=(0,import_react.useState)([]),[loading,setLoading]=(0,import_react.useState)(!0),[selectedOrganizationId,setSelected]=(0,import_react.useState)(()=>localStorage.getItem(STORAGE_KEY)??void 0);(0,import_react.useEffect)(()=>{let cancelled=!1,loadAffiliatedPractices=async()=>{let profile=medplum.getProfile(),practitionerId=resolvePractitionerId(profile),references=new Set;if(practitionerId){let roles=await medplum.searchResources("PractitionerRole",{practitioner:`Practitioner/${practitionerId}`,_count:"100"});for(let role of roles)role.active!==!1&&addOrganizationReference(references,role.organization?.reference)}let membership=medplum.getProjectMembership();for(let access of membership?.access??[])for(let param of access.parameter??[])param.name==="organization"&&addOrganizationReference(references,param.valueReference?.reference);let settledOrgs=await Promise.allSettled([...references].map(reference=>medplum.readReference({reference}))),seen=new Set,result=[];for(let settledOrg of settledOrgs){if(settledOrg.status==="rejected")continue;let org=settledOrg.value;org.id&&!seen.has(org.id)&&hasPracticeIdentifier(org)&&(seen.add(org.id),result.push(org))}return result};return(async()=>{setLoading(!0);try{let orgs=await loadAffiliatedPractices();cancelled||(setPractices(orgs),setSelected(current=>current&&orgs.some(o=>o.id===current)?current:orgs.length===1?orgs[0].id:void 0))}catch{cancelled||setPractices([])}finally{cancelled||setLoading(!1)}})().catch(()=>{}),()=>{cancelled=!0}},[medplum]);let setSelectedOrganizationId=(0,import_react.useCallback)(id=>{setSelected(id),id?localStorage.setItem(STORAGE_KEY,id):localStorage.removeItem(STORAGE_KEY)},[]),selectedOrganization=(0,import_react.useMemo)(()=>selectedOrganizationId?{reference:`Organization/${selectedOrganizationId}`}:void 0,[selectedOrganizationId]),value=(0,import_react.useMemo)(()=>({practices,selectedOrganizationId,selectedOrganization,setSelectedOrganizationId,loading}),[practices,selectedOrganizationId,selectedOrganization,setSelectedOrganizationId,loading]);return(0,import_jsx_runtime.jsx)(ScriptSurePracticeContext.Provider,{value,children:props.children})}function useScriptSurePractice(){return(0,import_react.useContext)(ScriptSurePracticeContext)}
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts", "../../src/common.ts", "../../src/loadScriptSureQuantityQualifiers.ts", "../../src/pharmacy-search.ts", "../../src/useScriptSureIFrame.ts", "../../src/useScriptSureOrderMedication.ts", "../../src/useScriptSureOrderSet.ts", "../../src/useScriptSurePharmacySearch.ts"],
|
|
4
|
-
"sourcesContent": ["// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nexport * from './common';\nexport * from './loadScriptSureQuantityQualifiers';\nexport * from './pharmacy-search';\nexport * from './useScriptSureIFrame';\nexport * from './useScriptSureOrderMedication';\nexport * from './useScriptSureOrderSet';\nexport * from './useScriptSurePharmacySearch';\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { MedicationOrderExtensions } from '@medplum/core';\nimport type { Identifier } from '@medplum/fhirtypes';\n\nexport const MEDPLUM_BOT_SYSTEM = 'https://www.medplum.com/bots';\n\n/**\n * @deprecated Use the vendor-neutral `$drug-search` custom FHIR operation via\n * `useMedicationOrder().searchMedications(...)` (see `@medplum/react-hooks`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `drug-search` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_DRUG_SEARCH_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-drug-search-bot',\n};\n\n/**\n * @deprecated Use the vendor-neutral `$order-medication` custom FHIR operation via\n * `useMedicationOrder().orderMedication(...)` (see `@medplum/react-hooks`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `order-medication` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_ORDER_MEDICATION_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-order-medication-bot',\n};\n\n/** Identifier system for ScriptSure ROUTED_MED_ID on in-memory Medication resources from drug search. */\nexport const SCRIPTSURE_ROUTED_MED_ID_SYSTEM = 'https://scriptsure.com/routed-med-id';\n\nexport const SCRIPTSURE_PENDING_ORDER_ID_SYSTEM = 'https://scriptsure.com/pending-order-id';\n\nexport const SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION = 'https://scriptsure.com/pending-order-status';\n\nexport const SCRIPTSURE_IFRAME_URL_EXTENSION = 'https://scriptsure.com/iframe-url';\n\nexport const SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS: MedicationOrderExtensions = {\n pendingOrderIdSystem: SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,\n pendingOrderStatusUrl: SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,\n iframeUrlExtension: SCRIPTSURE_IFRAME_URL_EXTENSION,\n};\n\nexport const SCRIPTSURE_IFRAME_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-iframe-bot',\n};\n\nexport const SCRIPTSURE_PATIENT_SYNC_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-patient-sync-bot',\n};\n\n/**\n * @deprecated Use the vendor-neutral `$order-set-url` custom FHIR operation via\n * `useScriptSureOrderSet(...)` (thin wrapper around `useMedicationOrderSet`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `order-set-url` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_ORDER_SET_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-order-set-bot',\n};\n\n/** Identifier system for the ScriptSure orderset id stamped on FHIR PlanDefinitions. */\nexport const SCRIPTSURE_ORDERSET_ID_SYSTEM = 'https://spa.scriptsure.com/orderset-id';\n\nexport const SCRIPTSURE_SEARCH_PHARMACY_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-search-pharmacy-bot',\n};\n\nexport const SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-add-patient-pharmacy-bot',\n};\n\nexport const SCRIPTSURE_PATIENT_ID_SYSTEM = 'https://scriptsure.com/patient-id';\n\n/** Base URL for ScriptSure-specific extensions on in-memory Medication resources (e.g. `/sig`). */\nexport const SCRIPTSURE_SYSTEM = 'https://scriptsure.com';\n\n/** Pre-built dosing option on a Medication from drug-format lookup (`routedMedId` search). */\nexport const SCRIPTSURE_SIG_EXTENSION = `${SCRIPTSURE_SYSTEM}/sig`;\n\n/** ScriptSure MED_NAME_TYPE_CD on a search-result Medication: `'1'` = brand, `'2'` = generic. */\nexport const SCRIPTSURE_NAME_TYPE_EXTENSION = `${SCRIPTSURE_SYSTEM}/name-type`;\n\n/** ScriptSure GenericName on a search-result Medication (parent generic when the row is a brand). */\nexport const SCRIPTSURE_GENERIC_NAME_EXTENSION = `${SCRIPTSURE_SYSTEM}/generic-name`;\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { MedplumClient } from '@medplum/core';\nimport { isResource, medicationSearchParamsToParameters } from '@medplum/core';\nimport type { Parameters } from '@medplum/fhirtypes';\n\n/**\n * Reads `{ code, label }` rows from a `Parameters` resource produced by the\n * `$drug-quantity-qualifiers` custom operation.\n *\n * The OperationDefinition (see `scriptsure-drug-search-bot` registration in\n * `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`) declares a single\n * repeating output parameter named `quantityQualifier`, each entry bearing\n * `part: [{ name: 'code', valueString }, { name: 'label', valueString }]`.\n * The server's `buildOutputParameters` wraps the bot return value into that\n * shape, so the parser only needs to handle this one canonical layout.\n * Entries missing either inner part are skipped defensively.\n *\n * @param params - `Parameters` resource returned by the operation.\n * @returns `{ code, label }` rows for UI selects.\n */\nfunction parametersToQuantityQualifiers(params: Parameters): { code: string; label: string }[] {\n const rows: { code: string; label: string }[] = [];\n for (const p of params.parameter ?? []) {\n if (p.name !== 'quantityQualifier' || !p.part) {\n continue;\n }\n const code = p.part.find((part) => part.name === 'code')?.valueString;\n const label = p.part.find((part) => part.name === 'label')?.valueString;\n if (typeof code === 'string' && typeof label === 'string') {\n rows.push({ code, label });\n }\n }\n return rows;\n}\n\n/**\n * Fetches NCI potency-unit codes for dispense quantity qualifiers via the\n * vendor-neutral `$drug-quantity-qualifiers` custom FHIR operation. Each\n * Medplum project picks the vendor implementation at deploy time by pointing\n * its `OperationDefinition` at the appropriate Bot (ScriptSure's\n * `scriptsure-drug-search-bot` today; see `deploy.ts`).\n *\n * @param medplum - Medplum client (user session).\n * @returns `{ code, label }` rows for UI selects.\n */\nexport async function loadScriptSureQuantityQualifiers(\n medplum: MedplumClient\n): Promise<{ code: string; label: string }[]> {\n const url = medplum.fhirUrl('Medication', '$drug-quantity-qualifiers');\n const body = medicationSearchParamsToParameters({ quantityQualifiers: true });\n const response = await medplum.post(url, body);\n if (!isResource<Parameters>(response, 'Parameters')) {\n return [];\n }\n return parametersToQuantityQualifiers(response);\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PharmacySearchParams } from '@medplum/core';\n\n/**\n * SureScripts pharmacy specialty tags accepted by POST /v3/pharmacy/search `specialties`.\n * Must stay aligned with ScriptSure API allowed values.\n */\nexport type ScriptSurePharmacySpecialty =\n | 'Retail'\n | 'MailOrder'\n | 'TwentyFourHourStore'\n | 'SupportsDigitalSignature'\n | 'LongTermCare'\n | 'Specialty'\n | 'FaxPharmacySurescripts';\n\nexport interface ScriptSurePharmacySpecialtyOption {\n readonly value: ScriptSurePharmacySpecialty;\n readonly label: string;\n}\n\n/** Category filters shown in the ScriptSure pharmacy search dialog. */\nexport const SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS: readonly ScriptSurePharmacySpecialtyOption[] = [\n { value: 'Retail', label: 'Retail' },\n { value: 'MailOrder', label: 'Mail order' },\n { value: 'TwentyFourHourStore', label: '24-hour' },\n { value: 'LongTermCare', label: 'Long-term care' },\n { value: 'Specialty', label: 'Specialty' },\n { value: 'SupportsDigitalSignature', label: 'Digital signature' },\n { value: 'FaxPharmacySurescripts', label: 'Fax (Surescripts)' },\n] as const;\n\n/** Default specialty filter for nearby retail pharmacy pickers. */\nexport const SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES: readonly ScriptSurePharmacySpecialty[] = ['Retail'];\n\n/**\n * ScriptSure pharmacy search parameters.\n * Extends the shared dialog fields with SureScripts specialty filters.\n */\nexport interface ScriptSurePharmacySearchParams extends PharmacySearchParams {\n specialties?: ScriptSurePharmacySpecialty[];\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { MedicationIFrameOptions } from '@medplum/react-hooks';\nimport { useMedicationIFrame } from '@medplum/react-hooks';\nimport { SCRIPTSURE_IFRAME_BOT, SCRIPTSURE_PATIENT_SYNC_BOT } from './common';\n\nexport type ScriptSureIFrameOptions = MedicationIFrameOptions;\n\n/**\n * React hook that syncs a patient to ScriptSure and returns the iframe URL.\n *\n * Thin wrapper around the generic {@link useMedicationIFrame} hook,\n * pre-configured with ScriptSure bot identifiers.\n *\n * @param options - Configuration and callback options.\n * @returns The ScriptSure iframe URL, or undefined while loading.\n */\nexport function useScriptSureIFrame(options: ScriptSureIFrameOptions): string | undefined {\n return useMedicationIFrame(SCRIPTSURE_PATIENT_SYNC_BOT, SCRIPTSURE_IFRAME_BOT, options);\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UseMedicationOrderReturn } from '@medplum/react-hooks';\nimport { useMedicationOrder } from '@medplum/react-hooks';\n\nexport type UseScriptSureOrderMedicationReturn = UseMedicationOrderReturn;\n\n/**\n * React hook for ScriptSure drug search and pending order creation (iframe launch URL).\n *\n * Now a near-empty re-export of `useMedicationOrder` from `@medplum/react-hooks`: the\n * vendor binding lives entirely on the server, where each Medplum project's\n * `OperationDefinition` resources for `$drug-search` and `$order-medication`\n * point at the ScriptSure bots via the\n * `operationDefinition-implementation` extension. See the deploy script in\n * `medplum-ee/packages/scriptsure/src/scripts/deploy.ts` for how those\n * resources are upserted.\n *\n * Kept as a typed alias for backwards source-compatibility with apps importing\n * `useScriptSureOrderMedication` and as a documentation anchor for the\n * ScriptSure-specific behavior (e.g. patient-must-be-synced precondition).\n *\n * @returns The same API as `useMedicationOrder` (search + order callbacks).\n */\nexport function useScriptSureOrderMedication(): UseScriptSureOrderMedicationReturn {\n return useMedicationOrder();\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { UseMedicationOrderSetReturn } from '@medplum/react-hooks';\nimport { useMedicationOrderSet } from '@medplum/react-hooks';\n\nexport interface UseScriptSureOrderSetOptions {\n /** Patient to prescribe against. Hook stays idle (no operation call) until set. */\n readonly patientId: string | undefined;\n /** Medplum PlanDefinition id; bot reverse-looks up the ScriptSure orderset id. */\n readonly planDefinitionId?: string;\n /** ScriptSure orderset id (escape hatch when no synced PD exists yet). */\n readonly scriptSureOrdersetId?: number;\n readonly appId?: string;\n}\n\nexport type UseScriptSureOrderSetReturn = UseMedicationOrderSetReturn;\n\n/**\n * React hook that returns the ScriptSure order-set prescribing widget URL via\n * the vendor-neutral `$order-set-url` FHIR custom operation\n * (`POST /fhir/R4/PlanDefinition/$order-set-url`).\n *\n * Thin wrapper around {@link useMedicationOrderSet}: forwards\n * `scriptSureOrdersetId` as the operation's `vendorOrderSetId` parameter,\n * leaves vendor binding to the deployed `OperationDefinition` \u2192\n * `Bot/scriptsure-order-set-bot` link.\n *\n * The operation is naturally idempotent \u2014 re-calls only refresh the session\n * token in the returned URL \u2014 so callers can safely wire `refresh` into\n * `PrescriptionIFrameModal.onRefreshLaunchUrl`.\n *\n * @param options - Patient + order-set picker (PD or ScriptSure id).\n * @returns `{ url, loading, error, refresh }`.\n */\nexport function useScriptSureOrderSet(options: UseScriptSureOrderSetOptions): UseScriptSureOrderSetReturn {\n return useMedicationOrderSet({\n patientId: options.patientId,\n planDefinitionId: options.planDefinitionId,\n vendorOrderSetId: options.scriptSureOrdersetId,\n appId: options.appId,\n });\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UsePharmacySearchReturn } from '@medplum/react-hooks';\nimport { usePharmacySearch } from '@medplum/react-hooks';\nimport { SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT, SCRIPTSURE_SEARCH_PHARMACY_BOT } from './common';\nimport type { ScriptSurePharmacySearchParams } from './pharmacy-search';\n\nexport type UseScriptSurePharmacySearchReturn = UsePharmacySearchReturn<ScriptSurePharmacySearchParams>;\n\n/**\n * React hook that provides ScriptSure-specific pharmacy search and add-to-favorites functionality.\n *\n * Thin wrapper around the generic {@link usePharmacySearch} hook, pre-configured with\n * ScriptSure bot identifiers and widened so search params carry ScriptSure-only\n * `specialties` filters for POST /v3/pharmacy/search.\n *\n * @returns An object with `searchPharmacies` and `addToFavorites` callbacks.\n */\nexport function useScriptSurePharmacySearch(): UseScriptSurePharmacySearchReturn {\n return usePharmacySearch<ScriptSurePharmacySearchParams>(\n SCRIPTSURE_SEARCH_PHARMACY_BOT,\n SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT\n );\n}\n"],
|
|
5
|
-
"mappings": "wpBAAA,
|
|
6
|
-
"names": ["import_react_hooks", "import_react_hooks", "import_react_hooks"]
|
|
3
|
+
"sources": ["../../src/index.ts", "../../src/common.ts", "../../src/loadScriptSureQuantityQualifiers.ts", "../../src/pharmacy-search.ts", "../../src/useScriptSureCart.ts", "../../src/useScriptSureIFrame.ts", "../../src/useScriptSureOrderMedication.ts", "../../src/useScriptSureOrderSet.ts", "../../src/useScriptSurePharmacySearch.ts", "../../src/useScriptSurePractice.tsx"],
|
|
4
|
+
"sourcesContent": ["// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nexport * from './common';\nexport * from './loadScriptSureQuantityQualifiers';\nexport * from './pharmacy-search';\nexport * from './useScriptSureCart';\nexport * from './useScriptSureIFrame';\nexport * from './useScriptSureOrderMedication';\nexport * from './useScriptSureOrderSet';\nexport * from './useScriptSurePharmacySearch';\nexport * from './useScriptSurePractice';\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { MedicationOrderExtensions } from '@medplum/core';\nimport type { Identifier } from '@medplum/fhirtypes';\n\nexport const MEDPLUM_BOT_SYSTEM = 'https://www.medplum.com/bots';\n\n/**\n * @deprecated Use the vendor-neutral `$drug-search` custom FHIR operation via\n * `useMedicationOrder().searchMedications(...)` (see `@medplum/react-hooks`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `drug-search` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_DRUG_SEARCH_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-drug-search-bot',\n};\n\n/**\n * @deprecated Use the vendor-neutral `$order-medication` custom FHIR operation via\n * `useMedicationOrder().orderMedication(...)` (see `@medplum/react-hooks`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `order-medication` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_ORDER_MEDICATION_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-order-medication-bot',\n};\n\n/** Identifier system for ScriptSure ROUTED_MED_ID on in-memory Medication resources from drug search. */\nexport const SCRIPTSURE_ROUTED_MED_ID_SYSTEM = 'https://scriptsure.com/routed-med-id';\n\n/**\n * Identifier/coding system for the FDB GCN Sequence Number (`GCN_SEQNO`) \u2014 the\n * clinical-formulation key (ingredient+strength+dose-form+route), independent of\n * brand and NDC. Stamped as a `medicationCodeableConcept.coding` on the draft\n * MedicationRequest so the ScriptSure prescription webhook can reconcile a draft\n * to its sent prescription even when the NDC drifts or the pharmacy substitutes a\n * generic (brand and generic share the same GCN). Mirrors the medplum-ee bot\n * constant of the same name.\n */\nexport const SCRIPTSURE_GCN_SEQNO_SYSTEM = 'https://scriptsure.com/gcn-seqno';\n\nexport const SCRIPTSURE_PENDING_ORDER_ID_SYSTEM = 'https://scriptsure.com/pending-order-id';\n\nexport const SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION = 'https://scriptsure.com/pending-order-status';\n\n/**\n * `SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION` value marking a draft\n * `MedicationRequest` as staged in the patient's ScriptSure MedCart (added by\n * `$checkout-medications`, before the prescriber sends from the MedCart widget).\n * Consumed by the paired `medplum-ee` cart-checkout / cart-manage bots when\n * stamping drafts; the Provider App uses the pure-cart model (all drafts on the\n * Draft tab) rather than filtering on this code today.\n */\nexport const SCRIPTSURE_PENDING_ORDER_STATUS_IN_CART = 'in-cart';\n\nexport const SCRIPTSURE_IFRAME_URL_EXTENSION = 'https://scriptsure.com/iframe-url';\n\n/**\n * Identifier system for the SureScripts `messageId` stamped on a draft\n * `MedicationRequest` by the cart-checkout flow (electronic-queue submit).\n * Consumed by the paired `medplum-ee` `scriptsure-cart-checkout-bot` when\n * stamping queued drafts and by `scriptsure-prescription-webhook-bot` when\n * reconciling the approval webhook back to the originating draft.\n */\nexport const SCRIPTSURE_MESSAGE_ID_SYSTEM = 'https://scriptsure.com/message-id';\n\nexport const SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS: MedicationOrderExtensions = {\n pendingOrderIdSystem: SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,\n pendingOrderStatusUrl: SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,\n iframeUrlExtension: SCRIPTSURE_IFRAME_URL_EXTENSION,\n messageIdSystem: SCRIPTSURE_MESSAGE_ID_SYSTEM,\n};\n\nexport const SCRIPTSURE_IFRAME_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-iframe-bot',\n};\n\nexport const SCRIPTSURE_PATIENT_SYNC_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-patient-sync-bot',\n};\n\n/**\n * @deprecated Use the vendor-neutral `$order-set-url` custom FHIR operation via\n * `useScriptSureOrderSet(...)` (thin wrapper around `useMedicationOrderSet`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `order-set-url` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_ORDER_SET_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-order-set-bot',\n};\n\n/** Identifier system for the ScriptSure orderset id stamped on FHIR PlanDefinitions. */\nexport const SCRIPTSURE_ORDERSET_ID_SYSTEM = 'https://spa.scriptsure.com/orderset-id';\n\nexport const SCRIPTSURE_SEARCH_PHARMACY_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-search-pharmacy-bot',\n};\n\nexport const SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-add-patient-pharmacy-bot',\n};\n\nexport const SCRIPTSURE_PATIENT_ID_SYSTEM = 'https://scriptsure.com/patient-id';\n\n/**\n * Identifier system for the ScriptSure `practiceId` stamped on the Practice-level\n * Medplum `Organization`. Used by the practice/location selector to discover the\n * prescriber's ScriptSure practices and pass the chosen `organizationId` to bots.\n */\nexport const SCRIPTSURE_PRACTICE_ID_SYSTEM = 'https://scriptsure.com/practice-id';\n\n/** Identifier system for the ScriptSure `businessUnitId` on the BU-level Medplum `Organization`. */\nexport const SCRIPTSURE_BUSINESS_UNIT_ID_SYSTEM = 'https://scriptsure.com/business-unit-id';\n\n/** `Organization.type` coding system discriminating ScriptSure entity Organizations (`business-unit` | `practice`). */\nexport const SCRIPTSURE_ORGANIZATION_TYPE_SYSTEM = 'https://scriptsure.com/organization-type';\n\n/** Base URL for ScriptSure-specific extensions on in-memory Medication resources (e.g. `/sig`). */\nexport const SCRIPTSURE_SYSTEM = 'https://scriptsure.com';\n\n/** Pre-built dosing option on a Medication from drug-format lookup (`routedMedId` search). */\nexport const SCRIPTSURE_SIG_EXTENSION = `${SCRIPTSURE_SYSTEM}/sig`;\n\n/** ScriptSure MED_NAME_TYPE_CD on a search-result Medication: `'1'` = brand, `'2'` = generic. */\nexport const SCRIPTSURE_NAME_TYPE_EXTENSION = `${SCRIPTSURE_SYSTEM}/name-type`;\n\n/** ScriptSure GenericName on a search-result Medication (parent generic when the row is a brand). */\nexport const SCRIPTSURE_GENERIC_NAME_EXTENSION = `${SCRIPTSURE_SYSTEM}/generic-name`;\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { MedplumClient } from '@medplum/core';\nimport { isResource, medicationSearchParamsToParameters } from '@medplum/core';\nimport type { Parameters } from '@medplum/fhirtypes';\n\n/**\n * Reads `{ code, label }` rows from a `Parameters` resource produced by the\n * `$drug-quantity-qualifiers` custom operation.\n *\n * The OperationDefinition (see `scriptsure-drug-search-bot` registration in\n * `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`) declares a single\n * repeating output parameter named `quantityQualifier`, each entry bearing\n * `part: [{ name: 'code', valueString }, { name: 'label', valueString }]`.\n * The server's `buildOutputParameters` wraps the bot return value into that\n * shape, so the parser only needs to handle this one canonical layout.\n * Entries missing either inner part are skipped defensively.\n *\n * @param params - `Parameters` resource returned by the operation.\n * @returns `{ code, label }` rows for UI selects.\n */\nfunction parametersToQuantityQualifiers(params: Parameters): { code: string; label: string }[] {\n const rows: { code: string; label: string }[] = [];\n for (const p of params.parameter ?? []) {\n if (p.name !== 'quantityQualifier' || !p.part) {\n continue;\n }\n const code = p.part.find((part) => part.name === 'code')?.valueString;\n const label = p.part.find((part) => part.name === 'label')?.valueString;\n if (typeof code === 'string' && typeof label === 'string') {\n rows.push({ code, label });\n }\n }\n return rows;\n}\n\n/**\n * Fetches NCI potency-unit codes for dispense quantity qualifiers via the\n * vendor-neutral `$drug-quantity-qualifiers` custom FHIR operation. Each\n * Medplum project picks the vendor implementation at deploy time by pointing\n * its `OperationDefinition` at the appropriate Bot (ScriptSure's\n * `scriptsure-drug-search-bot` today; see `deploy.ts`).\n *\n * @param medplum - Medplum client (user session).\n * @returns `{ code, label }` rows for UI selects.\n */\nexport async function loadScriptSureQuantityQualifiers(\n medplum: MedplumClient\n): Promise<{ code: string; label: string }[]> {\n const url = medplum.fhirUrl('Medication', '$drug-quantity-qualifiers');\n const body = medicationSearchParamsToParameters({ quantityQualifiers: true });\n const response = await medplum.post(url, body);\n if (!isResource<Parameters>(response, 'Parameters')) {\n return [];\n }\n return parametersToQuantityQualifiers(response);\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PharmacySearchParams } from '@medplum/core';\n\n/**\n * SureScripts pharmacy specialty tags accepted by POST /v3/pharmacy/search `specialties`.\n * Must stay aligned with ScriptSure API allowed values.\n */\nexport type ScriptSurePharmacySpecialty =\n | 'Retail'\n | 'MailOrder'\n | 'TwentyFourHourStore'\n | 'SupportsDigitalSignature'\n | 'LongTermCare'\n | 'Specialty'\n | 'FaxPharmacySurescripts';\n\nexport interface ScriptSurePharmacySpecialtyOption {\n readonly value: ScriptSurePharmacySpecialty;\n readonly label: string;\n}\n\n/** Category filters shown in the ScriptSure pharmacy search dialog. */\nexport const SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS: readonly ScriptSurePharmacySpecialtyOption[] = [\n { value: 'Retail', label: 'Retail' },\n { value: 'MailOrder', label: 'Mail order' },\n { value: 'TwentyFourHourStore', label: '24-hour' },\n { value: 'LongTermCare', label: 'Long-term care' },\n { value: 'Specialty', label: 'Specialty' },\n { value: 'SupportsDigitalSignature', label: 'Digital signature' },\n { value: 'FaxPharmacySurescripts', label: 'Fax (Surescripts)' },\n] as const;\n\n/** Default specialty filter for nearby retail pharmacy pickers. */\nexport const SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES: readonly ScriptSurePharmacySpecialty[] = ['Retail'];\n\n/**\n * ScriptSure pharmacy search parameters.\n * Extends the shared dialog fields with SureScripts specialty filters.\n */\nexport interface ScriptSurePharmacySearchParams extends PharmacySearchParams {\n specialties?: ScriptSurePharmacySpecialty[];\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UseMedicationCartReturn } from '@medplum/react-hooks';\nimport { useMedicationCart } from '@medplum/react-hooks';\n\nexport type UseScriptSureCartReturn = UseMedicationCartReturn;\n\n/**\n * React hook for the ScriptSure **medication cart** lifecycle: add a draft\n * `MedicationRequest` line (`createResource`), check out drafts into the\n * patient's ScriptSure MedCart (`$checkout-medications` \u2192\n * `/widgets/medcart/{patientId}`), and remove/clear cart lines\n * (`$remove-cart-medication` / `$clear-cart`).\n *\n * A near-empty re-export of `useMedicationCart` from `@medplum/react-hooks`: the\n * vendor binding for the custom operations lives entirely on the server, where\n * each Medplum project's `OperationDefinition`s point at the ScriptSure bots via\n * the `operationDefinition-implementation` extension \u2014 see\n * [Custom FHIR Operations](https://www.medplum.com/docs/bots/custom-fhir-operations).\n * (Internal deploy: `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`.)\n *\n * `addToCart` is plain FHIR create (no vendor call); MedCart staging happens at\n * `checkout`. DoseSpot and other iframe-first vendors do not use this surface.\n *\n * Kept as a typed alias for source-compatibility with apps importing\n * `useScriptSureCart` and as a documentation anchor for ScriptSure-specific\n * behavior (patient-must-be-synced precondition; cart items await sign-off in\n * the MedCart widget).\n *\n * @returns The same API as `useMedicationCart` (`addToCart`, `adding`,\n * `checkout`, `removeFromCart`, `clearCart`).\n */\nexport function useScriptSureCart(): UseScriptSureCartReturn {\n return useMedicationCart();\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { MedicationIFrameOptions } from '@medplum/react-hooks';\nimport { useMedicationIFrame } from '@medplum/react-hooks';\nimport { SCRIPTSURE_IFRAME_BOT, SCRIPTSURE_PATIENT_SYNC_BOT } from './common';\n\nexport type ScriptSureIFrameOptions = MedicationIFrameOptions;\n\n/**\n * React hook that syncs a patient to ScriptSure and returns the iframe URL.\n *\n * Thin wrapper around the generic {@link @medplum/react-hooks#useMedicationIFrame} hook,\n * pre-configured with ScriptSure bot identifiers.\n *\n * @param options - Configuration and callback options.\n * @returns The ScriptSure iframe URL, or undefined while loading.\n */\nexport function useScriptSureIFrame(options: ScriptSureIFrameOptions): string | undefined {\n return useMedicationIFrame(SCRIPTSURE_PATIENT_SYNC_BOT, SCRIPTSURE_IFRAME_BOT, options);\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UseMedicationOrderReturn } from '@medplum/react-hooks';\nimport { useMedicationOrder } from '@medplum/react-hooks';\n\nexport type UseScriptSureOrderMedicationReturn = UseMedicationOrderReturn;\n\n/**\n * React hook for ScriptSure drug search and pending order creation (iframe launch URL).\n *\n * Now a near-empty re-export of `useMedicationOrder` from `@medplum/react-hooks`: the\n * vendor binding lives entirely on the server, where each Medplum project's\n * `OperationDefinition` resources for `$drug-search` and `$order-medication`\n * point at the ScriptSure bots via the\n * `operationDefinition-implementation` extension. See the deploy script in\n * `medplum-ee/packages/scriptsure/src/scripts/deploy.ts` for how those\n * resources are upserted.\n *\n * Kept as a typed alias for backwards source-compatibility with apps importing\n * `useScriptSureOrderMedication` and as a documentation anchor for the\n * ScriptSure-specific behavior (e.g. patient-must-be-synced precondition).\n *\n * @returns The same API as `useMedicationOrder` (search + order callbacks).\n */\nexport function useScriptSureOrderMedication(): UseScriptSureOrderMedicationReturn {\n return useMedicationOrder();\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { Organization, Reference } from '@medplum/fhirtypes';\nimport type { UseMedicationOrderSetReturn } from '@medplum/react-hooks';\nimport { useMedicationOrderSet } from '@medplum/react-hooks';\n\nexport interface UseScriptSureOrderSetOptions {\n /** Patient to prescribe against. Hook stays idle (no operation call) until set. */\n readonly patientId: string | undefined;\n /** Medplum PlanDefinition id; bot reverse-looks up the ScriptSure orderset id. */\n readonly planDefinitionId?: string;\n /** ScriptSure orderset id (escape hatch when no synced PD exists yet). */\n readonly scriptSureOrdersetId?: number;\n readonly appId?: string;\n /** Selected practice location for multi-practice deployments. */\n readonly organization?: Reference<Organization>;\n}\n\nexport type UseScriptSureOrderSetReturn = UseMedicationOrderSetReturn;\n\n/**\n * React hook that returns the ScriptSure order-set prescribing widget URL via\n * the vendor-neutral `$order-set-url` FHIR custom operation\n * (`POST /fhir/R4/PlanDefinition/$order-set-url`).\n *\n * Thin wrapper around {@link @medplum/react-hooks#useMedicationOrderSet}: forwards\n * `scriptSureOrdersetId` as the operation's `vendorOrderSetId` parameter,\n * leaves vendor binding to the deployed `OperationDefinition` \u2192\n * `Bot/scriptsure-order-set-bot` link.\n *\n * The operation is naturally idempotent \u2014 re-calls only refresh the session\n * token in the returned URL \u2014 so callers can safely wire `refresh` into\n * `PrescriptionIFrameModal.onRefreshLaunchUrl`.\n *\n * @param options - Patient + order-set picker (PD or ScriptSure id).\n * @returns `{ url, loading, error, refresh }`.\n */\nexport function useScriptSureOrderSet(options: UseScriptSureOrderSetOptions): UseScriptSureOrderSetReturn {\n return useMedicationOrderSet({\n patientId: options.patientId,\n planDefinitionId: options.planDefinitionId,\n vendorOrderSetId: options.scriptSureOrdersetId,\n appId: options.appId,\n organization: options.organization,\n });\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UsePharmacySearchReturn } from '@medplum/react-hooks';\nimport { usePharmacySearch } from '@medplum/react-hooks';\nimport { SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT, SCRIPTSURE_SEARCH_PHARMACY_BOT } from './common';\nimport type { ScriptSurePharmacySearchParams } from './pharmacy-search';\n\nexport type UseScriptSurePharmacySearchReturn = UsePharmacySearchReturn<ScriptSurePharmacySearchParams>;\n\n/**\n * React hook that provides ScriptSure-specific pharmacy search and add-to-favorites functionality.\n *\n * Thin wrapper around the generic {@link @medplum/react-hooks#usePharmacySearch} hook, pre-configured with\n * ScriptSure bot identifiers and widened so search params carry ScriptSure-only\n * `specialties` filters for POST /v3/pharmacy/search.\n *\n * @returns An object with `searchPharmacies` and `addToFavorites` callbacks.\n */\nexport function useScriptSurePharmacySearch(): UseScriptSurePharmacySearchReturn {\n return usePharmacySearch<ScriptSurePharmacySearchParams>(\n SCRIPTSURE_SEARCH_PHARMACY_BOT,\n SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT\n );\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { getIdentifier, resolveId } from '@medplum/core';\nimport type { Organization, Practitioner, PractitionerRole, Reference } from '@medplum/fhirtypes';\nimport { useMedplum } from '@medplum/react-hooks';\nimport type { JSX, ReactNode } from 'react';\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport { SCRIPTSURE_PRACTICE_ID_SYSTEM } from './common';\n\nconst STORAGE_KEY = 'medplum.scriptsure.selectedPracticeOrganization';\n\n/** The current ScriptSure practice-location selection for the signed-in prescriber. */\nexport interface ScriptSurePracticeContextValue {\n /**\n * The prescriber's ScriptSure practice `Organization`s \u2014 discovered from their\n * own affiliations (`PractitionerRole.organization` + `ProjectMembership.access`\n * organization parameters), filtered to those carrying a `practice-id` identifier.\n * Never the project-wide list.\n */\n readonly practices: Organization[];\n /** Bare Organization id used by the selector and persisted in localStorage. */\n readonly selectedOrganizationId: string | undefined;\n /** FHIR reference for the selected practice, suitable for operation and hook inputs. */\n readonly selectedOrganization: Reference<Organization> | undefined;\n /** Selects a practice Organization (persisted to localStorage). */\n readonly setSelectedOrganizationId: (id: string | undefined) => void;\n readonly loading: boolean;\n}\n\nconst ScriptSurePracticeContext = createContext<ScriptSurePracticeContextValue>({\n practices: [],\n selectedOrganizationId: undefined,\n selectedOrganization: undefined,\n setSelectedOrganizationId: () => undefined,\n loading: false,\n});\n\nfunction addOrganizationReference(refs: Set<string>, reference: string | undefined): void {\n if (reference?.startsWith('Organization/')) {\n refs.add(reference);\n }\n}\n\nfunction hasPracticeIdentifier(org: Organization): boolean {\n return Boolean(getIdentifier(org, SCRIPTSURE_PRACTICE_ID_SYSTEM));\n}\n\n/**\n * Resolves the signed-in prescriber's `Practitioner.id` from the current profile,\n * whether the profile is a `Practitioner` or a `PractitionerRole`.\n *\n * @param profile - The current Medplum profile resource.\n * @returns The Practitioner id, or undefined when it cannot be resolved.\n */\nfunction resolvePractitionerId(profile: Practitioner | PractitionerRole | undefined): string | undefined {\n if (profile?.resourceType === 'Practitioner') {\n return profile.id;\n }\n if (profile?.resourceType === 'PractitionerRole') {\n return resolveId(profile.practitioner);\n }\n return undefined;\n}\n\n/**\n * Provides the signed-in prescriber's current ScriptSure practice-location\n * selection, discovered from **their own affiliations** \u2014 mirroring the server's\n * multi-practice resolver so the UI never offers a practice the prescriber is not\n * a member of.\n *\n * Discovery: active `PractitionerRole.organization` references for the current\n * `Practitioner` plus any `ProjectMembership.access[].parameter` named\n * `organization`, resolved to `Organization`s and filtered to those carrying a\n * `practice-id` identifier. The sole practice is auto-selected; a previously used\n * selection is restored only when it is still in the affiliation set.\n *\n * @param props - Component props.\n * @param props.children - Child nodes rendered within the provider.\n * @returns The context provider element.\n */\nexport function ScriptSurePracticeProvider(props: { readonly children: ReactNode }): JSX.Element {\n const medplum = useMedplum();\n const [practices, setPractices] = useState<Organization[]>([]);\n const [loading, setLoading] = useState(true);\n const [selectedOrganizationId, setSelected] = useState<string | undefined>(\n () => localStorage.getItem(STORAGE_KEY) ?? undefined\n );\n\n useEffect(() => {\n let cancelled = false;\n\n const loadAffiliatedPractices = async (): Promise<Organization[]> => {\n const profile = medplum.getProfile() as Practitioner | PractitionerRole | undefined;\n const practitionerId = resolvePractitionerId(profile);\n const references = new Set<string>();\n\n if (practitionerId) {\n const roles = await medplum.searchResources('PractitionerRole', {\n practitioner: `Practitioner/${practitionerId}`,\n _count: '100',\n });\n for (const role of roles) {\n // `active` is not a standard R4 PractitionerRole search param \u2014 filter in code.\n if (role.active !== false) {\n addOrganizationReference(references, role.organization?.reference);\n }\n }\n }\n\n const membership = medplum.getProjectMembership();\n for (const access of membership?.access ?? []) {\n for (const param of access.parameter ?? []) {\n if (param.name === 'organization') {\n addOrganizationReference(references, param.valueReference?.reference);\n }\n }\n }\n\n const settledOrgs = await Promise.allSettled(\n [...references].map((reference) => medplum.readReference<Organization>({ reference }))\n );\n const seen = new Set<string>();\n const result: Organization[] = [];\n for (const settledOrg of settledOrgs) {\n if (settledOrg.status === 'rejected') {\n continue;\n }\n const org = settledOrg.value;\n if (org.id && !seen.has(org.id) && hasPracticeIdentifier(org)) {\n seen.add(org.id);\n result.push(org);\n }\n }\n return result;\n };\n\n const updateAffiliatedPractices = async (): Promise<void> => {\n setLoading(true);\n try {\n const orgs = await loadAffiliatedPractices();\n if (!cancelled) {\n setPractices(orgs);\n // Default: keep a stored id only if it is still an affiliation; else the sole practice.\n setSelected((current) => {\n if (current && orgs.some((o) => o.id === current)) {\n return current;\n }\n return orgs.length === 1 ? orgs[0].id : undefined;\n });\n }\n } catch {\n if (!cancelled) {\n setPractices([]);\n }\n } finally {\n if (!cancelled) {\n setLoading(false);\n }\n }\n };\n updateAffiliatedPractices().catch(() => undefined);\n\n return (): void => {\n cancelled = true;\n };\n }, [medplum]);\n\n const setSelectedOrganizationId = useCallback((id: string | undefined): void => {\n setSelected(id);\n if (id) {\n localStorage.setItem(STORAGE_KEY, id);\n } else {\n localStorage.removeItem(STORAGE_KEY);\n }\n }, []);\n\n const selectedOrganization = useMemo<Reference<Organization> | undefined>(\n () => (selectedOrganizationId ? { reference: `Organization/${selectedOrganizationId}` } : undefined),\n [selectedOrganizationId]\n );\n\n const value = useMemo<ScriptSurePracticeContextValue>(\n () => ({ practices, selectedOrganizationId, selectedOrganization, setSelectedOrganizationId, loading }),\n [practices, selectedOrganizationId, selectedOrganization, setSelectedOrganizationId, loading]\n );\n\n return <ScriptSurePracticeContext.Provider value={value}>{props.children}</ScriptSurePracticeContext.Provider>;\n}\n\n/**\n * Hook returning the current ScriptSure practice selection + setter.\n *\n * @returns The practice context value.\n */\nexport function useScriptSurePractice(): ScriptSurePracticeContextValue {\n return useContext(ScriptSurePracticeContext);\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_react_hooks", "import_react_hooks", "import_react_hooks", "import_react_hooks", "import_core", "import_react_hooks"]
|
|
7
7
|
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { Identifier } from '@medplum/fhirtypes';
|
|
2
|
+
import type { JSX } from 'react';
|
|
2
3
|
import type { MedicationIFrameOptions } from '@medplum/react-hooks';
|
|
3
4
|
import type { MedicationOrderExtensions } from '@medplum/core';
|
|
4
5
|
import type { MedplumClient } from '@medplum/core';
|
|
6
|
+
import type { Organization } from '@medplum/fhirtypes';
|
|
5
7
|
import type { PharmacySearchParams } from '@medplum/core';
|
|
8
|
+
import type { ReactNode } from 'react';
|
|
9
|
+
import type { Reference } from '@medplum/fhirtypes';
|
|
10
|
+
import type { UseMedicationCartReturn } from '@medplum/react-hooks';
|
|
6
11
|
import type { UseMedicationOrderReturn } from '@medplum/react-hooks';
|
|
7
12
|
import type { UseMedicationOrderSetReturn } from '@medplum/react-hooks';
|
|
8
13
|
import type { UsePharmacySearchReturn } from '@medplum/react-hooks';
|
|
@@ -26,6 +31,9 @@ export declare const MEDPLUM_BOT_SYSTEM = "https://www.medplum.com/bots";
|
|
|
26
31
|
|
|
27
32
|
export declare const SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT: Identifier;
|
|
28
33
|
|
|
34
|
+
/** Identifier system for the ScriptSure `businessUnitId` on the BU-level Medplum `Organization`. */
|
|
35
|
+
export declare const SCRIPTSURE_BUSINESS_UNIT_ID_SYSTEM = "https://scriptsure.com/business-unit-id";
|
|
36
|
+
|
|
29
37
|
/** Default specialty filter for nearby retail pharmacy pickers. */
|
|
30
38
|
export declare const SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES: readonly ScriptSurePharmacySpecialty[];
|
|
31
39
|
|
|
@@ -40,6 +48,17 @@ export declare const SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES: readonly ScriptSur
|
|
|
40
48
|
*/
|
|
41
49
|
export declare const SCRIPTSURE_DRUG_SEARCH_BOT: Identifier;
|
|
42
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Identifier/coding system for the FDB GCN Sequence Number (`GCN_SEQNO`) — the
|
|
53
|
+
* clinical-formulation key (ingredient+strength+dose-form+route), independent of
|
|
54
|
+
* brand and NDC. Stamped as a `medicationCodeableConcept.coding` on the draft
|
|
55
|
+
* MedicationRequest so the ScriptSure prescription webhook can reconcile a draft
|
|
56
|
+
* to its sent prescription even when the NDC drifts or the pharmacy substitutes a
|
|
57
|
+
* generic (brand and generic share the same GCN). Mirrors the medplum-ee bot
|
|
58
|
+
* constant of the same name.
|
|
59
|
+
*/
|
|
60
|
+
export declare const SCRIPTSURE_GCN_SEQNO_SYSTEM = "https://scriptsure.com/gcn-seqno";
|
|
61
|
+
|
|
43
62
|
/** ScriptSure GenericName on a search-result Medication (parent generic when the row is a brand). */
|
|
44
63
|
export declare const SCRIPTSURE_GENERIC_NAME_EXTENSION = "https://scriptsure.com/generic-name";
|
|
45
64
|
|
|
@@ -49,6 +68,15 @@ export declare const SCRIPTSURE_IFRAME_URL_EXTENSION = "https://scriptsure.com/i
|
|
|
49
68
|
|
|
50
69
|
export declare const SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS: MedicationOrderExtensions;
|
|
51
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Identifier system for the SureScripts `messageId` stamped on a draft
|
|
73
|
+
* `MedicationRequest` by the cart-checkout flow (electronic-queue submit).
|
|
74
|
+
* Consumed by the paired `medplum-ee` `scriptsure-cart-checkout-bot` when
|
|
75
|
+
* stamping queued drafts and by `scriptsure-prescription-webhook-bot` when
|
|
76
|
+
* reconciling the approval webhook back to the originating draft.
|
|
77
|
+
*/
|
|
78
|
+
export declare const SCRIPTSURE_MESSAGE_ID_SYSTEM = "https://scriptsure.com/message-id";
|
|
79
|
+
|
|
52
80
|
/** ScriptSure MED_NAME_TYPE_CD on a search-result Medication: `'1'` = brand, `'2'` = generic. */
|
|
53
81
|
export declare const SCRIPTSURE_NAME_TYPE_EXTENSION = "https://scriptsure.com/name-type";
|
|
54
82
|
|
|
@@ -77,6 +105,9 @@ export declare const SCRIPTSURE_ORDER_SET_BOT: Identifier;
|
|
|
77
105
|
/** Identifier system for the ScriptSure orderset id stamped on FHIR PlanDefinitions. */
|
|
78
106
|
export declare const SCRIPTSURE_ORDERSET_ID_SYSTEM = "https://spa.scriptsure.com/orderset-id";
|
|
79
107
|
|
|
108
|
+
/** `Organization.type` coding system discriminating ScriptSure entity Organizations (`business-unit` | `practice`). */
|
|
109
|
+
export declare const SCRIPTSURE_ORGANIZATION_TYPE_SYSTEM = "https://scriptsure.com/organization-type";
|
|
110
|
+
|
|
80
111
|
export declare const SCRIPTSURE_PATIENT_ID_SYSTEM = "https://scriptsure.com/patient-id";
|
|
81
112
|
|
|
82
113
|
export declare const SCRIPTSURE_PATIENT_SYNC_BOT: Identifier;
|
|
@@ -85,9 +116,26 @@ export declare const SCRIPTSURE_PENDING_ORDER_ID_SYSTEM = "https://scriptsure.co
|
|
|
85
116
|
|
|
86
117
|
export declare const SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION = "https://scriptsure.com/pending-order-status";
|
|
87
118
|
|
|
119
|
+
/**
|
|
120
|
+
* `SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION` value marking a draft
|
|
121
|
+
* `MedicationRequest` as staged in the patient's ScriptSure MedCart (added by
|
|
122
|
+
* `$checkout-medications`, before the prescriber sends from the MedCart widget).
|
|
123
|
+
* Consumed by the paired `medplum-ee` cart-checkout / cart-manage bots when
|
|
124
|
+
* stamping drafts; the Provider App uses the pure-cart model (all drafts on the
|
|
125
|
+
* Draft tab) rather than filtering on this code today.
|
|
126
|
+
*/
|
|
127
|
+
export declare const SCRIPTSURE_PENDING_ORDER_STATUS_IN_CART = "in-cart";
|
|
128
|
+
|
|
88
129
|
/** Category filters shown in the ScriptSure pharmacy search dialog. */
|
|
89
130
|
export declare const SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS: readonly ScriptSurePharmacySpecialtyOption[];
|
|
90
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Identifier system for the ScriptSure `practiceId` stamped on the Practice-level
|
|
134
|
+
* Medplum `Organization`. Used by the practice/location selector to discover the
|
|
135
|
+
* prescriber's ScriptSure practices and pass the chosen `organizationId` to bots.
|
|
136
|
+
*/
|
|
137
|
+
export declare const SCRIPTSURE_PRACTICE_ID_SYSTEM = "https://scriptsure.com/practice-id";
|
|
138
|
+
|
|
91
139
|
/** Identifier system for ScriptSure ROUTED_MED_ID on in-memory Medication resources from drug search. */
|
|
92
140
|
export declare const SCRIPTSURE_ROUTED_MED_ID_SYSTEM = "https://scriptsure.com/routed-med-id";
|
|
93
141
|
|
|
@@ -120,10 +168,77 @@ export declare interface ScriptSurePharmacySpecialtyOption {
|
|
|
120
168
|
readonly label: string;
|
|
121
169
|
}
|
|
122
170
|
|
|
171
|
+
/** The current ScriptSure practice-location selection for the signed-in prescriber. */
|
|
172
|
+
export declare interface ScriptSurePracticeContextValue {
|
|
173
|
+
/**
|
|
174
|
+
* The prescriber's ScriptSure practice `Organization`s — discovered from their
|
|
175
|
+
* own affiliations (`PractitionerRole.organization` + `ProjectMembership.access`
|
|
176
|
+
* organization parameters), filtered to those carrying a `practice-id` identifier.
|
|
177
|
+
* Never the project-wide list.
|
|
178
|
+
*/
|
|
179
|
+
readonly practices: Organization[];
|
|
180
|
+
/** Bare Organization id used by the selector and persisted in localStorage. */
|
|
181
|
+
readonly selectedOrganizationId: string | undefined;
|
|
182
|
+
/** FHIR reference for the selected practice, suitable for operation and hook inputs. */
|
|
183
|
+
readonly selectedOrganization: Reference<Organization> | undefined;
|
|
184
|
+
/** Selects a practice Organization (persisted to localStorage). */
|
|
185
|
+
readonly setSelectedOrganizationId: (id: string | undefined) => void;
|
|
186
|
+
readonly loading: boolean;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Provides the signed-in prescriber's current ScriptSure practice-location
|
|
191
|
+
* selection, discovered from **their own affiliations** — mirroring the server's
|
|
192
|
+
* multi-practice resolver so the UI never offers a practice the prescriber is not
|
|
193
|
+
* a member of.
|
|
194
|
+
*
|
|
195
|
+
* Discovery: active `PractitionerRole.organization` references for the current
|
|
196
|
+
* `Practitioner` plus any `ProjectMembership.access[].parameter` named
|
|
197
|
+
* `organization`, resolved to `Organization`s and filtered to those carrying a
|
|
198
|
+
* `practice-id` identifier. The sole practice is auto-selected; a previously used
|
|
199
|
+
* selection is restored only when it is still in the affiliation set.
|
|
200
|
+
*
|
|
201
|
+
* @param props - Component props.
|
|
202
|
+
* @param props.children - Child nodes rendered within the provider.
|
|
203
|
+
* @returns The context provider element.
|
|
204
|
+
*/
|
|
205
|
+
export declare function ScriptSurePracticeProvider(props: {
|
|
206
|
+
readonly children: ReactNode;
|
|
207
|
+
}): JSX.Element;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* React hook for the ScriptSure **medication cart** lifecycle: add a draft
|
|
211
|
+
* `MedicationRequest` line (`createResource`), check out drafts into the
|
|
212
|
+
* patient's ScriptSure MedCart (`$checkout-medications` →
|
|
213
|
+
* `/widgets/medcart/{patientId}`), and remove/clear cart lines
|
|
214
|
+
* (`$remove-cart-medication` / `$clear-cart`).
|
|
215
|
+
*
|
|
216
|
+
* A near-empty re-export of `useMedicationCart` from `@medplum/react-hooks`: the
|
|
217
|
+
* vendor binding for the custom operations lives entirely on the server, where
|
|
218
|
+
* each Medplum project's `OperationDefinition`s point at the ScriptSure bots via
|
|
219
|
+
* the `operationDefinition-implementation` extension — see
|
|
220
|
+
* [Custom FHIR Operations](https://www.medplum.com/docs/bots/custom-fhir-operations).
|
|
221
|
+
* (Internal deploy: `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`.)
|
|
222
|
+
*
|
|
223
|
+
* `addToCart` is plain FHIR create (no vendor call); MedCart staging happens at
|
|
224
|
+
* `checkout`. DoseSpot and other iframe-first vendors do not use this surface.
|
|
225
|
+
*
|
|
226
|
+
* Kept as a typed alias for source-compatibility with apps importing
|
|
227
|
+
* `useScriptSureCart` and as a documentation anchor for ScriptSure-specific
|
|
228
|
+
* behavior (patient-must-be-synced precondition; cart items await sign-off in
|
|
229
|
+
* the MedCart widget).
|
|
230
|
+
*
|
|
231
|
+
* @returns The same API as `useMedicationCart` (`addToCart`, `adding`,
|
|
232
|
+
* `checkout`, `removeFromCart`, `clearCart`).
|
|
233
|
+
*/
|
|
234
|
+
export declare function useScriptSureCart(): UseScriptSureCartReturn;
|
|
235
|
+
|
|
236
|
+
export declare type UseScriptSureCartReturn = UseMedicationCartReturn;
|
|
237
|
+
|
|
123
238
|
/**
|
|
124
239
|
* React hook that syncs a patient to ScriptSure and returns the iframe URL.
|
|
125
240
|
*
|
|
126
|
-
* Thin wrapper around the generic {@link useMedicationIFrame} hook,
|
|
241
|
+
* Thin wrapper around the generic {@link @medplum/react-hooks#useMedicationIFrame} hook,
|
|
127
242
|
* pre-configured with ScriptSure bot identifiers.
|
|
128
243
|
*
|
|
129
244
|
* @param options - Configuration and callback options.
|
|
@@ -157,7 +272,7 @@ export declare type UseScriptSureOrderMedicationReturn = UseMedicationOrderRetur
|
|
|
157
272
|
* the vendor-neutral `$order-set-url` FHIR custom operation
|
|
158
273
|
* (`POST /fhir/R4/PlanDefinition/$order-set-url`).
|
|
159
274
|
*
|
|
160
|
-
* Thin wrapper around {@link useMedicationOrderSet}: forwards
|
|
275
|
+
* Thin wrapper around {@link @medplum/react-hooks#useMedicationOrderSet}: forwards
|
|
161
276
|
* `scriptSureOrdersetId` as the operation's `vendorOrderSetId` parameter,
|
|
162
277
|
* leaves vendor binding to the deployed `OperationDefinition` →
|
|
163
278
|
* `Bot/scriptsure-order-set-bot` link.
|
|
@@ -179,6 +294,8 @@ export declare interface UseScriptSureOrderSetOptions {
|
|
|
179
294
|
/** ScriptSure orderset id (escape hatch when no synced PD exists yet). */
|
|
180
295
|
readonly scriptSureOrdersetId?: number;
|
|
181
296
|
readonly appId?: string;
|
|
297
|
+
/** Selected practice location for multi-practice deployments. */
|
|
298
|
+
readonly organization?: Reference<Organization>;
|
|
182
299
|
}
|
|
183
300
|
|
|
184
301
|
export declare type UseScriptSureOrderSetReturn = UseMedicationOrderSetReturn;
|
|
@@ -186,7 +303,7 @@ export declare type UseScriptSureOrderSetReturn = UseMedicationOrderSetReturn;
|
|
|
186
303
|
/**
|
|
187
304
|
* React hook that provides ScriptSure-specific pharmacy search and add-to-favorites functionality.
|
|
188
305
|
*
|
|
189
|
-
* Thin wrapper around the generic {@link usePharmacySearch} hook, pre-configured with
|
|
306
|
+
* Thin wrapper around the generic {@link @medplum/react-hooks#usePharmacySearch} hook, pre-configured with
|
|
190
307
|
* ScriptSure bot identifiers and widened so search params carry ScriptSure-only
|
|
191
308
|
* `specialties` filters for POST /v3/pharmacy/search.
|
|
192
309
|
*
|
|
@@ -196,4 +313,11 @@ export declare function useScriptSurePharmacySearch(): UseScriptSurePharmacySear
|
|
|
196
313
|
|
|
197
314
|
export declare type UseScriptSurePharmacySearchReturn = UsePharmacySearchReturn<ScriptSurePharmacySearchParams>;
|
|
198
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Hook returning the current ScriptSure practice selection + setter.
|
|
318
|
+
*
|
|
319
|
+
* @returns The practice context value.
|
|
320
|
+
*/
|
|
321
|
+
export declare function useScriptSurePractice(): ScriptSurePracticeContextValue;
|
|
322
|
+
|
|
199
323
|
export { }
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { Identifier } from '@medplum/fhirtypes';
|
|
2
|
+
import type { JSX } from 'react';
|
|
2
3
|
import type { MedicationIFrameOptions } from '@medplum/react-hooks';
|
|
3
4
|
import type { MedicationOrderExtensions } from '@medplum/core';
|
|
4
5
|
import type { MedplumClient } from '@medplum/core';
|
|
6
|
+
import type { Organization } from '@medplum/fhirtypes';
|
|
5
7
|
import type { PharmacySearchParams } from '@medplum/core';
|
|
8
|
+
import type { ReactNode } from 'react';
|
|
9
|
+
import type { Reference } from '@medplum/fhirtypes';
|
|
10
|
+
import type { UseMedicationCartReturn } from '@medplum/react-hooks';
|
|
6
11
|
import type { UseMedicationOrderReturn } from '@medplum/react-hooks';
|
|
7
12
|
import type { UseMedicationOrderSetReturn } from '@medplum/react-hooks';
|
|
8
13
|
import type { UsePharmacySearchReturn } from '@medplum/react-hooks';
|
|
@@ -26,6 +31,9 @@ export declare const MEDPLUM_BOT_SYSTEM = "https://www.medplum.com/bots";
|
|
|
26
31
|
|
|
27
32
|
export declare const SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT: Identifier;
|
|
28
33
|
|
|
34
|
+
/** Identifier system for the ScriptSure `businessUnitId` on the BU-level Medplum `Organization`. */
|
|
35
|
+
export declare const SCRIPTSURE_BUSINESS_UNIT_ID_SYSTEM = "https://scriptsure.com/business-unit-id";
|
|
36
|
+
|
|
29
37
|
/** Default specialty filter for nearby retail pharmacy pickers. */
|
|
30
38
|
export declare const SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES: readonly ScriptSurePharmacySpecialty[];
|
|
31
39
|
|
|
@@ -40,6 +48,17 @@ export declare const SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES: readonly ScriptSur
|
|
|
40
48
|
*/
|
|
41
49
|
export declare const SCRIPTSURE_DRUG_SEARCH_BOT: Identifier;
|
|
42
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Identifier/coding system for the FDB GCN Sequence Number (`GCN_SEQNO`) — the
|
|
53
|
+
* clinical-formulation key (ingredient+strength+dose-form+route), independent of
|
|
54
|
+
* brand and NDC. Stamped as a `medicationCodeableConcept.coding` on the draft
|
|
55
|
+
* MedicationRequest so the ScriptSure prescription webhook can reconcile a draft
|
|
56
|
+
* to its sent prescription even when the NDC drifts or the pharmacy substitutes a
|
|
57
|
+
* generic (brand and generic share the same GCN). Mirrors the medplum-ee bot
|
|
58
|
+
* constant of the same name.
|
|
59
|
+
*/
|
|
60
|
+
export declare const SCRIPTSURE_GCN_SEQNO_SYSTEM = "https://scriptsure.com/gcn-seqno";
|
|
61
|
+
|
|
43
62
|
/** ScriptSure GenericName on a search-result Medication (parent generic when the row is a brand). */
|
|
44
63
|
export declare const SCRIPTSURE_GENERIC_NAME_EXTENSION = "https://scriptsure.com/generic-name";
|
|
45
64
|
|
|
@@ -49,6 +68,15 @@ export declare const SCRIPTSURE_IFRAME_URL_EXTENSION = "https://scriptsure.com/i
|
|
|
49
68
|
|
|
50
69
|
export declare const SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS: MedicationOrderExtensions;
|
|
51
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Identifier system for the SureScripts `messageId` stamped on a draft
|
|
73
|
+
* `MedicationRequest` by the cart-checkout flow (electronic-queue submit).
|
|
74
|
+
* Consumed by the paired `medplum-ee` `scriptsure-cart-checkout-bot` when
|
|
75
|
+
* stamping queued drafts and by `scriptsure-prescription-webhook-bot` when
|
|
76
|
+
* reconciling the approval webhook back to the originating draft.
|
|
77
|
+
*/
|
|
78
|
+
export declare const SCRIPTSURE_MESSAGE_ID_SYSTEM = "https://scriptsure.com/message-id";
|
|
79
|
+
|
|
52
80
|
/** ScriptSure MED_NAME_TYPE_CD on a search-result Medication: `'1'` = brand, `'2'` = generic. */
|
|
53
81
|
export declare const SCRIPTSURE_NAME_TYPE_EXTENSION = "https://scriptsure.com/name-type";
|
|
54
82
|
|
|
@@ -77,6 +105,9 @@ export declare const SCRIPTSURE_ORDER_SET_BOT: Identifier;
|
|
|
77
105
|
/** Identifier system for the ScriptSure orderset id stamped on FHIR PlanDefinitions. */
|
|
78
106
|
export declare const SCRIPTSURE_ORDERSET_ID_SYSTEM = "https://spa.scriptsure.com/orderset-id";
|
|
79
107
|
|
|
108
|
+
/** `Organization.type` coding system discriminating ScriptSure entity Organizations (`business-unit` | `practice`). */
|
|
109
|
+
export declare const SCRIPTSURE_ORGANIZATION_TYPE_SYSTEM = "https://scriptsure.com/organization-type";
|
|
110
|
+
|
|
80
111
|
export declare const SCRIPTSURE_PATIENT_ID_SYSTEM = "https://scriptsure.com/patient-id";
|
|
81
112
|
|
|
82
113
|
export declare const SCRIPTSURE_PATIENT_SYNC_BOT: Identifier;
|
|
@@ -85,9 +116,26 @@ export declare const SCRIPTSURE_PENDING_ORDER_ID_SYSTEM = "https://scriptsure.co
|
|
|
85
116
|
|
|
86
117
|
export declare const SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION = "https://scriptsure.com/pending-order-status";
|
|
87
118
|
|
|
119
|
+
/**
|
|
120
|
+
* `SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION` value marking a draft
|
|
121
|
+
* `MedicationRequest` as staged in the patient's ScriptSure MedCart (added by
|
|
122
|
+
* `$checkout-medications`, before the prescriber sends from the MedCart widget).
|
|
123
|
+
* Consumed by the paired `medplum-ee` cart-checkout / cart-manage bots when
|
|
124
|
+
* stamping drafts; the Provider App uses the pure-cart model (all drafts on the
|
|
125
|
+
* Draft tab) rather than filtering on this code today.
|
|
126
|
+
*/
|
|
127
|
+
export declare const SCRIPTSURE_PENDING_ORDER_STATUS_IN_CART = "in-cart";
|
|
128
|
+
|
|
88
129
|
/** Category filters shown in the ScriptSure pharmacy search dialog. */
|
|
89
130
|
export declare const SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS: readonly ScriptSurePharmacySpecialtyOption[];
|
|
90
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Identifier system for the ScriptSure `practiceId` stamped on the Practice-level
|
|
134
|
+
* Medplum `Organization`. Used by the practice/location selector to discover the
|
|
135
|
+
* prescriber's ScriptSure practices and pass the chosen `organizationId` to bots.
|
|
136
|
+
*/
|
|
137
|
+
export declare const SCRIPTSURE_PRACTICE_ID_SYSTEM = "https://scriptsure.com/practice-id";
|
|
138
|
+
|
|
91
139
|
/** Identifier system for ScriptSure ROUTED_MED_ID on in-memory Medication resources from drug search. */
|
|
92
140
|
export declare const SCRIPTSURE_ROUTED_MED_ID_SYSTEM = "https://scriptsure.com/routed-med-id";
|
|
93
141
|
|
|
@@ -120,10 +168,77 @@ export declare interface ScriptSurePharmacySpecialtyOption {
|
|
|
120
168
|
readonly label: string;
|
|
121
169
|
}
|
|
122
170
|
|
|
171
|
+
/** The current ScriptSure practice-location selection for the signed-in prescriber. */
|
|
172
|
+
export declare interface ScriptSurePracticeContextValue {
|
|
173
|
+
/**
|
|
174
|
+
* The prescriber's ScriptSure practice `Organization`s — discovered from their
|
|
175
|
+
* own affiliations (`PractitionerRole.organization` + `ProjectMembership.access`
|
|
176
|
+
* organization parameters), filtered to those carrying a `practice-id` identifier.
|
|
177
|
+
* Never the project-wide list.
|
|
178
|
+
*/
|
|
179
|
+
readonly practices: Organization[];
|
|
180
|
+
/** Bare Organization id used by the selector and persisted in localStorage. */
|
|
181
|
+
readonly selectedOrganizationId: string | undefined;
|
|
182
|
+
/** FHIR reference for the selected practice, suitable for operation and hook inputs. */
|
|
183
|
+
readonly selectedOrganization: Reference<Organization> | undefined;
|
|
184
|
+
/** Selects a practice Organization (persisted to localStorage). */
|
|
185
|
+
readonly setSelectedOrganizationId: (id: string | undefined) => void;
|
|
186
|
+
readonly loading: boolean;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Provides the signed-in prescriber's current ScriptSure practice-location
|
|
191
|
+
* selection, discovered from **their own affiliations** — mirroring the server's
|
|
192
|
+
* multi-practice resolver so the UI never offers a practice the prescriber is not
|
|
193
|
+
* a member of.
|
|
194
|
+
*
|
|
195
|
+
* Discovery: active `PractitionerRole.organization` references for the current
|
|
196
|
+
* `Practitioner` plus any `ProjectMembership.access[].parameter` named
|
|
197
|
+
* `organization`, resolved to `Organization`s and filtered to those carrying a
|
|
198
|
+
* `practice-id` identifier. The sole practice is auto-selected; a previously used
|
|
199
|
+
* selection is restored only when it is still in the affiliation set.
|
|
200
|
+
*
|
|
201
|
+
* @param props - Component props.
|
|
202
|
+
* @param props.children - Child nodes rendered within the provider.
|
|
203
|
+
* @returns The context provider element.
|
|
204
|
+
*/
|
|
205
|
+
export declare function ScriptSurePracticeProvider(props: {
|
|
206
|
+
readonly children: ReactNode;
|
|
207
|
+
}): JSX.Element;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* React hook for the ScriptSure **medication cart** lifecycle: add a draft
|
|
211
|
+
* `MedicationRequest` line (`createResource`), check out drafts into the
|
|
212
|
+
* patient's ScriptSure MedCart (`$checkout-medications` →
|
|
213
|
+
* `/widgets/medcart/{patientId}`), and remove/clear cart lines
|
|
214
|
+
* (`$remove-cart-medication` / `$clear-cart`).
|
|
215
|
+
*
|
|
216
|
+
* A near-empty re-export of `useMedicationCart` from `@medplum/react-hooks`: the
|
|
217
|
+
* vendor binding for the custom operations lives entirely on the server, where
|
|
218
|
+
* each Medplum project's `OperationDefinition`s point at the ScriptSure bots via
|
|
219
|
+
* the `operationDefinition-implementation` extension — see
|
|
220
|
+
* [Custom FHIR Operations](https://www.medplum.com/docs/bots/custom-fhir-operations).
|
|
221
|
+
* (Internal deploy: `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`.)
|
|
222
|
+
*
|
|
223
|
+
* `addToCart` is plain FHIR create (no vendor call); MedCart staging happens at
|
|
224
|
+
* `checkout`. DoseSpot and other iframe-first vendors do not use this surface.
|
|
225
|
+
*
|
|
226
|
+
* Kept as a typed alias for source-compatibility with apps importing
|
|
227
|
+
* `useScriptSureCart` and as a documentation anchor for ScriptSure-specific
|
|
228
|
+
* behavior (patient-must-be-synced precondition; cart items await sign-off in
|
|
229
|
+
* the MedCart widget).
|
|
230
|
+
*
|
|
231
|
+
* @returns The same API as `useMedicationCart` (`addToCart`, `adding`,
|
|
232
|
+
* `checkout`, `removeFromCart`, `clearCart`).
|
|
233
|
+
*/
|
|
234
|
+
export declare function useScriptSureCart(): UseScriptSureCartReturn;
|
|
235
|
+
|
|
236
|
+
export declare type UseScriptSureCartReturn = UseMedicationCartReturn;
|
|
237
|
+
|
|
123
238
|
/**
|
|
124
239
|
* React hook that syncs a patient to ScriptSure and returns the iframe URL.
|
|
125
240
|
*
|
|
126
|
-
* Thin wrapper around the generic {@link useMedicationIFrame} hook,
|
|
241
|
+
* Thin wrapper around the generic {@link @medplum/react-hooks#useMedicationIFrame} hook,
|
|
127
242
|
* pre-configured with ScriptSure bot identifiers.
|
|
128
243
|
*
|
|
129
244
|
* @param options - Configuration and callback options.
|
|
@@ -157,7 +272,7 @@ export declare type UseScriptSureOrderMedicationReturn = UseMedicationOrderRetur
|
|
|
157
272
|
* the vendor-neutral `$order-set-url` FHIR custom operation
|
|
158
273
|
* (`POST /fhir/R4/PlanDefinition/$order-set-url`).
|
|
159
274
|
*
|
|
160
|
-
* Thin wrapper around {@link useMedicationOrderSet}: forwards
|
|
275
|
+
* Thin wrapper around {@link @medplum/react-hooks#useMedicationOrderSet}: forwards
|
|
161
276
|
* `scriptSureOrdersetId` as the operation's `vendorOrderSetId` parameter,
|
|
162
277
|
* leaves vendor binding to the deployed `OperationDefinition` →
|
|
163
278
|
* `Bot/scriptsure-order-set-bot` link.
|
|
@@ -179,6 +294,8 @@ export declare interface UseScriptSureOrderSetOptions {
|
|
|
179
294
|
/** ScriptSure orderset id (escape hatch when no synced PD exists yet). */
|
|
180
295
|
readonly scriptSureOrdersetId?: number;
|
|
181
296
|
readonly appId?: string;
|
|
297
|
+
/** Selected practice location for multi-practice deployments. */
|
|
298
|
+
readonly organization?: Reference<Organization>;
|
|
182
299
|
}
|
|
183
300
|
|
|
184
301
|
export declare type UseScriptSureOrderSetReturn = UseMedicationOrderSetReturn;
|
|
@@ -186,7 +303,7 @@ export declare type UseScriptSureOrderSetReturn = UseMedicationOrderSetReturn;
|
|
|
186
303
|
/**
|
|
187
304
|
* React hook that provides ScriptSure-specific pharmacy search and add-to-favorites functionality.
|
|
188
305
|
*
|
|
189
|
-
* Thin wrapper around the generic {@link usePharmacySearch} hook, pre-configured with
|
|
306
|
+
* Thin wrapper around the generic {@link @medplum/react-hooks#usePharmacySearch} hook, pre-configured with
|
|
190
307
|
* ScriptSure bot identifiers and widened so search params carry ScriptSure-only
|
|
191
308
|
* `specialties` filters for POST /v3/pharmacy/search.
|
|
192
309
|
*
|
|
@@ -196,4 +313,11 @@ export declare function useScriptSurePharmacySearch(): UseScriptSurePharmacySear
|
|
|
196
313
|
|
|
197
314
|
export declare type UseScriptSurePharmacySearchReturn = UsePharmacySearchReturn<ScriptSurePharmacySearchParams>;
|
|
198
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Hook returning the current ScriptSure practice selection + setter.
|
|
318
|
+
*
|
|
319
|
+
* @returns The practice context value.
|
|
320
|
+
*/
|
|
321
|
+
export declare function useScriptSurePractice(): ScriptSurePracticeContextValue;
|
|
322
|
+
|
|
199
323
|
export { }
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var MEDPLUM_BOT_SYSTEM="https://www.medplum.com/bots",SCRIPTSURE_DRUG_SEARCH_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-drug-search-bot"},SCRIPTSURE_ORDER_MEDICATION_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-order-medication-bot"},SCRIPTSURE_ROUTED_MED_ID_SYSTEM="https://scriptsure.com/routed-med-id",SCRIPTSURE_PENDING_ORDER_ID_SYSTEM="https://scriptsure.com/pending-order-id",SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION="https://scriptsure.com/pending-order-status",SCRIPTSURE_IFRAME_URL_EXTENSION="https://scriptsure.com/iframe-url",SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS={pendingOrderIdSystem:SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,pendingOrderStatusUrl:SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,iframeUrlExtension:SCRIPTSURE_IFRAME_URL_EXTENSION},SCRIPTSURE_IFRAME_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-iframe-bot"},SCRIPTSURE_PATIENT_SYNC_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-patient-sync-bot"},SCRIPTSURE_ORDER_SET_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-order-set-bot"},SCRIPTSURE_ORDERSET_ID_SYSTEM="https://spa.scriptsure.com/orderset-id",SCRIPTSURE_SEARCH_PHARMACY_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-search-pharmacy-bot"},SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-add-patient-pharmacy-bot"},SCRIPTSURE_PATIENT_ID_SYSTEM="https://scriptsure.com/patient-id",SCRIPTSURE_SYSTEM="https://scriptsure.com",SCRIPTSURE_SIG_EXTENSION=`${SCRIPTSURE_SYSTEM}/sig`,SCRIPTSURE_NAME_TYPE_EXTENSION=`${SCRIPTSURE_SYSTEM}/name-type`,SCRIPTSURE_GENERIC_NAME_EXTENSION=`${SCRIPTSURE_SYSTEM}/generic-name`;import{isResource,medicationSearchParamsToParameters}from"@medplum/core";function parametersToQuantityQualifiers(params){let rows=[];for(let p of params.parameter??[]){if(p.name!=="quantityQualifier"||!p.part)continue;let code=p.part.find(part=>part.name==="code")?.valueString,label=p.part.find(part=>part.name==="label")?.valueString;typeof code=="string"&&typeof label=="string"&&rows.push({code,label})}return rows}async function loadScriptSureQuantityQualifiers(medplum){let url=medplum.fhirUrl("Medication","$drug-quantity-qualifiers"),body=medicationSearchParamsToParameters({quantityQualifiers:!0}),response=await medplum.post(url,body);return isResource(response,"Parameters")?parametersToQuantityQualifiers(response):[]}var SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS=[{value:"Retail",label:"Retail"},{value:"MailOrder",label:"Mail order"},{value:"TwentyFourHourStore",label:"24-hour"},{value:"LongTermCare",label:"Long-term care"},{value:"Specialty",label:"Specialty"},{value:"SupportsDigitalSignature",label:"Digital signature"},{value:"FaxPharmacySurescripts",label:"Fax (Surescripts)"}],SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES=["Retail"];import{useMedicationIFrame}from"@medplum/react-hooks";function useScriptSureIFrame(options){return useMedicationIFrame(SCRIPTSURE_PATIENT_SYNC_BOT,SCRIPTSURE_IFRAME_BOT,options)}import{useMedicationOrder}from"@medplum/react-hooks";function useScriptSureOrderMedication(){return useMedicationOrder()}import{useMedicationOrderSet}from"@medplum/react-hooks";function useScriptSureOrderSet(options){return useMedicationOrderSet({patientId:options.patientId,planDefinitionId:options.planDefinitionId,vendorOrderSetId:options.scriptSureOrdersetId,appId:options.appId})}import{usePharmacySearch}from"@medplum/react-hooks";function useScriptSurePharmacySearch(){return usePharmacySearch(SCRIPTSURE_SEARCH_PHARMACY_BOT,SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT)}export{MEDPLUM_BOT_SYSTEM,SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT,SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES,SCRIPTSURE_DRUG_SEARCH_BOT,SCRIPTSURE_GENERIC_NAME_EXTENSION,SCRIPTSURE_IFRAME_BOT,SCRIPTSURE_IFRAME_URL_EXTENSION,SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS,SCRIPTSURE_NAME_TYPE_EXTENSION,SCRIPTSURE_ORDERSET_ID_SYSTEM,SCRIPTSURE_ORDER_MEDICATION_BOT,SCRIPTSURE_ORDER_SET_BOT,SCRIPTSURE_PATIENT_ID_SYSTEM,SCRIPTSURE_PATIENT_SYNC_BOT,SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS,SCRIPTSURE_ROUTED_MED_ID_SYSTEM,SCRIPTSURE_SEARCH_PHARMACY_BOT,SCRIPTSURE_SIG_EXTENSION,SCRIPTSURE_SYSTEM,loadScriptSureQuantityQualifiers,useScriptSureIFrame,useScriptSureOrderMedication,useScriptSureOrderSet,useScriptSurePharmacySearch};
|
|
1
|
+
var MEDPLUM_BOT_SYSTEM="https://www.medplum.com/bots",SCRIPTSURE_DRUG_SEARCH_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-drug-search-bot"},SCRIPTSURE_ORDER_MEDICATION_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-order-medication-bot"},SCRIPTSURE_ROUTED_MED_ID_SYSTEM="https://scriptsure.com/routed-med-id",SCRIPTSURE_GCN_SEQNO_SYSTEM="https://scriptsure.com/gcn-seqno",SCRIPTSURE_PENDING_ORDER_ID_SYSTEM="https://scriptsure.com/pending-order-id",SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION="https://scriptsure.com/pending-order-status",SCRIPTSURE_PENDING_ORDER_STATUS_IN_CART="in-cart",SCRIPTSURE_IFRAME_URL_EXTENSION="https://scriptsure.com/iframe-url",SCRIPTSURE_MESSAGE_ID_SYSTEM="https://scriptsure.com/message-id",SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS={pendingOrderIdSystem:SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,pendingOrderStatusUrl:SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,iframeUrlExtension:SCRIPTSURE_IFRAME_URL_EXTENSION,messageIdSystem:SCRIPTSURE_MESSAGE_ID_SYSTEM},SCRIPTSURE_IFRAME_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-iframe-bot"},SCRIPTSURE_PATIENT_SYNC_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-patient-sync-bot"},SCRIPTSURE_ORDER_SET_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-order-set-bot"},SCRIPTSURE_ORDERSET_ID_SYSTEM="https://spa.scriptsure.com/orderset-id",SCRIPTSURE_SEARCH_PHARMACY_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-search-pharmacy-bot"},SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-add-patient-pharmacy-bot"},SCRIPTSURE_PATIENT_ID_SYSTEM="https://scriptsure.com/patient-id",SCRIPTSURE_PRACTICE_ID_SYSTEM="https://scriptsure.com/practice-id",SCRIPTSURE_BUSINESS_UNIT_ID_SYSTEM="https://scriptsure.com/business-unit-id",SCRIPTSURE_ORGANIZATION_TYPE_SYSTEM="https://scriptsure.com/organization-type",SCRIPTSURE_SYSTEM="https://scriptsure.com",SCRIPTSURE_SIG_EXTENSION=`${SCRIPTSURE_SYSTEM}/sig`,SCRIPTSURE_NAME_TYPE_EXTENSION=`${SCRIPTSURE_SYSTEM}/name-type`,SCRIPTSURE_GENERIC_NAME_EXTENSION=`${SCRIPTSURE_SYSTEM}/generic-name`;import{isResource,medicationSearchParamsToParameters}from"@medplum/core";function parametersToQuantityQualifiers(params){let rows=[];for(let p of params.parameter??[]){if(p.name!=="quantityQualifier"||!p.part)continue;let code=p.part.find(part=>part.name==="code")?.valueString,label=p.part.find(part=>part.name==="label")?.valueString;typeof code=="string"&&typeof label=="string"&&rows.push({code,label})}return rows}async function loadScriptSureQuantityQualifiers(medplum){let url=medplum.fhirUrl("Medication","$drug-quantity-qualifiers"),body=medicationSearchParamsToParameters({quantityQualifiers:!0}),response=await medplum.post(url,body);return isResource(response,"Parameters")?parametersToQuantityQualifiers(response):[]}var SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS=[{value:"Retail",label:"Retail"},{value:"MailOrder",label:"Mail order"},{value:"TwentyFourHourStore",label:"24-hour"},{value:"LongTermCare",label:"Long-term care"},{value:"Specialty",label:"Specialty"},{value:"SupportsDigitalSignature",label:"Digital signature"},{value:"FaxPharmacySurescripts",label:"Fax (Surescripts)"}],SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES=["Retail"];import{useMedicationCart}from"@medplum/react-hooks";function useScriptSureCart(){return useMedicationCart()}import{useMedicationIFrame}from"@medplum/react-hooks";function useScriptSureIFrame(options){return useMedicationIFrame(SCRIPTSURE_PATIENT_SYNC_BOT,SCRIPTSURE_IFRAME_BOT,options)}import{useMedicationOrder}from"@medplum/react-hooks";function useScriptSureOrderMedication(){return useMedicationOrder()}import{useMedicationOrderSet}from"@medplum/react-hooks";function useScriptSureOrderSet(options){return useMedicationOrderSet({patientId:options.patientId,planDefinitionId:options.planDefinitionId,vendorOrderSetId:options.scriptSureOrdersetId,appId:options.appId,organization:options.organization})}import{usePharmacySearch}from"@medplum/react-hooks";function useScriptSurePharmacySearch(){return usePharmacySearch(SCRIPTSURE_SEARCH_PHARMACY_BOT,SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT)}import{getIdentifier,resolveId}from"@medplum/core";import{useMedplum}from"@medplum/react-hooks";import{createContext,useCallback,useContext,useEffect,useMemo,useState}from"react";import{jsx}from"react/jsx-runtime";var STORAGE_KEY="medplum.scriptsure.selectedPracticeOrganization",ScriptSurePracticeContext=createContext({practices:[],selectedOrganizationId:void 0,selectedOrganization:void 0,setSelectedOrganizationId:()=>{},loading:!1});function addOrganizationReference(refs,reference){reference?.startsWith("Organization/")&&refs.add(reference)}function hasPracticeIdentifier(org){return!!getIdentifier(org,SCRIPTSURE_PRACTICE_ID_SYSTEM)}function resolvePractitionerId(profile){if(profile?.resourceType==="Practitioner")return profile.id;if(profile?.resourceType==="PractitionerRole")return resolveId(profile.practitioner)}function ScriptSurePracticeProvider(props){let medplum=useMedplum(),[practices,setPractices]=useState([]),[loading,setLoading]=useState(!0),[selectedOrganizationId,setSelected]=useState(()=>localStorage.getItem(STORAGE_KEY)??void 0);useEffect(()=>{let cancelled=!1,loadAffiliatedPractices=async()=>{let profile=medplum.getProfile(),practitionerId=resolvePractitionerId(profile),references=new Set;if(practitionerId){let roles=await medplum.searchResources("PractitionerRole",{practitioner:`Practitioner/${practitionerId}`,_count:"100"});for(let role of roles)role.active!==!1&&addOrganizationReference(references,role.organization?.reference)}let membership=medplum.getProjectMembership();for(let access of membership?.access??[])for(let param of access.parameter??[])param.name==="organization"&&addOrganizationReference(references,param.valueReference?.reference);let settledOrgs=await Promise.allSettled([...references].map(reference=>medplum.readReference({reference}))),seen=new Set,result=[];for(let settledOrg of settledOrgs){if(settledOrg.status==="rejected")continue;let org=settledOrg.value;org.id&&!seen.has(org.id)&&hasPracticeIdentifier(org)&&(seen.add(org.id),result.push(org))}return result};return(async()=>{setLoading(!0);try{let orgs=await loadAffiliatedPractices();cancelled||(setPractices(orgs),setSelected(current=>current&&orgs.some(o=>o.id===current)?current:orgs.length===1?orgs[0].id:void 0))}catch{cancelled||setPractices([])}finally{cancelled||setLoading(!1)}})().catch(()=>{}),()=>{cancelled=!0}},[medplum]);let setSelectedOrganizationId=useCallback(id=>{setSelected(id),id?localStorage.setItem(STORAGE_KEY,id):localStorage.removeItem(STORAGE_KEY)},[]),selectedOrganization=useMemo(()=>selectedOrganizationId?{reference:`Organization/${selectedOrganizationId}`}:void 0,[selectedOrganizationId]),value=useMemo(()=>({practices,selectedOrganizationId,selectedOrganization,setSelectedOrganizationId,loading}),[practices,selectedOrganizationId,selectedOrganization,setSelectedOrganizationId,loading]);return jsx(ScriptSurePracticeContext.Provider,{value,children:props.children})}function useScriptSurePractice(){return useContext(ScriptSurePracticeContext)}export{MEDPLUM_BOT_SYSTEM,SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT,SCRIPTSURE_BUSINESS_UNIT_ID_SYSTEM,SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES,SCRIPTSURE_DRUG_SEARCH_BOT,SCRIPTSURE_GCN_SEQNO_SYSTEM,SCRIPTSURE_GENERIC_NAME_EXTENSION,SCRIPTSURE_IFRAME_BOT,SCRIPTSURE_IFRAME_URL_EXTENSION,SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS,SCRIPTSURE_MESSAGE_ID_SYSTEM,SCRIPTSURE_NAME_TYPE_EXTENSION,SCRIPTSURE_ORDERSET_ID_SYSTEM,SCRIPTSURE_ORDER_MEDICATION_BOT,SCRIPTSURE_ORDER_SET_BOT,SCRIPTSURE_ORGANIZATION_TYPE_SYSTEM,SCRIPTSURE_PATIENT_ID_SYSTEM,SCRIPTSURE_PATIENT_SYNC_BOT,SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,SCRIPTSURE_PENDING_ORDER_STATUS_IN_CART,SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS,SCRIPTSURE_PRACTICE_ID_SYSTEM,SCRIPTSURE_ROUTED_MED_ID_SYSTEM,SCRIPTSURE_SEARCH_PHARMACY_BOT,SCRIPTSURE_SIG_EXTENSION,SCRIPTSURE_SYSTEM,ScriptSurePracticeProvider,loadScriptSureQuantityQualifiers,useScriptSureCart,useScriptSureIFrame,useScriptSureOrderMedication,useScriptSureOrderSet,useScriptSurePharmacySearch,useScriptSurePractice};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/common.ts", "../../src/loadScriptSureQuantityQualifiers.ts", "../../src/pharmacy-search.ts", "../../src/useScriptSureIFrame.ts", "../../src/useScriptSureOrderMedication.ts", "../../src/useScriptSureOrderSet.ts", "../../src/useScriptSurePharmacySearch.ts"],
|
|
4
|
-
"sourcesContent": ["// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { MedicationOrderExtensions } from '@medplum/core';\nimport type { Identifier } from '@medplum/fhirtypes';\n\nexport const MEDPLUM_BOT_SYSTEM = 'https://www.medplum.com/bots';\n\n/**\n * @deprecated Use the vendor-neutral `$drug-search` custom FHIR operation via\n * `useMedicationOrder().searchMedications(...)` (see `@medplum/react-hooks`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `drug-search` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_DRUG_SEARCH_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-drug-search-bot',\n};\n\n/**\n * @deprecated Use the vendor-neutral `$order-medication` custom FHIR operation via\n * `useMedicationOrder().orderMedication(...)` (see `@medplum/react-hooks`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `order-medication` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_ORDER_MEDICATION_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-order-medication-bot',\n};\n\n/** Identifier system for ScriptSure ROUTED_MED_ID on in-memory Medication resources from drug search. */\nexport const SCRIPTSURE_ROUTED_MED_ID_SYSTEM = 'https://scriptsure.com/routed-med-id';\n\nexport const SCRIPTSURE_PENDING_ORDER_ID_SYSTEM = 'https://scriptsure.com/pending-order-id';\n\nexport const SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION = 'https://scriptsure.com/pending-order-status';\n\nexport const SCRIPTSURE_IFRAME_URL_EXTENSION = 'https://scriptsure.com/iframe-url';\n\nexport const SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS: MedicationOrderExtensions = {\n pendingOrderIdSystem: SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,\n pendingOrderStatusUrl: SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,\n iframeUrlExtension: SCRIPTSURE_IFRAME_URL_EXTENSION,\n};\n\nexport const SCRIPTSURE_IFRAME_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-iframe-bot',\n};\n\nexport const SCRIPTSURE_PATIENT_SYNC_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-patient-sync-bot',\n};\n\n/**\n * @deprecated Use the vendor-neutral `$order-set-url` custom FHIR operation via\n * `useScriptSureOrderSet(...)` (thin wrapper around `useMedicationOrderSet`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `order-set-url` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_ORDER_SET_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-order-set-bot',\n};\n\n/** Identifier system for the ScriptSure orderset id stamped on FHIR PlanDefinitions. */\nexport const SCRIPTSURE_ORDERSET_ID_SYSTEM = 'https://spa.scriptsure.com/orderset-id';\n\nexport const SCRIPTSURE_SEARCH_PHARMACY_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-search-pharmacy-bot',\n};\n\nexport const SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-add-patient-pharmacy-bot',\n};\n\nexport const SCRIPTSURE_PATIENT_ID_SYSTEM = 'https://scriptsure.com/patient-id';\n\n/** Base URL for ScriptSure-specific extensions on in-memory Medication resources (e.g. `/sig`). */\nexport const SCRIPTSURE_SYSTEM = 'https://scriptsure.com';\n\n/** Pre-built dosing option on a Medication from drug-format lookup (`routedMedId` search). */\nexport const SCRIPTSURE_SIG_EXTENSION = `${SCRIPTSURE_SYSTEM}/sig`;\n\n/** ScriptSure MED_NAME_TYPE_CD on a search-result Medication: `'1'` = brand, `'2'` = generic. */\nexport const SCRIPTSURE_NAME_TYPE_EXTENSION = `${SCRIPTSURE_SYSTEM}/name-type`;\n\n/** ScriptSure GenericName on a search-result Medication (parent generic when the row is a brand). */\nexport const SCRIPTSURE_GENERIC_NAME_EXTENSION = `${SCRIPTSURE_SYSTEM}/generic-name`;\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { MedplumClient } from '@medplum/core';\nimport { isResource, medicationSearchParamsToParameters } from '@medplum/core';\nimport type { Parameters } from '@medplum/fhirtypes';\n\n/**\n * Reads `{ code, label }` rows from a `Parameters` resource produced by the\n * `$drug-quantity-qualifiers` custom operation.\n *\n * The OperationDefinition (see `scriptsure-drug-search-bot` registration in\n * `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`) declares a single\n * repeating output parameter named `quantityQualifier`, each entry bearing\n * `part: [{ name: 'code', valueString }, { name: 'label', valueString }]`.\n * The server's `buildOutputParameters` wraps the bot return value into that\n * shape, so the parser only needs to handle this one canonical layout.\n * Entries missing either inner part are skipped defensively.\n *\n * @param params - `Parameters` resource returned by the operation.\n * @returns `{ code, label }` rows for UI selects.\n */\nfunction parametersToQuantityQualifiers(params: Parameters): { code: string; label: string }[] {\n const rows: { code: string; label: string }[] = [];\n for (const p of params.parameter ?? []) {\n if (p.name !== 'quantityQualifier' || !p.part) {\n continue;\n }\n const code = p.part.find((part) => part.name === 'code')?.valueString;\n const label = p.part.find((part) => part.name === 'label')?.valueString;\n if (typeof code === 'string' && typeof label === 'string') {\n rows.push({ code, label });\n }\n }\n return rows;\n}\n\n/**\n * Fetches NCI potency-unit codes for dispense quantity qualifiers via the\n * vendor-neutral `$drug-quantity-qualifiers` custom FHIR operation. Each\n * Medplum project picks the vendor implementation at deploy time by pointing\n * its `OperationDefinition` at the appropriate Bot (ScriptSure's\n * `scriptsure-drug-search-bot` today; see `deploy.ts`).\n *\n * @param medplum - Medplum client (user session).\n * @returns `{ code, label }` rows for UI selects.\n */\nexport async function loadScriptSureQuantityQualifiers(\n medplum: MedplumClient\n): Promise<{ code: string; label: string }[]> {\n const url = medplum.fhirUrl('Medication', '$drug-quantity-qualifiers');\n const body = medicationSearchParamsToParameters({ quantityQualifiers: true });\n const response = await medplum.post(url, body);\n if (!isResource<Parameters>(response, 'Parameters')) {\n return [];\n }\n return parametersToQuantityQualifiers(response);\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PharmacySearchParams } from '@medplum/core';\n\n/**\n * SureScripts pharmacy specialty tags accepted by POST /v3/pharmacy/search `specialties`.\n * Must stay aligned with ScriptSure API allowed values.\n */\nexport type ScriptSurePharmacySpecialty =\n | 'Retail'\n | 'MailOrder'\n | 'TwentyFourHourStore'\n | 'SupportsDigitalSignature'\n | 'LongTermCare'\n | 'Specialty'\n | 'FaxPharmacySurescripts';\n\nexport interface ScriptSurePharmacySpecialtyOption {\n readonly value: ScriptSurePharmacySpecialty;\n readonly label: string;\n}\n\n/** Category filters shown in the ScriptSure pharmacy search dialog. */\nexport const SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS: readonly ScriptSurePharmacySpecialtyOption[] = [\n { value: 'Retail', label: 'Retail' },\n { value: 'MailOrder', label: 'Mail order' },\n { value: 'TwentyFourHourStore', label: '24-hour' },\n { value: 'LongTermCare', label: 'Long-term care' },\n { value: 'Specialty', label: 'Specialty' },\n { value: 'SupportsDigitalSignature', label: 'Digital signature' },\n { value: 'FaxPharmacySurescripts', label: 'Fax (Surescripts)' },\n] as const;\n\n/** Default specialty filter for nearby retail pharmacy pickers. */\nexport const SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES: readonly ScriptSurePharmacySpecialty[] = ['Retail'];\n\n/**\n * ScriptSure pharmacy search parameters.\n * Extends the shared dialog fields with SureScripts specialty filters.\n */\nexport interface ScriptSurePharmacySearchParams extends PharmacySearchParams {\n specialties?: ScriptSurePharmacySpecialty[];\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { MedicationIFrameOptions } from '@medplum/react-hooks';\nimport { useMedicationIFrame } from '@medplum/react-hooks';\nimport { SCRIPTSURE_IFRAME_BOT, SCRIPTSURE_PATIENT_SYNC_BOT } from './common';\n\nexport type ScriptSureIFrameOptions = MedicationIFrameOptions;\n\n/**\n * React hook that syncs a patient to ScriptSure and returns the iframe URL.\n *\n * Thin wrapper around the generic {@link useMedicationIFrame} hook,\n * pre-configured with ScriptSure bot identifiers.\n *\n * @param options - Configuration and callback options.\n * @returns The ScriptSure iframe URL, or undefined while loading.\n */\nexport function useScriptSureIFrame(options: ScriptSureIFrameOptions): string | undefined {\n return useMedicationIFrame(SCRIPTSURE_PATIENT_SYNC_BOT, SCRIPTSURE_IFRAME_BOT, options);\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UseMedicationOrderReturn } from '@medplum/react-hooks';\nimport { useMedicationOrder } from '@medplum/react-hooks';\n\nexport type UseScriptSureOrderMedicationReturn = UseMedicationOrderReturn;\n\n/**\n * React hook for ScriptSure drug search and pending order creation (iframe launch URL).\n *\n * Now a near-empty re-export of `useMedicationOrder` from `@medplum/react-hooks`: the\n * vendor binding lives entirely on the server, where each Medplum project's\n * `OperationDefinition` resources for `$drug-search` and `$order-medication`\n * point at the ScriptSure bots via the\n * `operationDefinition-implementation` extension. See the deploy script in\n * `medplum-ee/packages/scriptsure/src/scripts/deploy.ts` for how those\n * resources are upserted.\n *\n * Kept as a typed alias for backwards source-compatibility with apps importing\n * `useScriptSureOrderMedication` and as a documentation anchor for the\n * ScriptSure-specific behavior (e.g. patient-must-be-synced precondition).\n *\n * @returns The same API as `useMedicationOrder` (search + order callbacks).\n */\nexport function useScriptSureOrderMedication(): UseScriptSureOrderMedicationReturn {\n return useMedicationOrder();\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { UseMedicationOrderSetReturn } from '@medplum/react-hooks';\nimport { useMedicationOrderSet } from '@medplum/react-hooks';\n\nexport interface UseScriptSureOrderSetOptions {\n /** Patient to prescribe against. Hook stays idle (no operation call) until set. */\n readonly patientId: string | undefined;\n /** Medplum PlanDefinition id; bot reverse-looks up the ScriptSure orderset id. */\n readonly planDefinitionId?: string;\n /** ScriptSure orderset id (escape hatch when no synced PD exists yet). */\n readonly scriptSureOrdersetId?: number;\n readonly appId?: string;\n}\n\nexport type UseScriptSureOrderSetReturn = UseMedicationOrderSetReturn;\n\n/**\n * React hook that returns the ScriptSure order-set prescribing widget URL via\n * the vendor-neutral `$order-set-url` FHIR custom operation\n * (`POST /fhir/R4/PlanDefinition/$order-set-url`).\n *\n * Thin wrapper around {@link useMedicationOrderSet}: forwards\n * `scriptSureOrdersetId` as the operation's `vendorOrderSetId` parameter,\n * leaves vendor binding to the deployed `OperationDefinition` \u2192\n * `Bot/scriptsure-order-set-bot` link.\n *\n * The operation is naturally idempotent \u2014 re-calls only refresh the session\n * token in the returned URL \u2014 so callers can safely wire `refresh` into\n * `PrescriptionIFrameModal.onRefreshLaunchUrl`.\n *\n * @param options - Patient + order-set picker (PD or ScriptSure id).\n * @returns `{ url, loading, error, refresh }`.\n */\nexport function useScriptSureOrderSet(options: UseScriptSureOrderSetOptions): UseScriptSureOrderSetReturn {\n return useMedicationOrderSet({\n patientId: options.patientId,\n planDefinitionId: options.planDefinitionId,\n vendorOrderSetId: options.scriptSureOrdersetId,\n appId: options.appId,\n });\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UsePharmacySearchReturn } from '@medplum/react-hooks';\nimport { usePharmacySearch } from '@medplum/react-hooks';\nimport { SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT, SCRIPTSURE_SEARCH_PHARMACY_BOT } from './common';\nimport type { ScriptSurePharmacySearchParams } from './pharmacy-search';\n\nexport type UseScriptSurePharmacySearchReturn = UsePharmacySearchReturn<ScriptSurePharmacySearchParams>;\n\n/**\n * React hook that provides ScriptSure-specific pharmacy search and add-to-favorites functionality.\n *\n * Thin wrapper around the generic {@link usePharmacySearch} hook, pre-configured with\n * ScriptSure bot identifiers and widened so search params carry ScriptSure-only\n * `specialties` filters for POST /v3/pharmacy/search.\n *\n * @returns An object with `searchPharmacies` and `addToFavorites` callbacks.\n */\nexport function useScriptSurePharmacySearch(): UseScriptSurePharmacySearchReturn {\n return usePharmacySearch<ScriptSurePharmacySearchParams>(\n SCRIPTSURE_SEARCH_PHARMACY_BOT,\n SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT\n );\n}\n"],
|
|
5
|
-
"mappings": "AAKO,IAAM,mBAAqB,+BAWrB,2BAAyC,CACpD,OAAQ,mBACR,MAAO,4BACT,EAWa,gCAA8C,CACzD,OAAQ,mBACR,MAAO,iCACT,EAGa,gCAAkC,
|
|
3
|
+
"sources": ["../../src/common.ts", "../../src/loadScriptSureQuantityQualifiers.ts", "../../src/pharmacy-search.ts", "../../src/useScriptSureCart.ts", "../../src/useScriptSureIFrame.ts", "../../src/useScriptSureOrderMedication.ts", "../../src/useScriptSureOrderSet.ts", "../../src/useScriptSurePharmacySearch.ts", "../../src/useScriptSurePractice.tsx"],
|
|
4
|
+
"sourcesContent": ["// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { MedicationOrderExtensions } from '@medplum/core';\nimport type { Identifier } from '@medplum/fhirtypes';\n\nexport const MEDPLUM_BOT_SYSTEM = 'https://www.medplum.com/bots';\n\n/**\n * @deprecated Use the vendor-neutral `$drug-search` custom FHIR operation via\n * `useMedicationOrder().searchMedications(...)` (see `@medplum/react-hooks`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `drug-search` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_DRUG_SEARCH_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-drug-search-bot',\n};\n\n/**\n * @deprecated Use the vendor-neutral `$order-medication` custom FHIR operation via\n * `useMedicationOrder().orderMedication(...)` (see `@medplum/react-hooks`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `order-medication` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_ORDER_MEDICATION_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-order-medication-bot',\n};\n\n/** Identifier system for ScriptSure ROUTED_MED_ID on in-memory Medication resources from drug search. */\nexport const SCRIPTSURE_ROUTED_MED_ID_SYSTEM = 'https://scriptsure.com/routed-med-id';\n\n/**\n * Identifier/coding system for the FDB GCN Sequence Number (`GCN_SEQNO`) \u2014 the\n * clinical-formulation key (ingredient+strength+dose-form+route), independent of\n * brand and NDC. Stamped as a `medicationCodeableConcept.coding` on the draft\n * MedicationRequest so the ScriptSure prescription webhook can reconcile a draft\n * to its sent prescription even when the NDC drifts or the pharmacy substitutes a\n * generic (brand and generic share the same GCN). Mirrors the medplum-ee bot\n * constant of the same name.\n */\nexport const SCRIPTSURE_GCN_SEQNO_SYSTEM = 'https://scriptsure.com/gcn-seqno';\n\nexport const SCRIPTSURE_PENDING_ORDER_ID_SYSTEM = 'https://scriptsure.com/pending-order-id';\n\nexport const SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION = 'https://scriptsure.com/pending-order-status';\n\n/**\n * `SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION` value marking a draft\n * `MedicationRequest` as staged in the patient's ScriptSure MedCart (added by\n * `$checkout-medications`, before the prescriber sends from the MedCart widget).\n * Consumed by the paired `medplum-ee` cart-checkout / cart-manage bots when\n * stamping drafts; the Provider App uses the pure-cart model (all drafts on the\n * Draft tab) rather than filtering on this code today.\n */\nexport const SCRIPTSURE_PENDING_ORDER_STATUS_IN_CART = 'in-cart';\n\nexport const SCRIPTSURE_IFRAME_URL_EXTENSION = 'https://scriptsure.com/iframe-url';\n\n/**\n * Identifier system for the SureScripts `messageId` stamped on a draft\n * `MedicationRequest` by the cart-checkout flow (electronic-queue submit).\n * Consumed by the paired `medplum-ee` `scriptsure-cart-checkout-bot` when\n * stamping queued drafts and by `scriptsure-prescription-webhook-bot` when\n * reconciling the approval webhook back to the originating draft.\n */\nexport const SCRIPTSURE_MESSAGE_ID_SYSTEM = 'https://scriptsure.com/message-id';\n\nexport const SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS: MedicationOrderExtensions = {\n pendingOrderIdSystem: SCRIPTSURE_PENDING_ORDER_ID_SYSTEM,\n pendingOrderStatusUrl: SCRIPTSURE_PENDING_ORDER_STATUS_EXTENSION,\n iframeUrlExtension: SCRIPTSURE_IFRAME_URL_EXTENSION,\n messageIdSystem: SCRIPTSURE_MESSAGE_ID_SYSTEM,\n};\n\nexport const SCRIPTSURE_IFRAME_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-iframe-bot',\n};\n\nexport const SCRIPTSURE_PATIENT_SYNC_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-patient-sync-bot',\n};\n\n/**\n * @deprecated Use the vendor-neutral `$order-set-url` custom FHIR operation via\n * `useScriptSureOrderSet(...)` (thin wrapper around `useMedicationOrderSet`).\n * The bot identifier is kept exported for one release to preserve source\n * compatibility for any caller still invoking `medplum.executeBot(...)`\n * directly. Project deploys via `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`\n * now register an `OperationDefinition` with code `order-set-url` whose\n * `operationDefinition-implementation` extension points at this bot.\n */\nexport const SCRIPTSURE_ORDER_SET_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-order-set-bot',\n};\n\n/** Identifier system for the ScriptSure orderset id stamped on FHIR PlanDefinitions. */\nexport const SCRIPTSURE_ORDERSET_ID_SYSTEM = 'https://spa.scriptsure.com/orderset-id';\n\nexport const SCRIPTSURE_SEARCH_PHARMACY_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-search-pharmacy-bot',\n};\n\nexport const SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-add-patient-pharmacy-bot',\n};\n\nexport const SCRIPTSURE_PATIENT_ID_SYSTEM = 'https://scriptsure.com/patient-id';\n\n/**\n * Identifier system for the ScriptSure `practiceId` stamped on the Practice-level\n * Medplum `Organization`. Used by the practice/location selector to discover the\n * prescriber's ScriptSure practices and pass the chosen `organizationId` to bots.\n */\nexport const SCRIPTSURE_PRACTICE_ID_SYSTEM = 'https://scriptsure.com/practice-id';\n\n/** Identifier system for the ScriptSure `businessUnitId` on the BU-level Medplum `Organization`. */\nexport const SCRIPTSURE_BUSINESS_UNIT_ID_SYSTEM = 'https://scriptsure.com/business-unit-id';\n\n/** `Organization.type` coding system discriminating ScriptSure entity Organizations (`business-unit` | `practice`). */\nexport const SCRIPTSURE_ORGANIZATION_TYPE_SYSTEM = 'https://scriptsure.com/organization-type';\n\n/** Base URL for ScriptSure-specific extensions on in-memory Medication resources (e.g. `/sig`). */\nexport const SCRIPTSURE_SYSTEM = 'https://scriptsure.com';\n\n/** Pre-built dosing option on a Medication from drug-format lookup (`routedMedId` search). */\nexport const SCRIPTSURE_SIG_EXTENSION = `${SCRIPTSURE_SYSTEM}/sig`;\n\n/** ScriptSure MED_NAME_TYPE_CD on a search-result Medication: `'1'` = brand, `'2'` = generic. */\nexport const SCRIPTSURE_NAME_TYPE_EXTENSION = `${SCRIPTSURE_SYSTEM}/name-type`;\n\n/** ScriptSure GenericName on a search-result Medication (parent generic when the row is a brand). */\nexport const SCRIPTSURE_GENERIC_NAME_EXTENSION = `${SCRIPTSURE_SYSTEM}/generic-name`;\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { MedplumClient } from '@medplum/core';\nimport { isResource, medicationSearchParamsToParameters } from '@medplum/core';\nimport type { Parameters } from '@medplum/fhirtypes';\n\n/**\n * Reads `{ code, label }` rows from a `Parameters` resource produced by the\n * `$drug-quantity-qualifiers` custom operation.\n *\n * The OperationDefinition (see `scriptsure-drug-search-bot` registration in\n * `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`) declares a single\n * repeating output parameter named `quantityQualifier`, each entry bearing\n * `part: [{ name: 'code', valueString }, { name: 'label', valueString }]`.\n * The server's `buildOutputParameters` wraps the bot return value into that\n * shape, so the parser only needs to handle this one canonical layout.\n * Entries missing either inner part are skipped defensively.\n *\n * @param params - `Parameters` resource returned by the operation.\n * @returns `{ code, label }` rows for UI selects.\n */\nfunction parametersToQuantityQualifiers(params: Parameters): { code: string; label: string }[] {\n const rows: { code: string; label: string }[] = [];\n for (const p of params.parameter ?? []) {\n if (p.name !== 'quantityQualifier' || !p.part) {\n continue;\n }\n const code = p.part.find((part) => part.name === 'code')?.valueString;\n const label = p.part.find((part) => part.name === 'label')?.valueString;\n if (typeof code === 'string' && typeof label === 'string') {\n rows.push({ code, label });\n }\n }\n return rows;\n}\n\n/**\n * Fetches NCI potency-unit codes for dispense quantity qualifiers via the\n * vendor-neutral `$drug-quantity-qualifiers` custom FHIR operation. Each\n * Medplum project picks the vendor implementation at deploy time by pointing\n * its `OperationDefinition` at the appropriate Bot (ScriptSure's\n * `scriptsure-drug-search-bot` today; see `deploy.ts`).\n *\n * @param medplum - Medplum client (user session).\n * @returns `{ code, label }` rows for UI selects.\n */\nexport async function loadScriptSureQuantityQualifiers(\n medplum: MedplumClient\n): Promise<{ code: string; label: string }[]> {\n const url = medplum.fhirUrl('Medication', '$drug-quantity-qualifiers');\n const body = medicationSearchParamsToParameters({ quantityQualifiers: true });\n const response = await medplum.post(url, body);\n if (!isResource<Parameters>(response, 'Parameters')) {\n return [];\n }\n return parametersToQuantityQualifiers(response);\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PharmacySearchParams } from '@medplum/core';\n\n/**\n * SureScripts pharmacy specialty tags accepted by POST /v3/pharmacy/search `specialties`.\n * Must stay aligned with ScriptSure API allowed values.\n */\nexport type ScriptSurePharmacySpecialty =\n | 'Retail'\n | 'MailOrder'\n | 'TwentyFourHourStore'\n | 'SupportsDigitalSignature'\n | 'LongTermCare'\n | 'Specialty'\n | 'FaxPharmacySurescripts';\n\nexport interface ScriptSurePharmacySpecialtyOption {\n readonly value: ScriptSurePharmacySpecialty;\n readonly label: string;\n}\n\n/** Category filters shown in the ScriptSure pharmacy search dialog. */\nexport const SCRIPTSURE_PHARMACY_SPECIALTY_OPTIONS: readonly ScriptSurePharmacySpecialtyOption[] = [\n { value: 'Retail', label: 'Retail' },\n { value: 'MailOrder', label: 'Mail order' },\n { value: 'TwentyFourHourStore', label: '24-hour' },\n { value: 'LongTermCare', label: 'Long-term care' },\n { value: 'Specialty', label: 'Specialty' },\n { value: 'SupportsDigitalSignature', label: 'Digital signature' },\n { value: 'FaxPharmacySurescripts', label: 'Fax (Surescripts)' },\n] as const;\n\n/** Default specialty filter for nearby retail pharmacy pickers. */\nexport const SCRIPTSURE_DEFAULT_PHARMACY_SPECIALTIES: readonly ScriptSurePharmacySpecialty[] = ['Retail'];\n\n/**\n * ScriptSure pharmacy search parameters.\n * Extends the shared dialog fields with SureScripts specialty filters.\n */\nexport interface ScriptSurePharmacySearchParams extends PharmacySearchParams {\n specialties?: ScriptSurePharmacySpecialty[];\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UseMedicationCartReturn } from '@medplum/react-hooks';\nimport { useMedicationCart } from '@medplum/react-hooks';\n\nexport type UseScriptSureCartReturn = UseMedicationCartReturn;\n\n/**\n * React hook for the ScriptSure **medication cart** lifecycle: add a draft\n * `MedicationRequest` line (`createResource`), check out drafts into the\n * patient's ScriptSure MedCart (`$checkout-medications` \u2192\n * `/widgets/medcart/{patientId}`), and remove/clear cart lines\n * (`$remove-cart-medication` / `$clear-cart`).\n *\n * A near-empty re-export of `useMedicationCart` from `@medplum/react-hooks`: the\n * vendor binding for the custom operations lives entirely on the server, where\n * each Medplum project's `OperationDefinition`s point at the ScriptSure bots via\n * the `operationDefinition-implementation` extension \u2014 see\n * [Custom FHIR Operations](https://www.medplum.com/docs/bots/custom-fhir-operations).\n * (Internal deploy: `medplum-ee/packages/scriptsure/src/scripts/deploy.ts`.)\n *\n * `addToCart` is plain FHIR create (no vendor call); MedCart staging happens at\n * `checkout`. DoseSpot and other iframe-first vendors do not use this surface.\n *\n * Kept as a typed alias for source-compatibility with apps importing\n * `useScriptSureCart` and as a documentation anchor for ScriptSure-specific\n * behavior (patient-must-be-synced precondition; cart items await sign-off in\n * the MedCart widget).\n *\n * @returns The same API as `useMedicationCart` (`addToCart`, `adding`,\n * `checkout`, `removeFromCart`, `clearCart`).\n */\nexport function useScriptSureCart(): UseScriptSureCartReturn {\n return useMedicationCart();\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { MedicationIFrameOptions } from '@medplum/react-hooks';\nimport { useMedicationIFrame } from '@medplum/react-hooks';\nimport { SCRIPTSURE_IFRAME_BOT, SCRIPTSURE_PATIENT_SYNC_BOT } from './common';\n\nexport type ScriptSureIFrameOptions = MedicationIFrameOptions;\n\n/**\n * React hook that syncs a patient to ScriptSure and returns the iframe URL.\n *\n * Thin wrapper around the generic {@link @medplum/react-hooks#useMedicationIFrame} hook,\n * pre-configured with ScriptSure bot identifiers.\n *\n * @param options - Configuration and callback options.\n * @returns The ScriptSure iframe URL, or undefined while loading.\n */\nexport function useScriptSureIFrame(options: ScriptSureIFrameOptions): string | undefined {\n return useMedicationIFrame(SCRIPTSURE_PATIENT_SYNC_BOT, SCRIPTSURE_IFRAME_BOT, options);\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UseMedicationOrderReturn } from '@medplum/react-hooks';\nimport { useMedicationOrder } from '@medplum/react-hooks';\n\nexport type UseScriptSureOrderMedicationReturn = UseMedicationOrderReturn;\n\n/**\n * React hook for ScriptSure drug search and pending order creation (iframe launch URL).\n *\n * Now a near-empty re-export of `useMedicationOrder` from `@medplum/react-hooks`: the\n * vendor binding lives entirely on the server, where each Medplum project's\n * `OperationDefinition` resources for `$drug-search` and `$order-medication`\n * point at the ScriptSure bots via the\n * `operationDefinition-implementation` extension. See the deploy script in\n * `medplum-ee/packages/scriptsure/src/scripts/deploy.ts` for how those\n * resources are upserted.\n *\n * Kept as a typed alias for backwards source-compatibility with apps importing\n * `useScriptSureOrderMedication` and as a documentation anchor for the\n * ScriptSure-specific behavior (e.g. patient-must-be-synced precondition).\n *\n * @returns The same API as `useMedicationOrder` (search + order callbacks).\n */\nexport function useScriptSureOrderMedication(): UseScriptSureOrderMedicationReturn {\n return useMedicationOrder();\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport type { Organization, Reference } from '@medplum/fhirtypes';\nimport type { UseMedicationOrderSetReturn } from '@medplum/react-hooks';\nimport { useMedicationOrderSet } from '@medplum/react-hooks';\n\nexport interface UseScriptSureOrderSetOptions {\n /** Patient to prescribe against. Hook stays idle (no operation call) until set. */\n readonly patientId: string | undefined;\n /** Medplum PlanDefinition id; bot reverse-looks up the ScriptSure orderset id. */\n readonly planDefinitionId?: string;\n /** ScriptSure orderset id (escape hatch when no synced PD exists yet). */\n readonly scriptSureOrdersetId?: number;\n readonly appId?: string;\n /** Selected practice location for multi-practice deployments. */\n readonly organization?: Reference<Organization>;\n}\n\nexport type UseScriptSureOrderSetReturn = UseMedicationOrderSetReturn;\n\n/**\n * React hook that returns the ScriptSure order-set prescribing widget URL via\n * the vendor-neutral `$order-set-url` FHIR custom operation\n * (`POST /fhir/R4/PlanDefinition/$order-set-url`).\n *\n * Thin wrapper around {@link @medplum/react-hooks#useMedicationOrderSet}: forwards\n * `scriptSureOrdersetId` as the operation's `vendorOrderSetId` parameter,\n * leaves vendor binding to the deployed `OperationDefinition` \u2192\n * `Bot/scriptsure-order-set-bot` link.\n *\n * The operation is naturally idempotent \u2014 re-calls only refresh the session\n * token in the returned URL \u2014 so callers can safely wire `refresh` into\n * `PrescriptionIFrameModal.onRefreshLaunchUrl`.\n *\n * @param options - Patient + order-set picker (PD or ScriptSure id).\n * @returns `{ url, loading, error, refresh }`.\n */\nexport function useScriptSureOrderSet(options: UseScriptSureOrderSetOptions): UseScriptSureOrderSetReturn {\n return useMedicationOrderSet({\n patientId: options.patientId,\n planDefinitionId: options.planDefinitionId,\n vendorOrderSetId: options.scriptSureOrdersetId,\n appId: options.appId,\n organization: options.organization,\n });\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { UsePharmacySearchReturn } from '@medplum/react-hooks';\nimport { usePharmacySearch } from '@medplum/react-hooks';\nimport { SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT, SCRIPTSURE_SEARCH_PHARMACY_BOT } from './common';\nimport type { ScriptSurePharmacySearchParams } from './pharmacy-search';\n\nexport type UseScriptSurePharmacySearchReturn = UsePharmacySearchReturn<ScriptSurePharmacySearchParams>;\n\n/**\n * React hook that provides ScriptSure-specific pharmacy search and add-to-favorites functionality.\n *\n * Thin wrapper around the generic {@link @medplum/react-hooks#usePharmacySearch} hook, pre-configured with\n * ScriptSure bot identifiers and widened so search params carry ScriptSure-only\n * `specialties` filters for POST /v3/pharmacy/search.\n *\n * @returns An object with `searchPharmacies` and `addToFavorites` callbacks.\n */\nexport function useScriptSurePharmacySearch(): UseScriptSurePharmacySearchReturn {\n return usePharmacySearch<ScriptSurePharmacySearchParams>(\n SCRIPTSURE_SEARCH_PHARMACY_BOT,\n SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT\n );\n}\n", "// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { getIdentifier, resolveId } from '@medplum/core';\nimport type { Organization, Practitioner, PractitionerRole, Reference } from '@medplum/fhirtypes';\nimport { useMedplum } from '@medplum/react-hooks';\nimport type { JSX, ReactNode } from 'react';\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport { SCRIPTSURE_PRACTICE_ID_SYSTEM } from './common';\n\nconst STORAGE_KEY = 'medplum.scriptsure.selectedPracticeOrganization';\n\n/** The current ScriptSure practice-location selection for the signed-in prescriber. */\nexport interface ScriptSurePracticeContextValue {\n /**\n * The prescriber's ScriptSure practice `Organization`s \u2014 discovered from their\n * own affiliations (`PractitionerRole.organization` + `ProjectMembership.access`\n * organization parameters), filtered to those carrying a `practice-id` identifier.\n * Never the project-wide list.\n */\n readonly practices: Organization[];\n /** Bare Organization id used by the selector and persisted in localStorage. */\n readonly selectedOrganizationId: string | undefined;\n /** FHIR reference for the selected practice, suitable for operation and hook inputs. */\n readonly selectedOrganization: Reference<Organization> | undefined;\n /** Selects a practice Organization (persisted to localStorage). */\n readonly setSelectedOrganizationId: (id: string | undefined) => void;\n readonly loading: boolean;\n}\n\nconst ScriptSurePracticeContext = createContext<ScriptSurePracticeContextValue>({\n practices: [],\n selectedOrganizationId: undefined,\n selectedOrganization: undefined,\n setSelectedOrganizationId: () => undefined,\n loading: false,\n});\n\nfunction addOrganizationReference(refs: Set<string>, reference: string | undefined): void {\n if (reference?.startsWith('Organization/')) {\n refs.add(reference);\n }\n}\n\nfunction hasPracticeIdentifier(org: Organization): boolean {\n return Boolean(getIdentifier(org, SCRIPTSURE_PRACTICE_ID_SYSTEM));\n}\n\n/**\n * Resolves the signed-in prescriber's `Practitioner.id` from the current profile,\n * whether the profile is a `Practitioner` or a `PractitionerRole`.\n *\n * @param profile - The current Medplum profile resource.\n * @returns The Practitioner id, or undefined when it cannot be resolved.\n */\nfunction resolvePractitionerId(profile: Practitioner | PractitionerRole | undefined): string | undefined {\n if (profile?.resourceType === 'Practitioner') {\n return profile.id;\n }\n if (profile?.resourceType === 'PractitionerRole') {\n return resolveId(profile.practitioner);\n }\n return undefined;\n}\n\n/**\n * Provides the signed-in prescriber's current ScriptSure practice-location\n * selection, discovered from **their own affiliations** \u2014 mirroring the server's\n * multi-practice resolver so the UI never offers a practice the prescriber is not\n * a member of.\n *\n * Discovery: active `PractitionerRole.organization` references for the current\n * `Practitioner` plus any `ProjectMembership.access[].parameter` named\n * `organization`, resolved to `Organization`s and filtered to those carrying a\n * `practice-id` identifier. The sole practice is auto-selected; a previously used\n * selection is restored only when it is still in the affiliation set.\n *\n * @param props - Component props.\n * @param props.children - Child nodes rendered within the provider.\n * @returns The context provider element.\n */\nexport function ScriptSurePracticeProvider(props: { readonly children: ReactNode }): JSX.Element {\n const medplum = useMedplum();\n const [practices, setPractices] = useState<Organization[]>([]);\n const [loading, setLoading] = useState(true);\n const [selectedOrganizationId, setSelected] = useState<string | undefined>(\n () => localStorage.getItem(STORAGE_KEY) ?? undefined\n );\n\n useEffect(() => {\n let cancelled = false;\n\n const loadAffiliatedPractices = async (): Promise<Organization[]> => {\n const profile = medplum.getProfile() as Practitioner | PractitionerRole | undefined;\n const practitionerId = resolvePractitionerId(profile);\n const references = new Set<string>();\n\n if (practitionerId) {\n const roles = await medplum.searchResources('PractitionerRole', {\n practitioner: `Practitioner/${practitionerId}`,\n _count: '100',\n });\n for (const role of roles) {\n // `active` is not a standard R4 PractitionerRole search param \u2014 filter in code.\n if (role.active !== false) {\n addOrganizationReference(references, role.organization?.reference);\n }\n }\n }\n\n const membership = medplum.getProjectMembership();\n for (const access of membership?.access ?? []) {\n for (const param of access.parameter ?? []) {\n if (param.name === 'organization') {\n addOrganizationReference(references, param.valueReference?.reference);\n }\n }\n }\n\n const settledOrgs = await Promise.allSettled(\n [...references].map((reference) => medplum.readReference<Organization>({ reference }))\n );\n const seen = new Set<string>();\n const result: Organization[] = [];\n for (const settledOrg of settledOrgs) {\n if (settledOrg.status === 'rejected') {\n continue;\n }\n const org = settledOrg.value;\n if (org.id && !seen.has(org.id) && hasPracticeIdentifier(org)) {\n seen.add(org.id);\n result.push(org);\n }\n }\n return result;\n };\n\n const updateAffiliatedPractices = async (): Promise<void> => {\n setLoading(true);\n try {\n const orgs = await loadAffiliatedPractices();\n if (!cancelled) {\n setPractices(orgs);\n // Default: keep a stored id only if it is still an affiliation; else the sole practice.\n setSelected((current) => {\n if (current && orgs.some((o) => o.id === current)) {\n return current;\n }\n return orgs.length === 1 ? orgs[0].id : undefined;\n });\n }\n } catch {\n if (!cancelled) {\n setPractices([]);\n }\n } finally {\n if (!cancelled) {\n setLoading(false);\n }\n }\n };\n updateAffiliatedPractices().catch(() => undefined);\n\n return (): void => {\n cancelled = true;\n };\n }, [medplum]);\n\n const setSelectedOrganizationId = useCallback((id: string | undefined): void => {\n setSelected(id);\n if (id) {\n localStorage.setItem(STORAGE_KEY, id);\n } else {\n localStorage.removeItem(STORAGE_KEY);\n }\n }, []);\n\n const selectedOrganization = useMemo<Reference<Organization> | undefined>(\n () => (selectedOrganizationId ? { reference: `Organization/${selectedOrganizationId}` } : undefined),\n [selectedOrganizationId]\n );\n\n const value = useMemo<ScriptSurePracticeContextValue>(\n () => ({ practices, selectedOrganizationId, selectedOrganization, setSelectedOrganizationId, loading }),\n [practices, selectedOrganizationId, selectedOrganization, setSelectedOrganizationId, loading]\n );\n\n return <ScriptSurePracticeContext.Provider value={value}>{props.children}</ScriptSurePracticeContext.Provider>;\n}\n\n/**\n * Hook returning the current ScriptSure practice selection + setter.\n *\n * @returns The practice context value.\n */\nexport function useScriptSurePractice(): ScriptSurePracticeContextValue {\n return useContext(ScriptSurePracticeContext);\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medplum/scriptsure-react",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.27",
|
|
4
4
|
"description": "Medplum ScriptSure React SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"medplum",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"test:watch": "vitest watch"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@medplum/core": "5.1.
|
|
62
|
-
"@medplum/fhirtypes": "5.1.
|
|
63
|
-
"@medplum/mock": "5.1.
|
|
64
|
-
"@medplum/react-hooks": "5.1.
|
|
61
|
+
"@medplum/core": "5.1.27",
|
|
62
|
+
"@medplum/fhirtypes": "5.1.27",
|
|
63
|
+
"@medplum/mock": "5.1.27",
|
|
64
|
+
"@medplum/react-hooks": "5.1.27",
|
|
65
65
|
"@testing-library/jest-dom": "6.9.1",
|
|
66
66
|
"@testing-library/react": "16.3.2",
|
|
67
67
|
"@types/react": "19.2.17",
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
"react-dom": "19.2.7"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@medplum/core": "5.1.
|
|
75
|
-
"@medplum/fhirtypes": "5.1.
|
|
76
|
-
"@medplum/react-hooks": "5.1.
|
|
74
|
+
"@medplum/core": "5.1.27",
|
|
75
|
+
"@medplum/fhirtypes": "5.1.27",
|
|
76
|
+
"@medplum/react-hooks": "5.1.27",
|
|
77
77
|
"react": "^18.0.0 || ^19.0.0"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|