@medplum/scriptsure-react 5.1.27 → 5.1.29

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.
@@ -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_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)}
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_MESSAGE_TASK_BOT:()=>SCRIPTSURE_MESSAGE_TASK_BOT,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,useScriptSureMessageTask:()=>useScriptSureMessageTask,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_MESSAGE_TASK_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-message-task-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_core2=require("@medplum/core"),import_react_hooks3=require("@medplum/react-hooks"),import_react=require("react");var INVALID_MESSAGE_TASK_RESPONSE="Invalid ScriptSure message-task response";function parseMessageTaskResponse(value){if(!value||typeof value!="object")throw new Error(INVALID_MESSAGE_TASK_RESPONSE);let response=value;if(!(0,import_core2.isResource)(response.task,"Task")||response.launchUrl!==void 0&&typeof response.launchUrl!="string"||response.vendorStatus!==void 0&&typeof response.vendorStatus!="string")throw new Error(INVALID_MESSAGE_TASK_RESPONSE);return response}function useScriptSureMessageTask(){let medplum=(0,import_react_hooks3.useMedplum)(),execute=(0,import_react.useCallback)(async(action,params)=>{let request={...params,action};return parseMessageTaskResponse(await medplum.executeBot(SCRIPTSURE_MESSAGE_TASK_BOT,request))},[medplum]),launch=(0,import_react.useCallback)(params=>execute("launch",params),[execute]),reconcile=(0,import_react.useCallback)(params=>execute("reconcile",params),[execute]),acknowledge=(0,import_react.useCallback)(params=>execute("acknowledge",params),[execute]);return{launch,reconcile,acknowledge}}var import_react_hooks4=require("@medplum/react-hooks");function useScriptSureOrderMedication(){return(0,import_react_hooks4.useMedicationOrder)()}var import_react_hooks5=require("@medplum/react-hooks");function useScriptSureOrderSet(options){return(0,import_react_hooks5.useMedicationOrderSet)({patientId:options.patientId,planDefinitionId:options.planDefinitionId,vendorOrderSetId:options.scriptSureOrdersetId,appId:options.appId,organization:options.organization})}var import_react_hooks6=require("@medplum/react-hooks");function useScriptSurePharmacySearch(){return(0,import_react_hooks6.usePharmacySearch)(SCRIPTSURE_SEARCH_PHARMACY_BOT,SCRIPTSURE_ADD_PATIENT_PHARMACY_BOT)}var import_core3=require("@medplum/core"),import_react_hooks7=require("@medplum/react-hooks"),import_react2=require("react");var import_jsx_runtime=require("react/jsx-runtime"),STORAGE_KEY="medplum.scriptsure.selectedPracticeOrganization",ScriptSurePracticeContext=(0,import_react2.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_core3.getIdentifier)(org,SCRIPTSURE_PRACTICE_ID_SYSTEM)}function resolvePractitionerId(profile){if(profile?.resourceType==="Practitioner")return profile.id;if(profile?.resourceType==="PractitionerRole")return(0,import_core3.resolveId)(profile.practitioner)}function ScriptSurePracticeProvider(props){let medplum=(0,import_react_hooks7.useMedplum)(),[practices,setPractices]=(0,import_react2.useState)([]),[loading,setLoading]=(0,import_react2.useState)(!0),[selectedOrganizationId,setSelected]=(0,import_react2.useState)(()=>localStorage.getItem(STORAGE_KEY)??void 0);(0,import_react2.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_react2.useCallback)(id=>{setSelected(id),id?localStorage.setItem(STORAGE_KEY,id):localStorage.removeItem(STORAGE_KEY)},[]),selectedOrganization=(0,import_react2.useMemo)(()=>selectedOrganizationId?{reference:`Organization/${selectedOrganizationId}`}:void 0,[selectedOrganizationId]),value=(0,import_react2.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_react2.useContext)(ScriptSurePracticeContext)}
2
2
  //# sourceMappingURL=index.cjs.map
