CyberSeed2017 / unf

0 stars 1 forks source link

Steps #1

Open tylercoverstone opened 7 years ago

tylercoverstone commented 7 years ago

check if maria db installed:

mysqladmin -u root -p version password: --not this

create db called smirk:

mysql -u root -p

CREATE DATABASE SMIRK;

python manage.py startapp smirk

cd smirk

wget -O models.py https://raw.githubusercontent.com/this-is-for-a-team/cyberseed/master/moussa/projectname/app/models.py

cd ../unf vi settings.py add 'smirk.apps.SmirkConfig',

cd ../

python manage.py makemigrations smirk

python manage.py migrate

python manage.py createsuperuser

admin/LetMeIn@UNF

python manage.py runserver

append in unf/urls.py:

urlpatterns = [ url(r'^', admin.site.urls), ]
admin.site.site_header= 'Secure Medical Information Repository Kit'
admin.site.index_title= 'SMIRK'
admin.site.site_title= 'Welcome' 

append in smirk/admin.py:

from django.apps import apps
from .models import *

for model in apps.get_app_config('smirk').models.values():
    admin.site.register(model)
tylercoverstone commented 7 years ago

Create permissions for each group

tylercoverstone commented 7 years ago

urls.py


from django.conf.urls import url
from django.contrib import admin
from django.shortcuts import redirect
from django.views.generic.base import RedirectView

urlpatterns = [
        url(r'^', admin.site.urls),
    url(r'^createPatient', RedirectView.as_view(url='smirk/patient/add/', permanent=True), name="createPatient"),
    url(r'^createDoctor', RedirectView.as_view(url='smirk/doctor/add/', permanent=False)),
    url(r'^createNurse', RedirectView.as_view(url='smirk/nurse/add/', permanent=False)),
    url(r'^createSysAdmin', RedirectView.as_view(url='smirk/system_administrator/add/', permanent=False)),
    url(r'^createMedAdmin', RedirectView.as_view(url='smirk/medical_administrator/add/', permanent=False)),
    url(r'^createInsAdmin', RedirectView.as_view(url='smirk/insurance_administrator/add/', permanent=False)),
    url(r'^editPerm', RedirectView.as_view(url='auth/group/', permanent=False)),
    url(r'^addDoctorExamRecord', RedirectView.as_view(url='smirk/doctor_exam_record/add/', permanent=False)),
    url(r'^addTestResultRecord', RedirectView.as_view(url='smirk/test_results_record/add/', permanent=False)),
    url(r'^addDiagnosisRecord', RedirectView.as_view(url='smirk/diagnosis_record/add/', permanent=False)),
    url(r'^addInsuranceClaimRecord', RedirectView.as_view(url='smirk/insurance_claim_record/add/', permanent=False)),
    url(r'^addRawRecord', RedirectView.as_view(url='smirk/raw_record/add/', permanent=False)),
    url(r'^createCorrespondenceRecord', RedirectView.as_view(url='smirk/patient_doctor_correspondence_record/add/', permanent=False)),
    url(r'^addCorrespondenceNote', RedirectView.as_view(url='smirk/note/add/', permanent=False)),
    url(r'^listRecords', RedirectView.as_view(url='smirk/record/', permanent=False)),
    url(r'^viewRecord',  RedirectView.as_view(url='smirk/record/', permanent=False)),
    url(r'^editRecordPerm', RedirectView.as_view(url='auth/group/', permanent=False)),
    url(r'^editPatient', RedirectView.as_view(url='smirk/patient/', permanent=False)),
    url(r'^editDoctor', RedirectView.as_view(url='smirk/doctor/', permanent=False)),
    url(r'^editNurse', RedirectView.as_view(url='smirk/nurse/', permanent=False)),
    url(r'^editSysAdmin', RedirectView.as_view(url='smirk/system_administrator/', permanent=False)),
    url(r'^editMedAdmin', RedirectView.as_view(url='smirk/medical_administrator/', permanent=False)),
    url(r'^editInsAdmin', RedirectView.as_view(url='smirk/insurance_administrator/', permanent=False)),
    url(r'^viewPatientProfile', RedirectView.as_view(url='smirk/patient/', permanent=False)),
    url(r'^viewRecoveryPhrase', RedirectView.as_view(url='smirk/doctor/', permanent=False)),
    url(r'^removeUserProfile', RedirectView.as_view(url='auth/user/', permanent=False))
]

