wiki:FirstQuery
Last modified 12 years ago Last modified on 09/27/06 15:02:43

return to XbrainEvaluation

let $maleSurgeryPatientCount := 
	dxq:csm("
		<count>
		{
			let $male_surgery_patients := 
				for $p in $pv/patient[sex='M']
				where exists($p/surgery)
				return 
					$p
			return
				count($male_surgery_patients)
		}
		</count>
	")
	
let $femaleSurgeryPatientCount := 
	dxq:csm("
		<count>
		{
			let $female_surgery_patients := 
				for $p in $pv/patient[sex='F']
				where exists($p/surgery)
				return 
					$p
			return
				count($female_surgery_patients)
		}
		</count>
	")
	
let $maleSemParaCount :=
	dxq:csm("
		<count>
		{
			let $code := '2'
			let $males_with_semantic_paraphasia := 
				for $p in $pv/patient[sex='M']
				where $p/surgery/csmstudy/trial[stimulated='Y']/trialcode/term[type='CSM error code']/abbrev/text()
					=$code
				return 
					$p
			return
				count($males_with_semantic_paraphasia)
		}
		</count>
	")
	
let $femaleSemParaCount :=
	dxq:csm("
		<count>
		{
			let $code := '2'
			let $females_with_semantic_paraphasia := 
				for $p in $pv/patient[sex='F']
				where $p/surgery/csmstudy/trial[stimulated='Y']/trialcode/term[type='CSM error code']/abbrev/text()
					=$code
				return 
					$p
			return
				count($females_with_semantic_paraphasia)
		}
		</count>
	")


return	
	<results>
		<male_results>
			<surgery_patient_count>{$maleSurgeryPatientCount/count/text()}</surgery_patient_count>
			<semantic_paraphasia_count>{$maleSemParaCount/count/text()}</semantic_paraphasia_count>
			<percentage>
			{
				($maleSemParaCount/count/text() div $maleSurgeryPatientCount/count/text())*100
			}
			</percentage>
		</male_results>
		<female_results>
			<surgery_patient_count>{$femaleSurgeryPatientCount/count/text()}</surgery_patient_count>
			<semantic_paraphasia_count>{$femaleSemParaCount/count/text()}</semantic_paraphasia_count>
			<percentage>
			{
				($femaleSemParaCount/count/text() div $femaleSurgeryPatientCount/count/text())*100
			}
			</percentage>
		</female_results>
	</results>