@@ -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/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": "wpBAAA,0wECKO,IAAM,mBAAqB,+BAWrB,2BAAyC,CACpD,OAAQ,mBACR,MAAO,4BACT,EAWa,gCAA8C,CACzD,OAAQ,mBACR,MAAO,iCACT,EAGa,gCAAkC,uCAWlC,4BAA8B,mCAE9B,mCAAqC,0CAErC,0CAA4C,8CAU5C,wCAA0C,UAE1C,gCAAkC,oCASlC,6BAA+B,oCAE/B,uCAAoE,CAC/E,qBAAsB,mCACtB,sBAAuB,0CACvB,mBAAoB,gCACpB,gBAAiB,4BACnB,EAEa,sBAAoC,CAC/C,OAAQ,mBACR,MAAO,uBACT,EAEa,4BAA0C,CACrD,OAAQ,mBACR,MAAO,6BACT,EAWa,yBAAuC,CAClD,OAAQ,mBACR,MAAO,0BACT,EAGa,8BAAgC,yCAEhC,+BAA6C,CACxD,OAAQ,mBACR,MAAO,gCACT,EAEa,oCAAkD,CAC7D,OAAQ,mBACR,MAAO,qCACT,EAEa,6BAA+B,oCAO/B,8BAAgC,qCAGhC,mCAAqC,0CAGrC,oCAAsC,2CAGtC,kBAAoB,yBAGpB,yBAA2B,GAAG,iBAAiB,OAG/C,+BAAiC,GAAG,iBAAiB,aAGrD,kCAAoC,GAAG,iBAAiB,gBC3IrE,gBAA+D,yBAkB/D,SAAS,+BAA+B,OAAuD,CAC7F,IAAM,KAA0C,CAAC,EACjD,QAAW,KAAK,OAAO,WAAa,CAAC,EAAG,CACtC,GAAI,EAAE,OAAS,qBAAuB,CAAC,EAAE,KACvC,SAEF,IAAM,KAAO,EAAE,KAA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,SAAO,wBAAC,0BAA0B,SAA1B,CAAmC,MAAe,eAAM,SAAS,CAC3E,CAOO,SAAS,uBAAwD,CACtE,SAAO,yBAAW,yBAAyB,CAC7C",
6
- "names": ["import_react_hooks", "import_react_hooks", "import_react_hooks", "import_react_hooks", "import_core", "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/useScriptSureMessageTask.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 './useScriptSureMessageTask';\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\n/** Bot that launches and reconciles ScriptSure pharmacy-message Tasks. */\nexport const SCRIPTSURE_MESSAGE_TASK_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-message-task-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\nimport { isResource } from '@medplum/core';\nimport type { Task } from '@medplum/fhirtypes';\nimport { useMedplum } from '@medplum/react-hooks';\nimport { useCallback } from 'react';\nimport { SCRIPTSURE_MESSAGE_TASK_BOT } from './common';\n\nexport type ScriptSureMessageTaskAction = 'launch' | 'reconcile' | 'acknowledge';\n\n/** Request accepted by the ScriptSure message-task bot. */\nexport interface ScriptSureMessageTaskRequest {\n taskId: string;\n action: ScriptSureMessageTaskAction;\n organizationId?: string;\n}\n\n/** Validated response returned by the ScriptSure message-task bot. */\nexport interface ScriptSureMessageTaskResponse {\n task: Task;\n launchUrl?: string;\n vendorStatus?: string;\n}\n\nexport interface ScriptSureMessageTaskParams {\n taskId: string;\n organizationId?: string;\n}\n\nexport interface UseScriptSureMessageTaskReturn {\n launch: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;\n reconcile: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;\n acknowledge: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;\n}\n\nconst INVALID_MESSAGE_TASK_RESPONSE = 'Invalid ScriptSure message-task response';\n\nfunction parseMessageTaskResponse(value: unknown): ScriptSureMessageTaskResponse {\n if (!value || typeof value !== 'object') {\n throw new Error(INVALID_MESSAGE_TASK_RESPONSE);\n }\n const response = value as Record<string, unknown>;\n if (\n !isResource<Task>(response.task, 'Task') ||\n (response.launchUrl !== undefined && typeof response.launchUrl !== 'string') ||\n (response.vendorStatus !== undefined && typeof response.vendorStatus !== 'string')\n ) {\n throw new Error(INVALID_MESSAGE_TASK_RESPONSE);\n }\n return response as unknown as ScriptSureMessageTaskResponse;\n}\n\n/**\n * Executes the ScriptSure pharmacy-message Task lifecycle bot.\n *\n * The hook intentionally exposes only the three supported actions and validates\n * the untyped Bot response before returning it to the application.\n *\n * @returns Typed launch, reconcile, and acknowledge callbacks.\n */\nexport function useScriptSureMessageTask(): UseScriptSureMessageTaskReturn {\n const medplum = useMedplum();\n\n const execute = useCallback(\n async (\n action: ScriptSureMessageTaskAction,\n params: ScriptSureMessageTaskParams\n ): Promise<ScriptSureMessageTaskResponse> => {\n const request: ScriptSureMessageTaskRequest = { ...params, action };\n return parseMessageTaskResponse(await medplum.executeBot(SCRIPTSURE_MESSAGE_TASK_BOT, request));\n },\n [medplum]\n );\n\n const launch = useCallback((params: ScriptSureMessageTaskParams) => execute('launch', params), [execute]);\n const reconcile = useCallback((params: ScriptSureMessageTaskParams) => execute('reconcile', params), [execute]);\n const acknowledge = useCallback((params: ScriptSureMessageTaskParams) => execute('acknowledge', params), [execute]);\n\n return { launch, reconcile, acknowledge };\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": "wpBAAA,43ECKO,IAAM,mBAAqB,+BAWrB,2BAAyC,CACpD,OAAQ,mBACR,MAAO,4BACT,EAWa,gCAA8C,CACzD,OAAQ,mBACR,MAAO,iCACT,EAGa,gCAAkC,uCAWlC,4BAA8B,mCAE9B,mCAAqC,0CAErC,0CAA4C,8CAU5C,wCAA0C,UAE1C,gCAAkC,oCASlC,6BAA+B,oCAE/B,uCAAoE,CAC/E,qBAAsB,mCACtB,sBAAuB,0CACvB,mBAAoB,gCACpB,gBAAiB,4BACnB,EAEa,sBAAoC,CAC/C,OAAQ,mBACR,MAAO,uBACT,EAEa,4BAA0C,CACrD,OAAQ,mBACR,MAAO,6BACT,EAWa,yBAAuC,CAClD,OAAQ,mBACR,MAAO,0BACT,EAGa,8BAAgC,yCAEhC,+BAA6C,CACxD,OAAQ,mBACR,MAAO,gCACT,EAEa,oCAAkD,CAC7D,OAAQ,mBACR,MAAO,qCACT,EAGa,4BAA0C,CACrD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AO,CAC9F,EAEA,SAAO,wBAAC,0BAA0B,SAA1B,CAAmC,MAAe,eAAM,SAAS,CAC3E,CAOO,SAAS,uBAAwD,CACtE,SAAO,0BAAW,yBAAyB,CAC7C",
6
+ "names": ["import_react_hooks", "import_core", "import_react_hooks", "import_react_hooks", "import_react_hooks", "import_react_hooks", "import_core", "import_react_hooks", "import_react"]
7
7
  }
