eCQM QICore Content Implementation Guide
2025.0.0 - CI Build

eCQM QICore Content Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2025.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/ecqm-content-qicore-2025/ and changes regularly. See the Directory of published versions

Library: CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement

CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement

Official URL: https://madie.cms.gov/Library/CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement Version: 1.1.000
Active as of 2025-04-15 Responsible: Centers for Medicare & Medicaid Services (CMS) /td> Computable Name: CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement
Other Identifiers: https://madie.cms.gov/login#CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement (use: official, )
Title: CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement
Id: CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement
Version: 1.1.000
Url: https://madie.cms.gov/Library/CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement
official

CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement

Type:

system: http://terminology.hl7.org/CodeSystem/library-type

code: logic-library

Date: 2025-04-15T18:43:25+00:00
Publisher: Centers for Medicare & Medicaid Services (CMS)
Description: CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement
Related Artifacts:

Dependencies

  • https://madie.cms.gov/Library/SupplementalDataElements|5.1.000
  • https://madie.cms.gov/Library/Status|1.13.000
  • https://madie.cms.gov/Library/QICoreCommon|4.0.000
  • https://madie.cms.gov/Library/FHIRHelpers|4.4.000
  • https://madie.cms.gov/Library/Hospice|6.15.000
  • http://loinc.org
  • http://www.ama-assn.org/go/cpt
  • http://snomed.info/sct
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.198.12.1006
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1080
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1089
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1178
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1184
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1189
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1180
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1182
Data Requirements:
TypeProfileMSCode Filter
Patient http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient ;;;
Procedure http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure ;; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.198.12.1006
Procedure http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-procedure ;; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1584
Observation http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-screening-assessment ; code filter:
path: code

system: http://loinc.org

code: 82323-7

display: Total interval score [HOOSJR]

Observation http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-screening-assessment ;
Observation http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-screening-assessment ;;; code filter:
path: code

system: http://loinc.org

code: 45755-6

display: Hospice care [Minimum Data Set]

Encounter http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter ; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008
Encounter http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter ; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001
Encounter http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter ;
Encounter http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter ; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1080
Encounter http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter ; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1089
Encounter http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter ;;;; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Encounter http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter ;; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1003
Coverage http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage ;; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
ServiceRequest http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest ;;; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1584
Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1165
Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns ; code filter:
path: code

system: http://snomed.info/sct

code: 702956004

display: Severe cognitive impairment (finding)

Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1178
Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1180
Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1182
Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1165
Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis ; code filter:
path: code

system: http://snomed.info/sct

code: 702956004

display: Severe cognitive impairment (finding)

Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1178
Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1180
Condition http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1182
Content: text/cql
library CMS56FHIRFunctionalStatusAssessmentforTotalHipReplacement version '1.1.000'

using QICore version '6.0.0'

include FHIRHelpers version '4.4.000' called FHIRHelpers
include QICoreCommon version '4.0.000' called QICoreCommon
include SupplementalDataElements version '5.1.000' called SDE
include Hospice version '6.15.000' called Hospice
include Status version '1.13.000' called Status

codesystem "LOINC": 'http://loinc.org'
codesystem "CPT": 'http://www.ama-assn.org/go/cpt'
codesystem "SNOMEDCT": 'http://snomed.info/sct'

valueset "Lower Body Fractures Excluding Ankle and Foot": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1178'
valueset "Malignant Neoplasms of Lower and Unspecified Limbs": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1180'
valueset "Mechanical Complications Excluding Upper Body": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1182'
valueset "Office Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001'
valueset "Virtual Encounter": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1089'
valueset "Outpatient Consultation": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008'
valueset "Partial Arthroplasty of Hip": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1184'
valueset "Primary THA Procedure": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.198.12.1006'
valueset "Removal, Revision and Supplement Procedures of the Lower Body and Spine": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1189'
valueset "Telephone Visits": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1080'

