Medication History Element Documentation
Overview
Section titled “Overview”Medication History elements represent medications the patient is currently taking or has taken in the past. These create FHIR MedicationStatement resources to document medication history and current medications.
Function
Section titled “Function”builder.add_medication_history( medication: CodeInput, dosage: Optional[Union[Dosage, List[Dosage]]] = None, status: Union[MedicationStatementStatus, str] = "active", effective_start: Optional[DateTimeInput] = None, effective_end: Optional[DateTimeInput] = None, notes: Optional[str] = None, reason: Optional[CodeInput] = None, date_asserted: Optional[DateTimeInput] = None, id: Optional[str] = None,) -> MedicationStatementParameters
Section titled “Parameters”Required Parameters
Section titled “Required Parameters”- medication: The medication name or code
Optional Parameters
Section titled “Optional Parameters”- dosage: How the medication is/was taken (see DosageBuilder)
- status: Current status of medication use (default: “active”)
- effective_start: When patient started taking the medication
- effective_end: When patient stopped taking the medication
- notes: Additional notes about medication use
- reason: Why the medication is/was being taken
- date_asserted: When this information was recorded
- id: Custom resource ID
Basic Usage
Section titled “Basic Usage”Current Medication (Preferred with CodeableConcept)
Section titled “Current Medication (Preferred with CodeableConcept)”from fhir_sdk import FHIRDocumentBuilder, MedicationStatementStatusfrom fhir_sdk.types import create_codeable_conceptfrom datetime import datetime, timedelta
builder = FHIRDocumentBuilder()builder.add_patient(name="John Doe", age=30)
# Add current medicationmed_history = builder.add_medication_history( medication=create_codeable_concept( text="Lisinopril 10mg", code="386872004", system="http://snomed.info/sct", display="Lisinopril" ), status=MedicationStatementStatus.ACTIVE, effective_start=datetime.now() - timedelta(days=180), notes="Taking daily for blood pressure control")Using String (Alternative)
Section titled “Using String (Alternative)”med_history = builder.add_medication_history( medication="Lisinopril 10mg", status="active", notes="Taking daily for blood pressure")With Dosage Information
Section titled “With Dosage Information”from fhir_sdk import DosageBuilder, RouteOfAdministration, EventTiming
# Create dosagedosage = DosageBuilder.build( dose_value=10, dose_unit="mg", frequency=1, period=1, period_unit="d", route=RouteOfAdministration.ORAL, timing_code=EventTiming.MORNING, text="Take 10mg once daily in the morning")
med_history = builder.add_medication_history( medication="Lisinopril 10mg", dosage=dosage, effective_start=datetime.now() - timedelta(days=90), reason="Hypertension")Medication Status Options
Section titled “Medication Status Options”from fhir_sdk import MedicationStatementStatus
# Active medicationmed = builder.add_medication_history( medication="Metformin 500mg", status=MedicationStatementStatus.ACTIVE)
# Completed coursemed = builder.add_medication_history( medication="Amoxicillin 500mg", status=MedicationStatementStatus.COMPLETED, effective_start=datetime.now() - timedelta(days=14), effective_end=datetime.now() - timedelta(days=7))
# Stopped medicationmed = builder.add_medication_history( medication="Aspirin 81mg", status=MedicationStatementStatus.STOPPED, notes="Stopped due to gastric irritation")Available medication statuses:
MedicationStatementStatus.ACTIVEor"active"- Currently takingMedicationStatementStatus.COMPLETEDor"completed"- Finished courseMedicationStatementStatus.INTENDEDor"intended"- Planned to startMedicationStatementStatus.STOPPEDor"stopped"- Discontinued
Common Current Medications
Section titled “Common Current Medications”Cardiovascular Medications
Section titled “Cardiovascular Medications”# ACE Inhibitormed = builder.add_medication_history( medication=create_codeable_concept( text="Lisinopril 10mg", code="386872004", system="http://snomed.info/sct" ), status="active", effective_start=datetime.now() - timedelta(days=365), reason="Hypertension", notes="Well tolerated, good BP control")
# Beta Blockermed = builder.add_medication_history( medication=create_codeable_concept( text="Metoprolol 50mg", code="386864001", system="http://snomed.info/sct" ), status="active", notes="Twice daily for heart rate control")Diabetes Medications
Section titled “Diabetes Medications”# Metforminmed = builder.add_medication_history( medication=create_codeable_concept( text="Metformin 1000mg", code="387467008", system="http://snomed.info/sct" ), status="active", effective_start=datetime.now() - timedelta(days=730), reason="Type 2 diabetes mellitus", notes="Twice daily with meals, good glucose control")
# Insulinmed = builder.add_medication_history( medication=create_codeable_concept( text="Insulin glargine", code="411529005", system="http://snomed.info/sct" ), status="active", notes="20 units at bedtime")Pain and Anti-inflammatory
Section titled “Pain and Anti-inflammatory”# NSAIDsmed = builder.add_medication_history( medication="Ibuprofen 400mg", status="active", notes="As needed for arthritis pain, maximum 3 times daily")
# Acetaminophenmed = builder.add_medication_history( medication="Acetaminophen 500mg", status="stopped", effective_start=datetime.now() - timedelta(days=30), effective_end=datetime.now() - timedelta(days=15), notes="Stopped after completing course for headaches")Psychiatric Medications
Section titled “Psychiatric Medications”med = builder.add_medication_history( medication=create_codeable_concept( text="Sertraline 50mg", code="387467007", system="http://snomed.info/sct" ), status="active", effective_start=datetime.now() - timedelta(days=180), reason="Depression", notes="Daily dose, patient reports improved mood")Medication History with Reason
Section titled “Medication History with Reason”med = builder.add_medication_history( medication="Crocin 650mg", status="active", effective_start=datetime.now() - timedelta(days=90), reason=create_codeable_concept( text="Pain management", code="278414003", system="http://snomed.info/sct" ), notes="Takes as needed for chronic back pain")Over-the-Counter Medications
Section titled “Over-the-Counter Medications”# Vitaminsmed = builder.add_medication_history( medication="Vitamin D3 2000 IU", status="active", notes="Daily supplement for vitamin D deficiency")
# Herbal supplementsmed = builder.add_medication_history( medication="Turmeric supplement", status="active", notes="500mg daily, patient reports joint pain improvement")Medication Adherence Documentation
Section titled “Medication Adherence Documentation”med = builder.add_medication_history( medication="Warfarin 5mg", status="active", notes="Good adherence, takes same time daily, regular INR monitoring")
# Poor adherencemed = builder.add_medication_history( medication="Metformin 500mg", status="active", notes="Patient admits to missing doses frequently")Stopped Medications
Section titled “Stopped Medications”med = builder.add_medication_history( medication="Aspirin 81mg", status="stopped", effective_start=datetime.now() - timedelta(days=365), effective_end=datetime.now() - timedelta(days=30), reason="Cardiac prophylaxis", notes="Discontinued due to GI bleeding risk")Time Periods
Section titled “Time Periods”# Ongoing medication (start only)med = builder.add_medication_history( medication="Thyroid hormone", status="active", effective_start=datetime(2020, 1, 1))
# Completed course (start and end)med = builder.add_medication_history( medication="Prednisone 20mg", status="completed", effective_start=datetime.now() - timedelta(days=21), effective_end=datetime.now() - timedelta(days=1), notes="Tapered course for inflammation")Best Practices
Section titled “Best Practices”- Use create_codeable_concept with RxNorm or SNOMED CT codes when available
- Include start dates for chronic medications
- Document reasons for medication use
- Record adherence information when relevant
- Include notes about effectiveness, side effects, or concerns
- Update status when medications are changed or stopped
- Use detailed dosage instructions when known
- Document both prescription and over-the-counter medications
- Medication history creates MedicationStatement resources
- Different from prescriptions (MedicationRequest) - this documents actual usage
- Effective periods help track medication duration
- Status changes track medication lifecycle
- Important for medication reconciliation and interaction checking