Question
· Sep 20, 2023

How to validate FHIR resource from production?

Hi Community

I have created one business service created from "HS.FHIRServer.Interop.Service" in FHIR production.

I want to validate FHIR Patient resource that the age must be greater than 18 years.

How can I achieve this from objectscript as well as from DTL?

Thanks

Discussion (2)1
Log in or sign up to continue

Hello @Muhammad Waseem 

Maybe you can try extract the patient resource from bundle or use if it's already resource. Load into FHIR model patient class  HS.FHIR.DTL.vR4.Model.Resource.Patient with the extracted resource. Then you can convert the Birthdate and validate the Age. You can use the same logic in your code DTL in your FHIR process in between FHIR service (HS.FHIRServer.Interop.Service) to FHIR operation (HS.FHIRServer.Interop.Operation)

ClassMethod VaidatePatientResource(patientResourceStreram As %Stream.Object)
{
	#dim patient As HS.FHIR.DTL.vR4.Model.Resource.Patient
	try {
		set patient = ##class(HS.FHIR.DTL.vR4.Model.Resource.Patient).FromJSON(patientResourceStreram)
		Set age = $horolog - $ZdateH(patient.birthDate,3)\360
		if age<18 $$$ThrowStatus($$$ERROR($$$GeneralError, "Age is less than 18"))
	}
	catch ex {
		w ex.DisplayString()
	}
}