admin.site.site_header= 'Secure Medical Information Repository Kit'
admin.site.index_title= 'SMIRK'
admin.site.site_title= 'Welcome' 

`

tylercoverstone commented 7 years ago

sudo pip install django-tastypie

tylercoverstone commented 7 years ago

add resources.py file to smirk directory:

from tastypie.resources import ModelResource
from tastypie.authorization import Authorization
from smirk.models import *

from django.db import models
from django.contrib.auth.models import User

# Create your API endPoints here.

#System Administrator Role
class System_Administrator(ModelResource):
    class Meta:
    queryset = System_Administrator.objects.all()
    resource_name = 'System_Administrator'
    authorization = Authorization()

#Doctor Role
class Doctor(ModelResource):
    class Meta:
    queryset = Doctor.objects.all()
    resource_name = 'Doctor'
    authorization = Authorization()

#Nurse Role
class Nurse(ModelResource):
    class Meta:
    queryset = Nurse.objects.all()
    resource_name = 'Nurse'
    authorization = Authorization()

#Medical Administrator Role
class Medical_Administrator(ModelResource):
    class Meta:
    queryset = Medical_Administrator.objects.all()
    resource_name = 'Medical_Administrator'
    authorization = Authorization()

#Insurance Administrator Role
class Insurance_Administrator(ModelResource):
    class Meta:
    queryset = Insurance_Administrator.objects.all()
    resource_name = 'Insurance_Administrator'
    authorization = Authorization()

#Patient Role
class Patient(ModelResource):
    class Meta:
    queryset = Patient.objects.all()
    resource_name = 'Patient'
    authorization = Authorization()

#Record
class Record(ModelResource):
    class Meta:
    queryset = Record.objects.all()
    resource_name = 'Record'
    authorization = Authorization()

#Doctor Exam Record
class Doctor_Exam_Record(ModelResource):
    class Meta:
    queryset = Doctor_Exam_Record.objects.all()
    resource_name = 'Doctor_Exam_Record'
    authorization = Authorization()

#Diagnosis Record
class Diagnosis_Record(ModelResource):
    class Meta:
    queryset = Diagnosis_Record.objects.all()
    resource_name = 'Diagnosis_Record'
    authorization = Authorization()

#Test Results Record
class Test_Results_Record(ModelResource):
   class Meta:
    queryset = Test_Results_Record.objects.all()
    resource_name = 'Test_Results_Record'
    authorization = Authorization()

#Insurance Claim Record
class Insurance_Claim_Record(ModelResource):
   class Meta:
    queryset = Insurance_Claim_Record.objects.all()
    resource_name = 'Insurance_Claim_Record'
    authorization = Authorization()

#Patient_Doctor_Correspondence_Record
class Patient_Doctor_Correspondence_Record(ModelResource):
    class Meta:
    queryset = Patient_Doctor_Correspondence_Record.objects.all()
    resource_name = 'Patient_Doctor_Correspondence_Record'
    authorization = Authorization()

#Raw Record
class Raw_Record(ModelResource):
    class Meta:
    queryset = Raw_Record.objects.all()
    resource_name = 'Raw_Record'
    authorization = Authorization()

#Note
class Note(ModelResource):
    class Meta:
    queryset = Note.objects.all()
    resource_name = 'Note'
    authorization = Authorization()
tylercoverstone commented 7 years ago

edit urls.py to the following:

"""unf URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from django.shortcuts import redirect
from django.views.generic.base import RedirectView
from smirk.resources import *

urlpatterns = [
        url(r'^', admin.site.urls),
    url(r'^createPatient', RedirectView.as_view(url='smirk/patient/add/', permanent=True), name="createPatient"),
    url(r'^createDoctor', RedirectView.as_view(url='smirk/doctor/add/', permanent=False)),
    url(r'^createNurse', RedirectView.as_view(url='smirk/nurse/add/', permanent=False)),
    url(r'^createSysAdmin', RedirectView.as_view(url='smirk/system_administrator/add/', permanent=False)),
    url(r'^createMedAdmin', RedirectView.as_view(url='smirk/medical_administrator/add/', permanent=False)),
    url(r'^createInsAdmin', RedirectView.as_view(url='smirk/insurance_administrator/add/', permanent=False)),
    url(r'^editPerm', RedirectView.as_view(url='auth/group/', permanent=False)),
    url(r'^addDoctorExamRecord', RedirectView.as_view(url='smirk/doctor_exam_record/add/', permanent=False)),
    url(r'^addTestResultRecord', RedirectView.as_view(url='smirk/test_results_record/add/', permanent=False)),
    url(r'^addDiagnosisRecord', RedirectView.as_view(url='smirk/diagnosis_record/add/', permanent=False)),
    url(r'^addInsuranceClaimRecord', RedirectView.as_view(url='smirk/insurance_claim_record/add/', permanent=False)),
    url(r'^addRawRecord', RedirectView.as_view(url='smirk/raw_record/add/', permanent=False)),
    url(r'^createCorrespondenceRecord', RedirectView.as_view(url='smirk/patient_doctor_correspondence_record/add/', permanent=False)),
    url(r'^addCorrespondenceNote', RedirectView.as_view(url='smirk/note/add/', permanent=False)),
    url(r'^listRecords', RedirectView.as_view(url='smirk/record/', permanent=False)),
    url(r'^viewRecord',  RedirectView.as_view(url='smirk/record/', permanent=False)),
    url(r'^editRecordPerm', RedirectView.as_view(url='auth/group/', permanent=False)),
    url(r'^editPatient', RedirectView.as_view(url='smirk/patient/', permanent=False)),
    url(r'^editDoctor', RedirectView.as_view(url='smirk/doctor/', permanent=False)),
    url(r'^editNurse', RedirectView.as_view(url='smirk/nurse/', permanent=False)),
    url(r'^editSysAdmin', RedirectView.as_view(url='smirk/system_administrator/', permanent=False)),
    url(r'^editMedAdmin', RedirectView.as_view(url='smirk/medical_administrator/', permanent=False)),
    url(r'^editInsAdmin', RedirectView.as_view(url='smirk/insurance_administrator/', permanent=False)),
    url(r'^viewPatientProfile', RedirectView.as_view(url='smirk/patient/', permanent=False)),
    url(r'^viewRecoveryPhrase', RedirectView.as_view(url='smirk/doctor/', permanent=False)),
    url(r'^removeUserProfile', RedirectView.as_view(url='auth/user/', permanent=False)),
    url(r'^api/', include(System_Administrator().urls)),
    url(r'^api/', include(Doctor().urls)),
    url(r'^api/', include(Nurse().urls)),
    url(r'^api/', include(Medical_Administrator().urls)),
    url(r'^api/', include(Insurance_Administrator().urls)),
    url(r'^api/', include(Patient().urls)),
    url(r'^api/', include(Record().urls)),
    url(r'^api/', include(Doctor_Exam_Record().urls)),
    url(r'^api/', include(Diagnosis_Record().urls)),
    url(r'^api/', include(Test_Results_Record().urls)),
    url(r'^api/', include(Insurance_Claim_Record().urls)),
    url(r'^api/', include(Patient_Doctor_Correspondence_Record().urls)),
    url(r'^api/', include(Raw_Record().urls)),
    url(r'^api/', include(Note().urls)),

]

admin.site.site_header= 'Secure Medical Information Repository Kit'
admin.site.index_title= 'SMIRK'
admin.site.site_title= 'Welcome' 
tylercoverstone commented 7 years ago

make a new folder in the project directory named "fixtures"

the append this to the end of settings.py:

FIXTURE_DIRS = (
    '/fixtures/',
)
tylercoverstone commented 7 years ago

within the project directory:

python manage.py dumpdata auth --natural-foreign --natural-primary -e auth.permission > fixtures/initial_data.json

tylercoverstone commented 7 years ago

to configure db in settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'myprojectdb',
    'USER':'student',
        'PASSWORD':'ask_mike',
    'HOST':'localhost',
    'PORT':'',
    }
}