SQL Dealing with multiple choice answers in a DB with no unique identifier

I am working with a Database that has forms set up with multiple select fields.  As seen below, (Question_ID 2533) the Patient_ID, Visit_ID, and Question_ID are the same and there are 3 different answers that were chosen.  I am trying to figure
out how to seperate these Multiple answers so I can use SSRS to pull them into seperate fields. I believe I know how to use SSRS to pull the data after I have differentiated each answer. I need help with the SQL code...
Patient_ID   Visit_ID   Form_ID   Question_ID   Answer_ID     Answer
124            1685        164          2533             1490             
Muscle pain
124            1685        164          2533             1492             
Weight loss
124            1685        164          2533             1494            
 Shoulder joint pain
124            1685        164          2534            
678                Good
124            1685        164          2535            
678                Good

I was able to get the unique identifier by creating a new table using the ROW_NUMBER()OVER and PARTITION BY Functions.  Then I was able to identify each answer of the multiple choice fields.  Here is the full code.
CREATE TABLE Multiple_Answer(
 Patient_ID INT,
 Visit_ID INT,
 Visit_Date DateTime,
 Form_ID INT,
 Form_Name nvarchar(255),
 Question_ID INT,
 Question_Name nvarchar(1000),
 Answer_ID INT,
    Answer  nvarchar(1000),
    Multiple_Answer INT)
    INSERT INTO Medred_Reporting.dbo.Multiple_Answer
           ([Patient_ID]
           ,[Visit_ID]
           ,[Visit_Date]
           ,[Form_ID]
           ,[Form_Name]
           ,[Question_ID]
           ,[Question_Name]
           ,[Answer_ID]
           ,[Answer]
           ,[Multiple_Answer])
SELECT        Patients.Patient_ID, Patient_Visits.Visit_ID, Patient_Visits.Visit_Date, Forms.Form_ID, Forms.Form_Name, Questions.Question_ID, Questions.Question_Name, Answers.Answer_ID,
                         Answers.Answer,
                         ROW_NUMBER()OVER
                         (PARTITION BY Patients.Patient_ID, Patient_Visits.Visit_ID,Forms.Form_ID,Questions.Question_ID
                         ORDER BY Questions.Question_ID)
                         AS Multiple_Answer
FROM            Patient_Visits INNER JOIN
                         Patients ON Patient_Visits.Patient_ID = Patients.Patient_ID INNER JOIN
                         User_Visit_REL ON Patient_Visits.Visit_ID = User_Visit_REL.Visit_ID INNER JOIN
                         Users ON User_Visit_REL.User_ID = Users.User_ID INNER JOIN
                         Visit_Question_Answer_REL ON User_Visit_REL.User_Visit_ID = Visit_Question_Answer_REL.User_Visit_ID INNER JOIN
                         Symptom ON Visit_Question_Answer_REL.Symptom_ID = Symptom.Symptom_ID INNER JOIN
                         Question_Answer_REL ON Symptom.Question_Answer_ID = Question_Answer_REL.Question_Answer_ID INNER JOIN
                         Answers ON Question_Answer_REL.Answer_ID = Answers.Answer_ID INNER JOIN
                         Form_Question_REL ON Question_Answer_REL.Form_Question_ID = Form_Question_REL.Form_Question_ID INNER JOIN
                         Questions ON Form_Question_REL.Question_ID = Questions.Question_ID INNER JOIN
                         Protocol_Form_REL ON Form_Question_REL.Protocol_Form_ID = Protocol_Form_REL.Protocol_Form_ID INNER JOIN
                         Forms ON Protocol_Form_REL.Form_ID = Forms.Form_ID

