from typing import Optional


def create_specimen_observation(specimen_reference: dict,
                                patient_reference: dict,
                                encounter_reference: dict) -> Optional[dict]:
    """
    Create an observation resource that is a links a specimen, a patient, and
    an encounter. Follows the FHIR format
    (http://www.hl7.org/implement/standards/fhir/observation.html)
    """
    if not specimen_reference:
        return None

    return {
        "resourceType": "Observation",
        "status": "final",
        "code": {
            "coding": [
                {
                    "system": "http://loinc.org",
                    "code": "89873-4",
                    "display": "Unique ID Initial sample"
                }
            ]
        },
        "encounter": encounter_reference,
        "subject": patient_reference,
        "specimen": specimen_reference
    }