Changeset 1608 for fmts/trunk


Ignore:
Timestamp:
Feb 20, 2013, 6:15:15 PM (12 years ago)
Author:
Sam Habiel
Message:

code to extract fulfillments of medications (# of times it's dispensed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmts/trunk/p/C0XPT3.m

    r1607 r1608  
    1 C0XPT3  ;ISI/MLS,VEN/SMH -- MEDS IMPORT;2013-02-19  5:01 PM
    2         ;;FILEMAN TRIPLE STORE;1.0;;;Jun 26,2012;Build 29
     1C0XPT3  ;ISI/MLS,VEN/SMH -- MEDS IMPORT;2013-02-20  3:15 PM
     2        ;;1.0;FILEMAN TRIPLE STORE;;Jun 26,2012;Build 29
    33        ;
    44MEDS(G,DFN) ; Private Proc; Extract Medication Data from a Patient's Graph
     
    88        ;
    99        ; For each medication (I = COUNTER; S = Medication Node as Subject)
    10         N I,S F I=0:0 S I=$O(^TMP($J,"MEDS",I)) Q:'I  S S=^(I) DO MED1(G,S) 
     10        N I,S F I=0:0 S I=$O(^TMP($J,"MEDS",I)) Q:'I  S S=^(I) DO MED1(G,S)
    1111        ;
    1212        K ^TMP($J,"MEDS")
    1313        QUIT
     14        ;
    1415MED1(G,S) ; Private Procedure; Process each medication in Graph.
    1516        ; G = Graph; S = Medication Description ID as subject.
     
    1718        ; 1. Start Date; obtain and then conv to fileman format
    1819        N STARTDT S STARTDT=$$GSPO1^C0XGET3(G,S,"sp:startDate") ; Duh! Start Date.
    19         X "N %DT,X,Y S X=STARTDT D ^%DT S STARTDT=Y" ; New stack level for variables.
     20        D
     21        . N %DT,X,Y S X=STARTDT D ^%DT S STARTDT=Y ; New stack level for variables.
    2022        ;
    2123        ;DEBUG.ASSERT that STARTDT is greater than 1900
     
    3537        ;
    3638        ; 5. Drug Name and Code
    37         N RXN S RXN=$$GSPO1^C0XGET3(G,S,"sp:drugName.sp:code") ; RxNorm Code
     39        N RXN S RXN=$$GSPO1^C0XGET3(G,S,"sp:drugName.sp:code"),RXN=$P(RXN,"/",$L(RXN,"/")) ; RxNorm Code
    3840        N DN S DN=$$GSPO1^C0XGET3(G,S,"sp:drugName.dcterms:title") ; Drug Name
    3941        ;
     
    4143        ;
    4244        ; 6. Get Fill Dates
    43         ;TODO.
     45        N FULF ; Fulfillments
     46        D GSPO^C0XGET3($NA(FULF),G,S,"sp:fulfillment")
     47        ;
     48        N FILLS ; Fills array. Contains every time a drug was dispensed.
     49        N FILL S FILL="" F  S FILL=$O(FULF(FILL)) Q:FILL=""  D
     50        . N S S S=FULF(FILL) ; New subject; subsumes above one in this loop
     51        . ;
     52        . ; Dispense Date
     53        . N FILLDATE S FILLDATE=$$GSPO1^C0XGET3(G,S,"dcterms:date")
     54        . D
     55        . . N %DT,X,Y S X=FILLDATE D ^%DT S FILLDATE=Y
     56        . I FILLDATE<2000000 W $EC=",U1," ; Converstion error
     57        . ;
     58        . S FILLS(RXN,FILLDATE,"sp:dispenseDaysSupply")=$$GSPO1^C0XGET3(G,S,"sp:dispenseDaysSupply") ; Self Explanatory?
     59        . ;
     60        . ; Get quantity value and unit
     61        . S FILLS(RXN,FILLDATE,"sp:quantityDispensed.sp:value")=$$GSPO1^C0XGET3(G,S,"sp:quantityDispensed.sp:value")
     62        . S FILLS(RXN,FILLDATE,"sp:quantityDispensed.sp:unit")=$TR($$GSPO1^C0XGET3(G,S,"sp:quantityDispensed.sp:unit"),"{}")
     63        ;
     64        ZWRITE:$D(FILLS) FILLS
    4465        QUIT
    45 
     66        ;
    4667MED(ISIMISC)    ;Create med order entry
    4768        ; Input - ISIMISC(ARRAY)
     
    6788        Q ISIRC
    6889        ;
    69 PREP   
     90PREP ;
    7091        ;
    7192        N EXIT
     
    7596        S PROV=ISIMISC("PROV") ;NEW PERSON FILE (#200)
    7697        S PSODRUG=ISIMISC("DRUG") ;"" ;POINTER TO DRUG FILE (#50)
    77         S PSODRUG("DEA")=$P($G(^PSDRUG(PSODRUG,0)),U,3) 
     98        S PSODRUG("DEA")=$P($G(^PSDRUG(PSODRUG,0)),U,3)
    7899        S QTY=ISIMISC("QTY") ;NUMBER ;0;7 NUMBER (Required)
    79100        S DAYSUPLY=ISIMISC("SUPPLY") ;NUMBER ; 0;8 NUMBER (Required)
     
    101122        Q
    102123        ;
    103 CREATE 
    104         D AUTO^PSONRXN  ;RX auto number
     124CREATE ;
     125        D AUTO^PSONRXN ;RX auto number
    105126        I $G(PSONEW("RX #"))="" S ISIRC="-1^RX Auto number error." Q
    106127        S RXNUM=PSONEW("RX #")
    107128        ;
    108129        S PSOIEN=$P($G(^PSRX(0)),"^",3)+1
    109         I $D(^PSRX(PSOIEN)) S ISIRC="-1^Problem with PSRX (#50) internal counter" Q ;pointer error
     130        I $D(^PSRX(PSOIEN)) S ISIRC="-1^Problem with PSRX (#50) internal counter" Q  ;pointer error
    110131        S $P(^PSRX(0),U,3)=PSOIEN
    111132        ;
     
    137158        ;
    138159        S ^PSRX(PSOIEN,"A",0)="^52.3DA^1^1"
    139         S $P(^PSRX(PSOIEN,"A",1,0),"^",1)=LOGDT ;DATE
     160        S $P(^PSRX(PSOIEN,"A",1,0),"^",1)=LOGDT ;DATE
    140161        S $P(^PSRX(PSOIEN,"A",1,0),"^",2)=REASON ;SET
    141162        S $P(^PSRX(PSOIEN,"A",1,0),"^",3)=INIT ;NEW PERSON FILE (#200)
     
    153174        ;
    154175        ;S ^PSRX(PSOIEN,"IB")=TRNSTYP ;COPAY TRANSACTION TYPE   IB ACTION TYPE FILE (#350.1)
    155         S ^PSRX(PSOIEN,"TYPE")=0        ;TYPE OF RX             TYPE;1 NUMBER
     176        S ^PSRX(PSOIEN,"TYPE")=0 ;TYPE OF RX             TYPE;1 NUMBER
    156177        D OERR,F55,F52,F525
    157178        Q
Note: See TracChangeset for help on using the changeset viewer.