This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Advanced Filtering

Hello Everyone
Hope you are having a good day.

I have a question, please. 

Now i have the "Patient" Object. and under that patient there is an object "Consent" as the following.


Now, I have a code that do the following:
before we make that patient status as "Active" we need to have a consent ( Consent must have a file inside it before making the status of the patient Active)

The code: 

Const ApprovalDocumentsClassId = 37 'Consent Class ID
Const RelatedPatientPropId = 1054 'Pateint PropID
Const ConsentTypePropId = 2964 'ConsentType PropID

If Not IsApprovalDocumentAvailable(ObjVer.ID) Then
Err.raise mfscriptcancel, "No Patient Consent Form found for patient."
End If


Function IsApprovalDocumentAvailable(patientId)

Dim oScsP : Set oScsP = CreateObject("MFilesAPI.SearchConditions")
Dim oScP : Set oScP = CreateObject("MFilesAPI.SearchCondition")

oScP.Expression.DataPropertyValuePropertyDef = MFBuiltInPropertyDefClass
oScP.ConditionType = MFConditionTypeEqual
oScP.TypedValue.SetValue MFDatatypeLookup, ApprovalDocumentsClassId
oScsP.Add -1, oScP

oScP.Expression.DataPropertyValuePropertyDef = RelatedPatientPropId
oScP.ConditionType = MFConditionTypeEqual
oScP.TypedValue.SetValue MFDatatypeLookup, patientId
oScsP.Add -1, oScP

oScP.Expression.DataStatusValueType = MFStatusTypeDeleted
oScP.ConditionType = MFConditionTypeEqual
oScP.TypedValue.SetValue MFDatatypeBoolean, False 'Silinmemis
oScsP.Add -1, oScP


Set oSearchResultsP = Vault.ObjectSearchOperations.SearchForObjectsByConditions(oScsP,MFSearchFlagNone,False)

If oSearchResultsP.Count = 0 Then
IsApprovalDocumentAvailable = False
Else
IsApprovalDocumentAvailable = True
End If
End Function



Now, the point that i need help with is modifying this code to further search inside that consent type.

What i have inside the "Consent" object is this:

"Consent type"

I want my code to search not only if the class "Consent" is there for the patient, but also to look further for the type of that consent, if it is "General Consent for Treatment" or not.

Is that possible to do?

Thank you

Parents
  • Right now your code is just searching for class = consent class, and patient = (patient id), you can add another search condition for consent type ="General consent for treatment" above the following line:

    Set oSearchResultsP = Vault.ObjectSearchOperations.SearchForObjectsByConditions(oScsP,MFSearchFlagNone,False)

    I do my search conditions a bit different but assuming your code works you can probably just add this section 

    oScP.Expression.DataPropertyValuePropertyDef = ConsentTypePropId
    oScP.ConditionType = MFConditionTypeEqual
    oScP.TypedValue.SetValue MFDatatypeText, "General Consent for Treatment" 'replace hardcoded text with variable 
    oScsP.Add -1, oScP

    However, adding the above code to your search will make it return a consent object ONLY if the consent type = "General  Consent for Treatment".

    Is this the desired outcome? Or did you want it to return the Consent object regardless, and take different actions if the value was not "General  Consent for Treatment".

Reply
  • Right now your code is just searching for class = consent class, and patient = (patient id), you can add another search condition for consent type ="General consent for treatment" above the following line:

    Set oSearchResultsP = Vault.ObjectSearchOperations.SearchForObjectsByConditions(oScsP,MFSearchFlagNone,False)

    I do my search conditions a bit different but assuming your code works you can probably just add this section 

    oScP.Expression.DataPropertyValuePropertyDef = ConsentTypePropId
    oScP.ConditionType = MFConditionTypeEqual
    oScP.TypedValue.SetValue MFDatatypeText, "General Consent for Treatment" 'replace hardcoded text with variable 
    oScsP.Add -1, oScP

    However, adding the above code to your search will make it return a consent object ONLY if the consent type = "General  Consent for Treatment".

    Is this the desired outcome? Or did you want it to return the Consent object regardless, and take different actions if the value was not "General  Consent for Treatment".

Children