code "Activities of daily living score [HOOS]": '72095-3' from "LOINC" display 'Activities of daily living score [HOOS]'
code "Dead (finding)": '419099009' from "SNOMEDCT" display 'Dead (finding)'
code "Discharge to healthcare facility for hospice care (procedure)": '428371000124100' from "SNOMEDCT" display 'Discharge to healthcare facility for hospice care (procedure)'
code "Discharge to home for hospice care (procedure)": '428371000124100' from "SNOMEDCT" display 'Discharge to home for hospice care (procedure)'
code "Hospice care [Minimum Data Set]": '45755-6' from "LOINC" display 'Hospice care [Minimum Data Set]'
code "Pain score [HOOS]": '72097-9' from "LOINC" display 'Pain score [HOOS]'
code "Postoperative follow-up visit, normally included in the surgical package, to indicate that an evaluation and management service was performed during a postoperative period for a reason(s) related to the original procedure": '99024' from "CPT" display 'Postoperative follow-up visit, normally included in the surgical package, to indicate that an evaluation and management service was performed during a postoperative period for a reason(s) related to the original procedure'
code "PROMIS-10 Global Mental Health (GMH) score T-score": '71969-0' from "LOINC" display 'PROMIS-10 Global Mental Health (GMH) score T-score'
code "PROMIS-10 Global Physical Health (GPH) score T-score": '71971-6' from "LOINC" display 'PROMIS-10 Global Physical Health (GPH) score T-score'
code "Quality of life score [HOOS]": '72093-8' from "LOINC" display 'Quality of life score [HOOS]'
code "Severe cognitive impairment (finding)": '702956004' from "SNOMEDCT" display 'Severe cognitive impairment (finding)'
code "Sport-recreation score [HOOS]": '72094-6' from "LOINC" display 'Sport-recreation score [HOOS]'
code "Symptoms score [HOOS]": '72096-1' from "LOINC" display 'Symptoms score [HOOS]'
code "Total interval score [HOOSJR]": '82323-7' from "LOINC" display 'Total interval score [HOOSJR]'
code "VR-12 Mental component summary (MCS) score - oblique method T-score": '72026-8' from "LOINC" display 'VR-12 Mental component summary (MCS) score - oblique method T-score'
code "VR-12 Mental component summary (MCS) score - orthogonal method T-score": '72028-4' from "LOINC" display 'VR-12 Mental component summary (MCS) score - orthogonal method T-score'
code "VR-12 Physical component summary (PCS) score - oblique method T-score": '72025-0' from "LOINC" display 'VR-12 Physical component summary (PCS) score - oblique method T-score'
code "VR-12 Physical component summary (PCS) score - orthogonal method T-score": '72027-6' from "LOINC" display 'VR-12 Physical component summary (PCS) score - orthogonal method T-score'
code "Yes (qualifier value)": '373066001' from "SNOMEDCT" display 'Yes (qualifier value)'

parameter "Measurement Period" Interval<DateTime>

context Patient

define "SDE Ethnicity":
  SDE."SDE Ethnicity"

define "SDE Payer Type":
  SDE."SDE Payer"

define "SDE Race":
  SDE."SDE Race"

define "SDE Sex":
  SDE."SDE Sex"

define "Initial Population":
  "Has Qualifying Encounter"
    and exists ( "Total Hip Arthroplasty Procedure" )
    and AgeInYearsAt(date from start of "Measurement Period") >= 19

define "Has Qualifying Encounter":
  exists ( ( ( [Encounter: type in "Outpatient Consultation"]
        union [Encounter: type in "Office Visit"]
        union ( [Encounter] E
            where exists ( ( E.type ) T
                where T ~ "Postoperative follow-up visit, normally included in the surgical package, to indicate that an evaluation and management service was performed during a postoperative period for a reason(s) related to the original procedure"
            )
        )
        union [Encounter: type in "Telephone Visits"]
        union [Encounter: type in "Virtual Encounter"]
    ).isEncounterPerformed ( ) ) ValidEncounters
      where ValidEncounters.period.toInterval ( ) during day of Interval["August 1 Year Prior to the Measurement Period", end of "Measurement Period"]
  )

define "August 1 Year Prior to the Measurement Period":
  DateTime((year from start of "Measurement Period" - 1), 8, 1, 0, 0, 0, 0, 0)

define "Total Hip Arthroplasty Procedure":
  ( ( [Procedure: "Primary THA Procedure"] ).isProcedurePerformed ( ) ) THAProcedure
    where THAProcedure.performed.toInterval ( ) starts during day of Interval["November 1 Two Years Prior to the Measurement Period", "October 31 Year Prior to the Measurement Period"]