Similar Messages

  • Create Service Request with Multiple Choices

    Dears,
    I need to create Service Request to appear in the portal with Multiple Choices like blow 
    Mohamed Fawzi | http://fawzi.wordpress.com

    Hi Mohamed.
    I am sitting almost in the same sudation, I am designing a service request form in the portal and will be using multiple checkboxes for various new equipment aka desktop, laptop, mobile blah blah.
    were you able to get multiple checkboxes to work in the portal, and if so, could you possibly share the solution. also if I may ask, can you have two or there checkboxes in the same row (next to each other), or only in a column?
    thanks in advance

  • This is my first use of this program. How do I remove a page break? How do line up my drop down box along side the text box on the left of it? The drop down is for a multiple choice answer for the question to the left.

    This is my first use of this program. How do I remove a page break? How do line up my drop down box along side the text box on the left of it? The drop down is for a multiple choice answer for the question to the left of each drop down.

    See McAfee support to find out how to disable that McAfee feature - that isn't part of the normal Firefox installation.

  • Adobe Captivate more than 15 multiple choice answers

    Hi,
    I am trying to create one slide multiple choice question.
    My options in answers are 16 and from these 16 answers only 4 of them is correct.
    Why Captivate doesn't allow me to have more than 15 multiple choice answers?
    Thanks,
    Shirin

    Sorry, but the limit is 15. Even that is pretty much for a MCQ.

  • How to print an excel file (2010 version) with multiple tabs into a pdf file with bookmarks (acrobat 9). I was able to do this easily using excel (2007 version).

    Recently I got a new laptop, with excel 2010 version and acrobat 9 standard.
    I could no longer print (save as) an excel file with multiple tabs into a pdf file with bookmarks.
    My old computer has excel 2007 version and acrobat 9 standard.
    Print an excel file into pdf with bookmarks was a piece of cake.
    Both machine has the same add-in -- Acrobat PDFMaker Office COM addin
    Thanks if anyone could help me with this.
        Tom

    You need to upgrade Acrobat to a newer version.
    On Thu, Oct 30, 2014 at 4:12 PM, excel-pdf-bookmarks <

  • Report with multiple dimensions in Row and Column with EvEXP

    Hi
    We are currently running BPC 7.0 SP3 and try to create the report(or schedule) with more 2 x 2 dimensions in the row and column.
    e.g.
    row dimension : Outer row is Entity, Inner row is Account
    column dimension : Outer column is Time, Inner row is Category
    We created the report with  2 x 2 dimensions like above e.g. with EvEXP and EvNXP, NOT EvDRE
    based on default dynamic template:Template13.xlt(Nested Row, 2 x 1 dimensions defined by EvEXP and EvNXP formula).
    However, when expanding the dimension with double click these dimensions or change CV of the report with  2 x 2 dimensions defined by EvEXP and EvNXP formula,
    error occurs on EvEXP and EvNXP formula and can't retrieve the result correctly.
    [Question]
    Can't we create the report with more 2 x 2 dimensions in the row and column using EvEXP and EvNXP function ?
    We understand that we can make the report with more 2 x 2 dimensions in the row and column if using EvDRE.
    Thank You in advance
    Kenya

    Thank you for your advice.
    I understand that we should use EvDRE when creating the report with multiple dimension in the row/column because EvEXP have some erros, poor performance, etc.
    Then, we have two questions.
    1)
    >plus they had some errors in the designs.
    what kind of errors they have as an example?
    2)
    >If you must build the EVEXP and EVNXP, I would suggest building the template from scratch
    We built the simple template with just 2 x 2 dimension from scratch.
    But this report doesn't work well when double-click the dimension or changing CV...
    Would you please check the following template?
    <https://sapmats-de.sap-ag.de/download/download.cgi?id=RCZE1ME4YSORY3DCDO4NNMANZLBL1L5ZBUOB2F71YVNVS8XDJW>
    It would be greatly appreciated if you could give me your advice for the template.
    Thank you again
    And my best regards,
    Kenya

  • Multiple OUs with GPOs - One OU with multiple GPOs and security - One OU with one GPO and item level targeting

    Background...
    We have around 30 locations and we need to deliver different GPOs to these locations.
    There can be between 3 and 8 PCs in each location.
    These PCs can move around at short notice (mainly as a backup with neighbouring locations should
    PCs fail)
    The GPOs differ to change printers (2 per location and 2 backup printers from neighbouring location), auto login, desktop wallpaper
    Which is in your opinion the best solution for login speed, GPO & device management?
    1) Multiple OUs with a single GPO in each OU, the devices can be moved into new OU when the PCs move
    2) Single OU with multiple GPOs, add devices to security group and use security filtering on the GPOs
    3) Single OU with single GPO, add devices to security group and use item level targeting on the group

    > 1) Multiple OUs with a single GPO in each OU, the devices can be moved
    > into new OU when the PCs move
    > 2) Single OU with multiple GPOs, add devices to security group and use
    > security filtering on the GPOs
    > 3) Single OU with single GPO, add devices to security group and use item
    > level targeting on the group
    4) GPMC, Sites, "show sites". Then link appropriate GPOs to each
    individual site.
    That's the way to go here...
    Martin
    Mal ein
    GUTES Buch über GPOs lesen?
    NO THEY ARE NOT EVIL, if you know what you are doing:
    Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))

  • Problem with multiple versions of documents being published with 001, 002, etc.

    I am using Contribute CS3. I am having a problem with multiple versions of documents being published on the sever with 001, 002, etc in the name. So that I end up with 2 or 3 versions of a document on the server. Does anyone know why / how Contribute  is doing this? Thanks for any help you can give.

    Your Web site administrator will need to update your key to allow you to delete files you are able to edit.

  • Report with multiple choice in column for same dimension......

    Hi All,
    We have a report with two dimensions in col , one in row remaining in pov...user want to select multiple members [its more than 10 members..so we thought prompts will not be good.] for one column for different members in second dimension of column and want see the variance between them.
    can anyone suggest me how can i achieve this. thank you
    regards,
    Ravi

    Hi All,
    Can any one suggest me on this. thanks inadvance.
    Regards,
    Ravi

  • (new) flash cdfrid with multiple choices

    My cfgrid allows the user to select several options.  What I need to know is how to capture those selections.  Here's the grid code:
    <cfgrid name='art_grid' format='flash' selectOnLode='no' selectMode='edit' query='GetArticles'>
         <cfgridcolumn name='ArticleIndex' select='yes' values='1' type='boolean' display='yes'>
         <cfgridcolumn name='ArticleName' select='no'>
    </cfgrid>
    I've tried a cfselect and a cfset (both with selectedItem and selectedIndex); both receiving the same error:  You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.
    I created a structure to hold the responses and then tried to populate it with:
    <cfloop collection='#art_grid.selectedItem# item='i'>
         <cfset ArtStruct[i]='#art_grid.selectedItem.ArticleName[i]#'>
    </cfloop>
    What should I use instead?  (Yes, I googled the error message and this is where I got the structure idea.)

    Kind of a weird dump using <cfdump var='#art_grid#'>    (The form.art_grid was undefined...)
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" height="320" marginBottom="0" marginLeft="0" marginRight="0" marginTop="0" rsl="/CFIDE/scripts/cfform.swc" width="580"> <mx:Script><![CDATA[ import mx.core.UIObject; var errorpopup; function compareNumeric(a,b) { var a1 = parseFloat(a); var b1 = parseFloat(b); if( a1.toString() == 'NaN' ) a1 = 0; if( b1.toString() == 'NaN' ) b1 = 0; if( a1 < b1 ) return -1; if( a1 == b1 ) return 0; return 1; } function compareCurrency(a,b) { var a1 = new mx.formatters.NumberBase().parseNumberString( a ); var b1 = new mx.formatters.NumberBase().parseNumberString( b ); var a1 = parseFloat(a1); var b1 = parseFloat(b1); if( a1.toString() == 'NaN' ) a1 = 0; if( b1.toString() == 'NaN' ) b1 = 0; if( a1 < b1 ) return -1; if( a1 == b1 ) return 0; return 1; } function compareTextNoCase(a,b) { var a1 = a.toLowerCase(); var b1 = b.toLowerCase(); if( a1 < b1 ) return -1; if( a1 == b1 ) return 0; return 1; } var __art_grid_cacheid = "0"; var __art_grid_editedFields = new Object(); var __art_grid; ]]></mx:Script> <mx:Model id="CFForm_1"> <__CFGRID__CFForm_1__art_grid>{__art_grid}</__CFGRID__CFForm_1__art_grid> </mx:Model> <mx:Style> .artgridHeader { textAlign: Left; } </mx:Style> <mx:Form heightFlex="1" marginBottom="0" marginLeft="0" marginRight="0" marginTop="0" widthFlex="1"> <mx:DataGrid editable="true" fontFamily="tahoma" fontSize="12" hGridLines="true" headerStyle="artgridHeader" height="320" id="art_grid" initialize="GridData.initGrid(true, __art_grid_cacheid, art_grid, this, 'CFForm_1', '__CFGRID__CFForm_1__art_grid', remoteObject_art_grid)" textAlign="left" vGridLines="true" width="580"> <mx:columns> <mx:Array> <mx:DataGridColumn columnName="CFGRIDROWINDEX" editable="false" headerText="" resizable="false" sortable="true" width="0"/> <mx:DataGridColumn cellRenderer="{CheckCellRenderer}" columnName="ArticleIndex" editable="false" headerText="Select" resizable="true" sortable="true" width="50"/> <mx:DataGridColumn columnName="ArticleName" editable="false" headerText="Article" resizable="true" sortable="true" width="530"/> </mx:Array> </mx:columns> </mx:DataGrid> </mx:Form> <mx:RemoteObject concurrency="multiple" endpoint="@ContextRoot()/CFFormGateway/" id="remoteObject_art_grid" showBusyCursor="true" source="coldfusion.flash.adapter.CFFormAdapter"/> </mx:Application>
    Interesting, but I don't understand it.

  • How to create VO with multiple dynamic where clauses on select with UNION?

    I am trying to implement the View Object for the UNION query that looks like this:
         select a,b,c...
              from t1,t2,...
              where dynamic_where_clause1     
         union all
         select a,b,c,...
              from t11,t12, ...
              where dynamic_where_clause2
    There are up to 60 input parameters that are used to generate dynamic where clauses. They are actually created by calling PL SQL function.
    So far, I was not able to assign both where clauses to the view object. Is there a workable solution for this problem, besides resorting to programmatic View Object?
    I understand that recommended way with UNIONs is to wrap both queries into a parent select:
    select * from (
         select a,b,c...
              from t1,t2,...
              where ... -- table relationship joints
         union all
         select a,b,c,...
              from t11,t12, ...
              where ... -- table relationship joints
    ) QRSLT
         where dynamic_where_clause
    Unfortunately this approach doesn't work here, since individual selects are producing unmanageable amount of data and resulting query takes forever to complete.

    I afraid I would not have any real benefits from using VO if I replace the entire query with every request. Actually, the performance may suffer.
    I solved the problem by creating a POJO Data Control and invoking the custom select query from java. Not sure if it is the best approach to the problem, but implementation time is limited and it works.
    Actually, this is not the first time I see the need to implement VO with complicated SQL like select with unions and dynamic pieces. It would be nice to find a solution and not resort to workarounds.
    Edited by: viksicom on Aug 2, 2012 8:48 AM

  • Firefox 4.01 with multiple tabs/windows open will close with the following dialoog boxes appearing, one for each window, evidently, "invalid preferences extensions.bprivacy.timer check that is listed in defaults/prefs.js"

    The cause of the need to revert to the last known good operating condition was trying to download a file from a Yahoo discussion group. The download froze the machine. When Firefox was restarted, it froze on loading, at first step of loading multiple windows and tabs. Many reboots to the same frozen state led to revert to the last restore point. That produced equivalent results on startup of Firefox, the option of F8 and revert to last known good operating condition was done. Everything seemingly operate OK, with the exception of the pop-up dialog boxes on shutdown of Firefox .
    Began Thursday 5/26/11
    I know locations and dates of all files "prefs.js" but don't know what to do with them, if anything.

    I removed add-on BetterPrivacy. No problems since then anymore.
    Regards,
    HABSBURGER

  • Rsrb with multiple ring groups on head ends with one phy ring?

    working on an issue for a customer and I cant find good documentation on this anywhere for multiple ring-groups
    have 2 routers, each with 2 ring groups connected on a mau terminating multiple serial connections (wan, hence the rsrb) and utilizing rsrb tcp with local ack. The configuration was done sometime ago. It was set up to utilize frame which now they are using ptp t1s. I see in the remote routers they are forwarding pakcets to both routers to ring 20. (there are 2 routers if one fails then it is meant to learn its path to the CIP through the other router)
    ---------router1
    source-bridge ring-group 30
    source-bridge ring-group 31
    blahblah peers tcp local-ack
    int t0
    source-bridge 20 1 30 <----notice bridge 1
    source-bridge spanning
    int t1
    source-bridge 20 1 31 <----notice bridge 1
    source-bridge spanning
    --------router2
    source-bridge ring-group 30
    source-bridge ring-group 31
    blahblah peers tcp local-ack
    int t0
    source-bridge 20 2 30 <----notice bridge 2
    source-bridge spanning
    int t1
    source-bridge 20 2 31 <----notice bridge 2
    source-bridge spanning
    I thought the physical rings had to be different in order to run parrallel links. Or are different bridge #'s feasible? The end issue they are having is that when links bounce, they are not releasing the tcp session and the show llc shows remote sides as busy and the head end as connected. (then obviously removal of local ack fixed the issue)
    Not ready to live without local ack... could the same ring # on both routers be the issue since they are on the same mau and destined for the same location?
    ==MAU to CIP==
    | | | | all physical connection on mau are ring 20
    router1 router2
    | | | | | ring groups 30 and 31 configured on both routers with 1 statement to each router in the network per router (so each remote side is only connected to either ring group 30 or 31 (not both since you can only do over token ring) and the show source-bridge is showing forwards to each head end router's physical ring 20. I thought I would see one with forwards the other 0 since first response, but then saw the bridge # differed.)

    case was opened over a month ago with no luck or serious help. Have had great luck in the past with tac, but this one was frustrating and nothing was done.
    case#D039413
    And the remote routers connect directly to the cip with LLC2. (end to end connection, not remote to router 1 and 2 to CIP)
    show llc shows the local mac of the gateway and the cip token.
    the network goes like this
    rr = remote router
    fr= frame relay
    ptp= ptp t1
    rtr1 and rtr2 = router 1 and 2
    rr--fr--rr--ptp--rtr1 and rtr2 ---rr---cip
    I have tried numerous things on this and its apparent that the only option is dlsw and I have pressed the issue enough to start on it with test segments.
    my theory was when the host queried the gateway, its first reply was local-ack on rtr2 (could be rtr1 but for theory we will say rtr2) which was giving back RR and the other end was actually in a disconnect state and sending rnr's to the rtr1 (in this exapmple the host was talking thru rtr2 to the remote side and the remote side was trying the opposite router) which local ack would reply to the supervisor frames
    what was causing the problems in my opinion is the host provider does not utilize local ack since they only have lanned token rings and the customer provides their own wan routers. So the explorer would be answered quicker by the other router and that would be the source route bridged path to the remote side, where the other sides local ack and rif cache was routing through the opposite router. Unfortunately the site where we collected the data on I can not test since I have transitioned it to dlsw to solve their issues and show them the benfits of dlsw

  • Windows Server 2008 R2 with multiple Roles OS Rebuild, Need help with Certificates.

    Hi,
    I have rebuilt a Server for my client and I require help with certificates..
    I am unsure exactly what to do to get this server working as it was.
    Example, The Windows Server 2008 R2 has Microsoft Exchange, DNS, DHCP, ADDS, FileServices,Network Policy and access Services and Webservices roles installed on a single box.
    Since the Server OS Rebuild I am getting 2 issues that pop up usually when Outlook in opened on a client Workstation,
    I have not dont anything certificate wise to the server since OS Install, and the messages I get and best described here
    I seen on a backdrive, a few certificate files I dont know if we can use these files for anything but we have the following files of drive E (Backup)
    e:\server.xxxx.com.au\gd_iis_intermediates.p7b
    e:\server.xxxx.com.au\server.xxxx.com.au.crt
    e:\ssl\2013-2018.cer
    1st Message is about a Proxy certificate I dont get this often but saw it today and my client clicked ok too quickly.
    I have seen it and didnt see it again after trying to close outlook and reopen
    I looked up google images and tried to find it...
    It's like this, (There is a problem with the proxy server's security certificate.
    The security certificate is not from a trusted certifying authority.)
    2nd Message is about Security Alert, Autodiscover.xxxx.com.au Information you exchange with this site cannot be viewed or changed by others. However, there is a problem with the sites security certificate.
    -X- The security certificate was issued by a company you have not chosen to trust. View the certificate to determine whether you want to trust the certificating authority
    -TICK- The security certificate date is valid
    -X- The name on the security certificate is invalid or does not match the name of the site
    Do you want to preceed
    [Yes][No][View Certificate ...]
    3rd Message is very Close to the 2nd Message, is about Security Alert, xxxx-server.xxxx.local, Information you exchange with this site cannot be viewed or changed by others. However, there is a problem with the sites security certificate.
    -X- The security certificate was issued by a company you have not chosen to trust. View the certificate to determine whether you want to trust the certificating authority
    -TICK- The security certificate date is valid
    -TICK- The name on the security certificate is invalid or does not match the name of the site
    Do you want to preceded
    [Yes][No][View Certificate ...]
    If you can help guide me thou this as I'm very new to setting up certificates. I had a friend tell me about something in DNS.. but he has been super busy and I want to learn what to do.
    Thank-You.

    Hiya,
    quite a lot has the same confusions as you do, so I've written a simple explanation on the subjet of certificates
    http://jesperarnecke.wordpress.com/2014/03/22/certificates-simple-explanation/
    Let me know if that helps you and if you need further assistance.

  • How to create a link with 2 choices in Xcode: one selected with UICollectionViewController and the other with UITableViewController

    Hi
    I want to create a app redirecting to my mebsite.This app permit to select a "area" selected on a UICollectionViewController, and an "event" selected with a UITableViewController.
    I need to integer both informations on the FinalViewController (called in my app AnnoncesViewController) =>
    The fisrst array is selected on CollectionViewController:@"http://carnet-du-jour.com/index.php/component/ohanah/?option=com_ohanah&view=e vents&Itemid=0&ohanah_venue_id=21"
    The second array is selected onUITableViewController:@"&ohanah_category_id=1&textToSearch="
    The final array must be:http://carnet-du-jour.com/index.php/component/ohanah/?option=com_ohanah&view=eve nts&Itemid=0&ohanah_venue_id=21&ohanah_category_id=1&textToSearch=
    How can I integer these 2 NSArray to obtain this result to link  to a UIWebView as FinalViewController?
    Thank you for your help!!
    My App is on Drobox:https://www.dropbox.com/s/43l1p2hj5bqamvn/Carnet%20du%20Jour.zip
    Gracefully
    RémySpehler

    Hi
    I want to create a app redirecting to my mebsite.This app permit to select a "area" selected on a UICollectionViewController, and an "event" selected with a UITableViewController.
    I need to integer both informations on the FinalViewController (called in my app AnnoncesViewController) =>
    The fisrst array is selected on CollectionViewController:@"http://carnet-du-jour.com/index.php/component/ohanah/?option=com_ohanah&view=e vents&Itemid=0&ohanah_venue_id=21"
    The second array is selected onUITableViewController:@"&ohanah_category_id=1&textToSearch="
    The final array must be:http://carnet-du-jour.com/index.php/component/ohanah/?option=com_ohanah&view=eve nts&Itemid=0&ohanah_venue_id=21&ohanah_category_id=1&textToSearch=
    How can I integer these 2 NSArray to obtain this result to link  to a UIWebView as FinalViewController?
    Thank you for your help!!
    My App is on Drobox:https://www.dropbox.com/s/43l1p2hj5bqamvn/Carnet%20du%20Jour.zip
    Gracefully
    RémySpehler

Maybe you are looking for