> ## Documentation Index
> Fetch the complete documentation index at: https://docs.humaniq.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Healthcare Recipes

> HIPAA-compliant approval workflows for healthcare operations

<Note>
  These recipes demonstrate HIPAA-compliant approval workflows designed for healthcare operations, with built-in audit trails and access controls.
</Note>

<Tabs>
  <Tab title="Patient Data Access">
    ### Patient Data Access

    Secure patient record access with role-based approvals and automatic logging.

    <CodeGroup>
      ```typescript Basic theme={null}
      const accessPatientRecords = needsHumanApproval({
        type: 'sync',
        title: 'Patient Record Access',
        ask: (args) => `Approve access to records for patient #${args.patientId}?`,
        // Auto-approve for attending physicians
        autoApprove: async (args) => args.requestorRole === 'ATTENDING_PHYSICIAN'
      })
      ```

      ```typescript Advanced theme={null}
      const accessPatientRecords = needsHumanApproval({
        type: 'sync',
        title: 'Patient Record Access',
        ask: (args) => {
          const urgent = args.isEmergency ? '🚨 URGENT: ' : '';
          return `${urgent}Approve access to ${args.recordType} records for patient #${args.patientId}?`;
        },
        // Route to appropriate approvers based on record type
        approvers: (args) => {
          if (args.recordType === 'MENTAL_HEALTH') {
            return [{ name: 'Mental Health Director', email: 'mh-director@hospital.com' }];
          }
          return [{ name: 'Medical Records', email: 'records@hospital.com' }];
        },
        approvalArguments: {
          requestReason: {
            type: 'string',
            value: args.reason,
            label: 'Access Reason',
            editable: true
          },
          accessDuration: {
            type: 'number',
            value: 30,
            label: 'Access Duration (minutes)',
            editable: true
          },
          recordType: {
            type: 'string',
            value: args.recordType,
            label: 'Record Type',
            editable: false
          },
          isEmergency: {
            type: 'boolean',
            value: args.isEmergency,
            label: 'Emergency Access',
            editable: true
          }
        },
        // Log all access attempts for HIPAA compliance
        onApprovedCallbackUrl: 'https://audit-log.hospital.com/record-access'
      })
      ```
    </CodeGroup>

    <AccordionGroup>
      <Accordion title="When to use this" icon="lightbulb">
        * Third-party provider requests
        * Research data access
        * Insurance company requests
        * Emergency access situations
      </Accordion>

      <Accordion title="Best practices" icon="check">
        * Always document access reason
        * Set appropriate time limits
        * Maintain detailed audit logs
        * Consider emergency protocols
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Treatment Plans">
    ### Treatment Plan Modifications

    Handle treatment plan changes with appropriate clinical oversight.

    ```typescript theme={null}
    const modifyTreatmentPlan = needsHumanApproval({
      type: 'async',
      title: 'Treatment Plan Update',
      ask: (args) => {
        const priority = args.urgency === 'HIGH' ? '🔔 HIGH PRIORITY: ' : '';
        return `${priority}Review treatment plan changes for patient #${args.patientId}`;
      },
      approvers: (args) => {
        const approvers = [{ 
          name: 'Primary Physician', 
          email: `dr-${args.primaryPhysicianId}@hospital.com` 
        }];
        
        // Add specialist approval if needed
        if (args.requiresSpecialist) {
          approvers.push({ 
            name: 'Specialist', 
            email: `dr-${args.specialistId}@hospital.com` 
          });
        }
        
        return approvers;
      },
      approvalArguments: {
        currentPlan: {
          type: 'longString',
          value: args.currentPlan,
          label: 'Current Treatment Plan',
          editable: false
        },
        proposedChanges: {
          type: 'longString',
          value: args.changes,
          label: 'Proposed Changes',
          editable: true
        },
        clinicalReason: {
          type: 'string',
          value: args.reason,
          label: 'Clinical Justification',
          editable: true
        }
      }
    })
    ```

    <AccordionGroup>
      <Accordion title="Approval Routing" icon="route">
        * Primary physician review
        * Specialist consultation
        * Care team coordination
        * Insurance pre-authorization
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Medication Changes">
    ### Medication Changes

    Manage medication changes with pharmacy oversight and interaction checking.

    <CodeGroup>
      ```typescript Basic theme={null}
      const updateMedication = needsHumanApproval({
        type: 'sync',
        title: 'Medication Change',
        ask: (args) => `Approve change in medication for patient #${args.patientId}?`,
        autoApprove: async (args) => !args.hasInteractions
      })
      ```

      ```typescript Advanced theme={null}
      const updateMedication = needsHumanApproval({
        type: 'sync',
        title: 'Medication Change',
        ask: (args) => {
          const warning = args.hasInteractions ? '⚠️ INTERACTION ALERT: ' : '';
          return `${warning}Review medication change for patient #${args.patientId}`;
        },
        approvalArguments: {
          currentMeds: {
            type: 'longString',
            value: args.currentMedications.join('\n'),
            label: 'Current Medications',
            editable: false
          },
          proposedMed: {
            type: 'string',
            value: args.newMedication,
            label: 'Proposed Medication',
            editable: true
          },
          dosage: {
            type: 'string',
            value: args.dosage,
            label: 'Proposed Dosage',
            editable: true
          },
          interactions: {
            type: 'longString',
            value: args.interactionWarnings || 'None detected',
            label: 'Potential Interactions',
            editable: false
          }
        },
        // Require pharmacy approval for certain medications
        shouldSeekApprovals: async (args) => {
          return args.hasInteractions || args.isControlledSubstance;
        }
      })
      ```
    </CodeGroup>

    <Note>
      All medication changes automatically check for drug interactions and require pharmacy approval if interactions are detected.
    </Note>
  </Tab>

  <Tab title="Remote Care">
    ### Remote Care Authorization

    Handle remote care and telehealth approvals with licensing verification.

    ```typescript theme={null}
    const authorizeRemoteCare = needsHumanApproval({
      type: 'sync',
      title: 'Remote Care Authorization',
      ask: (args) => `Authorize remote care session for patient #${args.patientId}?`,
      approvalArguments: {
        serviceType: {
          type: 'string',
          value: args.serviceType,
          label: 'Service Type',
          editable: true
        },
        patientLocation: {
          type: 'string',
          value: args.location,
          label: 'Patient Location',
          editable: false
        },
        crossState: {
          type: 'boolean',
          value: args.isCrossState,
          label: 'Cross-state Care',
          editable: false
        },
        providerLicense: {
          type: 'string',
          value: args.providerLicenses.join(', '),
          label: 'Provider Licenses',
          editable: false
        }
      },
      // Check licensing for cross-state care
      shouldSeekApprovals: async (args) => {
        return args.isCrossState || args.serviceType === 'CONTROLLED_SUBSTANCE';
      },
      // Require medical director approval for certain cases
      approvers: (args) => {
        if (args.isCrossState || args.serviceType === 'CONTROLLED_SUBSTANCE') {
          return [{ name: 'Medical Director', email: 'medical-director@hospital.com' }];
        }
        return [{ name: 'Care Coordinator', email: 'care@hospital.com' }];
      }
    })
    ```

    <AccordionGroup>
      <Accordion title="Compliance Checks" icon="clipboard-check">
        * State licensing verification
        * Patient location validation
        * Service type restrictions
        * Provider credentials
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

## Next Steps

<CardGroup cols={2}>
  <Card title="Compliance Integration" icon="shield-halved" href="/recipes/legal">
    Explore legal approval workflows
  </Card>
</CardGroup>