define "November 1 Two Years Prior to the Measurement Period":
  DateTime((year from start of "Measurement Period" - 2), 11, 1, 0, 0, 0, 0, 0)

define "October 31 Year Prior to the Measurement Period":
  DateTime((year from start of "Measurement Period" - 1), 10, 31, 23, 59, 59, 0, 0)

define "Denominator":
  "Initial Population"

define "Denominator Exclusions":
  Hospice."Has Hospice Services"
    or "Has Severe Cognitive Impairment"
    or "Has Total Hip Arthroplasty with 1 or More Lower Body Fractures"
    or "Has Partial Hip Arthroplasty Procedure"
    or "Has Revision Hip Arthroplasty Procedure or Implanted Device or Prosthesis Removal Procedure"
    or "Has Malignant Neoplasm of Lower and Unspecified Limbs"
    or "Has Mechanical Complication"
    or "Has More Than One Elective Primary Total Hip Arthroplasty Performed"
    or "Death Within 300 Days of the THA Procedure"

define "Has Severe Cognitive Impairment":
  exists ( [ConditionProblemsHealthConcerns: "Severe cognitive impairment (finding)"]
    union [ConditionEncounterDiagnosis: "Severe cognitive impairment (finding)"] ) Dementia
    where Dementia.prevalenceInterval ( ) overlaps day of "Measurement Period"

define "Has Total Hip Arthroplasty with 1 or More Lower Body Fractures":
  exists ( "Total Hip Arthroplasty Procedure" THAProcedure
      with ( [ConditionEncounterDiagnosis: "Lower Body Fractures Excluding Ankle and Foot"]
        union [ConditionProblemsHealthConcerns: "Lower Body Fractures Excluding Ankle and Foot"] ) LowerBodyFracture
        such that LowerBodyFracture.prevalenceInterval ( ) starts 48 hours or less on or before start of THAProcedure.performed.toInterval ( )
  )

define "Has Partial Hip Arthroplasty Procedure":
  exists ( ( ( [Procedure: "Partial Arthroplasty of Hip"] ).isProcedurePerformed ( ) ) PartialTHAProcedure
      with "Total Hip Arthroplasty Procedure" THAProcedure
        such that PartialTHAProcedure.performed.toInterval ( ) during day of THAProcedure.performed.toInterval ( )
  )

define "Has Revision Hip Arthroplasty Procedure or Implanted Device or Prosthesis Removal Procedure":
  exists ( "Total Hip Arthroplasty Procedure" THAProcedure
      with ( ( [Procedure: "Removal, Revision and Supplement Procedures of the Lower Body and Spine"] ).isProcedurePerformed ( ) ) RevisionTHAProcedure
        such that RevisionTHAProcedure.performed.toInterval ( ) during day of THAProcedure.performed.toInterval ( )
  )

define "Has Malignant Neoplasm of Lower and Unspecified Limbs":
  exists ( ( [ConditionProblemsHealthConcerns: "Malignant Neoplasms of Lower and Unspecified Limbs"]
      union [ConditionEncounterDiagnosis: "Malignant Neoplasms of Lower and Unspecified Limbs"] ) MalignantNeoplasm
      with "Total Hip Arthroplasty Procedure" THAProcedure
        such that MalignantNeoplasm.prevalenceInterval ( ) overlaps day of THAProcedure.performed.toInterval ( )
  )

define "Has Mechanical Complication":
  exists ( ( [ConditionEncounterDiagnosis: "Mechanical Complications Excluding Upper Body"]
      union [ConditionProblemsHealthConcerns: "Mechanical Complications Excluding Upper Body"] ) MechanicalComplications
      with "Total Hip Arthroplasty Procedure" THAProcedure
        such that MechanicalComplications.prevalenceInterval ( ) overlaps day of THAProcedure.performed.toInterval ( )
  )

define "Has More Than One Elective Primary Total Hip Arthroplasty Performed":
  exists ( "Total Hip Arthroplasty Procedure" THAProcedure
      with ( ( [Procedure: "Primary THA Procedure"] ).isProcedurePerformed ( ) ) ElectiveTHAProcedure
        such that THAProcedure.id !~ ElectiveTHAProcedure.id
          and start of ElectiveTHAProcedure.performed.toInterval ( ) during day of Interval[( start of THAProcedure.performed.toInterval ( ) ) - 1 year, ( start of THAProcedure.performed.toInterval ( ) ) + 1 year]
  )

