Skip to content

armgit / pdfcn

Public Imported from GitHub
0

Beautiful pdf components, built on Takumi and Forme. 100% Free, Zero config, one command setup.

18.3 KB
Raw Blame
{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "forme/medical-intake-form",
  "title": "Medical Intake Form",
  "description": "Medical Intake Form PDF block (forme)",
  "dependencies": [
    "@formepdf/react",
    "@formepdf/core"
  ],
  "registryDependencies": [
    "@pdfcn/forme/utils",
    "@pdfcn/forme/form",
    "@pdfcn/forme/list",
    "@pdfcn/forme/page-footer",
    "@pdfcn/forme/page-header",
    "@pdfcn/forme/pdf-image",
    "@pdfcn/forme/section",
    "@pdfcn/forme/signature",
    "@pdfcn/forme/table",
    "@pdfcn/forme/text"
  ],
  "files": [
    {
      "path": "registry/bases/forme/blocks/medical-intake-form/medical-intake-form.tsx",
      "content": "import { Document, Page, StyleSheet, View } from \"@formepdf/react\";\n\nimport { PdfForm } from \"@/components/pdf/form/form\";\nimport { PdfList } from \"@/components/pdf/list/list\";\nimport { PageFooter } from \"@/components/pdf/page-footer/page-footer\";\nimport { PageHeader } from \"@/components/pdf/page-header/page-header\";\nimport { PdfImage } from \"@/components/pdf/pdf-image/pdf-image\";\nimport { Section } from \"@/components/pdf/section/section\";\nimport { PdfSignatureBlock } from \"@/components/pdf/signature/signature\";\nimport {\n  Table,\n  TableBody,\n  TableCell,\n  TableHeader,\n  TableRow,\n} from \"@/components/pdf/table/table\";\nimport { Text } from \"@/components/pdf/text/text\";\nimport {\n  PdfcnThemeProvider,\n  usePdfcnTheme,\n  useSafeMemo,\n} from \"@/components/pdf/theme-provider\";\nimport { resolveColor } from \"@/lib/resolve-color\";\nimport type { PdfcnTheme } from \"@/types/pdf-themes\";\n\nimport type { MedicalIntakeFormProps } from \"./medical-intake-form.types\";\n\nconst FORM_VERSION = \"Form v1.0 · Revised 09/2026\";\nconst FORM_STYLE = { marginBottom: 0 };\n\nconst SECOND_PAGE_MARGIN_BOTTOM = 44;\nconst SECOND_PAGE_MARGIN_TOP = 24;\n\nconst MEDICAL_CONDITIONS = [\n  \"Diabetes\",\n  \"High Blood Pressure\",\n  \"Heart Disease\",\n  \"Asthma\",\n  \"COPD\",\n  \"Cancer\",\n  \"Stroke\",\n  \"Thyroid Disorder\",\n  \"Kidney Disease\",\n  \"Liver Disease\",\n  \"Seizures / Epilepsy\",\n  \"Other\",\n];\n\nconst CONSENT_ACKNOWLEDGMENTS = [\n  { checked: false, text: \"I have read and understand the consent above.\" },\n  { checked: false, text: \"I have received the Notice of Privacy Practices.\" },\n];\n\nconst MEDICATION_ROWS = [\n  \"medication-1\",\n  \"medication-2\",\n  \"medication-3\",\n  \"medication-4\",\n];\n\nconst ALLERGY_ROWS = [\"allergy-1\", \"allergy-2\", \"allergy-3\"];\n\nconst BLANK_CELL = <View style={{ minHeight: 14 }} />;\n\nconst blankChecklist = (labels: string[]) =>\n  labels.map((text) => ({ checked: false, text }));\n\nconst createIntakeStyles = (t: PdfcnTheme) =>\n  StyleSheet.create({\n    column: { flex: 1 },\n    consentText: {\n      fontSize: t.primitives.typography.xs,\n      lineHeight: 1.4,\n      marginBottom: 6,\n    },\n    labelText: { fontSize: 9, fontWeight: \"bold\", letterSpacing: 0.6 },\n    page: { backgroundColor: t.colors.background },\n    pageTwoHeader: {\n      alignItems: \"flex-end\",\n      flexDirection: \"row\",\n      justifyContent: \"space-between\",\n      marginBottom: 8,\n    },\n    reasonBox: {\n      borderColor: t.colors.border,\n      borderRadius: t.primitives.borderRadius.sm,\n      borderStyle: \"solid\",\n      borderWidth: 1,\n      height: 40,\n      minHeight: 40,\n    },\n    row: { flexDirection: \"row\", gap: 20 },\n    section: { marginBottom: 4 },\n    sectionRule: {\n      borderBottomStyle: \"solid\",\n      borderBottomWidth: 1,\n      marginBottom: 4,\n      paddingBottom: 2,\n    },\n    signature: { marginBottom: 0, marginTop: 8 },\n    title: { fontSize: 13, fontWeight: \"bold\" },\n  });\n\nconst useIntakeStyles = () => {\n  const theme = usePdfcnTheme();\n  const styles = useSafeMemo(() => createIntakeStyles(theme), [theme]);\n  return { styles, theme };\n};\n\nconst SectionLabel = ({ accent, label }: { accent: string; label: string }) => {\n  const { styles } = useIntakeStyles();\n\n  return (\n    <View style={{ ...styles.sectionRule, borderBottomColor: accent } as never}>\n      <Text noMargin style={styles.labelText} transform=\"uppercase\">\n        {label}\n      </Text>\n    </View>\n  );\n};\n\nconst IntakeHeader = ({\n  clinicAddress,\n  clinicLogo,\n  clinicName,\n  clinicPhone,\n}: Pick<\n  MedicalIntakeFormProps,\n  \"clinicAddress\" | \"clinicLogo\" | \"clinicName\" | \"clinicPhone\"\n>) => (\n  <PageHeader\n    logo={\n      clinicLogo ? (\n        <PdfImage\n          height={48}\n          src={clinicLogo}\n          style={{ margin: 0 }}\n          width={48}\n        />\n      ) : undefined\n    }\n    marginBottom={16}\n    rightSubText={clinicAddress}\n    rightText={clinicPhone}\n    subtitle=\"Patient Intake Form\"\n    title={clinicName}\n    variant=\"logo-left\"\n  />\n);\n\nconst SecondPageHeader = ({\n  clinicName,\n  clinicPhone,\n}: Pick<MedicalIntakeFormProps, \"clinicName\" | \"clinicPhone\">) => {\n  const { styles } = useIntakeStyles();\n\n  return (\n    <View style={styles.pageTwoHeader as never}>\n      <Text noMargin style={styles.title}>\n        {`${clinicName} — Patient Intake Form (continued)`}\n      </Text>\n      <Text color=\"mutedForeground\" noMargin variant=\"xs\">\n        {clinicPhone}\n      </Text>\n    </View>\n  );\n};\n\nconst IntakeFooter = ({\n  clinicAddress,\n  clinicPhone,\n  page,\n  pagePadding,\n  totalPages,\n}: Pick<MedicalIntakeFormProps, \"clinicAddress\" | \"clinicPhone\"> & {\n  page: number;\n  pagePadding: number;\n  totalPages: number;\n}) => (\n  <PageFooter\n    address={clinicAddress}\n    leftText={FORM_VERSION}\n    pagePadding={pagePadding}\n    phone={clinicPhone}\n    rightText={`Page ${page} of ${totalPages}`}\n    sticky\n    variant=\"three-column\"\n  />\n);\n\nconst PersonalInfoSection = () => (\n  <PdfForm\n    groups={[\n      {\n        fields: [\n          { height: 14, label: \"Full Name\" },\n          { height: 14, hint: \"DD / MM / YYYY\", label: \"Date of Birth\" },\n          { height: 14, label: \"Gender\" },\n          { height: 14, hint: \"+1 (555) 000-0000\", label: \"Phone Number\" },\n          { height: 14, label: \"Email Address\" },\n        ],\n        layout: \"two-column\",\n        title: \"Patient Information\",\n      },\n      {\n        fields: [\n          { height: 14, label: \"Street Address\", width: \"100%\" },\n          { height: 14, label: \"City\" },\n          { height: 14, label: \"State / Province\" },\n          { height: 14, label: \"Postal Code\" },\n        ],\n        layout: \"two-column\",\n        title: \"Address\",\n      },\n    ]}\n    style={FORM_STYLE}\n    variant=\"underline\"\n  />\n);\n\nconst EmergencyContactSection = () => (\n  <PdfForm\n    groups={[\n      {\n        fields: [\n          { height: 14, label: \"Emergency Contact Name\" },\n          { height: 14, label: \"Relationship\" },\n          { height: 14, label: \"Phone Number\" },\n        ],\n        layout: \"two-column\",\n        title: \"Emergency Contact\",\n      },\n    ]}\n    style={FORM_STYLE}\n    variant=\"underline\"\n  />\n);\n\nconst InsuranceSection = () => (\n  <PdfForm\n    groups={[\n      {\n        fields: [\n          { height: 14, label: \"Insurance Provider\" },\n          { height: 14, label: \"Policy Number\" },\n          { height: 14, label: \"Group Number\" },\n          { height: 14, label: \"Subscriber Name\" },\n        ],\n        layout: \"two-column\",\n        title: \"Insurance\",\n      },\n    ]}\n    style={FORM_STYLE}\n    variant=\"underline\"\n  />\n);\n\nconst MedicalHistorySection = ({ accent }: { accent: string }) => {\n  const { styles } = useIntakeStyles();\n\n  return (\n    <View style={styles.section as never}>\n      <SectionLabel accent={accent} label=\"Medical History\" />\n      <View style={styles.row as never}>\n        <View style={styles.column as never}>\n          <PdfList\n            gap=\"xs\"\n            items={blankChecklist(MEDICAL_CONDITIONS.slice(0, 4))}\n            variant=\"checklist\"\n          />\n        </View>\n        <View style={styles.column as never}>\n          <PdfList\n            gap=\"xs\"\n            items={blankChecklist(MEDICAL_CONDITIONS.slice(4, 8))}\n            variant=\"checklist\"\n          />\n        </View>\n        <View style={styles.column as never}>\n          <PdfList\n            gap=\"xs\"\n            items={blankChecklist(MEDICAL_CONDITIONS.slice(8))}\n            variant=\"checklist\"\n          />\n        </View>\n      </View>\n    </View>\n  );\n};\n\nconst MedicationsSection = ({ accent }: { accent: string }) => {\n  const { styles } = useIntakeStyles();\n\n  return (\n    <View style={styles.section as never}>\n      <SectionLabel accent={accent} label=\"Current Medications\" />\n      <Table variant=\"grid\">\n        <TableHeader>\n          <TableRow header>\n            <TableCell>Medication</TableCell>\n            <TableCell>Dosage</TableCell>\n            <TableCell>Frequency</TableCell>\n            <TableCell>Prescribing Doctor</TableCell>\n          </TableRow>\n        </TableHeader>\n        <TableBody>\n          {MEDICATION_ROWS.map((row) => (\n            <TableRow key={row}>\n              <TableCell>{BLANK_CELL}</TableCell>\n              <TableCell>{BLANK_CELL}</TableCell>\n              <TableCell>{BLANK_CELL}</TableCell>\n              <TableCell>{BLANK_CELL}</TableCell>\n            </TableRow>\n          ))}\n        </TableBody>\n      </Table>\n    </View>\n  );\n};\n\nconst AllergiesSection = ({ accent }: { accent: string }) => {\n  const { styles } = useIntakeStyles();\n\n  return (\n    <View style={styles.section as never}>\n      <SectionLabel accent={accent} label=\"Allergies\" />\n      <Table variant=\"grid\">\n        <TableHeader>\n          <TableRow header>\n            <TableCell>Allergen</TableCell>\n            <TableCell>Reaction</TableCell>\n            <TableCell>Severity</TableCell>\n          </TableRow>\n        </TableHeader>\n        <TableBody>\n          {ALLERGY_ROWS.map((row) => (\n            <TableRow key={row}>\n              <TableCell>{BLANK_CELL}</TableCell>\n              <TableCell>{BLANK_CELL}</TableCell>\n              <TableCell>{BLANK_CELL}</TableCell>\n            </TableRow>\n          ))}\n        </TableBody>\n      </Table>\n    </View>\n  );\n};\n\nconst ReasonForVisitSection = ({ accent }: { accent: string }) => {\n  const { styles } = useIntakeStyles();\n\n  return (\n    <View style={styles.section as never}>\n      <SectionLabel accent={accent} label=\"Reason for Visit\" />\n      <View style={styles.reasonBox as never} />\n    </View>\n  );\n};\n\nconst ConsentSection = ({\n  accent,\n  accentColor,\n  clinicName,\n}: Pick<MedicalIntakeFormProps, \"accentColor\" | \"clinicName\"> & {\n  accent: string;\n}) => {\n  const { styles } = useIntakeStyles();\n\n  return (\n    <View style={styles.section as never}>\n      <SectionLabel accent={accent} label=\"Consent & Authorization\" />\n      <Section\n        accentColor={accentColor}\n        padding=\"sm\"\n        spacing=\"none\"\n        variant=\"highlight\"\n      >\n        <Text color=\"mutedForeground\" noMargin style={styles.consentText}>\n          {`I authorize ${clinicName} to provide treatment and to release the information required to process insurance claims for this visit, and I acknowledge that I have received the Notice of Privacy Practices (HIPAA) explaining how my health information may be used.`}\n        </Text>\n        <PdfList gap=\"xs\" items={CONSENT_ACKNOWLEDGMENTS} variant=\"checklist\" />\n      </Section>\n      <PdfSignatureBlock\n        signers={[{ label: \"Patient / Guardian Signature\" }, { label: \"Date\" }]}\n        style={styles.signature}\n        variant=\"double\"\n      />\n    </View>\n  );\n};\n\ntype IntakeSections = Required<\n  Pick<\n    MedicalIntakeFormProps,\n    | \"allergies\"\n    | \"consent\"\n    | \"emergencyContact\"\n    | \"insurance\"\n    | \"medicalHistory\"\n    | \"medications\"\n    | \"personalInfo\"\n    | \"reasonForVisit\"\n  >\n>;\n\nconst resolveSections = (props: MedicalIntakeFormProps): IntakeSections => ({\n  allergies: props.allergies ?? true,\n  consent: props.consent ?? true,\n  emergencyContact: props.emergencyContact ?? true,\n  insurance: props.insurance ?? true,\n  medicalHistory: props.medicalHistory ?? true,\n  medications: props.medications ?? true,\n  personalInfo: props.personalInfo ?? true,\n  reasonForVisit: props.reasonForVisit ?? true,\n});\n\nconst hasSecondPage = (sections: IntakeSections) =>\n  sections.allergies ||\n  sections.consent ||\n  sections.medications ||\n  sections.reasonForVisit;\n\nconst FirstPage = ({\n  clinicAddress,\n  clinicLogo,\n  clinicName,\n  clinicPhone,\n  sections,\n  totalPages,\n}: Pick<\n  MedicalIntakeFormProps,\n  \"clinicAddress\" | \"clinicLogo\" | \"clinicName\" | \"clinicPhone\"\n> & {\n  sections: IntakeSections;\n  totalPages: number;\n}) => {\n  const { styles, theme } = useIntakeStyles();\n  const margin = {\n    bottom: theme.spacing.page.marginBottom,\n    left: theme.spacing.page.marginLeft,\n    right: theme.spacing.page.marginRight,\n    top: theme.spacing.page.marginTop,\n  };\n\n  return (\n    <Page margin={margin} size=\"A4\">\n      <IntakeFooter\n        clinicAddress={clinicAddress}\n        clinicPhone={clinicPhone}\n        page={1}\n        pagePadding={margin.bottom}\n        totalPages={totalPages}\n      />\n      <View style={styles.page as never}>\n        <IntakeHeader\n          clinicAddress={clinicAddress}\n          clinicLogo={clinicLogo}\n          clinicName={clinicName}\n          clinicPhone={clinicPhone}\n        />\n        {sections.personalInfo ? <PersonalInfoSection /> : null}\n        {sections.emergencyContact ? <EmergencyContactSection /> : null}\n        {sections.insurance ? <InsuranceSection /> : null}\n      </View>\n    </Page>\n  );\n};\n\nconst SecondPage = ({\n  accent,\n  accentColor,\n  clinicAddress,\n  clinicName,\n  clinicPhone,\n  sections,\n  totalPages,\n}: Pick<\n  MedicalIntakeFormProps,\n  \"accentColor\" | \"clinicAddress\" | \"clinicName\" | \"clinicPhone\"\n> & {\n  accent: string;\n  sections: IntakeSections;\n  totalPages: number;\n}) => {\n  const { styles, theme } = useIntakeStyles();\n  const margin = {\n    bottom: SECOND_PAGE_MARGIN_BOTTOM,\n    left: theme.spacing.page.marginLeft,\n    right: theme.spacing.page.marginRight,\n    top: SECOND_PAGE_MARGIN_TOP,\n  };\n\n  return (\n    <Page margin={margin} size=\"A4\">\n      <IntakeFooter\n        clinicAddress={clinicAddress}\n        clinicPhone={clinicPhone}\n        page={2}\n        pagePadding={margin.bottom}\n        totalPages={totalPages}\n      />\n      <View style={styles.page as never}>\n        <SecondPageHeader clinicName={clinicName} clinicPhone={clinicPhone} />\n        {sections.medicalHistory ? (\n          <MedicalHistorySection accent={accent} />\n        ) : null}\n        {sections.medications ? <MedicationsSection accent={accent} /> : null}\n        {sections.allergies ? <AllergiesSection accent={accent} /> : null}\n        {sections.reasonForVisit ? (\n          <ReasonForVisitSection accent={accent} />\n        ) : null}\n        {sections.consent ? (\n          <ConsentSection\n            accent={accent}\n            accentColor={accentColor}\n            clinicName={clinicName}\n          />\n        ) : null}\n      </View>\n    </Page>\n  );\n};\n\nconst MedicalIntakeFormContent = (props: MedicalIntakeFormProps) => {\n  const { theme } = useIntakeStyles();\n  const sections = resolveSections(props);\n  const accent = props.accentColor\n    ? resolveColor(props.accentColor, theme.colors)\n    : theme.colors.primary;\n  const totalPages = hasSecondPage(sections) ? 2 : 1;\n\n  return (\n    <Document title={`${props.clinicName} — Patient Intake Form`}>\n      <FirstPage\n        clinicAddress={props.clinicAddress}\n        clinicLogo={props.clinicLogo}\n        clinicName={props.clinicName}\n        clinicPhone={props.clinicPhone}\n        sections={sections}\n        totalPages={totalPages}\n      />\n      {totalPages > 1 ? (\n        <SecondPage\n          accent={accent}\n          accentColor={props.accentColor}\n          clinicAddress={props.clinicAddress}\n          clinicName={props.clinicName}\n          clinicPhone={props.clinicPhone}\n          sections={sections}\n          totalPages={totalPages}\n        />\n      ) : null}\n    </Document>\n  );\n};\n\n/**\n * Print-ready medical intake form with patient, emergency contact, insurance,\n * medical history, medication, allergy, reason for visit, and consent\n * sections. Every section can be hidden through its boolean prop, and all\n * fields are left blank for the patient to complete by hand.\n */\nexport const MedicalIntakeFormDocument = ({\n  theme,\n  ...props\n}: MedicalIntakeFormProps) => (\n  <PdfcnThemeProvider theme={theme}>\n    <MedicalIntakeFormContent {...props} />\n  </PdfcnThemeProvider>\n);\n",
      "type": "registry:block",
      "target": "components/pdf/blocks/medical-intake-form/medical-intake-form.tsx"
    },
    {
      "path": "registry/bases/forme/blocks/medical-intake-form/medical-intake-form.types.ts",
      "content": "import type { PdfcnTheme } from \"@/types/pdf-themes\";\n\n/**\n * Medical intake form properties.\n * Props - `clinicName` | `clinicLogo` | `clinicAddress` | `clinicPhone` |\n * `personalInfo` | `emergencyContact` | `insurance` | `medicalHistory` |\n * `medications` | `allergies` | `reasonForVisit` | `consent` | `accentColor` | `theme`\n * @see {@link MedicalIntakeFormDocument}\n */\nexport interface MedicalIntakeFormProps {\n  clinicName: string;\n  clinicLogo?: string;\n  clinicAddress?: string;\n  clinicPhone?: string;\n  /**\n   * @default true\n   */\n  personalInfo?: boolean;\n  /**\n   * @default true\n   */\n  emergencyContact?: boolean;\n  /**\n   * @default true\n   */\n  insurance?: boolean;\n  /**\n   * @default true\n   */\n  medicalHistory?: boolean;\n  /**\n   * @default true\n   */\n  medications?: boolean;\n  /**\n   * @default true\n   */\n  allergies?: boolean;\n  /**\n   * @default true\n   */\n  reasonForVisit?: boolean;\n  /**\n   * @default true\n   */\n  consent?: boolean;\n  /**\n   * Theme color token (e.g. `\"primary\"`) or raw CSS color (e.g. `\"#0d9488\"`)\n   * applied to section rules, table accents, and the consent callout.\n   */\n  accentColor?: string;\n  theme?: PdfcnTheme;\n}\n",
      "type": "registry:block",
      "target": "components/pdf/blocks/medical-intake-form/medical-intake-form.types.ts"
    }
  ],
  "type": "registry:block"
}