@@ -7,6 +7,7 @@ import type { Organization } from '@medplum/fhirtypes';
7
7
  import type { PharmacySearchParams } from '@medplum/core';
8
8
  import type { ReactNode } from 'react';
9
9
  import type { Reference } from '@medplum/fhirtypes';
10
+ import type { Task } from '@medplum/fhirtypes';
10
11
  import type { UseMedicationCartReturn } from '@medplum/react-hooks';
11
12
  import type { UseMedicationOrderReturn } from '@medplum/react-hooks';
12
13
  import type { UseMedicationOrderSetReturn } from '@medplum/react-hooks';
@@ -77,6 +78,9 @@ export declare const SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS: MedicationOrderExte
77
78
  */
78
79
  export declare const SCRIPTSURE_MESSAGE_ID_SYSTEM = "https://scriptsure.com/message-id";
79
80
 
81
+ /** Bot that launches and reconciles ScriptSure pharmacy-message Tasks. */
82
+ export declare const SCRIPTSURE_MESSAGE_TASK_BOT: Identifier;
83
+
80
84
  /** ScriptSure MED_NAME_TYPE_CD on a search-result Medication: `'1'` = brand, `'2'` = generic. */
81
85
  export declare const SCRIPTSURE_NAME_TYPE_EXTENSION = "https://scriptsure.com/name-type";
82
86
 
@@ -149,6 +153,27 @@ export declare const SCRIPTSURE_SYSTEM = "https://scriptsure.com";
149
153
 