define "Death Within 300 Days of the THA Procedure":
  exists "Total Hip Arthroplasty Procedure" THAProcedure
    where date from Patient.deceased during day of Interval[date from start of THAProcedure.performed.toInterval ( ), date from start of THAProcedure.performed.toInterval ( ) + 300 days]

define "Numerator":
  ( "Has THA with Initial and Follow Up HOOS Assessments" )
    or ( "Has THA with Initial and Follow Up HOOSJr Assessments" )
    or ( "Has THA with Initial and Follow Up PROMIS10 Assessments" )
    or ( "Has THA with Initial and Follow Up VR12 Oblique Assessments" )
    or ( "Has THA with Initial and Follow Up VR12 Orthogonal Assessments" )

define "Has THA with Initial and Follow Up HOOS Assessments":
  exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
      return THAProcedure.performed.toInterval ( ) ) TotalHip
      with "Date HOOS Total Assessment Completed" InitialHipAssessmentHOOS
        such that TotalHip starts 90 days or less on or after day of InitialHipAssessmentHOOS
      with "Date HOOS Total Assessment Completed" FollowUpHipAssessmentHOOS
        such that date from FollowUpHipAssessmentHOOS during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
  )

define "Date HOOS Total Assessment Completed":
  from
    ( ( [ObservationScreeningAssessment: "Quality of life score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSLifeQuality,
    ( ( [ObservationScreeningAssessment: "Sport-recreation score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSSport,
    ( ( [ObservationScreeningAssessment: "Activities of daily living score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSActivityScore,
    ( ( [ObservationScreeningAssessment: "Symptoms score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSSymptoms,
    ( ( [ObservationScreeningAssessment: "Pain score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSPain
    let HOOSLifeQualityDate: date from start of HOOSLifeQuality.effective.toInterval ( ),
    HOOSSportDate: date from start of HOOSSport.effective.toInterval ( ),
    HOOSActivityScoreDate: date from start of HOOSActivityScore.effective.toInterval ( ),
    HOOSSymptomsDate: date from start of HOOSSymptoms.effective.toInterval ( ),
    HOOSPainDate: date from start of HOOSPain.effective.toInterval ( )
    where HOOSLifeQualityDate same day as HOOSSportDate
      and ( HOOSSport as ObservationScreeningAssessment ).value is not null
      and HOOSLifeQualityDate same day as HOOSActivityScoreDate
      and ( HOOSActivityScore as ObservationScreeningAssessment ).value is not null
      and HOOSLifeQualityDate same day as HOOSSymptomsDate
      and ( HOOSSymptoms as ObservationScreeningAssessment ).value is not null
      and HOOSLifeQualityDate same day as HOOSPainDate
      and ( HOOSPain as ObservationScreeningAssessment ).value is not null
      and ( HOOSLifeQuality as ObservationScreeningAssessment ).value is not null
    return Max({ HOOSLifeQualityDate, HOOSSportDate, HOOSActivityScoreDate, HOOSSymptomsDate, HOOSPainDate })

define "Has THA with Initial and Follow Up HOOSJr Assessments":
  exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
      return THAProcedure.performed.toInterval ( ) ) TotalHip
      with "Date HOOSJr Total Assessment Completed" InitialHipAssessment
        such that TotalHip starts 90 days or less on or after day of InitialHipAssessment
      with "Date HOOSJr Total Assessment Completed" FollowUpHipAssessment
        such that date from FollowUpHipAssessment during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
  )

define "Date HOOSJr Total Assessment Completed":
  ( ( ( [ObservationScreeningAssessment: "Total interval score [HOOSJR]"] ).isAssessmentPerformed ( ) ) HOOSJr
    where ( HOOSJr as ObservationScreeningAssessment ).value is not null ) DocumentedHOOSJr
    return date from start of DocumentedHOOSJr.effective.toInterval ( )

define "Has THA with Initial and Follow Up PROMIS10 Assessments":
  exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
      return THAProcedure.performed.toInterval ( ) ) TotalHip
      with "Date PROMIS10 Total Assessment Completed" InitialHipAssessmentPROMIS10
        such that TotalHip starts 90 days or less on or after day of InitialHipAssessmentPROMIS10
      with "Date PROMIS10 Total Assessment Completed" FollowUpHipAssessmentPROMIS10
        such that date from FollowUpHipAssessmentPROMIS10 during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
  )

define "Date PROMIS10 Total Assessment Completed":
  from
    ( ( [ObservationScreeningAssessment: "PROMIS-10 Global Mental Health (GMH) score T-score"] ).isAssessmentPerformed ( ) ) PROMIS10MentalScore,
    ( ( [ObservationScreeningAssessment: "PROMIS-10 Global Physical Health (GPH) score T-score"] ).isAssessmentPerformed ( ) ) PROMIS10PhysicalScore
    let PROMIS10MentalScoreDate: date from start of PROMIS10MentalScore.effective.toInterval ( ),
    PROMIS10PhysicalScoreDate: date from start of PROMIS10PhysicalScore.effective.toInterval ( )
    where PROMIS10MentalScoreDate same day as PROMIS10PhysicalScoreDate
      and ( PROMIS10PhysicalScore as ObservationScreeningAssessment ).value is not null
      and ( PROMIS10MentalScore as ObservationScreeningAssessment ).value is not null
    return Max({ PROMIS10MentalScoreDate, PROMIS10PhysicalScoreDate })

define "Has THA with Initial and Follow Up VR12 Oblique Assessments":
  exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
      return THAProcedure.performed.toInterval ( ) ) TotalHip
      with "Date VR12 Oblique Total Assessment Completed" InitialHipAssessmentOblique
        such that TotalHip starts 90 days or less on or after day of InitialHipAssessmentOblique
      with "Date VR12 Oblique Total Assessment Completed" FollowUpHipAssessmentOblique
        such that date from FollowUpHipAssessmentOblique during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
  )

define "Date VR12 Oblique Total Assessment Completed":
  from
    ( ( [ObservationScreeningAssessment: "VR-12 Mental component summary (MCS) score - oblique method T-score"] ).isAssessmentPerformed ( ) ) VR12MentalAssessment,
    ( ( [ObservationScreeningAssessment: "VR-12 Physical component summary (PCS) score - oblique method T-score"] ).isAssessmentPerformed ( ) ) VR12PhysicalAssessment
    let VR12MentalAssessmentDate: date from start of VR12MentalAssessment.effective.toInterval ( ),
    VR12PhysicalAssessmentDate: date from start of VR12PhysicalAssessment.effective.toInterval ( )
    where VR12MentalAssessmentDate same day as VR12PhysicalAssessmentDate
      and ( VR12MentalAssessment as ObservationScreeningAssessment ).value is not null
      and ( VR12PhysicalAssessment as ObservationScreeningAssessment ).value is not null
    return Max({ VR12MentalAssessmentDate, VR12PhysicalAssessmentDate })

define "Has THA with Initial and Follow Up VR12 Orthogonal Assessments":
  exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
      return THAProcedure.performed.toInterval ( ) ) TotalHip
      with "Date VR12 Orthogonal Total Assessment Completed" InitialHipAssessmentOrthogonal
        such that TotalHip starts 90 days or less on or after day of InitialHipAssessmentOrthogonal
      with "Date VR12 Orthogonal Total Assessment Completed" FollowUpHipAssessmentOrthogonal
        such that date from FollowUpHipAssessmentOrthogonal during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
  )

define "Date VR12 Orthogonal Total Assessment Completed":
  from
    ( ( [ObservationScreeningAssessment: "VR-12 Mental component summary (MCS) score - orthogonal method T-score"] ).isAssessmentPerformed ( ) ) VR12MentalAssessment,
    ( ( [ObservationScreeningAssessment: "VR-12 Physical component summary (PCS) score - orthogonal method T-score"] ).isAssessmentPerformed ( ) ) VR12PhysicalAssessment
    let VR12MentalAssessmentDate: date from start of VR12MentalAssessment.effective.toInterval ( ),
    VR12PhysicalAssessmentDate: date from start of VR12PhysicalAssessment.effective.toInterval ( )
    where VR12MentalAssessmentDate same day as VR12PhysicalAssessmentDate
      and ( VR12MentalAssessment as ObservationScreeningAssessment ).value is not null
      and ( VR12PhysicalAssessment as ObservationScreeningAssessment ).value is not null
    return Max({ VR12MentalAssessmentDate, VR12PhysicalAssessmentDate })