Model and schema for new StudyCreator api endpoint

Update StudyModel to use new model
This commit is contained in:
mike cullerton 2021-12-06 14:36:34 -05:00
parent 5cf011f1d9
commit db1f3ba6ab
2 changed files with 21 additions and 28 deletions

View File

@ -23,43 +23,36 @@ class ProtocolBuilderStatus(enum.Enum):
# • Hold: store boolean value in CR Connect (add to Study Model) # • Hold: store boolean value in CR Connect (add to Study Model)
# • Open To Enrollment: has start date? # • Open To Enrollment: has start date?
# • Abandoned: deleted in PB # • Abandoned: deleted in PB
incomplete = 'incomplete' # Found in PB but not ready to start (not q_complete) incomplete = 'incomplete' # Found in PB but not ready to start (not q_complete)
active = 'active' # found in PB, marked as "q_complete" and not hold active = 'active' # found in PB, marked as "q_complete" and not hold
hold = 'hold' # CR Connect side, if the Study ias marked as "hold". hold = 'hold' # CR Connect side, if the Study ias marked as "hold".
open = 'open' # Open To Enrollment: has start date? open = 'open' # Open To Enrollment: has start date?
abandoned = 'abandoned' # Not found in PB abandoned = 'abandoned' # Not found in PB
# DRAFT = 'draft', # !Q_COMPLETE
#DRAFT = 'draft', # !Q_COMPLETE # IN_PROCESS = 'in_process', # Q_COMPLETE && !UPLOAD_COMPLETE
#IN_PROCESS = 'in_process', # Q_COMPLETE && !UPLOAD_COMPLETE # IN_REVIEW = 'in_review', # Q_COMPLETE && (!UPLOAD_COMPLETE)
#IN_REVIEW = 'in_review', # Q_COMPLETE && (!UPLOAD_COMPLETE) # REVIEW_COMPLETE = 'review_complete', # Q_COMPLETE && UPLOAD_COMPLETE
#REVIEW_COMPLETE = 'review_complete', # Q_COMPLETE && UPLOAD_COMPLETE # INACTIVE = 'inactive', # Not found in PB
#INACTIVE = 'inactive', # Not found in PB
class ProtocolBuilderCreatorStudy(object):
class ProtocolBuilderStudy(object): def __init__(self, STUDYID, DATELASTMODIFIED, DATECREATED, TITLE):
def __init__(
self, STUDYID: int, TITLE: str, NETBADGEID: str,
DATE_MODIFIED: str, Q_COMPLETE: str, HSRNUMBER: str
):
self.STUDYID = STUDYID self.STUDYID = STUDYID
self.DATELASTMODIFIED = DATELASTMODIFIED
self.DATECREATED = DATECREATED
self.TITLE = TITLE self.TITLE = TITLE
self.NETBADGEID = NETBADGEID
self.DATE_MODIFIED = DATE_MODIFIED
self.Q_COMPLETE = Q_COMPLETE
self.HSRNUMBER = HSRNUMBER
class ProtocolBuilderStudySchema(ma.Schema):
class ProtocolBuilderCreatorStudySchema(ma.Schema):
class Meta: class Meta:
model = ProtocolBuilderStudy
unknown = INCLUDE unknown = INCLUDE
fields = ["STUDYID", "TITLE", "NETBADGEID", fields = ["STUDYID", "DATELASTMODIFIED", "DATECREATED", "TITLE"]
"DATE_MODIFIED", "Q_COMPLETE"]
@post_load @post_load
def make_pbs(self, data, **kwargs): def make_study(self, data, **kwargs):
return ProtocolBuilderStudy(**data) return ProtocolBuilderCreatorStudy(**data)
class ProtocolBuilderInvestigator(object): class ProtocolBuilderInvestigator(object):
@ -88,7 +81,7 @@ class ProtocolBuilderRequiredDocument(object):
class ProtocolBuilderRequiredDocumentSchema(ma.Schema): class ProtocolBuilderRequiredDocumentSchema(ma.Schema):
class Meta: class Meta:
fields = ["AUXDOCID","AUXDOC"] fields = ["AUXDOCID", "AUXDOC"]
unknown = INCLUDE unknown = INCLUDE
@post_load @post_load

View File

@ -11,7 +11,7 @@ from crc import db, ma
from crc.api.common import ApiErrorSchema, ApiError from crc.api.common import ApiErrorSchema, ApiError
from crc.models.file import FileModel, SimpleFileSchema, FileSchema from crc.models.file import FileModel, SimpleFileSchema, FileSchema
from crc.models.ldap import LdapModel, LdapSchema from crc.models.ldap import LdapModel, LdapSchema
from crc.models.protocol_builder import ProtocolBuilderStatus, ProtocolBuilderStudy from crc.models.protocol_builder import ProtocolBuilderCreatorStudy
from crc.models.workflow import WorkflowSpecCategoryModel, WorkflowState, WorkflowStatus, WorkflowSpecModel, \ from crc.models.workflow import WorkflowSpecCategoryModel, WorkflowState, WorkflowStatus, WorkflowSpecModel, \
WorkflowModel WorkflowModel
from crc.services.file_service import FileService from crc.services.file_service import FileService
@ -57,10 +57,10 @@ class StudyModel(db.Model):
short_name = db.Column(db.String, nullable=True) short_name = db.Column(db.String, nullable=True)
proposal_name = db.Column(db.String, nullable=True) proposal_name = db.Column(db.String, nullable=True)
def update_from_protocol_builder(self, pbs: ProtocolBuilderStudy): def update_from_protocol_builder(self, study: ProtocolBuilderCreatorStudy, user_id):
self.title = pbs.TITLE self.title = study.TITLE
self.user_uid = pbs.NETBADGEID self.user_uid = user_id
self.last_updated = pbs.DATE_MODIFIED self.last_updated = study.DATELASTMODIFIED
self.irb_status = IrbStatus.incomplete_in_protocol_builder self.irb_status = IrbStatus.incomplete_in_protocol_builder