Hi @Joe Roddy,
We understand the importance of the ServiceStartDate
and ServiceEndDate
fields, are currently not being returned, even for documents where they were previously extracted. This may be due to a recent model update or internal change. If these fields are critical, you might consider creating a custom model to ensure consistent extraction.
I tried to repro the issue with the below code and able to extract ServiceStartDate
and ServiceEndDate
fields:
from azure.core.credentials import AzureKeyCredential
from azure.ai.documentintelligence import DocumentIntelligenceClient
from azure.ai.documentintelligence.models import AnalyzeDocumentRequest
# Replace with your values
endpoint = "YOUR_ENDPOINT"
key = "YOUR_KEY"
# Image URL
form_url = "XXXXXX/invoice_sample.jpg"
# Create client
client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
# Create request object and call with correct argument position
request = AnalyzeDocumentRequest(url_source=form_url)
poller = client.begin_analyze_document("prebuilt-invoice", request)
# Get result
result = poller.result()
# Display results
# Assuming doc is a Document object from the analysis result
for idx, doc in enumerate(result.documents):
print(f"\n-------- Recognizing invoice #{idx + 1} --------")
# Extract and print main fields with their confidence values
fields_to_print = [
"VendorName", "VendorAddress", "VendorAddressRecipient",
"CustomerName", "CustomerId", "CustomerAddress", "CustomerAddressRecipient",
"InvoiceId", "InvoiceDate", "InvoiceTotal", "DueDate", "PurchaseOrder",
"BillingAddress", "BillingAddressRecipient", "ShippingAddress", "ShippingAddressRecipient",
"ServiceStartDate", "ServiceEndDate", "RemittanceAddress", "RemittanceAddressRecipient"
]
for field_name in fields_to_print:
field = doc.fields.get(field_name)
if field:
content = getattr(field, 'content', None)
confidence = getattr(field, 'confidence', None)
print(f"{field_name.replace('Address', ' Address')}: {content if content else 'Not found'} has confidence: {confidence if confidence else 'Not found'}")
# For invoice items (if present, assuming it's an array)
items = doc.fields.get("Items")
if items:
print("\nInvoice items:")
for i, item in enumerate(items.value_array):
print(f"...Item #{i + 1}")
for item_field_name, item_field in item.items():
item_content = getattr(item_field, 'content', None)
item_confidence = getattr(item_field, 'confidence', None)
print(f"......{item_field_name}: {item_content if item_content else 'Not found'} has confidence: {item_confidence if item_confidence else 'Not found'}")
print("-------------------------------------")
Output:
I hope this helps. Thank you.