150
154
  export declare type ScriptSureIFrameOptions = MedicationIFrameOptions;
151
155
 
156
+ export declare type ScriptSureMessageTaskAction = 'launch' | 'reconcile' | 'acknowledge';
157
+
158
+ export declare interface ScriptSureMessageTaskParams {
159
+ taskId: string;
160
+ organizationId?: string;
161
+ }
162
+
163
+ /** Request accepted by the ScriptSure message-task bot. */
164
+ export declare interface ScriptSureMessageTaskRequest {
165
+ taskId: string;
166
+ action: ScriptSureMessageTaskAction;
167
+ organizationId?: string;
168
+ }
169
+
170
+ /** Validated response returned by the ScriptSure message-task bot. */
171
+ export declare interface ScriptSureMessageTaskResponse {
172
+ task: Task;
173
+ launchUrl?: string;
174
+ vendorStatus?: string;
175
+ }
176
+
152
177
  /**
153
178
  * ScriptSure pharmacy search parameters.
154
179
  * Extends the shared dialog fields with SureScripts specialty filters.
@@ -246,6 +271,22 @@ export declare type UseScriptSureCartReturn = UseMedicationCartReturn;
246
271
  */
247
272
  export declare function useScriptSureIFrame(options: ScriptSureIFrameOptions): string | undefined;
248
273
 
274
+ /**
275
+ * Executes the ScriptSure pharmacy-message Task lifecycle bot.
276
+ *
277
+ * The hook intentionally exposes only the three supported actions and validates
278
+ * the untyped Bot response before returning it to the application.
279
+ *
280
+ * @returns Typed launch, reconcile, and acknowledge callbacks.
281
+ */
282
+ export declare function useScriptSureMessageTask(): UseScriptSureMessageTaskReturn;
283
+
284
+ export declare interface UseScriptSureMessageTaskReturn {
285
+ launch: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;
286
+ reconcile: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;
287
+ acknowledge: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;
288
+ }
289
+
249
290
  /**
250
291
  * React hook for ScriptSure drug search and pending order creation (iframe launch URL).
251
292
  *
@@ -7,6 +7,7 @@ import type { Organization } from '@medplum/fhirtypes';
7
7
  import type { PharmacySearchParams } from '@medplum/core';
8
8
  import type { ReactNode } from 'react';
9
9
  import type { Reference } from '@medplum/fhirtypes';
10
+ import type { Task } from '@medplum/fhirtypes';
10
11
  import type { UseMedicationCartReturn } from '@medplum/react-hooks';
11
12
  import type { UseMedicationOrderReturn } from '@medplum/react-hooks';
12
13
  import type { UseMedicationOrderSetReturn } from '@medplum/react-hooks';
@@ -77,6 +78,9 @@ export declare const SCRIPTSURE_MEDICATION_ORDER_EXTENSIONS: MedicationOrderExte
77
78
  */
78
79
  export declare const SCRIPTSURE_MESSAGE_ID_SYSTEM = "https://scriptsure.com/message-id";
79
80
 
81
+ /** Bot that launches and reconciles ScriptSure pharmacy-message Tasks. */
82
+ export declare const SCRIPTSURE_MESSAGE_TASK_BOT: Identifier;
83
+
80
84
  /** ScriptSure MED_NAME_TYPE_CD on a search-result Medication: `'1'` = brand, `'2'` = generic. */
81
85
  export declare const SCRIPTSURE_NAME_TYPE_EXTENSION = "https://scriptsure.com/name-type";
82
86
 
@@ -149,6 +153,27 @@ export declare const SCRIPTSURE_SYSTEM = "https://scriptsure.com";
149
153
 
150
154
  export declare type ScriptSureIFrameOptions = MedicationIFrameOptions;
151
155
 
