172 lines
6.4 KiB
Python
172 lines
6.4 KiB
Python
"""
|
|
Forms for integrations app.
|
|
"""
|
|
|
|
from django import forms
|
|
from django.utils.translation import gettext_lazy as _
|
|
from crispy_forms.helper import FormHelper
|
|
from crispy_forms.layout import Layout, Fieldset, Row, Column, Submit, HTML
|
|
|
|
from .models import ExternalOrder, PayerContract, ZatcaCredential
|
|
|
|
|
|
class ExternalOrderForm(forms.ModelForm):
|
|
"""Form for creating/updating external orders (lab/radiology)."""
|
|
|
|
class Meta:
|
|
model = ExternalOrder
|
|
fields = [
|
|
'patient',
|
|
'order_type',
|
|
'order_details',
|
|
'status',
|
|
'result_url',
|
|
'result_data',
|
|
'ordered_by',
|
|
]
|
|
widgets = {
|
|
'patient': forms.Select(attrs={'class': 'form-select select2', 'data-placeholder': 'Select patient'}),
|
|
'order_type': forms.Select(attrs={'class': 'form-control'}),
|
|
'order_details': forms.Textarea(attrs={'class': 'form-control', 'rows': 4}),
|
|
'status': forms.Select(attrs={'class': 'form-control'}),
|
|
'result_url': forms.URLInput(attrs={'class': 'form-control'}),
|
|
'result_data': forms.Textarea(attrs={'class': 'form-control', 'rows': 4}),
|
|
'ordered_by': forms.Select(attrs={'class': 'form-select select2', 'data-placeholder': 'Select provider'}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_method = 'post'
|
|
self.helper.layout = Layout(
|
|
Fieldset(
|
|
_('Order Information'),
|
|
Row(
|
|
Column('patient', css_class='form-group col-md-6 mb-0'),
|
|
Column('order_type', css_class='form-group col-md-6 mb-0'),
|
|
css_class='form-row'
|
|
),
|
|
'order_details',
|
|
Row(
|
|
Column('status', css_class='form-group col-md-6 mb-0'),
|
|
Column('ordered_by', css_class='form-group col-md-6 mb-0'),
|
|
css_class='form-row'
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Results'),
|
|
'result_url',
|
|
'result_data',
|
|
css_class='mt-3'
|
|
),
|
|
Submit('submit', _('Save Order'), css_class='btn btn-primary mt-3')
|
|
)
|
|
|
|
|
|
class PayerContractForm(forms.ModelForm):
|
|
"""Form for creating/updating payer contracts."""
|
|
|
|
class Meta:
|
|
model = PayerContract
|
|
fields = [
|
|
'payer_code',
|
|
'payer_name',
|
|
'credentials',
|
|
'endpoints',
|
|
'supports_eligibility',
|
|
'supports_prior_auth',
|
|
'supports_claims',
|
|
'is_active',
|
|
]
|
|
widgets = {
|
|
'payer_code': forms.TextInput(attrs={'class': 'form-control'}),
|
|
'payer_name': forms.TextInput(attrs={'class': 'form-control'}),
|
|
'credentials': forms.Textarea(attrs={'class': 'form-control', 'rows': 4}),
|
|
'endpoints': forms.Textarea(attrs={'class': 'form-control', 'rows': 4}),
|
|
'supports_eligibility': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
|
'supports_prior_auth': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
|
'supports_claims': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
|
'is_active': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_method = 'post'
|
|
self.helper.layout = Layout(
|
|
Fieldset(
|
|
_('Payer Information'),
|
|
Row(
|
|
Column('payer_code', css_class='form-group col-md-6 mb-0'),
|
|
Column('payer_name', css_class='form-group col-md-6 mb-0'),
|
|
css_class='form-row'
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Configuration'),
|
|
'credentials',
|
|
'endpoints',
|
|
css_class='mt-3'
|
|
),
|
|
Fieldset(
|
|
_('Capabilities'),
|
|
Row(
|
|
Column('supports_eligibility', css_class='form-group col-md-4 mb-0'),
|
|
Column('supports_prior_auth', css_class='form-group col-md-4 mb-0'),
|
|
Column('supports_claims', css_class='form-group col-md-4 mb-0'),
|
|
css_class='form-row'
|
|
),
|
|
'is_active',
|
|
css_class='mt-3'
|
|
),
|
|
Submit('submit', _('Save Payer Contract'), css_class='btn btn-primary mt-3')
|
|
)
|
|
|
|
|
|
class ZatcaCredentialForm(forms.ModelForm):
|
|
"""Form for creating/updating ZATCA credentials."""
|
|
|
|
class Meta:
|
|
model = ZatcaCredential
|
|
fields = [
|
|
'environment',
|
|
'csid',
|
|
'certificate',
|
|
'private_key',
|
|
'is_active',
|
|
'expires_at',
|
|
]
|
|
widgets = {
|
|
'environment': forms.Select(attrs={'class': 'form-control'}),
|
|
'csid': forms.Textarea(attrs={'class': 'form-control', 'rows': 3}),
|
|
'certificate': forms.Textarea(attrs={'class': 'form-control', 'rows': 5}),
|
|
'private_key': forms.Textarea(attrs={'class': 'form-control', 'rows': 5}),
|
|
'is_active': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
|
'expires_at': forms.DateTimeInput(attrs={'class': 'form-control', 'type': 'datetime-local'}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_method = 'post'
|
|
self.helper.layout = Layout(
|
|
Fieldset(
|
|
_('Environment'),
|
|
Row(
|
|
Column('environment', css_class='form-group col-md-6 mb-0'),
|
|
Column('expires_at', css_class='form-group col-md-6 mb-0'),
|
|
css_class='form-row'
|
|
),
|
|
'is_active',
|
|
),
|
|
Fieldset(
|
|
_('Credentials'),
|
|
HTML('<div class="alert alert-warning">{}</div>'.format(_('Keep these credentials secure!'))),
|
|
'csid',
|
|
'certificate',
|
|
'private_key',
|
|
css_class='mt-3'
|
|
),
|
|
Submit('submit', _('Save Credential'), css_class='btn btn-primary mt-3')
|
|
)
|