Skip to content

Commit fa21131

Browse files
committed
confirm that workers comp account is linked to encounter
1 parent 2dd7e87 commit fa21131

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

apps/ehr/src/features/external-labs/pages/CreateExternalLabOrder.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ export const CreateExternalLabOrder: React.FC<CreateExternalLabOrdersProps> = ()
224224
Information.
225225
</>,
226226
]);
227+
} else if (sdkError.code === 500) {
228+
setError(['Internal Server Error']);
227229
} else {
228230
setError(errorMessage);
229231
}

packages/zambdas/src/ehr/lab/external/create-lab-order/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,20 @@ const getAdditionalResources = async (
779779

780780
const workersCompAccount = workersCompAccounts[0];
781781

782+
console.log('checking that workers comp account is associated with this encounter');
783+
console.log('workersCompAccount', workersCompAccount.id);
784+
console.log('encounter.account', JSON.stringify(encounter?.account));
785+
786+
const encounterHasWorkersCompAccount = !!encounter?.account?.some(
787+
(ref) => ref.reference === `Account/${workersCompAccount.id}`
788+
);
789+
790+
if (!encounterHasWorkersCompAccount) {
791+
throw new Error(
792+
`There is a config issue with this encounter. The appointment is tagged as workers comp and the lab payment method selected is workers comp but the wc account is not linked to Encounter/${encounter?.id}.`
793+
);
794+
}
795+
782796
// todo labs oystehr submit lab will throw an error if there is no address under Account.guarantor.party, it would be good to validate that here too
783797
// we'll need to grab the workersCompAccount organization and check
784798

0 commit comments

Comments
 (0)