156
+ export declare type ScriptSureMessageTaskAction = 'launch' | 'reconcile' | 'acknowledge';
157
+
158
+ export declare interface ScriptSureMessageTaskParams {
159
+ taskId: string;
160
+ organizationId?: string;
161
+ }
162
+
163
+ /** Request accepted by the ScriptSure message-task bot. */
164
+ export declare interface ScriptSureMessageTaskRequest {
165
+ taskId: string;
166
+ action: ScriptSureMessageTaskAction;
167
+ organizationId?: string;
168
+ }
169
+
170
+ /** Validated response returned by the ScriptSure message-task bot. */
171
+ export declare interface ScriptSureMessageTaskResponse {
172
+ task: Task;
173
+ launchUrl?: string;
174
+ vendorStatus?: string;
175
+ }
176
+
152
177
  /**
153
178
  * ScriptSure pharmacy search parameters.
154
179
  * Extends the shared dialog fields with SureScripts specialty filters.
@@ -246,6 +271,22 @@ export declare type UseScriptSureCartReturn = UseMedicationCartReturn;
246
271
  */
247
272
  export declare function useScriptSureIFrame(options: ScriptSureIFrameOptions): string | undefined;
248
273
 
274
+ /**
275
+ * Executes the ScriptSure pharmacy-message Task lifecycle bot.
276
+ *
277
+ * The hook intentionally exposes only the three supported actions and validates
278
+ * the untyped Bot response before returning it to the application.
279
+ *
280
+ * @returns Typed launch, reconcile, and acknowledge callbacks.
281
+ */
282
+ export declare function useScriptSureMessageTask(): UseScriptSureMessageTaskReturn;
283
+
284
+ export declare interface UseScriptSureMessageTaskReturn {
285
+ launch: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;
286
+ reconcile: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;
287
+ acknowledge: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;
288
+ }
289
+
249
290
  /**
250
291
  * React hook for ScriptSure drug search and pending order creation (iframe launch URL).
251
292
  *
@@ -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_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};
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_MESSAGE_TASK_BOT={system:MEDPLUM_BOT_SYSTEM,value:"scriptsure-message-task-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{isResource as isResource2}from"@medplum/core";import{useMedplum}from"@medplum/react-hooks";import{useCallback}from"react";var INVALID_MESSAGE_TASK_RESPONSE="Invalid ScriptSure message-task response";function parseMessageTaskResponse(value){if(!value||typeof value!="object")throw new Error(INVALID_MESSAGE_TASK_RESPONSE);let response=value;if(!isResource2(response.task,"Task")||response.launchUrl!==void 0&&typeof response.launchUrl!="string"||response.vendorStatus!==void 0&&typeof response.vendorStatus!="string")throw new Error(INVALID_MESSAGE_TASK_RESPONSE);return response}function useScriptSureMessageTask(){let medplum=useMedplum(),execute=useCallback(async(action,params)=>{let request={...params,action};return parseMessageTaskResponse(await medplum.executeBot(SCRIPTSURE_MESSAGE_TASK_BOT,request))},[medplum]),launch=useCallback(params=>execute("launch",params),[execute]),reconcile=useCallback(params=>execute("reconcile",params),[execute]),acknowledge=useCallback(params=>execute("acknowledge",params),[execute]);return{launch,reconcile,acknowledge}}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 as useMedplum2}from"@medplum/react-hooks";import{createContext,useCallback as useCallback2,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=useMedplum2(),[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=useCallback2(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_MESSAGE_TASK_BOT,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,useScriptSureMessageTask,useScriptSureOrderMedication,useScriptSureOrderSet,useScriptSurePharmacySearch,useScriptSurePractice};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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": "AAKO,IAAM,mBAAqB,+BAWrB,2BAAyC,CACpD,OAAQ,mBACR,MAAO,4BACT,EAWa,gCAA8C,CACzD,OAAQ,mBACR,MAAO,iCACT,EAGa,gCAAkC,uCAWlC,4BAA8B,mCAE9B,mCAAqC,0CAErC,0CAA4C,8CAU5C,wCAA0C,UAE1C,gCAAkC,oCASlC,6BAA+B,oCAE/B,uCAAoE,CAC/E,qBAAsB,mCACtB,sBAAuB,0CACvB,mBAAoB,gCACpB,gBAAiB,4BACnB,EAEa,sBAAoC,CAC/C,OAAQ,mBACR,MAAO,uBACT,EAEa,4BAA0C,CACrD,OAAQ,mBACR,MAAO,6BACT,EAWa,yBAAuC,CAClD,OAAQ,mBACR,MAAO,0BACT,EAGa,8BAAgC,yCAEhC,+BAA6C,CACxD,OAAQ,mBACR,MAAO,gCACT,EAEa,oCAAkD,CAC7D,OAAQ,mBACR,MAAO,qCACT,EAEa,6BAA+B,oCAO/B,8BAAgC,qCAGhC,mCAAqC,0CAGrC,oCAAsC,2CAGtC,kBAAoB,yBAGpB,yBAA2B,GAAG,iBAAiB,OAG/C,+BAAiC,GAAG,iBAAiB,aAGrD,kCAAoC,GAAG,iBAAiB,gBC3IrE,OAAS,WAAY,uCAA0C,gBAkB/D,SAAS,+BAA+B,OAAuD,CAC7F,IAAM,KAA0C,CAAC,EACjD,QAAW,KAAK,OAAO,WAAa,CAAC,EAAG,CACtC,GAAI,EAAE,OAAS,qBAAuB,CAAC,E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AA2B,OAAQ,GACrG,CAAC,UAAW,uBAAwB,qBAAsB,0BAA2B,OAAO,CAC9F,EAEA,OAAO,IAAC,0BAA0B,SAA1B,CAAmC,MAAe,eAAM,SAAS,CAC3E,CAOO,SAAS,uBAAwD,CACtE,OAAO,WAAW,yBAAyB,CAC7C",
6
- "names": []
3
+ "sources": ["../../src/common.ts", "../../src/loadScriptSureQuantityQualifiers.ts", "../../src/pharmacy-search.ts", "../../src/useScriptSureCart.ts", "../../src/useScriptSureIFrame.ts", "../../src/useScriptSureMessageTask.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\n/** Bot that launches and reconciles ScriptSure pharmacy-message Tasks. */\nexport const SCRIPTSURE_MESSAGE_TASK_BOT: Identifier = {\n system: MEDPLUM_BOT_SYSTEM,\n value: 'scriptsure-message-task-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\nimport { isResource } from '@medplum/core';\nimport type { Task } from '@medplum/fhirtypes';\nimport { useMedplum } from '@medplum/react-hooks';\nimport { useCallback } from 'react';\nimport { SCRIPTSURE_MESSAGE_TASK_BOT } from './common';\n\nexport type ScriptSureMessageTaskAction = 'launch' | 'reconcile' | 'acknowledge';\n\n/** Request accepted by the ScriptSure message-task bot. */\nexport interface ScriptSureMessageTaskRequest {\n taskId: string;\n action: ScriptSureMessageTaskAction;\n organizationId?: string;\n}\n\n/** Validated response returned by the ScriptSure message-task bot. */\nexport interface ScriptSureMessageTaskResponse {\n task: Task;\n launchUrl?: string;\n vendorStatus?: string;\n}\n\nexport interface ScriptSureMessageTaskParams {\n taskId: string;\n organizationId?: string;\n}\n\nexport interface UseScriptSureMessageTaskReturn {\n launch: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;\n reconcile: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;\n acknowledge: (params: ScriptSureMessageTaskParams) => Promise<ScriptSureMessageTaskResponse>;\n}\n\nconst INVALID_MESSAGE_TASK_RESPONSE = 'Invalid ScriptSure message-task response';\n\nfunction parseMessageTaskResponse(value: unknown): ScriptSureMessageTaskResponse {\n if (!value || typeof value !== 'object') {\n throw new Error(INVALID_MESSAGE_TASK_RESPONSE);\n }\n const response = value as Record<string, unknown>;\n if (\n !isResource<Task>(response.task, 'Task') ||\n (response.launchUrl !== undefined && typeof response.launchUrl !== 'string') ||\n (response.vendorStatus !== undefined && typeof response.vendorStatus !== 'string')\n ) {\n throw new Error(INVALID_MESSAGE_TASK_RESPONSE);\n }\n return response as unknown as ScriptSureMessageTaskResponse;\n}\n\n/**\n * Executes the ScriptSure pharmacy-message Task lifecycle bot.\n *\n * The hook intentionally exposes only the three supported actions and validates\n * the untyped Bot response before returning it to the application.\n *\n * @returns Typed launch, reconcile, and acknowledge callbacks.\n */\nexport function useScriptSureMessageTask(): UseScriptSureMessageTaskReturn {\n const medplum = useMedplum();\n\n const execute = useCallback(\n async (\n action: ScriptSureMessageTaskAction,\n params: ScriptSureMessageTaskParams\n ): Promise<ScriptSureMessageTaskResponse> => {\n const request: ScriptSureMessageTaskRequest = { ...params, action };\n return parseMessageTaskResponse(await medplum.executeBot(SCRIPTSURE_MESSAGE_TASK_BOT, request));\n },\n [medplum]\n );\n\n const launch = useCallback((params: ScriptSureMessageTaskParams) => execute('launch', params), [execute]);\n const reconcile = useCallback((params: ScriptSureMessageTaskParams) => execute('reconcile', params), [execute]);\n const acknowledge = useCallback((params: ScriptSureMessageTaskParams) => execute('acknowledge', params), [execute]);\n\n return { launch, reconcile, acknowledge };\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": "AAKO,IAAM,mBAAqB,+BAWrB,2BAAyC,CACpD,OAAQ,mBACR,MAAO,4BACT,EAWa,gCAA8C,CACzD,OAAQ,mBACR,MAAO,iCACT,EAGa,gCAAkC,uCAWlC,4BAA8B,mCAE9B,mCAAqC,0CAErC,0CAA4C,8CAU5C,wCAA0C,UAE1C,gCAAkC,oCASlC,6BAA+B,oCAE/B,uCAAoE,CAC/E,qBAAsB,mCACtB,sBAAuB,0CACvB,mBAAoB,gCACpB,gBAAiB,4BACnB,EAEa,sBAAoC,CAC/C,OAAQ,mBACR,MAAO,uBACT,EAEa,4BAA0C,CACrD,OAAQ,mBACR,MAAO,6BACT,EAWa,yBAAuC,CAClD,OAAQ,mBACR,MAAO,0BACT,EAGa,8BAAgC,yCAEhC,+BAA6C,CACxD,OAAQ,mBACR,MAAO,gCACT,EAEa,oCAAkD,CAC7D,OAAQ,mBACR,MAAO,qCACT,EAGa,4BAA0C,CACrD,OAAQ,mBACR,MAAO,6BACT,EAEa,6BAA+B,oCAO/B,8BAAgC,qCAGhC,mCAAqC,0CAGrC,oCAAsC,2CAGtC,kBAAoB,yBAGpB,yBAA2B,GAAG,iBAAiB,OAG/C,+BAAiC,GAAG,iBAAiB,aAGrD,kCAAoC,GAAG,iBAAiB,gBCjJrE,OAAS,WAAY,uCAA0C,gBAkB/D,SAAS,+BAA+B,OAAuD,CAC7F,IAAM,KAA0C,CAAC,EACjD,QAAW,K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@
1
1
  {
2
2
  "name": "@medplum/scriptsure-react",
3
- "version": "5.1.27",
3
+ "version": "5.1.29",
4
4
  "description": "Medplum ScriptSure React SDK",
5
5
  "keywords": [
6
6
  "medplum",
@@ -58,22 +58,22 @@
58
58
  "test:watch": "vitest watch"
59
59
  },
60
60
  "devDependencies": {
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
- "@testing-library/jest-dom": "6.9.1",
61
+ "@medplum/core": "5.1.29",
62
+ "@medplum/fhirtypes": "5.1.29",
63
+ "@medplum/mock": "5.1.29",
64
+ "@medplum/react-hooks": "5.1.29",
65
+ "@testing-library/jest-dom": "7.0.0",
66
66
  "@testing-library/react": "16.3.2",
67
- "@types/react": "19.2.17",
68
- "@types/react-dom": "19.2.3",
69
- "@vitejs/plugin-react": "6.0.3",
70
- "react": "19.2.7",
71
- "react-dom": "19.2.7"
67
+ "@types/react": "19.2.18",
68
+ "@types/react-dom": "19.2.4",
69
+ "@vitejs/plugin-react": "6.0.5",
70
+ "react": "19.2.8",
71
+ "react-dom": "19.2.8"
72
72
  },
73
73
  "peerDependencies": {
74
- "@medplum/core": "5.1.27",
75
- "@medplum/fhirtypes": "5.1.27",
76
- "@medplum/react-hooks": "5.1.27",
74
+ "@medplum/core": "5.1.29",
75
+ "@medplum/fhirtypes": "5.1.29",
76
+ "@medplum/react-hooks": "5.1.29",
77
77
  "react": "^18.0.0 || ^19.0.0"
78
78
  },
79
79
  "engines": {