custom operation on patient type that will receive a business identifier and will search them and for each paient it will return a $everything for all the found patients
Hi,
I need a custom operation on patient type that will receive a business identifier and will search them and for each paient it will return a $everything for all the found patients written with object script
Product version: IRIS 2024.3
Discussion (0)0
Comments
Hi Eyal,
The idea is to implement a custom FHIR operation as per the docs.
Once you set up the pre-installation subclassing
(this is where you override those 3 classes:
HS.FHIRServer.Storage.JsonAdvSQL.Interactions, HS.FHIRServer.Storage.JsonAdvSQL.InteractionsStrategy, HS.FHIRServer.Storage.JsonAdvSQL.RepoManager)
.png)
You can create a custom operations class (make sure you reference it in your Interactions class):
Class Testing.Internal.Interactions Extends HS.FHIRServer.Storage.JsonAdvSQL.Interactions
{
Parameter OperationHandlerClass As%String = "Testing.Internal.myOperations";
}
Class Testing.Internal.myOperations Extends HS.FHIRServer.Storage.JsonAdvSQL.BuiltInOperations
{
ClassMethod FHIRTypeOpCustompatienteverything(pService As HS.FHIRServer.API.Service, pRequest As HS.FHIRServer.API.Data.Request, pResponse As HS.FHIRServer.API.Data.Response)
{
if pRequest.Type="Patient" {
if (pRequest.QueryString '= ""){
Set fhirService = ##class(HS.FHIRServer.Service).EnsureInstance("/api/internal/test1") //fhir server endpoint Set request = ##class(HS.FHIRServer.API.Data.Request).%New()
Set request.RequestPath = "/Patient"set request.QueryString = pRequest.QueryString
Set request.RequestMethod = "GET"Do fhirService.DispatchRequest(request, .response)
Set json = response.Json
If json.%Get("entry") '="" {
Set iter = json.entry.%GetIterator()
While iter.%GetNext(.key, .value) { //for each patient entry request an everythingSet everythingRequest = ##class(HS.FHIRServer.API.Data.Request).%New()
Set everythingRequest.RequestPath = "/Patient/"_value.resource.id_"/$everything"Set everythingRequest.RequestMethod = "GET"Write !
Write"Patient ID: ", value.resource.id, !
Do fhirService.DispatchRequest(everythingRequest, .everythingResponse)
Write"Everything: ", !, everythingResponse.Json.%ToJSON()
}
}
}
else{
Set pResponse.Json = ##class(HS.FHIRServer.Util.Outcome).Create("information", "No Query String", "informational")
}
}
set pResponse.Status = 200
}
ClassMethod AddSupportedOperations(pMap As%DynamicObject)
{
do##super(pMap)
Do pMap.%Set("patient-identifiers-everything", "http://hl7.org/fhir/OperationDefinition/patient-identifiers-everything")
}
}
Hope this helps.
Ari