scribe2fhir FHIR Specification
This document defines the FHIR resource specifications and output requirements for all scribe2fhir SDK implementations across different programming languages. All language implementations MUST produce identical FHIR Bundle structures to ensure interoperability.
Bundle Structure Requirements
Section titled “Bundle Structure Requirements”Bundle Metadata
Section titled “Bundle Metadata”All scribe2fhir SDKs MUST generate FHIR Bundles with:
- resourceType:
"Bundle" - id: UUID v4 format (e.g., “12345678-1234-1234-1234-123456789012”)
- type:
"collection"(default) or specified type - timestamp: ISO 8601 datetime with timezone (e.g., “2024-01-15T10:30:00.000Z”)
- entry: Array of BundleEntry objects containing resources
Bundle Entry Structure
Section titled “Bundle Entry Structure”Each entry MUST contain:
- fullUrl:
"urn:uuid:{resource-id}" - resource: Complete FHIR resource object
Resource Ordering in Bundle
Section titled “Resource Ordering in Bundle”Resources MUST appear in this order:
- Patient (if present)
- Encounter (if present)
- Observations (all types)
- Conditions
- MedicationRequests
- MedicationStatements
- ServiceRequests
- Procedures
- FamilyMemberHistory
- AllergyIntolerance
- Immunizations
- Appointments
- CarePlans
- Communications
Supported Elements and FHIR Resource Mapping
Section titled “Supported Elements and FHIR Resource Mapping”1. Patient Element → Patient Resource
Section titled “1. Patient Element → Patient Resource”Purpose: Demographics and administrative information
Cardinality: 0..1 (optional but recommended)
Required Fields:
id: UUID v4name: Array with at least one HumanName containingtextfield
Optional Fields:
gender: “male” | “female” | “other” | “unknown”birthDate: ISO date (YYYY-MM-DD)extension: Patient age extension when age provided instead of birthDateidentifier: Array of Identifier objectsaddress: Array of Address objectstelecom: Array of ContactPoint objects
SDK-Specific Constraints:
- Age provided as tuple (value, unit) creates extension with URL
"http://hl7.org/fhir/StructureDefinition/patient-age" - Name is stored as single HumanName with text field
- Maximum one address and multiple telecom entries (phone, email)
Reference Pattern:
- Referenced by all other resources in
subjectorpatientfield - Display name includes patient name for human readability
2. Encounter Element → Encounter Resource
Section titled “2. Encounter Element → Encounter Resource”Purpose: Healthcare interaction context
Cardinality: 0..1 (optional but recommended for clinical context)
Required Fields:
id: UUID v4status: “planned” | “arrived” | “triaged” | “in-progress” | “onleave” | “finished” | “cancelled”class: CodeableConcept with encounter class code
Optional Fields:
type: Array of CodeableConcept for encounter typesperiod: Period with start and optional endlocation: Array with location referencesserviceProvider: Reference to providing organizationsubject: Reference to Patient
SDK-Specific Constraints:
- Default status: “finished”
- Class codes: “AMB” (ambulatory), “EMER” (emergency), “IMP” (inpatient), “VR” (virtual)
- Facility name creates location reference
- Department creates serviceProvider reference
Reference Pattern:
- Referenced by clinical resources in
encounterfield
3. Symptom Element → Observation Resource
Section titled “3. Symptom Element → Observation Resource”Purpose: Patient-reported symptoms and chief complaints
Cardinality: 0..*
Required Fields:
id: UUID v4status: “registered” | “preliminary” | “final” | “amended” | “corrected” | “cancelled”category: Array with CodeableConcept containing survey categorycode: CodeableConcept for symptomsubject: Reference to Patient
Optional Fields:
encounter: Reference to EncountereffectiveDateTime: ISO datetime for single point in timeeffectivePeriod: Period for onset/offset rangecomponent: Array for severity, laterality, finding statusnote: Array of Annotation objects
SDK-Specific Constraints:
- Category MUST be “survey” (code: “survey”, system: “http://terminology.hl7.org/CodeSystem/observation-category”)
- Default status: “final”
- Severity component uses code “SEV” with SNOMED CT values
- Laterality component uses code “272741003” (SNOMED CT)
- Finding status component uses code “408729009” (SNOMED CT)
- When both onset and offset provided, use effectivePeriod instead of effectiveDateTime
Component Structure:
{ "component": [ { "code": { "coding": [{"system": "http://snomed.info/sct", "code": "SEV"}], "text": "Severity" }, "valueCodeableConcept": { "text": "Moderate", "coding": [{"system": "http://snomed.info/sct", "code": "6736007", "display": "Moderate"}] } } ]}4. Vital Signs Element → Observation Resource
Section titled “4. Vital Signs Element → Observation Resource”Purpose: Physiological measurements and vital signs
Cardinality: 0..*
Required Fields:
id: UUID v4status: Default “final”category: Array with vital-signs categorycode: CodeableConcept for vital sign typesubject: Reference to Patient
Optional Fields:
encounter: Reference to EncountereffectiveDateTime: When measuredvalueQuantity: Numeric value with unitvalueString: String value (for compound measurements)interpretation: Array of CodeableConceptnote: Array of Annotation objects
SDK-Specific Constraints:
- Category MUST be “vital-signs” (code: “vital-signs”, system: “http://terminology.hl7.org/CodeSystem/observation-category”)
- String values include unit in text (e.g., “120/80 mmHg”)
- Numeric values use separate unit field
- Interpretation codes from http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation
5. Lab Findings Element → Observation Resource
Section titled “5. Lab Findings Element → Observation Resource”Purpose: Laboratory test results and interpretations
Cardinality: 0..*
Required Fields: Same as Vital Signs Optional Fields: Same as Vital Signs
SDK-Specific Constraints:
- Category MUST be “laboratory” (code: “laboratory”, system: “http://terminology.hl7.org/CodeSystem/observation-category”)
- Values can be numeric (valueQuantity) or text (valueString)
- Interpretation same as vital signs
6. Examination Findings Element → Observation Resource
Section titled “6. Examination Findings Element → Observation Resource”Purpose: Physical examination results
Cardinality: 0..*
Required Fields: Same structure as other Observations SDK-Specific Constraints:
- Category MUST be “exam” (code: “exam”, system: “http://terminology.hl7.org/CodeSystem/observation-category”)
- Values typically text descriptions of findings
- No interpretation field typically used
7. Lifestyle History Element → Observation Resource
Section titled “7. Lifestyle History Element → Observation Resource”Purpose: Social history and lifestyle factors
Cardinality: 0..*
Required Fields: Same structure as other Observations SDK-Specific Constraints:
- Category MUST be “social-history” (code: “social-history”, system: “http://terminology.hl7.org/CodeSystem/observation-category”)
- Values are typically status strings (“Active”, “Inactive”, “Former”, “Never”)
8. Medical Condition Elements → Condition Resource
Section titled “8. Medical Condition Elements → Condition Resource”Purpose: Medical diagnoses and health problems
Cardinality: 0..*
Types: History conditions and encounter diagnoses
Required Fields:
id: UUID v4clinicalStatus: CodeableConcept with statuscategory: Array with condition categorycode: CodeableConcept for conditionsubject: Reference to Patient
Optional Fields:
encounter: Reference to EncounterverificationStatus: CodeableConcept for verificationseverity: CodeableConcept for severity (direct field, not extension)bodySite: Array for laterality/body siteonsetDateTime: Single point onsetonsetPeriod: Period for onset/offset rangeabatementDateTime: Resolution timenote: Array of Annotation objects
SDK-Specific Constraints:
History Conditions:
- Category: “problem-list-item” (code: “problem-list-item”, system: “http://terminology.hl7.org/CodeSystem/condition-category”)
- Default clinicalStatus: “active”
- No default verificationStatus
Encounter Diagnoses:
- Category: “encounter-diagnosis” (code: “encounter-diagnosis”, system: “http://terminology.hl7.org/CodeSystem/condition-category”)
- Default clinicalStatus: “active”
- Default verificationStatus: “confirmed”
Status Codes:
- Clinical: “active” | “inactive” | “resolved” | “recurrence”
- Verification: “unconfirmed” | “provisional” | “differential” | “confirmed” | “refuted”
9. Medication Prescription Element → MedicationRequest Resource
Section titled “9. Medication Prescription Element → MedicationRequest Resource”Purpose: Prescribed medications with dosage instructions
Cardinality: 0..*
Required Fields:
id: UUID v4status: “active” | “on-hold” | “cancelled” | “completed”intent: “proposal” | “plan” | “order” | “original-order”medication: CodeableConcept for medicationsubject: Reference to Patient
Optional Fields:
encounter: Reference to EncounterauthoredOn: ISO datetime when prescribeddosageInstruction: Array of Dosage objectsdispenseRequest: DispenseRequest with quantity/durationnote: Array of Annotation objectsreasonCode: Array of CodeableConcept
SDK-Specific Constraints:
- Default status: “active”
- Default intent: “order”
- Medication stored in
medicationfield (CodeableConcept) - Duration creates dispenseRequest.expectedSupplyDuration
- Quantity creates dispenseRequest.quantity
- Refills creates dispenseRequest.numberOfRepeatsAllowed
Dosage Structure Requirements:
text: Human-readable instructionroute: CodeableConcept with route codetiming: Timing object with repeat and optional codedoseAndRate: Array with doseQuantity
10. Medication History Element → MedicationStatement Resource
Section titled “10. Medication History Element → MedicationStatement Resource”Purpose: Patient’s medication history and current medications
Cardinality: 0..*
Required Fields:
id: UUID v4status: “active” | “completed” | “entered-in-error” | “intended” | “stopped” | “on-hold”medication: CodeableConcept for medicationsubject: Reference to Patient
Optional Fields:
effectivePeriod: When medication was/is being takendateAsserted: When information was recordeddosage: Array of Dosage objectsreasonCode: Array of CodeableConceptnote: Array of Annotation objects
SDK-Specific Constraints:
- Default status: “active”
- Effective period from start/end dates
- Same dosage structure as MedicationRequest
11. Lab Test Ordering Element → ServiceRequest Resource
Section titled “11. Lab Test Ordering Element → ServiceRequest Resource”Purpose: Laboratory test orders
Cardinality: 0..*
Required Fields:
id: UUID v4status: “draft” | “active” | “on-hold” | “revoked” | “completed”intent: “proposal” | “plan” | “directive” | “order”category: Array with laboratory categorycode: CodeableConcept for testsubject: Reference to Patient
Optional Fields:
encounter: Reference to EncounteroccurrenceDateTime: When test should be performedpriority: “routine” | “urgent” | “asap” | “stat”reasonCode: Array of CodeableConceptnote: Array of Annotation objects
SDK-Specific Constraints:
- Default status: “active”
- Default intent: “order”
- Category MUST be laboratory procedure (code: “108252007”, system: “http://snomed.info/sct”, display: “Laboratory procedure”)
12. Procedure Ordering Element → ServiceRequest Resource
Section titled “12. Procedure Ordering Element → ServiceRequest Resource”Purpose: Procedure and imaging orders
Cardinality: 0..*
Required Fields: Same as Lab Test Ordering SDK-Specific Constraints:
- Category MUST be surgical procedure (code: “387713003”, system: “http://snomed.info/sct”, display: “Surgical procedure”)
13. Family History Element → FamilyMemberHistory Resource
Section titled “13. Family History Element → FamilyMemberHistory Resource”Purpose: Family medical history
Cardinality: 0..*
Required Fields:
id: UUID v4status: “partial” | “completed” | “entered-in-error” | “health-unknown”patient: Reference to Patientrelationship: CodeableConcept for family relationshipcondition: Array with condition information
Optional Fields:
deceasedBoolean: Whether family member is deceasednote: Array of Annotation objects
SDK-Specific Constraints:
- Default status: “completed”
- Relationship text stored directly (e.g., “father”, “mother”, “brother”)
- Condition array contains objects with:
code: CodeableConcept for conditiononsetAge: Age at onset (if provided as integer)onsetString: Year or description (if provided as string)
14. Allergy History Element → AllergyIntolerance Resource
Section titled “14. Allergy History Element → AllergyIntolerance Resource”Purpose: Allergies and adverse reactions
Cardinality: 0..*
Required Fields:
id: UUID v4clinicalStatus: CodeableConcept with statuscode: CodeableConcept for allergenpatient: Reference to Patientcategory: Array of category strings
Optional Fields:
encounter: Reference to Encountercriticality: “low” | “high”reaction: Array with reaction informationnote: Array of Annotation objects
SDK-Specific Constraints:
- Default clinicalStatus: “active”
- Categories: “food” | “medication” | “environment” | “biologic”
- Reaction array contains objects with
manifestationarray containing reaction descriptions
15. Immunization History Element → Immunization Resource
Section titled “15. Immunization History Element → Immunization Resource”Purpose: Vaccination records
Cardinality: 0..*
Required Fields:
id: UUID v4status: “completed” | “entered-in-error” | “not-done”vaccineCode: CodeableConcept for vaccinepatient: Reference to Patient
Optional Fields:
encounter: Reference to EncounteroccurrenceDateTime: When vaccine was givenprotocolApplied: Array with dose informationnote: Array of Annotation objects
SDK-Specific Constraints:
- Default status: “completed”
- Protocol applied contains doseNumber and seriesDoses when provided
- Use CVX codes in vaccineCode when available
16. Procedure History Element → Procedure Resource
Section titled “16. Procedure History Element → Procedure Resource”Purpose: Past surgical procedures and interventions
Cardinality: 0..*
Required Fields:
id: UUID v4status: “preparation” | “in-progress” | “not-done” | “on-hold” | “stopped” | “completed”code: CodeableConcept for proceduresubject: Reference to Patient
Optional Fields:
encounter: Reference to EncounterperformedDateTime: When procedure was doneoutcome: CodeableConcept for resultnote: Array of Annotation objects
SDK-Specific Constraints:
- Default status: “completed”
- Performed date stored in performedDateTime (not performedPeriod)
17. Follow-up Appointment Element → Appointment Resource
Section titled “17. Follow-up Appointment Element → Appointment Resource”Purpose: Scheduled appointments and referrals
Cardinality: 0..*
Required Fields:
id: UUID v4status: “proposed” | “pending” | “booked” | “arrived” | “fulfilled” | “cancelled”start: ISO datetime for appointmentparticipant: Array with patient and optional practitioner
Optional Fields:
serviceType: Array of CodeableReference for servicespecialty: Array of CodeableConcept for medical specialtynote: Array of Annotation objects
SDK-Specific Constraints:
- Default status: “booked”
- Patient participant always included with status “accepted”
- Practitioner participant added when doctor name provided
- Specialty stored in specialty array, not appointmentType
- Notes stored in note array as Annotation objects
18. Patient Advice Element → CarePlan Resource
Section titled “18. Patient Advice Element → CarePlan Resource”Purpose: Patient instructions and care recommendations
Cardinality: 0..*
Required Fields:
id: UUID v4status: “draft” | “active” | “on-hold” | “revoked” | “completed”intent: “proposal” | “plan” | “order” | “option”subject: Reference to Patientactivity: Array with activity information
Optional Fields:
encounter: Reference to Encountercategory: Array of CodeableConcepttitle: Plan titledescription: Plan description
SDK-Specific Constraints:
- Default status: “active”
- Default intent: “plan”
- Activity array contains objects with
progressarray - Advice text stored in activity.progress[0].text (Annotation)
- Category text stored directly when provided
19. Clinical Notes Element → Communication Resource
Section titled “19. Clinical Notes Element → Communication Resource”Purpose: Provider documentation and clinical notes
Cardinality: 0..*
Required Fields:
id: UUID v4status: “preparation” | “in-progress” | “not-done” | “on-hold” | “stopped” | “completed”payload: Array with contentsubject: Reference to Patient
Optional Fields:
encounter: Reference to Encountercategory: Array of CodeableConceptsent: ISO datetime when sent/recorded
SDK-Specific Constraints:
- Default status: “completed”
- Payload uses contentCodeableConcept.text (not contentString)
- Category text stored directly when provided
Data Type Standards
Section titled “Data Type Standards”CodeableConcept Structure
Section titled “CodeableConcept Structure”All CodeableConcept objects MUST follow this pattern:
{ "coding": [ { "system": "http://snomed.info/sct", "code": "25064002", "display": "Headache" } ], "text": "Headache"}When only text provided, structure becomes:
{ "text": "Headache"}Reference Structure
Section titled “Reference Structure”All references MUST follow this pattern:
{ "reference": "Patient/12345678-1234-1234-1234-123456789012", "display": "John Doe"}DateTime Format
Section titled “DateTime Format”All datetime fields MUST use ISO 8601 format with timezone:
"2024-01-15T10:30:00.000Z"(UTC)"2024-01-15T10:30:00+05:30"(with timezone offset)
Quantity Structure
Section titled “Quantity Structure”Numeric values with units MUST follow:
{ "value": 120, "unit": "mmHg", "system": "http://unitsofmeasure.org", "code": "mm[Hg]"}Annotation Structure
Section titled “Annotation Structure”Notes and comments MUST use:
{ "text": "Additional information about the finding"}Enumerated Values
Section titled “Enumerated Values”Severity Levels
Section titled “Severity Levels”- Code: SNOMED CT system
- Values: “mild” | “moderate” | “severe”
- Codes: “255604002” (mild), “6736007” (moderate), “24484000” (severe)
Laterality Values
Section titled “Laterality Values”- Code: SNOMED CT system
- Values: “left” | “right” | “bilateral”
- Codes: “7771000” (left), “24028007” (right), “51440002” (bilateral)
Finding Status
Section titled “Finding Status”- Code: SNOMED CT system
- Values: “present” | “absent”
- Codes: “52101004” (present), “2667000” (absent)
Interpretation Values
Section titled “Interpretation Values”- System: “http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation”
- Values: “normal” (N), “high” (H), “low” (L), “abnormal” (A)
Validation Requirements
Section titled “Validation Requirements”Bundle Validation
Section titled “Bundle Validation”- Bundle MUST contain valid resourceType and id
- All entries MUST have fullUrl with urn:uuid format
- All resource IDs within bundle MUST be unique
- All references MUST point to existing resources in bundle
Resource Validation
Section titled “Resource Validation”- All resources MUST have required fields populated
- All CodeableConcept objects MUST have either coding or text
- All references MUST follow reference format specification
- All datetime values MUST be timezone-aware
- All UUIDs MUST be valid UUID v4 format
Reference Validation
Section titled “Reference Validation”- Patient references MUST exist when patient is added
- Encounter references MUST exist when encounter is added
- Reference display names MUST be populated when available
- Circular references MUST be avoided
Implementation Requirements for Language SDKs
Section titled “Implementation Requirements for Language SDKs”1. Builder Pattern
Section titled “1. Builder Pattern”All implementations MUST use builder pattern:
DocumentBuilder builder = new DocumentBuilder()builder.addPatient(name, age, gender)builder.addSymptom(code, severity)Bundle bundle = builder.convertToFHIR()2. Method Naming Convention
Section titled “2. Method Naming Convention”Method names MUST follow pattern: add{ElementType}()
- addPatient()
- addEncounter()
- addSymptom()
- addMedicalConditionHistory()
- addMedicalConditionEncountered()
- addVitalFinding()
- addLabFinding()
- addExaminationFinding()
- addLifestyleHistory()
- addMedicationPrescribed()
- addMedicationHistory()
- addTestPrescribed()
- addProcedurePrescribed()
- addProcedureHistory()
- addFamilyHistory()
- addAllergyHistory()
- addImmunisationHistory()
- addFollowup()
- addAdvice()
- addNotes()
3. Parameter Requirements
Section titled “3. Parameter Requirements”Each method MUST accept:
- Required parameters as defined above
- Optional parameters with documented defaults
- Code parameters accepting both CodeableConcept objects and strings
- DateTime parameters accepting multiple formats
4. Reference Management
Section titled “4. Reference Management”Implementations MUST:
- Auto-generate UUID v4 IDs for all resources
- Automatically create patient references when patient exists
- Automatically create encounter references when encounter exists
- Populate reference display names
- Validate reference integrity
5. Bundle Generation
Section titled “5. Bundle Generation”The convertToFHIR() method MUST:
- Return valid FHIR R5 Bundle as JSON/dictionary
- Include all added resources in specified order
- Generate proper fullUrl for each entry
- Include bundle metadata (id, type, timestamp)
Testing Requirements
Section titled “Testing Requirements”All language implementations MUST include test suites that verify:
- Each element type can be created with minimal and comprehensive parameters
- Generated FHIR resources match specification exactly
- Bundle structure follows requirements
- Reference relationships are correct
- Edge cases and error conditions are handled
- Cross-element integration works properly
Compliance Verification
Section titled “Compliance Verification”Language implementations can verify compliance by:
- Generating identical output for the same input across languages
- Validating against FHIR R5 schemas
- Testing reference integrity within bundles
- Comparing JSON output structure element-by-element
This specification ensures that all scribe2fhir SDK implementations produce identical FHIR output regardless of the programming language used.